Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp1012391ybi; Fri, 12 Jul 2019 08:13:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqz4xeSFOldusYKfqpthS0paIlCMHZk/GOoFxDXFI/kaQ7zyLy+phmBGyy1s+PtZWbRzotC1 X-Received: by 2002:a17:902:ff11:: with SMTP id f17mr12301917plj.121.1562944435893; Fri, 12 Jul 2019 08:13:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562944435; cv=none; d=google.com; s=arc-20160816; b=F+UN+N+KYRFxW5CgDTZ6QNsEfYUjennlhdS0oAQda2xjq8ppXsk3Kp8XhSndb+WKlo TbRpfxuIKJOjJ4N+Tp7P+yaPaTqLS7+SFpYrtA21IGjMZST3KnI8rUak0ZdgZgvoeamB eneao3r5sdMUjFYhcT+WGvXtBJLJMe3iNY1dJmvVSwnu0vlSxPSEsVhXJztyLy+DlsyQ 7ZR/ZYASRMYlfd0dS9vLLZGXEFJmyL8heU37VJJdTsrNHtUoF37GyWC7sbdJ4vRksjYI fK+4IhFG/VtOtFU/DXjjsD3yk7ps7fDSlW58Q7e2/8IyxguIDEJikCBGXQJI15bErUD2 IruQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=S7yU5gK84uAkMDnIe53K/SUY7pfY6lE4RUvTtu3XGsg=; b=YO+Cj4uw9wvggxDr4NFB/XZ5li3+AOM6I+scujYIppwA+3KjMry6u4eN/LOBPOxOEM kHbP2s4fA6/CZlrInyoTRRhnvG1xsmDxVLNlI9gz8CH8/Sdd5DiTbgzIospphQMdZofm CPilR74x232OUiTi/y56bpj1WM+qufR1bVkpRbO9YGz8rA4rF1dEKtE/qKlVhOSJcTUj wwKEcEBxGmecqDrdTT4RAjFffnmnKGVGxsInM7zlkcPLizgo72s0CwnLQZk4iv32kELa 4LpS9ernpmP29j68o1HGMZa63/+vhvMGi7XwC3Atl2WMq+w7BEOVrFxc98jbFCX84hj9 XWKQ== 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 i127si8411086pfc.177.2019.07.12.08.13.40; Fri, 12 Jul 2019 08:13:55 -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 S1727122AbfGLPNB (ORCPT + 99 others); Fri, 12 Jul 2019 11:13:01 -0400 Received: from mga04.intel.com ([192.55.52.120]:26427 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726318AbfGLPNB (ORCPT ); Fri, 12 Jul 2019 11:13:01 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Jul 2019 08:13:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.63,483,1557212400"; d="scan'208";a="171580427" Received: from sjchrist-coffee.jf.intel.com (HELO linux.intel.com) ([10.54.74.165]) by orsmga006.jf.intel.com with ESMTP; 12 Jul 2019 08:13:00 -0700 Date: Fri, 12 Jul 2019 08:13:00 -0700 From: Sean Christopherson To: Tao Xu 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 Subject: Re: [PATCH v7 1/3] KVM: x86: add support for user wait instructions Message-ID: <20190712151300.GB29659@linux.intel.com> References: <20190712082907.29137-1-tao3.xu@intel.com> <20190712082907.29137-2-tao3.xu@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190712082907.29137-2-tao3.xu@intel.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. > + /* 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 >