Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp5312503yba; Mon, 13 May 2019 08:47:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqyaLtPNbTBINN+ADGifEWNQ0m1D097CtcXxc2O3n5d7Q3d9xSU0JnZ69DSZNSmtzuZwJOyB X-Received: by 2002:a17:902:1347:: with SMTP id r7mr5132083ple.45.1557762440923; Mon, 13 May 2019 08:47:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557762440; cv=none; d=google.com; s=arc-20160816; b=InEOkWR6j9GYnIaksBz0Kk0xue24fQpivSvGKJOysiZhg8xR9iLn9HXISwKm9BDsQX itwVCm1+ZqEl9k1ujfwsKhY2L4k/r6p0tl2Eu4x4xUGiTCRZ3WIXvAWVpnM9qHyYJZUf dUPHi21x5IHUTfGhPujsnbPByxmrVi2u/BCayBTwxsAaT6pEv/G347g3WHL0mfJhycL8 2GwNpdiuj6yK21xPS5gO/VUarUxQLJNlXD8/WGwFkApZJkRCTHl1fag3TENgrirDzaw/ N0/2xdqXTSsloigFSiZRfiOXcEVFMLdcUxY3GT5exTd95ws0DDpBpuelUnlV2fubQN0u 8A/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=PhIh1foCtnM9k2VcTpKlrCZ6juo7j+CwZezctgPLnP4=; b=YZg1urAdEn6QFNozxK9/xUAHwJANwwpKsMmCYetQNO0ocgr9fSOf9Y9xZ0mjWxMp1L nolZbQTAzQgGVcekBp0awYax67Z2d7k7eacbc0AUP5ghuNDXyhT323ENLWbvnE4uttjo M4UMiROD4o2H4brNYh7/kYbB9dQyRNmsZUYsnomd43xzfGnRv5NvWKRmc9Wm+y5tziAS +s7ReVxcuG+bLTC9er2TzD00iuP5NNnxy7/HLFD65X67PvPrTs9LYRwaMs0wQ/e/Tafg Wpqv88lI6L4UtCi2ZO8tfrCD+a16R91VV6Th1a4CBVelG66Kh+nJAfVXtqJnLUJbap0+ JoNQ== 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 g1si16450689pgq.268.2019.05.13.08.47.04; Mon, 13 May 2019 08:47:20 -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; 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 S1729370AbfEMNfz (ORCPT + 99 others); Mon, 13 May 2019 09:35:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59096 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727202AbfEMNfz (ORCPT ); Mon, 13 May 2019 09:35:55 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E31D1552FC; Mon, 13 May 2019 13:35:54 +0000 (UTC) Received: from flask (unknown [10.40.205.238]) by smtp.corp.redhat.com (Postfix) with SMTP id 22DEB1001F54; Mon, 13 May 2019 13:35:51 +0000 (UTC) Received: by flask (sSMTP sendmail emulation); Mon, 13 May 2019 15:35:51 +0200 Date: Mon, 13 May 2019 15:35:51 +0200 From: Radim =?utf-8?B?S3LEjW3DocWZ?= To: Wanpeng Li Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Paolo Bonzini , Sean Christopherson , Liran Alon Subject: Re: [PATCH] KVM: X86: Enable IA32_MSIC_ENABLE MONITOR bit when exposing mwait/monitor Message-ID: <20190513133548.GA6538@flask> References: <1557740799-5792-1-git-send-email-wanpengli@tencent.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1557740799-5792-1-git-send-email-wanpengli@tencent.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 13 May 2019 13:35:55 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 2019-05-13 17:46+0800, Wanpeng Li: > From: Wanpeng Li > > MSR IA32_MSIC_ENABLE bit 18, according to SDM: > > | When this bit is set to 0, the MONITOR feature flag is not set (CPUID.01H:ECX[bit 3] = 0). > | This indicates that MONITOR/MWAIT are not supported. > | > | Software attempts to execute MONITOR/MWAIT will cause #UD when this bit is 0. > | > | When this bit is set to 1 (default), MONITOR/MWAIT are supported (CPUID.01H:ECX[bit 3] = 1). > > This bit should be set to 1, if BIOS enables MONITOR/MWAIT support on host and > we intend to expose mwait/monitor to the guest. The CPUID.01H:ECX[bit 3] ought to mirror the value of the MSR bit and as userspace has control of them both, I'd argue that it is userspace's job to configure both bits to match on the initial setup. Also, CPUID.01H:ECX[bit 3] is a better guard than kvm_mwait_in_guest(). kvm_mwait_in_guest() affects the behavior of MONITOR/MWAIT, not its guest visibility. Some weird migration cases might want MONITOR in CPUID without kvm_mwait_in_guest() and the MSR should be correct there as well. Missing the MSR bit shouldn't be a big problem for guests, so I am in favor of fixing the userspace code. Thanks. (For extra correctness in KVM, we could implement toggling of the CPUID bit based on guest writes to the MSR.)