OSDN Git Service

KVM: x86: prevent MWAIT in guest with buggy MONITOR
authorRadim Krčmář <rkrcmar@redhat.com>
Wed, 29 Nov 2017 21:23:41 +0000 (22:23 +0100)
committerPaolo Bonzini <pbonzini@redhat.com>
Thu, 14 Dec 2017 08:26:42 +0000 (09:26 +0100)
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 <agraf@suse.de>
Acked-by: Borislav Petkov <bp@suse.de>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/x86.h

index d0b95b7..81f5f50 100644 (file)
@@ -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