KVM: selftests: Verify KVM is loaded when getting a KVM module param
authorSean Christopherson <seanjc@google.com>
Fri, 16 May 2025 21:59:06 +0000 (14:59 -0700)
committerSean Christopherson <seanjc@google.com>
Fri, 20 Jun 2025 20:39:10 +0000 (13:39 -0700)
commitfcab107abe1ab5be9dbe874baa722372da8f4f73
tree112949460c1fbccd780424247c1d70e0b80dac35
parent30142a93b1641b19bf4ba2cd6beb5814adc5b746
KVM: selftests: Verify KVM is loaded when getting a KVM module param

Probe /dev/kvm when getting a KVM module param so that attempting to load
a module param super early in a selftest generates a SKIP message about
KVM not being loaded/enabled, versus some random parameter not existing.

E.g. KVM x86's unconditional retrieval of force_emulation_prefix during
kvm_selftest_arch_init() generates a rather confusing error message that
takes far too much triage to understand.

Link: https://lore.kernel.org/r/20250516215909.2551628-2-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
tools/testing/selftests/kvm/include/x86/processor.h
tools/testing/selftests/kvm/lib/kvm_util.c
tools/testing/selftests/kvm/lib/x86/processor.c
tools/testing/selftests/kvm/x86/vmx_exception_with_invalid_guest_state.c