Skip to content

Commit 2067028

Browse files
Sean Christophersonbonzini
authored andcommitted
KVM: selftests: Ignore KVM 5-level paging support for VM_MODE_PXXV48_4K
Explicitly set the VA width to 48 bits for the x86_64-only PXXV48_4K VM mode instead of asserting the guest VA width is 48 bits. The fact that KVM supports 5-level paging is irrelevant unless the selftests opt-in to 5-level paging by setting CR4.LA57 for the guest. The overzealous assert prevents running the selftests on a kernel with 5-level paging enabled. Incorporate LA57 into the assert instead of removing the assert entirely as a sanity check of KVM's CPUID output. Fixes: 567a9f1 ("KVM: selftests: Introduce VM_MODE_PXXV48_4K") Reported-by: Sergio Perez Gonzalez <[email protected]> Cc: Adriana Cervantes Jimenez <[email protected]> Cc: Peter Xu <[email protected]> Signed-off-by: Sean Christopherson <[email protected]> Message-Id: <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent e649b3f commit 2067028

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

tools/testing/selftests/kvm/lib/kvm_util.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,11 +195,18 @@ struct kvm_vm *_vm_create(enum vm_guest_mode mode, uint64_t phy_pages, int perm)
195195
case VM_MODE_PXXV48_4K:
196196
#ifdef __x86_64__
197197
kvm_get_cpu_address_width(&vm->pa_bits, &vm->va_bits);
198-
TEST_ASSERT(vm->va_bits == 48, "Linear address width "
199-
"(%d bits) not supported", vm->va_bits);
198+
/*
199+
* Ignore KVM support for 5-level paging (vm->va_bits == 57),
200+
* it doesn't take effect unless a CR4.LA57 is set, which it
201+
* isn't for this VM_MODE.
202+
*/
203+
TEST_ASSERT(vm->va_bits == 48 || vm->va_bits == 57,
204+
"Linear address width (%d bits) not supported",
205+
vm->va_bits);
200206
pr_debug("Guest physical address width detected: %d\n",
201207
vm->pa_bits);
202208
vm->pgtable_levels = 4;
209+
vm->va_bits = 48;
203210
#else
204211
TEST_FAIL("VM_MODE_PXXV48_4K not supported on non-x86 platforms");
205212
#endif

0 commit comments

Comments
 (0)