Received: by 10.192.165.156 with SMTP id m28csp490870imm; Wed, 11 Apr 2018 02:31:06 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/1+q3ehGJFOxxBwH44FbujijyhxdHGw5M1GHfQPPS1kztUkLHGhvlNAvj4qQNuSinTy8uP X-Received: by 10.167.128.194 with SMTP id a2mr3340851pfn.130.1523439066271; Wed, 11 Apr 2018 02:31:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523439066; cv=none; d=google.com; s=arc-20160816; b=bmNdNK78L/Cn2bQYrfjTvaFwm82tgvdV5FOKpOSnGf73uF2DXSJhtDF4w6xKlSAYzx 2l+6PAjzRjmlkK3lkrCad67UBjaVjIYezcrQYAMo3YgPwm0CnYSBKzcVLtB4bJxeLnJJ 9mCvujJOQq71NSRVFdJQXRAz0sFdXE5ic7mx5mQhKXxtv0P4NEvVaMoLjX6jg1p3n/XO MHGne7/SX9C5tQAlw6BPSFOpOnWy1XdmYvb0dEGnIWpxtsEhA8qHqLJARlp3Jft9ePvK jR9wyrr6PARSj0sQ9CcfyqK2sayi8kXpmuye0ocZyFtoKr1irvFARxZdgywVupjpbkfA 4cdg== 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 :message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=A72OFFiHSR86JeBAtMWYoxiZaGtEQwFZseiMl4TlxFQ=; b=okVGIUajK9kA/wBBxj3MPQUu6GmEoGuZXgfbd28seTlEFe++ap2AlgBIIoArtDJcuY wZkDopTx2s5muonnhWguZYreHQ5dp+EdP3Sx9+YQeb2ROth6dOl3Nv+BYXU8qBaUbdWf QnWmtDEHjhIMXmeGdvDnw35+YtFvfdcp1oESF80Urd5/jJTV2Cbps43ivUFIqL2UJdSQ Uw3ygeEYrKPavYc/z3Uq+qI2ZYajO6AYh7vIWZ1bII0B2tZhIHV+H2OX0U/2yEuacIo2 cpnMwBfzoHC0kJxJtBKwrrlexQlK2ywIMxhspSXdr+wdWogHSPyzCbfgtfWO24uA0Z0g B1+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.de header.s=amazon201209 header.b=TjGK2DVW; 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=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a1si521464pfn.314.2018.04.11.02.30.28; Wed, 11 Apr 2018 02:31:06 -0700 (PDT) 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; dkim=pass header.i=@amazon.de header.s=amazon201209 header.b=TjGK2DVW; 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=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752245AbeDKJYK (ORCPT + 99 others); Wed, 11 Apr 2018 05:24:10 -0400 Received: from smtp-fw-6001.amazon.com ([52.95.48.154]:33378 "EHLO smtp-fw-6001.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751734AbeDKJYI (ORCPT ); Wed, 11 Apr 2018 05:24:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazon201209; t=1523438647; x=1554974647; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=A72OFFiHSR86JeBAtMWYoxiZaGtEQwFZseiMl4TlxFQ=; b=TjGK2DVW5Rq+uEx9oKL9g3bJ6jVI4aw/rxrKbtBWy6+/c95phkAs+nNh HakF3AVC7kY+6+tLC6Ra3KcrISqYpmtHsQ9S3Hm/7JX6yWWvMfGXqU0vd FlqtNMywrxpVU5jADgpZzY/Xh65Fic8ilDDoXNiOjgTqFA6BPzZ8WqlWa Q=; X-IronPort-AV: E=Sophos;i="5.48,435,1517875200"; d="scan'208";a="339348924" Received: from iad6-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-1a-807d4a99.us-east-1.amazon.com) ([10.124.125.6]) by smtp-border-fw-out-6001.iad6.amazon.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 11 Apr 2018 09:24:06 +0000 Received: from u54e1ad5160425a4b64ea.ant.amazon.com (iad1-ws-svc-lb91-vlan2.amazon.com [10.0.103.146]) by email-inbound-relay-1a-807d4a99.us-east-1.amazon.com (8.14.7/8.14.7) with ESMTP id w3B9O0f0031241 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 11 Apr 2018 09:24:02 GMT Received: from u54e1ad5160425a4b64ea.ant.amazon.com (localhost [127.0.0.1]) by u54e1ad5160425a4b64ea.ant.amazon.com (8.15.2/8.15.2/Debian-3) with ESMTP id w3B9NxjI032699; Wed, 11 Apr 2018 11:23:59 +0200 Received: (from karahmed@localhost) by u54e1ad5160425a4b64ea.ant.amazon.com (8.15.2/8.15.2/Submit) id w3B9NwfS032691; Wed, 11 Apr 2018 11:23:58 +0200 From: KarimAllah Ahmed To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: KarimAllah Ahmed , Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , Thomas Gleixner , Ingo Molnar , "H . Peter Anvin" , x86@kernel.org Subject: [PATCH] X86/KVM: Do not allow DISABLE_EXITS_MWAIT when LAPIC ARAT is not available Date: Wed, 11 Apr 2018 11:16:03 +0200 Message-Id: <1523438163-768-1-git-send-email-karahmed@amazon.de> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If the processor does not have an "Always Running APIC Timer" (aka ARAT), we should not give guests direct access to MWAIT. The LAPIC timer would stop ticking in deep C-states, so any host deadlines would not wakeup the host kernel. The host kernel intel_idle driver handles this by switching to broadcast mode when ARAT is not available and MWAIT is issued with a deep C-state that would stop the LAPIC timer. When MWAIT is passed through, we can not tell when MWAIT is issued. So just disable this capability when LAPIC ARAT is not available. I am not even sure if there are any CPUs with VMX support but no LAPIC ARAT or not. Cc: Paolo Bonzini Cc: Radim Krčmář Cc: Thomas Gleixner Cc: Ingo Molnar Cc: H. Peter Anvin Cc: x86@kernel.org Cc: kvm@vger.kernel.org Cc: linux-kernel@vger.kernel.org Reported-by: Wanpeng Li Signed-off-by: KarimAllah Ahmed --- arch/x86/kvm/x86.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index b2ff74b..0334b25 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -2819,7 +2819,8 @@ static int msr_io(struct kvm_vcpu *vcpu, struct kvm_msrs __user *user_msrs, static inline bool kvm_can_mwait_in_guest(void) { return boot_cpu_has(X86_FEATURE_MWAIT) && - !boot_cpu_has_bug(X86_BUG_MONITOR); + !boot_cpu_has_bug(X86_BUG_MONITOR) && + boot_cpu_has(X86_FEATURE_ARAT); } int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext) -- 2.7.4