Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp56513imu; Wed, 2 Jan 2019 14:02:20 -0800 (PST) X-Google-Smtp-Source: AFSGD/UztGn6XdbJZcfFOvkXSWudv5i36lKyGzLGOWqwUPF1WiAzQ1KnJVsQV+LfwOodGpVF4Xw0 X-Received: by 2002:a62:3141:: with SMTP id x62mr45663069pfx.12.1546466540685; Wed, 02 Jan 2019 14:02:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546466540; cv=none; d=google.com; s=arc-20160816; b=IC/1mrCCzNx9vWpmndhGnTAk6GIkY4I7yb3XOUqp/id4pEZ10XDiz8e/dF+ZAXFE91 zhqrh67riN3kZZbt/xsqBDOlNXYj0/suGF68yK/3nhgjGmXdLetfp9bfVAJqFp+X3Fle tie1aZ4+P2mBheukMu3fdYloBM+S1zPbCJTMsjDPKiGKMikYFR6vG9L4PAxQlTxBUDSc xJWFv4x1CEqC2oyvP3WebVwYh2qUYG44xhZAga4L7egHatiLUMVEJNcDCyeqpMvGLd5J bgPMAXDSRFfWeG4nPyTvWbiTJmtf62ZkbGYQRaRYs9Z2bji3wA0vseeTMgYxkCh9ghIt 66PA== 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=1U3icBRmoPXpULi8KDy/Zu0AWre6DTsUpFM6gEr857k=; b=Z7hqExNaTIlpbMJ5Ks7IAKutuyi5ootEo3LoZvfZPD0tsnQpD1IayIL+BteV9Ii5Va R3VEaPo2lCs4PWb/Q0KDzw7Q1ZK1AdskdFA8Smcxwf9l5/wZXeDsNYptSzq8bbePBQ/X cD6QxiekDin+DFxur71dS4lSsM1TpMIyXFeYR4Pahe6lZKPKOR/4wXmxvRzBBH353i7s ZEOJ7+HG2TN6AApQU6Uz8Nfp3kFBe6El4XJ1O1PboCqabpbbG9PqQ4jt5tX7pCMKJRhf ua1CGEclbWxEjWU+BNvPqyRhchHiq+rSWalW5NGmF09nR+OvItdktqX4kXd11lGH1jQT CndQ== 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 61si993081plz.117.2019.01.02.14.02.02; Wed, 02 Jan 2019 14:02:20 -0800 (PST) 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 S1728643AbfABTAV (ORCPT + 99 others); Wed, 2 Jan 2019 14:00:21 -0500 Received: from mga07.intel.com ([134.134.136.100]:37911 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728395AbfABTAU (ORCPT ); Wed, 2 Jan 2019 14:00:20 -0500 X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Jan 2019 11:00:19 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,432,1539673200"; d="scan'208";a="105028414" Received: from sjchrist-coffee.jf.intel.com (HELO linux.intel.com) ([10.54.74.154]) by orsmga006.jf.intel.com with ESMTP; 02 Jan 2019 11:00:19 -0800 Date: Wed, 2 Jan 2019 11:00:19 -0800 From: Sean Christopherson To: Yang Weijiang Cc: pbonzini@redhat.com, rkrcmar@redhat.com, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, mst@redhat.com, yu-cheng.yu@intel.com, yi.z.zhang@intel.com, hjl.tools@gmail.com, Zhang Yi Z Subject: Re: [PATCH v1 8/8] kvm:cpuid Report CET SHSTK and IBT support in CPUID.(EAX=0x7,ECX=0). Message-ID: <20190102190019.GF7460@linux.intel.com> References: <20181226081532.30698-1-weijiang.yang@intel.com> <20181226081532.30698-9-weijiang.yang@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181226081532.30698-9-weijiang.yang@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 Wed, Dec 26, 2018 at 04:15:32PM +0800, Yang Weijiang wrote: > Guest OS can query CET SHSTK and IBT support by CPUID.(EAX=0x7,ECX=0), > in return, ECX[bit 7] corresponds to SHSTK feature, and EDX[bit 20] > corresponds to IBT feature. > > Signed-off-by: Zhang Yi Z > Signed-off-by: Yang Weijiang > --- > arch/x86/kvm/cpuid.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c > index 55c282f71f93..d7b60b3c4326 100644 > --- a/arch/x86/kvm/cpuid.c > +++ b/arch/x86/kvm/cpuid.c > @@ -67,6 +67,8 @@ u64 kvm_supported_xcr0(void) > > #define F(x) bit(X86_FEATURE_##x) > > +#define CET_IBT_BIT bit(20) Properly define X86_FEATURE_CET_IBT if it's not being defined by some other series, even if KVM is the only immediate user of the bit. Linux reserves all of word 18 for CPUID_7_0_EDX, i.e. defining the bit won't bloat some random scattered word. > + > /* For scattered features from cpufeatures.h; we currently expose none */ > #define KF(x) bit(KVM_CPUID_BIT_##x) > > @@ -407,12 +409,12 @@ static inline int __do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function, > F(AVX512VBMI) | F(LA57) | F(PKU) | 0 /*OSPKE*/ | > F(AVX512_VPOPCNTDQ) | F(UMIP) | F(AVX512_VBMI2) | F(GFNI) | > F(VAES) | F(VPCLMULQDQ) | F(AVX512_VNNI) | F(AVX512_BITALG) | > - F(CLDEMOTE); > + F(CLDEMOTE) | F(SHSTK); > > /* cpuid 7.0.edx*/ > const u32 kvm_cpuid_7_0_edx_x86_features = > F(AVX512_4VNNIW) | F(AVX512_4FMAPS) | F(SPEC_CTRL) | > - F(SPEC_CTRL_SSBD) | F(ARCH_CAPABILITIES); > + F(SPEC_CTRL_SSBD) | F(ARCH_CAPABILITIES) | CET_IBT_BIT; > > /* all calls to cpuid_count() should be made on the same cpu */ > get_cpu(); > -- > 2.17.1 >