Skip to contentSkip to conversation

KVM: selftests: Add back the missing check of MONITOR/MWAIT availability

PATCH Applied Chenyi Qiang 2 participants 2 messages Jun 20, 2025 – Jun 25, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 KVM: selftests: Add back the missing check of MONITOR/MWAIT availability

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/[email protected]/

Fixes 80fd663590cf ("selftests: kvm: revamp MONITOR/MWAIT tests")
---
 tools/testing/selftests/kvm/x86/monitor_mwait_test.c | 1 +
 1 file changed, 1 insertion(+)
tools/testing/selftests/kvm/x86/monitor_mwait_test.c +1 -0
index 390ae2d87493..0eb371c62ab8 100644
@@ -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();
Signature · 1 line
2.43.5
maintainer Applied
#1 lore raw
Quoted 8 lines · Chenyi Qiang

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/[email protected]/

[...]

Applied to kvm-x86 fixes, thanks!

[1/1] KVM: selftests: Add back the missing check of MONITOR/MWAIT availability

      https://github.com/kvm-x86/linux/commit/0048ca5e9945

--
https://github.com/kvm-x86/kvm-unit-tests/tree/next