Skip to content

Commit 5c107f7

Browse files
dmatlacksean-jc
authored andcommitted
KVM: selftests: Assert in prepare_eptp() that nEPT is supported
Now that a VM isn't needed to check for nEPT support, assert that KVM supports nEPT in prepare_eptp() instead of skipping the test, and push the TEST_REQUIRE() check out to individual tests. The require+assert are somewhat redundant and will incur some amount of ongoing maintenance burden, but placing the "require" logic in the test makes it easier to find/understand a test's requirements and in this case, provides a very strong hint that the test cares about nEPT. Suggested-by: Sean Christopherson <[email protected]> Signed-off-by: David Matlack <[email protected]> Link: https://lore.kernel.org/r/[email protected] [sean: rebase on merged code, write changelog] Signed-off-by: Sean Christopherson <[email protected]>
1 parent ecb89a5 commit 5c107f7

File tree

3 files changed

+3
-1
lines changed

3 files changed

+3
-1
lines changed

tools/testing/selftests/kvm/lib/x86_64/memstress.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ void memstress_setup_nested(struct kvm_vm *vm, int nr_vcpus, struct kvm_vcpu *vc
8585
int vcpu_id;
8686

8787
TEST_REQUIRE(kvm_cpu_has(X86_FEATURE_VMX));
88+
TEST_REQUIRE(kvm_cpu_has_ept());
8889

8990
for (vcpu_id = 0; vcpu_id < nr_vcpus; vcpu_id++) {
9091
vmx = vcpu_alloc_vmx(vm, &vmx_gva);

tools/testing/selftests/kvm/lib/x86_64/vmx.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ bool kvm_cpu_has_ept(void)
559559
void prepare_eptp(struct vmx_pages *vmx, struct kvm_vm *vm,
560560
uint32_t eptp_memslot)
561561
{
562-
TEST_REQUIRE(kvm_cpu_has_ept());
562+
TEST_ASSERT(kvm_cpu_has_ept(), "KVM doesn't support nested EPT");
563563

564564
vmx->eptp = (void *)vm_vaddr_alloc_page(vm);
565565
vmx->eptp_hva = addr_gva2hva(vm, (uintptr_t)vmx->eptp);

tools/testing/selftests/kvm/x86_64/vmx_dirty_log_test.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ int main(int argc, char *argv[])
7878
bool done = false;
7979

8080
TEST_REQUIRE(kvm_cpu_has(X86_FEATURE_VMX));
81+
TEST_REQUIRE(kvm_cpu_has_ept());
8182

8283
/* Create VM */
8384
vm = vm_create_with_one_vcpu(&vcpu, l1_guest_code);

0 commit comments

Comments
 (0)