Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp126264ybi; Tue, 2 Jul 2019 17:32:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqyOrJ/secpfeCURdj+w3bnhA4nDE4SY+dC8xH4d2feDXh7AkAFxmFJZ9qWLMUwh82lsNk7h X-Received: by 2002:a17:902:b610:: with SMTP id b16mr5727571pls.334.1562113948495; Tue, 02 Jul 2019 17:32:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562113948; cv=none; d=google.com; s=arc-20160816; b=xZ0wGXxFQAnbwDhGBqm5QlD82Kk3/2RGH4G2jNkVM9U3crNiySfcKS37+5wkYrjLfD v52cBXP599FeseF/SvWTUEA/9ryOmVVzOEuP61mQQab5TtKleavlBRE6WFrIs37gXeSo r8LaiND0eKx0IbjWE0G0geRH34jO+1jGkck6w8oyB+zY2T5LZVsLK+mv8uSajbm7LUx8 egsya2DIw4e2XuRSnlg4dCmVX3jwdVPu8bB2jEdjRtQbSp2gaf9cX/DmFy8zltHsjz7l EDht7sc1uwG7LEAhokTzrU5qfZjmmUDlywzaBvklPYBknk6tKG888jJ2Ix0z5rwRhhvW Z3FA== 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=ADFElcLw9MyP9Sk+U0Y9sS4ByW0vz9luxN4/t+OxX3M=; b=yhsGqgai3TaBGUwQ3xZgCcY/8FEd39lW04vqMDz0Rs38vXfaABJZXQKS5YOdE1gbJH 1aX3U8+3vP1TlYUQVmIfVQAx9cT7LArlJj9JkUitJ0Tk5MdWAOz0yVd1+H3ZmOjumPvH k4Mab0piE7P5ph3GcILQ9QDCKoPsvUwwViF3RinyT1C19M4EEv1vrireStEGI4/wy7Kl f605FUfed5gsTwUooPSHkZHDw1ATRDJmZscBxzcCj85anRAzeIFfWVjSUn4J6nb4mZp5 oBS8XKyd4qQhGq4qVc+3feDjPr2XkjOSUdWfxvJcBF2nHFB4uGwydrEg/mkP5lqhsLz5 vVbw== 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 y5si301441pgv.390.2019.07.02.17.32.12; Tue, 02 Jul 2019 17:32:28 -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 S1727325AbfGCAaH (ORCPT + 99 others); Tue, 2 Jul 2019 20:30:07 -0400 Received: from mga14.intel.com ([192.55.52.115]:11554 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727294AbfGCA36 (ORCPT ); Tue, 2 Jul 2019 20:29:58 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Jul 2019 17:29:58 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.63,445,1557212400"; d="scan'208";a="315413534" Received: from unknown (HELO [10.239.196.136]) ([10.239.196.136]) by orsmga004.jf.intel.com with ESMTP; 02 Jul 2019 17:29:55 -0700 Subject: Re: [PATCH v5 2/3] KVM: vmx: Emulate MSR IA32_UMWAIT_CONTROL To: Paolo Bonzini , Xiaoyao Li , rkrcmar@redhat.com, corbet@lwn.net, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, hpa@zytor.com, sean.j.christopherson@intel.com Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, fenghua.yu@intel.com, jingqi.liu@intel.com References: <20190620084620.17974-1-tao3.xu@intel.com> <20190620084620.17974-3-tao3.xu@intel.com> <22533924-f7e8-4b50-d5fe-7cbcc9295b53@redhat.com> From: Tao Xu Message-ID: <05d4c029-79f4-e513-1778-a7c245a48ad7@intel.com> Date: Wed, 3 Jul 2019 08:29:54 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: <22533924-f7e8-4b50-d5fe-7cbcc9295b53@redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 7/3/2019 12:37 AM, Paolo Bonzini wrote: > On 20/06/19 11:46, Xiaoyao Li wrote: >> You cannot put the atomic switch here. What if umwait_control_cached is changed >> at runtime? Host kernel patch exposed a sysfs interface to let it happen. > > Thanks for the review, Xiaoyao. I agree with both of your remarks. > > Paolo > Hi paolo, The issues have been solved in v6 patches, could you help to review v6 patches? Thanks Tao >>> + break; >>> case MSR_IA32_SPEC_CTRL: >>> if (!msr_info->host_initiated && >>> !guest_cpuid_has(vcpu, X86_FEATURE_SPEC_CTRL)) >>> @@ -4126,6 +4148,8 @@ static void vmx_vcpu_reset(struct kvm_vcpu *vcpu, bool >>> init_event) >>> vmx->rmode.vm86_active = 0; >>> vmx->spec_ctrl = 0; >>> >>> + vmx->msr_ia32_umwait_control = 0; >>> + >>> vcpu->arch.microcode_version = 0x100000000ULL; >>> vmx->vcpu.arch.regs[VCPU_REGS_RDX] = get_rdx_init_val(); >>> kvm_set_cr8(vcpu, 0); >>> diff --git a/arch/x86/kvm/vmx/vmx.h b/arch/x86/kvm/vmx/vmx.h >>> index 61128b48c503..8485bec7c38a 100644 >>> --- a/arch/x86/kvm/vmx/vmx.h >>> +++ b/arch/x86/kvm/vmx/vmx.h >>> @@ -14,6 +14,8 @@ >>> extern const u32 vmx_msr_index[]; >>> extern u64 host_efer; >>> >>> +extern u32 umwait_control_cached; >>> + >>> #define MSR_TYPE_R 1 >>> #define MSR_TYPE_W 2 >>> #define MSR_TYPE_RW 3 >>> @@ -194,6 +196,7 @@ struct vcpu_vmx { >>> #endif >>> >>> u64 spec_ctrl; >>> + u64 msr_ia32_umwait_control; >>> >>> u32 vm_entry_controls_shadow; >>> u32 vm_exit_controls_shadow; >>> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c >>> index 83aefd759846..4480de459bf4 100644 >>> --- a/arch/x86/kvm/x86.c >>> +++ b/arch/x86/kvm/x86.c >>> @@ -1138,6 +1138,7 @@ static u32 msrs_to_save[] = { >>> MSR_IA32_RTIT_ADDR1_A, MSR_IA32_RTIT_ADDR1_B, >>> MSR_IA32_RTIT_ADDR2_A, MSR_IA32_RTIT_ADDR2_B, >>> MSR_IA32_RTIT_ADDR3_A, MSR_IA32_RTIT_ADDR3_B, >>> + MSR_IA32_UMWAIT_CONTROL, >>> }; >>> >>> static unsigned num_msrs_to_save; >> >