The motivation behind this change is to test the routing logic when an exception occurs in an L2 guest and ensure the exception goes to the correct place. For example, if an exception occurs in L2, does L1 want to get involved, or L0, or do niether of them care about it and leave it to L2 to handle. Test that the exception doesn't end up going to L1 When L1 didn't ask for it. This was occurring before commit 18712c13709d ("KVM: nVMX: Use vmx_need_pf_intercept() when deciding if L0 wants a #PF") fixed the issue. Without that fix, running vmx_pf_exception_test_reduced_maxphyaddr with allow_smaller_maxphyaddr=Y would have resulted in the test failing with the following error: x86/vmx_tests.c:10698: assert failed: false: Unexpected exit to L1, exit_reason: VMX_EXC_NMI (0x0) This series only tests the routing logic for #PFs. A future series will address other exceptions, however, getting #PF testing in place is a big enough chunk that the other exceptions will be submitted seperately (in a future series). This series is dependant on Paolo's changes (inlcuded). Without them, running ac_test_run() on one of the userspace test fails. Of note: the commit ("x86: get rid of ring0stacktop") has been updated to include a fix for a compiler error to get it building on clang. This series is also dependant on the commit ("x86: Look up the PTEs rather than assuming them"). This was sent out for review seperately, however, it is needed to get ac_test_run() running on a different cr3 than the one access_test runs on, so it is included here as well. This is also v2 of that commit. While preparing this series a review came in, so I just included the changes here. Paolo Bonzini (9): x86: cleanup handling of 16-byte GDT descriptors x86: fix call to set_gdt_entry unify field names and definitions for GDT descriptors replace tss_descr global with a function x86: Move IDT to desc.c x86: unify name of 32-bit and 64-bit GDT x86: get rid of ring0stacktop x86: Move 64-bit GDT and TSS to desc.c x86: Move 32-bit GDT and TSS to desc.c Aaron Lewis (5): x86: Look up the PTEs rather than assuming them (v2) x86: Prepare access test for running in L2 x86: Fix tabs in access.c x86: Clean up the global, page_table_levels, in access.c x86: Add tests to run ac_test_run() in an L2 guest lib/libcflat.h | 1 + lib/x86/asm/setup.h | 6 + lib/x86/desc.c | 116 +++- lib/x86/desc.h | 31 +- lib/x86/setup.c | 49 ++ lib/x86/usermode.c | 9 +- lib/x86/vm.c | 21 + lib/x86/vm.h | 3 + x86/Makefile.common | 4 + x86/Makefile.x86_64 | 2 +- x86/access.c | 1447 ++++++++++++++++++++-------------------- x86/access.h | 9 + x86/access_test.c | 20 + x86/cstart.S | 115 +--- x86/cstart64.S | 98 +-- x86/flat.lds | 1 + x86/smap.c | 2 +- x86/svm_tests.c | 15 +- x86/taskswitch.c | 4 +- x86/umip.c | 19 +- x86/unittests.cfg | 17 +- x86/vmware_backdoors.c | 22 +- x86/vmx.c | 17 +- x86/vmx_tests.c | 53 +- 24 files changed, 1080 insertions(+), 1001 deletions(-) create mode 100644 lib/x86/asm/setup.h create mode 100644 x86/access.h create mode 100644 x86/access_test.c -- 2.34.0.rc1.387.gb447b232ab-goog