From: Radim Krčmář Date: Wed, 29 Nov 2017 21:23:41 +0000 (+0100) Subject: KVM: x86: prevent MWAIT in guest with buggy MONITOR X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=2a140f3b6e23a309453b6f68709a50ece543f0f4;p=linux.git KVM: x86: prevent MWAIT in guest with buggy MONITOR The bug prevents MWAIT from waking up after a write to the monitored cache line. KVM might emulate a CPU model that shouldn't have the bug, so the guest would not employ a workaround and possibly miss wakeups. Better to avoid the situation. Reviewed-by: Alexander Graf Acked-by: Borislav Petkov Acked-by: Michael S. Tsirkin Signed-off-by: Radim Krčmář Signed-off-by: Paolo Bonzini --- diff --git a/arch/x86/kvm/x86.h b/arch/x86/kvm/x86.h index d0b95b7a90b4e..81f5f50794f66 100644 --- a/arch/x86/kvm/x86.h +++ b/arch/x86/kvm/x86.h @@ -281,6 +281,9 @@ static inline bool kvm_mwait_in_guest(void) return false; } + if (boot_cpu_has_bug(X86_BUG_MONITOR)) + return false; + /* * Intel CPUs without CPUID5_ECX_INTERRUPT_BREAK are problematic as * they would allow guest to stop the CPU completely by disabling