KVM: x86: Tweak name of MONITOR/MWAIT #UD quirk to make it #UD specific
authorSean Christopherson <seanjc@google.com>
Mon, 11 Jul 2022 22:57:53 +0000 (22:57 +0000)
committerSean Christopherson <seanjc@google.com>
Thu, 14 Jul 2022 01:14:05 +0000 (18:14 -0700)
Add a "UD" clause to KVM_X86_QUIRK_MWAIT_NEVER_FAULTS to make it clear
that the quirk only controls the #UD behavior of MONITOR/MWAIT.  KVM
doesn't currently enforce fault checks when MONITOR/MWAIT are supported,
but that could change in the future.  SVM also has a virtualization hole
in that it checks all faults before intercepts, and so "never faults" is
already a lie when running on SVM.

Fixes: bfbcc81bb82c ("KVM: x86: Add a quirk for KVM's "MONITOR/MWAIT are NOPs!" behavior")
Signed-off-by: Sean Christopherson <seanjc@google.com>
Link: https://lore.kernel.org/r/20220711225753.1073989-4-seanjc@google.com
Documentation/virt/kvm/api.rst
arch/x86/include/asm/kvm_host.h
arch/x86/include/uapi/asm/kvm.h
arch/x86/kvm/x86.c
tools/testing/selftests/kvm/x86_64/monitor_mwait_test.c

index bafaeedd455c38da79b116c3199d2eb65c97a1bd..cd9361f225302c8f89f458f87b05a99cee3f541b 100644 (file)
@@ -7523,7 +7523,7 @@ The valid bits in cap.args[0] are:
                                     incorrect hypercall instruction will
                                     generate a #UD within the guest.
 
-KVM_X86_QUIRK_MWAIT_NEVER_FAULTS    By default, KVM emulates MONITOR/MWAIT (if
+KVM_X86_QUIRK_MWAIT_NEVER_UD_FAULTS By default, KVM emulates MONITOR/MWAIT (if
                                     they are intercepted) as NOPs regardless of
                                     whether or not MONITOR/MWAIT are supported
                                     according to guest CPUID.  When this quirk
index dd6a26f7d46cf18220580e492cce264f7b4e7304..d4ece7bf2124f2ee33baec17a6b767a868a5ab4e 100644 (file)
@@ -2096,6 +2096,6 @@ int memslot_rmap_alloc(struct kvm_memory_slot *slot, unsigned long npages);
         KVM_X86_QUIRK_OUT_7E_INC_RIP |         \
         KVM_X86_QUIRK_MISC_ENABLE_NO_MWAIT |   \
         KVM_X86_QUIRK_FIX_HYPERCALL_INSN |     \
-        KVM_X86_QUIRK_MWAIT_NEVER_FAULTS)
+        KVM_X86_QUIRK_MWAIT_NEVER_UD_FAULTS)
 
 #endif /* _ASM_X86_KVM_HOST_H */
index ee3896416c68ad0806f96084c7e79d63db4aa4d3..a0c0ab0c898e4d6313a04ce5efe27dbb60c5d64a 100644 (file)
@@ -439,7 +439,7 @@ struct kvm_sync_regs {
 #define KVM_X86_QUIRK_OUT_7E_INC_RIP           (1 << 3)
 #define KVM_X86_QUIRK_MISC_ENABLE_NO_MWAIT     (1 << 4)
 #define KVM_X86_QUIRK_FIX_HYPERCALL_INSN       (1 << 5)
-#define KVM_X86_QUIRK_MWAIT_NEVER_FAULTS       (1 << 6)
+#define KVM_X86_QUIRK_MWAIT_NEVER_UD_FAULTS    (1 << 6)
 
 #define KVM_STATE_NESTED_FORMAT_VMX    0
 #define KVM_STATE_NESTED_FORMAT_SVM    1
index 67dcaa6708748083bd736e48b5732adfe7989fe4..db46c060acb582f28fb2815b8e9ab31ad351a7eb 100644 (file)
@@ -2046,7 +2046,7 @@ EXPORT_SYMBOL_GPL(kvm_handle_invalid_op);
 
 static int kvm_emulate_monitor_mwait(struct kvm_vcpu *vcpu, const char *insn)
 {
-       if (!kvm_check_has_quirk(vcpu->kvm, KVM_X86_QUIRK_MWAIT_NEVER_FAULTS) &&
+       if (!kvm_check_has_quirk(vcpu->kvm, KVM_X86_QUIRK_MWAIT_NEVER_UD_FAULTS) &&
            !guest_cpuid_has(vcpu, X86_FEATURE_MWAIT))
                return kvm_handle_invalid_op(vcpu);
 
index 6a4ebcdfa374c507624da30bf7b016bcbf6cff80..094c68d744c0c56dc2eed8864149a5d3072393be 100644 (file)
@@ -113,7 +113,7 @@ int main(int argc, char *argv[])
 
                disabled_quirks = 0;
                if (testcase & MWAIT_QUIRK_DISABLED)
-                       disabled_quirks |= KVM_X86_QUIRK_MWAIT_NEVER_FAULTS;
+                       disabled_quirks |= KVM_X86_QUIRK_MWAIT_NEVER_UD_FAULTS;
                if (testcase & MISC_ENABLES_QUIRK_DISABLED)
                        disabled_quirks |= KVM_X86_QUIRK_MISC_ENABLE_NO_MWAIT;
                vm_enable_cap(vm, KVM_CAP_DISABLE_QUIRKS2, disabled_quirks);