]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
KVM: selftests: Fix a bad TEST_REQUIRE() in x86's KVM PV test
authorSean Christopherson <seanjc@google.com>
Thu, 28 Nov 2024 01:33:43 +0000 (17:33 -0800)
committerSean Christopherson <seanjc@google.com>
Wed, 18 Dec 2024 22:19:38 +0000 (14:19 -0800)
Actually check for KVM support for disabling HLT-exiting instead of
effectively checking that KVM_CAP_X86_DISABLE_EXITS is #defined to a
non-zero value, and convert the TEST_REQUIRE() to a simple return so
that only the sub-test is skipped if HLT-exiting is mandatory.

The goof has likely gone unnoticed because all x86 CPUs support disabling
HLT-exiting, only systems with the opt-in mitigate_smt_rsb KVM module
param disallow HLT-exiting.

Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com>
Reviewed-by: Binbin Wu <binbin.wu@linux.intel.com>
Reviewed-by: Xiaoyao Li <xiaoyao.li@intel.com>
Link: https://lore.kernel.org/r/20241128013424.4096668-17-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
tools/testing/selftests/kvm/x86/kvm_pv_test.c

index 78878b3a272522ddb85f97da1a7349d2064a1d4b..2aee93108a54c4800cca4d49749e725a66e47cba 100644 (file)
@@ -140,9 +140,10 @@ static void test_pv_unhalt(void)
        struct kvm_cpuid_entry2 *ent;
        u32 kvm_sig_old;
 
-       pr_info("testing KVM_FEATURE_PV_UNHALT\n");
+       if (!(kvm_check_cap(KVM_CAP_X86_DISABLE_EXITS) & KVM_X86_DISABLE_EXITS_HLT))
+               return;
 
-       TEST_REQUIRE(KVM_CAP_X86_DISABLE_EXITS);
+       pr_info("testing KVM_FEATURE_PV_UNHALT\n");
 
        /* KVM_PV_UNHALT test */
        vm = vm_create_with_one_vcpu(&vcpu, guest_main);