aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/kvm/lib/x86_64/vmx.c
diff options
context:
space:
mode:
authorJim Mattson <jmattson@google.com>2020-10-26 11:09:22 -0700
committerPaolo Bonzini <pbonzini@redhat.com>2020-10-31 10:04:38 -0400
commit97a71a5455997d72adfd74e9d575d782d7c2ab9a (patch)
treee0457dba18b679dfb5fa2c5fee815104cfc46495 /tools/testing/selftests/kvm/lib/x86_64/vmx.c
parentKVM: x86: Fix NULL dereference at kvm_msr_ignored_check() (diff)
downloadlinux-dev-97a71a5455997d72adfd74e9d575d782d7c2ab9a.tar.xz
linux-dev-97a71a5455997d72adfd74e9d575d782d7c2ab9a.zip
KVM: selftests: test behavior of unmapped L2 APIC-access address
Add a regression test for commit 671ddc700fd0 ("KVM: nVMX: Don't leak L1 MMIO regions to L2"). First, check to see that an L2 guest can be launched with a valid APIC-access address that is backed by a page of L1 physical memory. Next, set the APIC-access address to a (valid) L1 physical address that is not backed by memory. KVM can't handle this situation, so resuming L2 should result in a KVM exit for internal error (emulation). Signed-off-by: Jim Mattson <jmattson@google.com> Reviewed-by: Ricardo Koller <ricarkol@google.com> Reviewed-by: Peter Shier <pshier@google.com> Message-Id: <20201026180922.3120555-1-jmattson@google.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to '')
-rw-r--r--tools/testing/selftests/kvm/lib/x86_64/vmx.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/tools/testing/selftests/kvm/lib/x86_64/vmx.c b/tools/testing/selftests/kvm/lib/x86_64/vmx.c
index f1e00d43eea2..2448b30e8efa 100644
--- a/tools/testing/selftests/kvm/lib/x86_64/vmx.c
+++ b/tools/testing/selftests/kvm/lib/x86_64/vmx.c
@@ -542,3 +542,12 @@ void prepare_eptp(struct vmx_pages *vmx, struct kvm_vm *vm,
vmx->eptp_hva = addr_gva2hva(vm, (uintptr_t)vmx->eptp);
vmx->eptp_gpa = addr_gva2gpa(vm, (uintptr_t)vmx->eptp);
}
+
+void prepare_virtualize_apic_accesses(struct vmx_pages *vmx, struct kvm_vm *vm,
+ uint32_t eptp_memslot)
+{
+ vmx->apic_access = (void *)vm_vaddr_alloc(vm, getpagesize(),
+ 0x10000, 0, 0);
+ vmx->apic_access_hva = addr_gva2hva(vm, (uintptr_t)vmx->apic_access);
+ vmx->apic_access_gpa = addr_gva2gpa(vm, (uintptr_t)vmx->apic_access);
+}