linux-stable/tools/testing/selftests/kvm
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
..
aarch64 Merge branch kvm-arm64/selftest/timer into kvmarm-master/next 2021-10-17 11:19:42 +01:00
include selftests: KVM: Fix non-x86 compiling 2021-12-20 08:06:54 -05:00
lib selftests: KVM: Fix non-x86 compiling 2021-12-20 08:06:54 -05:00
s390x KVM: selftests: sync_regs test for diag318 2020-12-10 13:36:05 +01:00
x86_64 KVM: selftests: Add test to verify TRIPLE_FAULT on invalid L2 guest state 2021-12-20 08:06:55 -05:00
.gitignore KVM: selftests: Add test to verify TRIPLE_FAULT on invalid L2 guest state 2021-12-20 08:06:55 -05:00
access_tracking_perf_test.c KVM: selftests: Move vCPU thread creation and joining to common helpers 2021-11-16 07:43:28 -05:00
config selftests: kvm: Adding config fragments 2019-08-09 16:52:38 +02:00
demand_paging_test.c KVM: selftests: Move vCPU thread creation and joining to common helpers 2021-11-16 07:43:28 -05:00
dirty_log_perf_test.c KVM: selftests: Move vCPU thread creation and joining to common helpers 2021-11-16 07:43:28 -05:00
dirty_log_test.c KVM: selftests: Expose align() helpers to tests 2021-11-16 07:43:24 -05:00
hardware_disable_test.c KVM: selftests: Unconditionally use memslot 0 when loading elf binary 2021-06-24 04:31:17 -04:00
kvm_binary_stats_test.c KVM: selftests: Add checks for histogram stats bucket_size field 2021-08-20 16:06:32 -04:00
kvm_create_max_vcpus.c KVM: selftests: Make sure kvm_create_max_vcpus test won't hit RLIMIT_NOFILE 2021-11-26 08:14:20 -05:00
kvm_page_table_test.c KVM: selftests: page_table_test: fix calculation of guest_test_phys_mem 2021-11-30 03:12:13 -05:00
Makefile KVM: selftests: Add test to verify TRIPLE_FAULT on invalid L2 guest state 2021-12-20 08:06:55 -05:00
memslot_modification_stress_test.c KVM: selftests: Use perf_test_destroy_vm in memslot_modification_stress_test 2021-11-16 07:43:28 -05:00
memslot_perf_test.c KVM: selftests: Make memslot_perf_test arch independent 2021-10-21 11:36:34 +01:00
rseq_test.c KVM: selftests: Ensure all migrations are performed when test is affined 2021-09-30 04:25:57 -04:00
set_memory_region_test.c Merge tag 'kvm-s390-master-5.14-1' of git://git.kernel.org/pub/scm/linux/kernel/git/kvms390/linux into HEAD 2021-07-14 12:14:27 -04:00
settings selftests: kvm: Raise the default timeout to 120 seconds 2021-02-09 08:17:08 -05:00
steal_time.c x86: 2021-09-27 13:58:23 -07:00
system_counter_offset_test.c selftests: KVM: Introduce system counter offset test 2021-10-18 14:43:46 -04:00