From patchwork Wed Nov 29 21:23:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?UmFkaW0gS3LEjW3DocWZ?= X-Patchwork-Id: 10083635 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 58A5E6020B for ; Wed, 29 Nov 2017 21:25:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4C32629C7F for ; Wed, 29 Nov 2017 21:25:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4081C29C85; Wed, 29 Nov 2017 21:25:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.9 required=2.0 tests=BAYES_00,HK_RANDOM_FROM, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CA24E29B1D for ; Wed, 29 Nov 2017 21:25:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753219AbdK2VYc (ORCPT ); Wed, 29 Nov 2017 16:24:32 -0500 Received: from mx1.redhat.com ([209.132.183.28]:46626 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753216AbdK2VYa (ORCPT ); Wed, 29 Nov 2017 16:24:30 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C1B0C85541; Wed, 29 Nov 2017 21:24:30 +0000 (UTC) Received: from flask (ovpn-204-21.brq.redhat.com [10.40.204.21]) by smtp.corp.redhat.com (Postfix) with SMTP id 272EE60BE1; Wed, 29 Nov 2017 21:24:24 +0000 (UTC) Received: by flask (sSMTP sendmail emulation); Wed, 29 Nov 2017 22:24:24 +0100 From: =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: Paolo Bonzini , Borislav Petkov , Alexander Graf , "Michael S. Tsirkin" , =?UTF-8?q?Jan=20H=2E=20Sch=C3=B6nherr?= , KarimAllah Ahmed , Jim Mattson Subject: [PATCH v2 1/3] KVM: x86: prevent MWAIT in guest with buggy MONITOR Date: Wed, 29 Nov 2017 22:23:41 +0100 Message-Id: <20171129212343.23167-2-rkrcmar@redhat.com> In-Reply-To: <20171129212343.23167-1-rkrcmar@redhat.com> References: <20171129212343.23167-1-rkrcmar@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Wed, 29 Nov 2017 21:24:30 +0000 (UTC) Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Signed-off-by: Radim Krčmář --- arch/x86/kvm/x86.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/x86/kvm/x86.h b/arch/x86/kvm/x86.h index d0b95b7a90b4..81f5f50794f6 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