Skip to content

x86/access: nVMX: Big overhaul

Sean Christopherson kvm 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest39 patches 7 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/39x86/access: Add proper defines for hardcoded addressesx86/access.c+6 -20 replies
2/39x86/access: Cache CR3 to improve performancex86/access.c+4 -20 replies
3/39x86/access: Use do-while loop for what is obviously a do-while loopx86/access.c+3 -20 replies
4/39x86/access: Stop pretending the test is SMP friendlyx86/access.c+1 -40 replies
5/39x86/access: Refactor so called "page table pool" logicx86/access.c+10 -91 reply
6/39x86/access: Stash root page table level in test environmentx86/access.c+68 -640 replies
7/39x86/access: Hoist page table allocator helpers above "init" helperx86/access.c+21 -210 replies
8/39x86/access: Rename variables in page table walkersx86/access.c+14 -130 replies
9/39x86/access: Abort if page table insertion hits an unexpected levelx86/access.c+4 -10 replies
10/39x86/access: Make SMEP place nice with 5-level pagingx86/access.c+61 -250 replies
11/39x86/access: Use upper half of virtual address spacex86/access.c+30 -200 replies
12/39x86/access: Print the index when dumping PTEsx86/access.c+1 -10 replies
13/39x86/access: Pre-allocate all page tables at (sub)test initx86/access.c+101 -681 reply
14/39x86/access: Don't write page tables if desired PTE is same as current PTEx86/access.c+2 -10 replies
15/39x86/access: Preserve A/D bits when writing paging structure entriesx86/access.c+5 -10 replies
16/39x86/access: Make toggling of PRESENT bit a "higher order" actionx86/access.c+8 -40 replies
17/39x86/access: Manually override PMD in effective permissions sub-testx86/access.c+13 -100 replies
18/39x86/access: Remove manual override of PUD/PMD in prefetch sub-testx86/access.c+2 -20 replies
19/39x86/access: Remove PMD/PT target overridesx86/access.c+15 -320 replies
20/39x86/access: Remove timeout overrides now that performance doesn't suckx86/unittests.cfg+0 -40 replies
21/39nVMX: Skip EPT tests if INVEPT(SINGLE_CONTEXT) is unsupportedx86/vmx.h x86/vmx_tests.c+13 -00 replies
22/39nVMX: Hoist assert macros to the top of vmx.hx86/vmx.h+55 -550 replies
23/39nVMX: Add a non-reporting assertion macrox86/vmx.h+6 -10 replies
24/39nVMX: Assert success in unchecked INVEPT/INVVPID helpersx86/vmx.h x86/vmx_tests.c+21 -110 replies
25/39nVMX: Drop less-than-useless ept_sync() wrapperx86/vmx.c x86/vmx.h x86/vmx_tests.c+13 -350 replies
26/39nVMX: Move EPT capability check helpers to vmx.hx86/vmx.c x86/vmx.h+30 -360 replies
27/39nVMX: Drop unused and useless vpid_sync() helperx86/vmx.c x86/vmx.h+0 -190 replies
28/39nVMX: Remove "v1" version of INVVPID testx86/vmx_tests.c+2 -891 reply
29/39nVMX: Add helper to check if INVVPID type is supportedx86/vmx.h x86/vmx_tests.c+13 -120 replies
30/39nVMX: Add helper to check if INVVPID is supportedx86/vmx.h x86/vmx_tests.c+6 -40 replies
31/39nVMX: Add helper to get first supported INVVPID typex86/vmx_tests.c+10 -100 replies
32/39nVMX: Use helper to check for EPT A/D supportx86/vmx_tests.c+2 -20 replies
33/39nVMX: Add helpers to check for 4/5-level EPT supportx86/vmx.h x86/vmx_tests.c+12 -20 replies
34/39nVMX: Fix name of macro defining EPT execute only capabilityx86/vmx.c x86/vmx.h+3 -31 reply
35/39nVMX: Add helper to check if a memtype is supported for EPT structuresx86/vmx.h x86/vmx_tests.c+13 -310 replies
36/39nVMX: Get rid of horribly named "ctrl" boolean in test_ept_eptp()x86/vmx_tests.c+1 -60 replies
37/39nVMX: Rename awful "ctrl" booleans to "is_ctrl_valid"x86/vmx_tests.c+9 -90 replies
38/39nVMX: Add helper to check if VPID is supportedx86/vmx.h x86/vmx_tests.c+8 -40 replies
39/39x86/access: nVMX: Add "access" test variants to invalidate via (INV)VPIDx86/unittests.cfg x86/vmx_tests.c+91 -40 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [kvm-unit-tests PATCH 00/39] x86/access: nVMX: Big overhaul

