Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

KVM: selftests: Trust that MAXPHYADDR > memslot0 in vmx_apic_access_test

Use vm->max_gfn to compute the highest gpa in vmx_apic_access_test, and
blindly trust that the highest gfn/gpa will be well above the memory
carved out for memslot0. The existing check is beyond paranoid; KVM
doesn't support CPUs with host.MAXPHYADDR < 32, and the selftests are all
kinds of hosed if memslot0 overlaps the local xAPIC, which resides above
"lower" (below 4gb) DRAM.

Signed-off-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

authored by

Sean Christopherson and committed by
Paolo Bonzini
38081d28 6e1d13bf

+1 -8
+1 -8
tools/testing/selftests/kvm/x86_64/vmx_apic_access_test.c
··· 72 72 int main(int argc, char *argv[]) 73 73 { 74 74 unsigned long apic_access_addr = ~0ul; 75 - unsigned int paddr_width; 76 - unsigned int vaddr_width; 77 75 vm_vaddr_t vmx_pages_gva; 78 76 unsigned long high_gpa; 79 77 struct vmx_pages *vmx; ··· 84 86 85 87 vm = vm_create_with_one_vcpu(&vcpu, l1_guest_code); 86 88 87 - kvm_get_cpu_address_width(&paddr_width, &vaddr_width); 88 - high_gpa = (1ul << paddr_width) - getpagesize(); 89 - if ((unsigned long)DEFAULT_GUEST_PHY_PAGES * getpagesize() > high_gpa) { 90 - print_skip("No unbacked physical page available"); 91 - exit(KSFT_SKIP); 92 - } 89 + high_gpa = (vm->max_gfn - 1) << vm->page_shift; 93 90 94 91 vmx = vcpu_alloc_vmx(vm, &vmx_pages_gva); 95 92 prepare_virtualize_apic_accesses(vmx, vm);