Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp2685521ybi; Mon, 17 Jun 2019 08:55:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqz9DRUJVGoMCqUJt3f9FubD4Ru9yyvERZ9pBln3jOnd7SfQ4FCxnXNYjYiQwF3JGa1B9elr X-Received: by 2002:a63:4c0f:: with SMTP id z15mr48992080pga.245.1560786913746; Mon, 17 Jun 2019 08:55:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560786913; cv=none; d=google.com; s=arc-20160816; b=FtUq+pgzRQ+yWJITEZSlWYx+sp8bvCpCeKicrjYSAlWF3l9tC7lH8yKhCW1IsS/9ZT DAh53uVzEA3U4d9SeeWOV9lV1ATyl/hS1Es5heTP+YDM4OkyZanHpqWiajYioJrC05Od nvGF69zC7xl0mC/Q6fXlIzd6n/i2WENp2MP3dDeZsotrrgW2GtJp7GWHP02Cruy/rHQh ranzzSX5uGlPOwQw2THppCbNf9FuOR1VeaGl+swahTKbel3d3zK7QAOrbYOJpcTAVo1K RVxAXj7VLJwNh7jPBaU4Cyk+LRloqblDfzSpWGWEYS5MjrE4iGb8mYNGQ8lxUXeW4NFO xnrQ== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=sT9f64dgJ4lN6ITf0ILpZd0kVjx6OlBeY6gIVLrUNMY=; b=dhCrOgCctCE/55WeSJYCb2ny4JBXBcXRC5cXDaJe4TW4yyaO7rV8FamNNaH+mmcTMq Or1wrHWd1IyY83Adte4FO1E1wWbXIUSGVUmdW991M8G9+SVraeM77vA0V4TvoMRrl7O8 /yGUvemU1i6LQAi+6GId9fxdG/1Kn0BVMjSFu8T+RruWCn/h5sjTU7ItzzLs685cu1Z1 iIl9RgLBivY8CJ1u5qOXsnN4YRlsETBCAMm/GixqNfQCAQDfj1z4osqnd+RhdCgpDJtP BNM9CIlrveQNEj+N1FqhYs6jN1hbnvdNkWF9lxtOOciAWSdSCICoPuISN0g2WfX1kvnx PQ9g== 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=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a21si3185107pfo.249.2019.06.17.08.54.58; Mon, 17 Jun 2019 08:55:13 -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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728499AbfFQPyr (ORCPT + 99 others); Mon, 17 Jun 2019 11:54:47 -0400 Received: from mga12.intel.com ([192.55.52.136]:5029 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726292AbfFQPyr (ORCPT ); Mon, 17 Jun 2019 11:54:47 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Jun 2019 08:54:46 -0700 Received: from xiaoyaol-mobl.ccr.corp.intel.com (HELO [10.249.171.113]) ([10.249.171.113]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/AES256-SHA; 17 Jun 2019 08:54:43 -0700 Subject: Re: [PATCH RESEND v3 2/3] KVM: vmx: Emulate MSR IA32_UMWAIT_CONTROL To: =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= Cc: Tao Xu , pbonzini@redhat.com, corbet@lwn.net, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, hpa@zytor.com, sean.j.christopherson@intel.com, fenghua.yu@intel.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, jingqi.liu@intel.com References: <20190616095555.20978-1-tao3.xu@intel.com> <20190616095555.20978-3-tao3.xu@intel.com> <20190617155038.GA13955@flask> From: Xiaoyao Li Message-ID: <5f34bd4b-b3d1-1950-e4d5-8e65c3809ab1@linux.intel.com> Date: Mon, 17 Jun 2019 23:54:42 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 MIME-Version: 1.0 In-Reply-To: <20190617155038.GA13955@flask> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 6/17/2019 11:50 PM, Radim Krčmář wrote: > 2019-06-17 14:31+0800, Xiaoyao Li: >> On 6/17/2019 11:32 AM, Xiaoyao Li wrote: >>> On 6/16/2019 5:55 PM, Tao Xu wrote: >>>> +    if (vmx->msr_ia32_umwait_control != host_umwait_control) >>>> +        add_atomic_switch_msr(vmx, MSR_IA32_UMWAIT_CONTROL, >>>> +                      vmx->msr_ia32_umwait_control, >>>> +                      host_umwait_control, false); >>> >>> The bit 1 is reserved, at least, we need to do below to ensure not >>> modifying the reserved bit: >>> >>>     guest_val = (vmx->msr_ia32_umwait_control & ~BIT_ULL(1)) | >>>             (host_val & BIT_ULL(1)) >>> >> >> I find a better solution to ensure reserved bit 1 not being modified in >> vmx_set_msr() as below: >> >> if((data ^ umwait_control_cached) & BIT_ULL(1)) >> return 1; > > We could just be checking > > if (data & BIT_ULL(1)) > > because the guest cannot change its visible reserved value and KVM > currently initializes the value to 0. > > The arch/x86/kernel/cpu/umwait.c series assumes that the reserved bit > is 0 (hopefully deliberately) and I would do the same in KVM as it > simplifies the logic. (We don't have to even think about migrations > between machines with a different reserved value and making it play > nicely with possible future implementations of that bit.) > Got it, thanks. > Thanks. >