Received: by 10.223.164.202 with SMTP id h10csp4875018wrb; Wed, 29 Nov 2017 13:25:04 -0800 (PST) X-Google-Smtp-Source: AGs4zMaGzh45b89zi+bpRCPf5BN2wAB6CWTH8tSpUlltVvLUpXQlHGmUQQKg8RNesUZAUKrMVlO8 X-Received: by 10.84.204.8 with SMTP id a8mr224764ple.399.1511990704050; Wed, 29 Nov 2017 13:25:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511990704; cv=none; d=google.com; s=arc-20160816; b=xfVmGbg/J5h8sUBvhdyjjm1fV0GsgIgzTrpV148SXE/u0Lmj4PYeEl7e4t4V6S+0EX UNvGoN69Nd/5guaj5gkbbPEt85Dn2hdZs8k0GXjdxKourGpFRzFmFOE9lZa0jbRtZNfX dlkec91xNYAxReSvzR2ZCRulsHmA7gNQubdntKFZjYKgiZF7rN+Q5/XXyyfuuqy7inqU Mxk6Jb3u2Mn4Lo8NjXkozB7bNyr5uRWmSKPqEH6i5dn88/XadTjMqAilcF49sZR8v552 Xdae5+crrv/g9uKFj3tDCd65/QtdfaYgM7hRBr5yZcZsQQmnaYWHWPO2N5uxvtElJj9d CduQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=sneslWbtudJ4kP8GO70KysBDYYbshi//hPVGb7AnTPg=; b=b1MzTy5QpY5rUbRfw63qlvhm3iDZKd/QK3cuupkBl1xKMdaDfXdhPwHLelaQLtQX/b G91jmG7LnXjtotpxCIflD1ZBD6fom+ZdMRGQ7S2LxRUkOZgMYPv3DoFzVF59HSV/bacE Mvex0R1BKgh7p9cR/Zw1FK76KR20zCA7ZSgFA4zSF/09X+Gg9YUPTCFrOt0mLf/LnMlQ YQfzWBrO4RYhikNlPCuu0GJJ+kUeKLubpIZDjhWid9kpaHKlFe15rqIa+Kl5BbCnfrwu 9ijq8XrCRbr7/KoOjmvAGbRmsxfJzU5ilhCiHHpMnJp/pTiP8YNNVOlHLYpPCB01eGgf TYIw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h9si1839732pgp.365.2017.11.29.13.24.50; Wed, 29 Nov 2017 13:25:04 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753326AbdK2VYl (ORCPT + 99 others); Wed, 29 Nov 2017 16:24:41 -0500 Received: from mx1.redhat.com ([209.132.183.28]:46666 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752882AbdK2VYi (ORCPT ); Wed, 29 Nov 2017 16:24:38 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DC1348046E; Wed, 29 Nov 2017 21:24:37 +0000 (UTC) Received: from flask (ovpn-204-21.brq.redhat.com [10.40.204.21]) by smtp.corp.redhat.com (Postfix) with SMTP id 268E45D6A3; Wed, 29 Nov 2017 21:24:31 +0000 (UTC) Received: by flask (sSMTP sendmail emulation); Wed, 29 Nov 2017 22:24:31 +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 2/3] KVM: x86: drop bogus MWAIT check Date: Wed, 29 Nov 2017 22:23:42 +0100 Message-Id: <20171129212343.23167-3-rkrcmar@redhat.com> In-Reply-To: <20171129212343.23167-1-rkrcmar@redhat.com> References: <20171129212343.23167-1-rkrcmar@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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:37 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The check was added in some iteration while trying to fix a reported OS X on Core 2 bug, but that bug is elsewhere. The comment is misleading because the guest can call MWAIT with ECX = 0 even if we enforce CPUID5_ECX_INTERRUPT_BREAK; the call would have the exactly the same effect as if the host didn't have the feature. A problem is that a QEMU feature exposes CPUID5_ECX_INTERRUPT_BREAK on CPUs that do not support it. Removing the check changes behavior on last Pentium 4 lines (Presler, Dempsey, and Tulsa, which had VMX and MONITOR while missing INTERRUPT_BREAK) when running a guest OS that uses MWAIT without checking for its presence (QEMU doesn't expose MONITOR). The only known OS that ignores the MONITOR flag is old Mac OS X and we allowed it to bug on Core 2 (MWAIT used to throw #UD and only that OS noticed), so we can save another 20 lines letting it bug on even older CPUs. Alternatively, we can return MWAIT exiting by default and let userspace toggle it. Signed-off-by: Radim Krčmář --- arch/x86/kvm/x86.h | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/arch/x86/kvm/x86.h b/arch/x86/kvm/x86.h index 81f5f50794f6..d15859ec5e92 100644 --- a/arch/x86/kvm/x86.h +++ b/arch/x86/kvm/x86.h @@ -265,8 +265,6 @@ static inline u64 nsec_to_cycles(struct kvm_vcpu *vcpu, u64 nsec) static inline bool kvm_mwait_in_guest(void) { - unsigned int eax, ebx, ecx, edx; - if (!cpu_has(&boot_cpu_data, X86_FEATURE_MWAIT)) return false; @@ -275,29 +273,10 @@ static inline bool kvm_mwait_in_guest(void) /* All AMD CPUs have a working MWAIT implementation */ return true; case X86_VENDOR_INTEL: - /* Handle Intel below */ - break; + return !boot_cpu_has_bug(X86_BUG_MONITOR); default: 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 - * interrupts then invoking MWAIT. - */ - if (boot_cpu_data.cpuid_level < CPUID_MWAIT_LEAF) - return false; - - cpuid(CPUID_MWAIT_LEAF, &eax, &ebx, &ecx, &edx); - - if (!(ecx & CPUID5_ECX_INTERRUPT_BREAK)) - return false; - - return true; } #endif -- 2.14.2 From 1585453599549187072@xxx Thu Nov 30 01:46:17 +0000 2017 X-GM-THRID: 1585453599549187072 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread