Skip to content

Commit 43bb9e0

Browse files
committed
KVM: x86: Tweak name of MONITOR/MWAIT #UD quirk to make it #UD specific
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: bfbcc81 ("KVM: x86: Add a quirk for KVM's "MONITOR/MWAIT are NOPs!" behavior") Signed-off-by: Sean Christopherson <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 14fd95b commit 43bb9e0

File tree

5 files changed

+5
-5
lines changed

5 files changed

+5
-5
lines changed

Documentation/virt/kvm/api.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7523,7 +7523,7 @@ The valid bits in cap.args[0] are:
75237523
incorrect hypercall instruction will
75247524
generate a #UD within the guest.
75257525

7526-
KVM_X86_QUIRK_MWAIT_NEVER_FAULTS By default, KVM emulates MONITOR/MWAIT (if
7526+
KVM_X86_QUIRK_MWAIT_NEVER_UD_FAULTS By default, KVM emulates MONITOR/MWAIT (if
75277527
they are intercepted) as NOPs regardless of
75287528
whether or not MONITOR/MWAIT are supported
75297529
according to guest CPUID. When this quirk

arch/x86/include/asm/kvm_host.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2096,6 +2096,6 @@ int memslot_rmap_alloc(struct kvm_memory_slot *slot, unsigned long npages);
20962096
KVM_X86_QUIRK_OUT_7E_INC_RIP | \
20972097
KVM_X86_QUIRK_MISC_ENABLE_NO_MWAIT | \
20982098
KVM_X86_QUIRK_FIX_HYPERCALL_INSN | \
2099-
KVM_X86_QUIRK_MWAIT_NEVER_FAULTS)
2099+
KVM_X86_QUIRK_MWAIT_NEVER_UD_FAULTS)
21002100

21012101
#endif /* _ASM_X86_KVM_HOST_H */

arch/x86/include/uapi/asm/kvm.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ struct kvm_sync_regs {
439439
#define KVM_X86_QUIRK_OUT_7E_INC_RIP (1 << 3)
440440
#define KVM_X86_QUIRK_MISC_ENABLE_NO_MWAIT (1 << 4)
441441
#define KVM_X86_QUIRK_FIX_HYPERCALL_INSN (1 << 5)
442-
#define KVM_X86_QUIRK_MWAIT_NEVER_FAULTS (1 << 6)
442+
#define KVM_X86_QUIRK_MWAIT_NEVER_UD_FAULTS (1 << 6)
443443

444444
#define KVM_STATE_NESTED_FORMAT_VMX 0
445445
#define KVM_STATE_NESTED_FORMAT_SVM 1

arch/x86/kvm/x86.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2046,7 +2046,7 @@ EXPORT_SYMBOL_GPL(kvm_handle_invalid_op);
20462046

20472047
static int kvm_emulate_monitor_mwait(struct kvm_vcpu *vcpu, const char *insn)
20482048
{
2049-
if (!kvm_check_has_quirk(vcpu->kvm, KVM_X86_QUIRK_MWAIT_NEVER_FAULTS) &&
2049+
if (!kvm_check_has_quirk(vcpu->kvm, KVM_X86_QUIRK_MWAIT_NEVER_UD_FAULTS) &&
20502050
!guest_cpuid_has(vcpu, X86_FEATURE_MWAIT))
20512051
return kvm_handle_invalid_op(vcpu);
20522052

tools/testing/selftests/kvm/x86_64/monitor_mwait_test.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ int main(int argc, char *argv[])
113113

114114
disabled_quirks = 0;
115115
if (testcase & MWAIT_QUIRK_DISABLED)
116-
disabled_quirks |= KVM_X86_QUIRK_MWAIT_NEVER_FAULTS;
116+
disabled_quirks |= KVM_X86_QUIRK_MWAIT_NEVER_UD_FAULTS;
117117
if (testcase & MISC_ENABLES_QUIRK_DISABLED)
118118
disabled_quirks |= KVM_X86_QUIRK_MISC_ENABLE_NO_MWAIT;
119119
vm_enable_cap(vm, KVM_CAP_DISABLE_QUIRKS2, disabled_quirks);

0 commit comments

Comments
 (0)