linux/tools/testing/selftests/kvm/x86_64
Sean Christopherson ab1ef34416 KVM: selftests: Add test to verify TRIPLE_FAULT on invalid L2 guest state
Add a selftest to attempt to enter L2 with invalid guests state by
exiting to userspace via I/O from L2, and then using KVM_SET_SREGS to set
invalid guest state (marking TR unusable is arbitrary chosen for its
relative simplicity).

This is a regression test for a bug introduced by commit c8607e4a08
("KVM: x86: nVMX: don't fail nested VM entry on invalid guest state if
!from_vmentry"), which incorrectly set vmx->fail=true when L2 had invalid
guest state and ultimately triggered a WARN due to nested_vmx_vmexit()
seeing vmx->fail==true while attempting to synthesize a nested VM-Exit.

The is also a functional test to verify that KVM sythesizes TRIPLE_FAULT
for L2, which is somewhat arbitrary behavior, instead of emulating L2.
KVM should never emulate L2 due to invalid guest state, as it's
architecturally impossible for L1 to run an L2 guest with invalid state
as nested VM-Enter should always fail, i.e. L1 needs to do the emulation.
Stuffing state via KVM ioctl() is a non-architctural, out-of-band case,
hence the TRIPLE_FAULT being rather arbitrary.

Signed-off-by: Sean Christopherson <seanjc@google.com>
Message-Id: <20211207193006.120997-5-seanjc@google.com>
Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2021-12-20 08:06:55 -05:00
..
cr4_cpuid_sync_test.c KVM: selftests: Fix kvm_vm_free() in cr4_cpuid_sync and vmx_tsc_adjust tests 2021-09-30 04:27:08 -04:00
debug_regs.c KVM: selftests: test KVM_GUESTDBG_BLOCKIRQ 2021-08-20 16:06:39 -04:00
emulator_error_test.c selftests: kvm: Allows userspace to handle emulation errors. 2021-06-24 18:00:48 -04:00
evmcs_test.c KVM/arm64 updates for v5.14. 2021-06-25 11:24:24 -04:00
get_cpuid_test.c KVM: selftests: Unconditionally use memslot 0 for vaddr allocations 2021-06-24 11:47:42 -04:00
get_msr_index_features.c KVM: selftests: Print a message if /dev/kvm is missing 2021-05-27 07:45:55 -04:00
hyperv_clock.c KVM: selftests: fix hyperv_clock test 2021-08-04 09:43:03 -04:00
hyperv_cpuid.c selftests: kvm: Move kvm_get_supported_hv_cpuid() to common code 2021-02-09 08:17:09 -05:00
hyperv_features.c KVM: selftests: Avoid KVM_SET_CPUID2 after KVM_RUN in hyperv_features test 2021-11-26 08:14:19 -05:00
kvm_clock_test.c selftests: KVM: Add test for KVM_{GET,SET}_CLOCK 2021-10-18 14:43:45 -04:00
kvm_pv_test.c KVM: selftests: Rename vm_handle_exception 2021-06-14 09:06:22 +01:00
mmio_warning_test.c selftests: kvm: fix mismatched fclose() after popen() 2021-10-21 15:16:28 -06:00
mmu_role_test.c KVM: selftests: x86: Address missing vm_install_exception_handler conversions 2021-07-14 12:15:05 -04:00
platform_info_test.c KVM: selftests: Use consistent message for test skipping 2020-03-16 17:59:05 +01:00
set_boot_cpu_id.c KVM: selftests: Unconditionally use memslot 0 when loading elf binary 2021-06-24 04:31:17 -04:00
set_sregs_test.c KVM: selftests: Verify supported CR4 bits can be set before KVM_SET_CPUID2 2020-11-15 09:49:08 -05:00
sev_migrate_tests.c KVM: SEV: Prohibit migration of a VM that has mirrors 2021-11-30 03:54:14 -05:00
smm_test.c KVM: selftests: smm_test: Test SMM enter from L2 2021-07-15 10:19:44 -04:00
state_test.c KVM: selftests: x86: Set supported CPUIDs on default VM 2020-11-16 13:14:20 -05:00
svm_int_ctl_test.c KVM: x86: selftests: svm_int_ctl_test: fix intercept calculation 2021-12-09 12:44:39 -05:00
svm_vmcall_test.c KVM: selftests: x86: Set supported CPUIDs on default VM 2020-11-16 13:14:20 -05:00
sync_regs_test.c KVM: selftests: Complete x86_64/sync_regs_test ucall 2021-06-14 09:06:22 +01:00
tsc_msrs_test.c KVM: selftests: Move GUEST_ASSERT_EQ to utils header 2021-06-14 09:06:23 +01:00
userspace_io_test.c selftests: KVM: Add test to verify KVM doesn't explode on "bad" I/O 2021-12-10 09:38:02 -05:00
userspace_msr_exit_test.c KVM: selftests: Rename vm_handle_exception 2021-06-14 09:06:22 +01:00
vmx_apic_access_test.c KVM: selftests: Unconditionally allocate EPT tables in memslot 0 2021-06-24 11:47:48 -04:00
vmx_close_while_nested_test.c KVM: selftests: x86: Set supported CPUIDs on default VM 2020-11-16 13:14:20 -05:00
vmx_dirty_log_test.c tools: rename bitmap_alloc() to bitmap_zalloc() 2021-09-08 11:50:27 -07:00
vmx_invalid_nested_guest_state.c KVM: selftests: Add test to verify TRIPLE_FAULT on invalid L2 guest state 2021-12-20 08:06:55 -05:00
vmx_nested_tsc_scaling_test.c KVM: selftests: x86: Add vmx_nested_tsc_scaling_test 2021-06-17 13:09:30 -04:00
vmx_pmu_msrs_test.c KVM: selftests: vmx_pmu_msrs_test: Drop tests mangling guest visible CPUIDs 2021-12-19 19:35:29 +01:00
vmx_preemption_timer_test.c KVM: selftests: x86: Set supported CPUIDs on default VM 2020-11-16 13:14:20 -05:00
vmx_set_nested_state_test.c KVM: selftests: x86: Set supported CPUIDs on default VM 2020-11-16 13:14:20 -05:00
vmx_tsc_adjust_test.c KVM: selftests: Fix kvm_vm_free() in cr4_cpuid_sync and vmx_tsc_adjust tests 2021-09-30 04:27:08 -04:00
xapic_ipi_test.c KVM/arm64 updates for v5.14. 2021-06-25 11:24:24 -04:00
xen_shinfo_test.c KVM: selftests: Add event channel upcall support to xen_shinfo_test 2021-11-16 07:43:24 -05:00
xen_vmcall_test.c KVM: selftests: Unconditionally use memslot '0' for page table allocations 2021-06-24 11:47:48 -04:00
xss_msr_test.c KVM: selftests: Use consistent message for test skipping 2020-03-16 17:59:05 +01:00