This started out as a very simple test (patch 39/39) to expose a KVM bug where KVM doesn't sync a shadow MMU on a vmcs12->vpid change. Except the test didn't fail. And it turns out, completely removing INVLPG from the base access test doesn't fail when using shadow paging either.

The underlying problem in both cases is that the access test is flat out stupid when it comes to handling page tables. Instead of allocating page tables once and manipulating them on each iteration, it "allocates" a new paging structure when necessary on every. single. iteration. In addition to being incredibly inefficient (allocation also zeros the entire 4kb page, so the test zeros absurd amounts of memory), writing upper level PTEs on every iteration triggers write-protection mechanisms in KVM. In effect, KVM ends up synchronizing the relevant SPTEs on every iteration, which again is ridiculously slow and makes it all but impossible to actually test that KVM handles other TLB invalidation scenarios.

Trying to solve that mess by pre-allocating the page tables exposed a whole pile of 5-level paging issues. I'd say the test's 5-level support is held together by duct tape, but I've fixed many things with duct tape that are far less fragile.

The second half of this series is cleanups in the nVMX code to prepare for adding the (INV)VPID variants. Not directly related to the access tests, but it annoyed me to no end that simply checking if INVVPID is supported was non-trivial.

Sean Christopherson (39):
x86/access: Add proper defines for hardcoded addresses x86/access: Cache CR3 to improve performance
x86/access: Use do-while loop for what is obviously a do-while loop x86/access: Stop pretending the test is SMP friendly x86/access: Refactor so called "page table pool" logic x86/access: Stash root page table level in test environment x86/access: Hoist page table allocator helpers above "init" helper x86/access: Rename variables in page table walkers x86/access: Abort if page table insertion hits an unexpected level x86/access: Make SMEP place nice with 5-level paging x86/access: Use upper half of virtual address space x86/access: Print the index when dumping PTEs
x86/access: Pre-allocate all page tables at (sub)test init x86/access: Don't write page tables if desired PTE is same as current
PTE
x86/access: Preserve A/D bits when writing paging structure entries x86/access: Make toggling of PRESENT bit a "higher order" action x86/access: Manually override PMD in effective permissions sub-test x86/access: Remove manual override of PUD/PMD in prefetch sub-test x86/access: Remove PMD/PT target overrides
x86/access: Remove timeout overrides now that performance doesn't suck
nVMX: Skip EPT tests if INVEPT(SINGLE_CONTEXT) is unsupported
nVMX: Hoist assert macros to the top of vmx.h
nVMX: Add a non-reporting assertion macro
nVMX: Assert success in unchecked INVEPT/INVVPID helpers
nVMX: Drop less-than-useless ept_sync() wrapper
nVMX: Move EPT capability check helpers to vmx.h
nVMX: Drop unused and useless vpid_sync() helper
nVMX: Remove "v1" version of INVVPID test
nVMX: Add helper to check if INVVPID type is supported
nVMX: Add helper to check if INVVPID is supported
nVMX: Add helper to get first supported INVVPID type
nVMX: Use helper to check for EPT A/D support
nVMX: Add helpers to check for 4/5-level EPT support
nVMX: Fix name of macro defining EPT execute only capability
nVMX: Add helper to check if a memtype is supported for EPT structures
nVMX: Get rid of horribly named "ctrl" boolean in test_ept_eptp()
nVMX: Rename awful "ctrl" booleans to "is_ctrl_valid"
nVMX: Add helper to check if VPID is supported
x86/access: nVMX: Add "access" test variants to invalidate via
(INV)VPID

 x86/access.c      | 391 ++++++++++++++++++++++++++++------------------
 x86/unittests.cfg |  10 +-
 x86/vmx.c         |  71 +--------
 x86/vmx.h         | 229 ++++++++++++++++++---------
 x86/vmx_tests.c   | 327 +++++++++++++++++---------------------
 5 files changed, 543 insertions(+), 485 deletions(-)
Signature · 1 line
2.34.0.rc2.393.gf8c9666880-goog