Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3604699ybi; Sun, 14 Jul 2019 18:12:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqz63qpIn+6pawY7/AzDC03ubN1ldcxPE22ivSthIVzSrmO94xDLngIV5xgDX+joscQmh5IG X-Received: by 2002:a17:90a:ad41:: with SMTP id w1mr26019336pjv.52.1563153148181; Sun, 14 Jul 2019 18:12:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563153148; cv=none; d=google.com; s=arc-20160816; b=urbuWUX8heITzDbu3Mk9VuMzBW7q2syMfWrCa8wWw1vfIGsAbNOai8NZZQ49lW4UIP 3yQL4d2twcar9dQ4kRV+WtCgMzO4bBO9tIDRtXa/wXAHt/TsnoIARysgsJWmki4KTeaR IVWak+/b8opdHasaByHywABf3yS9ubE69Tm8AAk3OWNSNFH0lgffoloWxO7exRF2+Gxo hpAZ5vQxbUlWCXjrp5S5dBr6KjT+sZNukElIOH308kV6RKqRwQe7twD/qQ400vLeOkLy Ny0ulbYypsHyG3Z0lZDHrt6BtpfmnZVv8MUfky5vhbPk5Fe1smQEiV9OaBgBVtXtOGMA NLug== 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=0QBLWjSA7FJsa/DxHoRQ1zt4YXbZu4FYkQO2IduKrsk=; b=kaTE+eaymHyiK229hCRxTRuy8CQtSsADcUQVlMoAEU1TAjIANhrPeGgPNe+S2nFwDH VAiIHdX68TiW5lG8VV9WAeVhOB52XHHJ7t2PvIir360dwTW2n4gemyThMSd4NbYiLBfp UcTsWIjP4scvfbvi4ChStbJ89yr2W/6wzx1Ky5jwVJqkJ18KKuIWl5MhNpr4w9PaTH1E gd9e2zTDw3LfIg1gv4wpFbFagSQwipsQtzSjWm6SvFlFn4+CK4hmEFzidnTTgS9pNbr/ wo5mZuArC8+18OLGdn8dgAM8R+Lbbyl4ectzEyD8i52+SL51iOrETPbr74K4fl+N3f0w pCJg== 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 m9si13937173pgq.336.2019.07.14.18.12.09; Sun, 14 Jul 2019 18:12: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 S1729006AbfGOBLg (ORCPT + 99 others); Sun, 14 Jul 2019 21:11:36 -0400 Received: from mga04.intel.com ([192.55.52.120]:47392 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726916AbfGOBLg (ORCPT ); Sun, 14 Jul 2019 21:11:36 -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 fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Jul 2019 18:11:35 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.63,492,1557212400"; d="scan'208";a="160944974" Received: from txu2-mobl.ccr.corp.intel.com (HELO [10.239.196.203]) ([10.239.196.203]) by orsmga008.jf.intel.com with ESMTP; 14 Jul 2019 18:11:32 -0700 Subject: Re: [PATCH v7 1/3] KVM: x86: add support for user wait instructions To: Sean Christopherson Cc: pbonzini@redhat.com, rkrcmar@redhat.com, corbet@lwn.net, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, hpa@zytor.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, fenghua.yu@intel.com, xiaoyao.li@linux.intel.com, jingqi.liu@intel.com References: <20190712082907.29137-1-tao3.xu@intel.com> <20190712082907.29137-2-tao3.xu@intel.com> <20190712151300.GB29659@linux.intel.com> From: Tao Xu Message-ID: <72e39861-7af4-057c-f879-4cc5a363e3e4@intel.com> Date: Mon, 15 Jul 2019 09:11:31 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <20190712151300.GB29659@linux.intel.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/12/2019 11:13 PM, Sean Christopherson wrote: > On Fri, Jul 12, 2019 at 04:29:05PM +0800, Tao Xu wrote: >> diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c >> index 46af3a5e9209..a4d5da34b306 100644 >> --- a/arch/x86/kvm/vmx/nested.c >> +++ b/arch/x86/kvm/vmx/nested.c >> @@ -2048,6 +2048,7 @@ static void prepare_vmcs02_early(struct vcpu_vmx *vmx, struct vmcs12 *vmcs12) >> SECONDARY_EXEC_ENABLE_INVPCID | >> SECONDARY_EXEC_RDTSCP | >> SECONDARY_EXEC_XSAVES | >> + SECONDARY_EXEC_ENABLE_USR_WAIT_PAUSE | >> SECONDARY_EXEC_VIRTUAL_INTR_DELIVERY | >> SECONDARY_EXEC_APIC_REGISTER_VIRT | >> SECONDARY_EXEC_ENABLE_VMFUNC); >> diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c >> index d98eac371c0a..f411c9ae5589 100644 >> --- a/arch/x86/kvm/vmx/vmx.c >> +++ b/arch/x86/kvm/vmx/vmx.c >> @@ -2247,6 +2247,7 @@ static __init int setup_vmcs_config(struct vmcs_config *vmcs_conf, >> SECONDARY_EXEC_RDRAND_EXITING | >> SECONDARY_EXEC_ENABLE_PML | >> SECONDARY_EXEC_TSC_SCALING | >> + SECONDARY_EXEC_ENABLE_USR_WAIT_PAUSE | >> SECONDARY_EXEC_PT_USE_GPA | >> SECONDARY_EXEC_PT_CONCEAL_VMX | >> SECONDARY_EXEC_ENABLE_VMFUNC | >> @@ -3984,6 +3985,25 @@ static void vmx_compute_secondary_exec_control(struct vcpu_vmx *vmx) >> } >> } >> >> + if (vmcs_config.cpu_based_2nd_exec_ctrl & >> + SECONDARY_EXEC_ENABLE_USR_WAIT_PAUSE) { > > This should be aligned with the beginning of the conditional. > Alternatively, add a vmx_waitpkg_supported() helper, which is fairly > ubiquitous even when there is only a single call site. > OK, Thank you for your suggestion. >> + /* Exposing WAITPKG only when WAITPKG is exposed */ > No need for this comment. It's also oddly worded, e.g. the second > "exposed" should probably be "enabled"? > >> + bool waitpkg_enabled = >> + guest_cpuid_has(vcpu, X86_FEATURE_WAITPKG); >> + >> + if (!waitpkg_enabled) >> + exec_control &= ~SECONDARY_EXEC_ENABLE_USR_WAIT_PAUSE; >> + >> + if (nested) { >> + if (waitpkg_enabled) >> + vmx->nested.msrs.secondary_ctls_high |= >> + SECONDARY_EXEC_ENABLE_USR_WAIT_PAUSE; >> + else >> + vmx->nested.msrs.secondary_ctls_high &= >> + ~SECONDARY_EXEC_ENABLE_USR_WAIT_PAUSE; >> + } >> + } >> + >> vmx->secondary_exec_control = exec_control; >> } >> >> -- >> 2.20.1 >>