diff mbox series

KVM: selftests: Make monitor_mwait require MONITOR/MWAIT feature

Message ID 20240411210237.34646-1-zide.chen@intel.com (mailing list archive)
State Accepted
Commit 72cd4de01d8b106182741132d5e0b61c3f55d636
Headers show
Series KVM: selftests: Make monitor_mwait require MONITOR/MWAIT feature | expand

Commit Message

Zide Chen April 11, 2024, 9:02 p.m. UTC
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>
---
 tools/testing/selftests/kvm/x86_64/monitor_mwait_test.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Sean Christopherson April 29, 2024, 8:45 p.m. UTC | #1
On Thu, 11 Apr 2024 14:02:37 -0700, Zide Chen wrote:
> 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.
> 
> 
> [...]

Applied to kvm-x86 selftests, thanks!

[1/1] KVM: selftests: Make monitor_mwait require MONITOR/MWAIT feature
      https://github.com/kvm-x86/linux/commit/72cd4de01d8b

--
https://github.com/kvm-x86/linux/tree/next
diff mbox series

Patch

diff --git a/tools/testing/selftests/kvm/x86_64/monitor_mwait_test.c b/tools/testing/selftests/kvm/x86_64/monitor_mwait_test.c
index 853802641e1e..cdbfcf7cac5c 100644
--- a/tools/testing/selftests/kvm/x86_64/monitor_mwait_test.c
+++ b/tools/testing/selftests/kvm/x86_64/monitor_mwait_test.c
@@ -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);