KVM: selftests: Make monitor_mwait require MONITOR/MWAIT feature
authorZide Chen <zide.chen@intel.com>
Thu, 11 Apr 2024 21:02:37 +0000 (14:02 -0700)
committerSean Christopherson <seanjc@google.com>
Thu, 25 Apr 2024 23:08:59 +0000 (16:08 -0700)
If this feature is not supported or is disabled by IA32_MISC_ENABLE on
the host, executing MONITOR or MWAIT instruction from the guest doesn't
cause monitor/mwait VM exits, but a #UD.

So, we need to skip this test if CPUID.01H:ECX[3] is cleared.

Signed-off-by: Zide Chen <zide.chen@intel.com>
Link: https://lore.kernel.org/r/20240411210237.34646-1-zide.chen@intel.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
tools/testing/selftests/kvm/x86_64/monitor_mwait_test.c

index 853802641e1eafe553bc7c0676801227a5601be9..cdbfcf7cac5c4fcdff9d0e60c8c8c804560b377e 100644 (file)
@@ -75,6 +75,7 @@ int main(int argc, char *argv[])
        struct ucall uc;
        int testcase;
 
+       TEST_REQUIRE(this_cpu_has(X86_FEATURE_MWAIT));
        TEST_REQUIRE(kvm_has_cap(KVM_CAP_DISABLE_QUIRKS2));
 
        vm = vm_create_with_one_vcpu(&vcpu, guest_code);