KVM: selftests: Add back the missing check of MONITOR/MWAIT availability
authorChenyi Qiang <chenyi.qiang@intel.com>
Fri, 20 Jun 2025 06:22:18 +0000 (14:22 +0800)
committerSean Christopherson <seanjc@google.com>
Tue, 24 Jun 2025 19:58:19 +0000 (12:58 -0700)
The revamp of monitor/mwait test missed the original check of feature
availability [*]. If MONITOR/MWAIT is not supported or is disabled by
IA32_MISC_ENABLE on the host, executing MONITOR or MWAIT instruction
from guest doesn't cause monitor/mwait VM exits, but a #UD.

[*] https://lore.kernel.org/all/20240411210237.34646-1-zide.chen@intel.com/

Reported-by: Xuelian Guo <xuelian.guo@intel.com>
Fixes: 80fd663590cf ("selftests: kvm: revamp MONITOR/MWAIT tests")
Signed-off-by: Chenyi Qiang <chenyi.qiang@intel.com>
Link: https://lore.kernel.org/r/20250620062219.342930-1-chenyi.qiang@intel.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
tools/testing/selftests/kvm/x86/monitor_mwait_test.c

index 390ae2d874932b46e35f993c22712e5da9e7f656..0eb371c62ab876f6a4ba15557d026d2cf849e778 100644 (file)
@@ -74,6 +74,7 @@ int main(int argc, char *argv[])
        int testcase;
        char test[80];
 
+       TEST_REQUIRE(this_cpu_has(X86_FEATURE_MWAIT));
        TEST_REQUIRE(kvm_has_cap(KVM_CAP_DISABLE_QUIRKS2));
 
        ksft_print_header();