X86: Set up EPT before running vmx_pf_exception_test
PATCH 1/1 X86: Set up EPT before running vmx_pf_exception_test
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.
--- x86/vmx_tests.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
x86/vmx_tests.c +11 -0
@@ -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 ); }
Signature · 1 line
2.25.1
Sean Christopherson
reviewerQuoted 5 lines · Yu Zhang
Although currently
vmx_pf_exception_testcan 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.
I'm a bit lost. Is there an actual failure somewhere? AFAICT, this passes when run as L1 or L2, with or without EPT enabled.
Quoted 33 lines
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 <[email protected]>--- x86/vmx_tests.c | 11 +++++++++++ 1 file changed, 11 insertions(+)x86/vmx_tests.c +11
-0@@ -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 ); }Signature · 1 line
2.25.1
Quoted 9 lines · Sean Christopherson
Quoted 5 lines · Yu Zhang
Although currently
vmx_pf_exception_testcan 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.I'm a bit lost. Is there an actual failure somewhere? AFAICT, this passes when run as L1 or L2, with or without EPT enabled.
Thanks for your reply, Sean.
There's no failure. But IMHO, there should have been(for the vmx_pf_exception_test, not the access test) - L1 shall expect #PF induced VM exits, when it is using shadow for L2.
B.R.
Yu
Quoted 9 lines
x86/vmx_tests.c > > index
Quoted 9 lines
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 <[email protected]>--- x86/vmx_tests.c | 11 +++++++++++ 1 file changed, 11 insertions(+)x86/vmx_tests.c > > index renamed from x86/vmx_tests.c +0
-0
4d581e7..cc90611 100644
Quoted 23 lines
Quoted 23 lines
x86/vmx_tests.c +11
-0@@ -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 ); }Signature · 1 line
2.25.1
Sean Christopherson
reviewerQuoted 8 lines · Yu Zhang
Quoted 7 lines · Sean Christopherson
Quoted 5 lines · Yu Zhang
Although currently
vmx_pf_exception_testcan 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.
Quoted 8 lines
Quoted 2 lines
I'm a bit lost. Is there an actual failure somewhere? AFAICT, this passes when run as L1 or L2, with or without EPT enabled.
Thanks for your reply, Sean.
There's no failure. But IMHO, there should have
been(for the vmx_pf_exception_test, not the access test)- L1 shall expect #PF induced VM exits, when it is using shadow for L2.
Note, I'm assuming L1 == KVM-Unit-Tests, let me know if we're not using the same terminology.
Not using EPT / TDP doesn't strictly imply page table shadowing. E.g. if a hypervisor provides a paravirt interface to install mappings, and the contract is that the VM must use the paravirt API, then the hypervisor doesn't need to intercept page faults because there are effectively no guest PTEs to write-protect / shadow.
That's more or less what's happening here, L1 and L2 are collaborating to create page tables for L2, and so L1 doesn't need to intercept #PF.
Quoted 21 lines · Sean Christopherson
Quoted 8 lines · Yu Zhang
Quoted 7 lines · Sean Christopherson
Quoted 5 lines · Yu Zhang
Although currently
vmx_pf_exception_testcan 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.Quoted 8 lines
Quoted 2 lines
I'm a bit lost. Is there an actual failure somewhere? AFAICT, this passes when run as L1 or L2, with or without EPT enabled.
Thanks for your reply, Sean.
There's no failure. But IMHO, there should have
been(for the vmx_pf_exception_test, not the access test)- L1 shall expect #PF induced VM exits, when it is using shadow for L2.Note, I'm assuming L1 == KVM-Unit-Tests, let me know if we're not using the same terminology.
Quoted 7 lines
Not using EPT / TDP doesn't strictly imply page table shadowing. E.g. if a hypervisor provides a paravirt interface to install mappings, and the contract is that the VM must use the paravirt API, then the hypervisor doesn't need to intercept page faults because there are effectively no guest PTEs to write-protect / shadow.
That's more or less what's happening here, L1 and L2 are collaborating to create page tables for L2, and so L1 doesn't need to intercept #PF.
Oh... So it is intentionally designed to let L1 and L2 use the same address space. Then we can just drop this patch. Thanks a lot for the explanation!
B.R.
Yu