From: Jim Mattson <jmattson@google.com>
To: kvm@vger.kernel.org, pbonzini@redhat.com
Cc: Jim Mattson <jmattson@google.com>, Oliver Upton <oupton@google.com>
Subject: [PATCH v2 11/12] KVM: selftests: Introduce prepare_tpr_shadow
Date: Fri, 4 Jun 2021 10:26:10 -0700 [thread overview]
Message-ID: <20210604172611.281819-12-jmattson@google.com> (raw)
In-Reply-To: <20210604172611.281819-1-jmattson@google.com>
Add support for yet another page to hang from the VMCS12 for nested
VMX testing: the virtual APIC page. This page is necessary for a
VMCS12 to be launched with the "use TPR shadow" VM-execution control
set (except in some oddball circumstances permitted by KVM).
Signed-off-by: Jim Mattson <jmattson@google.com>
Reviewed-by: Oliver Upton <oupton@google.com>
---
tools/testing/selftests/kvm/include/x86_64/vmx.h | 5 +++++
tools/testing/selftests/kvm/lib/x86_64/vmx.c | 8 ++++++++
2 files changed, 13 insertions(+)
diff --git a/tools/testing/selftests/kvm/include/x86_64/vmx.h b/tools/testing/selftests/kvm/include/x86_64/vmx.h
index 516c81d86353..83ccb096b966 100644
--- a/tools/testing/selftests/kvm/include/x86_64/vmx.h
+++ b/tools/testing/selftests/kvm/include/x86_64/vmx.h
@@ -574,6 +574,10 @@ struct vmx_pages {
void *apic_access_hva;
uint64_t apic_access_gpa;
void *apic_access;
+
+ void *virtual_apic_hva;
+ uint64_t virtual_apic_gpa;
+ void *virtual_apic;
};
union vmx_basic {
@@ -618,5 +622,6 @@ void prepare_eptp(struct vmx_pages *vmx, struct kvm_vm *vm,
uint32_t eptp_memslot);
void prepare_virtualize_apic_accesses(struct vmx_pages *vmx, struct kvm_vm *vm,
uint32_t eptp_memslot);
+void prepare_tpr_shadow(struct vmx_pages *vmx, struct kvm_vm *vm);
#endif /* SELFTEST_KVM_VMX_H */
diff --git a/tools/testing/selftests/kvm/lib/x86_64/vmx.c b/tools/testing/selftests/kvm/lib/x86_64/vmx.c
index 2448b30e8efa..1023760d1bf7 100644
--- a/tools/testing/selftests/kvm/lib/x86_64/vmx.c
+++ b/tools/testing/selftests/kvm/lib/x86_64/vmx.c
@@ -551,3 +551,11 @@ void prepare_virtualize_apic_accesses(struct vmx_pages *vmx, struct kvm_vm *vm,
vmx->apic_access_hva = addr_gva2hva(vm, (uintptr_t)vmx->apic_access);
vmx->apic_access_gpa = addr_gva2gpa(vm, (uintptr_t)vmx->apic_access);
}
+
+void prepare_tpr_shadow(struct vmx_pages *vmx, struct kvm_vm *vm)
+{
+ vmx->virtual_apic = (void *)vm_vaddr_alloc(vm, getpagesize(),
+ 0x10000, 0, 0);
+ vmx->virtual_apic_hva = addr_gva2hva(vm, (uintptr_t)vmx->virtual_apic);
+ vmx->virtual_apic_gpa = addr_gva2gpa(vm, (uintptr_t)vmx->virtual_apic);
+}
--
2.32.0.rc1.229.g3e70b5a671-goog
next prev parent reply other threads:[~2021-06-04 17:28 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-04 17:25 [PATCH v2 00/12] KVM: nVMX: Fix vmcs02 PID use-after-free issue Jim Mattson
2021-06-04 17:26 ` [PATCH v2 01/12] KVM: x86: Remove guest mode check from kvm_check_nested_events Jim Mattson
2021-06-04 17:26 ` [PATCH v2 02/12] KVM: x86: Wake up a vCPU when kvm_check_nested_events fails Jim Mattson
2021-06-04 17:26 ` [PATCH v2 03/12] KVM: nVMX: Add a return code to vmx_complete_nested_posted_interrupt Jim Mattson
2021-06-04 17:26 ` [PATCH v2 04/12] KVM: x86: Add a return code to inject_pending_event Jim Mattson
2021-06-04 17:26 ` [PATCH v2 05/12] KVM: x86: Add a return code to kvm_apic_accept_events Jim Mattson
2021-06-04 17:26 ` [PATCH v2 06/12] KVM: nVMX: Fail on MMIO completion for nested posted interrupts Jim Mattson
2021-06-04 17:26 ` [PATCH v2 07/12] KVM: nVMX: Disable vmcs02 posted interrupts if vmcs12 PID isn't mappable Jim Mattson
2021-06-04 17:26 ` [PATCH v2 08/12] KVM: selftests: Move APIC definitions into a separate file Jim Mattson
2021-06-04 17:26 ` [PATCH v2 09/12] KVM: selftests: Hoist APIC functions out of individual tests Jim Mattson
2021-06-04 17:26 ` [PATCH v2 10/12] KVM: selftests: Introduce x2APIC register manipulation functions Jim Mattson
2021-06-04 17:26 ` Jim Mattson [this message]
2021-06-04 17:26 ` [PATCH v2 12/12] KVM: selftests: Add a test of an unbacked nested PI descriptor Jim Mattson
2021-06-10 11:55 ` [PATCH v2 00/12] KVM: nVMX: Fix vmcs02 PID use-after-free issue Paolo Bonzini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210604172611.281819-12-jmattson@google.com \
--to=jmattson@google.com \
--cc=kvm@vger.kernel.org \
--cc=oupton@google.com \
--cc=pbonzini@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).