public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [kvm-unit-tests PATCH] X86: Set up EPT before running vmx_pf_exception_test
@ 2022-07-15 11:33 Yu Zhang
  2022-08-02 20:41 ` Sean Christopherson
  0 siblings, 1 reply; 5+ messages in thread
From: Yu Zhang @ 2022-07-15 11:33 UTC (permalink / raw)
  To: pbonzini, kvm

Although currently vmx_pf_exception_test can succeed, its
success is actually because we are using identical mappings
in the page tables and EB.PF is not set by L1. In practice,
the #PFs shall be expected by L1, if it is using shadowing
for L2.

So just set up the EPT, and clear the EB.PT, then L1 has the
right to claim a failure if a #PF is encountered.

Signed-off-by: Yu Zhang <yu.c.zhang@linux.intel.com>
---
 x86/vmx_tests.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c
index 4d581e7..cc90611 100644
--- a/x86/vmx_tests.c
+++ b/x86/vmx_tests.c
@@ -10639,6 +10639,17 @@ static void __vmx_pf_exception_test(invalidate_tlb_t inv_fn, void *data)
 
 static void vmx_pf_exception_test(void)
 {
+	u32 eb;
+
+	if (setup_ept(false)) {
+		printf("EPT not supported.\n");
+		return;
+	}
+
+	eb = vmcs_read(EXC_BITMAP);
+	eb &= ~(1 << PF_VECTOR);
+	vmcs_write(EXC_BITMAP, eb);
+
 	__vmx_pf_exception_test(NULL, NULL);
 }
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-08-04  2:15 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-15 11:33 [kvm-unit-tests PATCH] X86: Set up EPT before running vmx_pf_exception_test Yu Zhang
2022-08-02 20:41 ` Sean Christopherson
2022-08-03  1:57   ` Yu Zhang
2022-08-03 14:25     ` Sean Christopherson
2022-08-04  2:14       ` Yu Zhang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox