Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3738imu; Wed, 2 Jan 2019 12:48:30 -0800 (PST) X-Google-Smtp-Source: ALg8bN4usSlFO3M+P9Pbz6/BpgThIUGv8//nvJ97vTjbh8JW9E/opQbdOCphEuTWVpFVFSiy1Voo X-Received: by 2002:a63:fa06:: with SMTP id y6mr43247692pgh.177.1546462110017; Wed, 02 Jan 2019 12:48:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546462109; cv=none; d=google.com; s=arc-20160816; b=reU7op6Si+cBzUrDc4KT4Y/dlTDglICYDZ5Xmt9LmWILPLVTYYO1cvdR1YWfIKi5o4 8zVZZwlIAZJdxGV1TArdPYNQ9zAqdRHOg2i3sBbciMlHE6jmWKe7vFb2yoS1FLiReWXm aYNhowoC9kdeXg7+n6LI6XdHPx6HA+pSIMWTACQ/SDWhmrHlGO6wfDWfYmJz53S3dSzA 4t/g86LpAaKX8HYEojOf69D+3FzywHE2zFqUGnVqu9cOMwEzcXBIzFTkCAmsFJ+KQXJ4 XWQ6u4pkOiTVK9q9SEx3Ixw26HLMck1Hso6CY6daT5BqwYOLgIED/eZ8j9/ihQw/xQ9p uUpA== 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=Uhr9FpmwOIrlZ8gM4T9iNpeMbBxj7a6pOdQJCYeFO0s=; b=C3Y/zC+FPUVFILP8e0gKwwNMuOGMmGlcpl9RfZgthKS4HlaZ+Dg91mdSBQ/5hGt+YQ sOuhhJ44KFPx9I+09/qstyxHLjzR0xkyYg3avzwyYi0/aeMXokxgYaz3E/6Rdfdzrhzc Ad/L/ZxHDxRMaVa8lYuefmYDW9Gwg7wMHSp/Wqwk68sgihKhjPdnCay437K/mqJyumNs fCus2mN+W5fN9MCznXf/LUEhYR4/ezrTXthWK/mPZYEejzbMvq3vx49vB1DAGa/xseOL S9SUy9eWBErFqXIVFAYzcqELwjKQOSInI64QVB1+/ZyqA/TrNyD4SDU7ZLdNpTmazlCk 4Qbw== 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 1si50588703plp.114.2019.01.02.12.48.11; Wed, 02 Jan 2019 12:48:29 -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 S1727514AbfABSYs (ORCPT + 99 others); Wed, 2 Jan 2019 13:24:48 -0500 Received: from mga05.intel.com ([192.55.52.43]:32487 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725993AbfABSYr (ORCPT ); Wed, 2 Jan 2019 13:24:47 -0500 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Jan 2019 10:24:47 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,431,1539673200"; d="scan'208";a="114952824" Received: from sjchrist-coffee.jf.intel.com (HELO linux.intel.com) ([10.54.74.154]) by orsmga003.jf.intel.com with ESMTP; 02 Jan 2019 10:24:46 -0800 Date: Wed, 2 Jan 2019 10:24:46 -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 5/8] kvm:x86 Enable MSR_IA32_XSS bit 11 and 12 for CET xsaves/xrstors. Message-ID: <20190102182446.GC7460@linux.intel.com> References: <20181226081532.30698-1-weijiang.yang@intel.com> <20181226081532.30698-6-weijiang.yang@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181226081532.30698-6-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:29PM +0800, Yang Weijiang wrote: > For kvm Guest OS, right now, only bit 11(user mode CET) and bit 12 > (supervisor CET) are supported in XSS MSR, if other bits are being set, > the write to XSS will be skipped. > > Signed-off-by: Zhang Yi Z > Signed-off-by: Yang Weijiang > --- > arch/x86/kvm/vmx.c | 11 ++++++++--- > 1 file changed, 8 insertions(+), 3 deletions(-) > > diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c > index fa2db6248404..5739ab393b90 100644 > --- a/arch/x86/kvm/vmx.c > +++ b/arch/x86/kvm/vmx.c > @@ -47,6 +47,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -4323,12 +4324,16 @@ static int vmx_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info) > case MSR_IA32_XSS: > if (!vmx_xsaves_supported()) > return 1; > + > /* > - * The only supported bit as of Skylake is bit 8, but > - * it is not supported on KVM. > + * Right now, only support XSS_CET_U[bit 11] and > + * XSS_CET_S[bit 12] in MSR_IA32_XSS. > */ > - if (data != 0) > + > + if (data & ~(XFEATURE_MASK_SHSTK_USER > + | XFEATURE_MASK_SHSTK_KERNEL)) New lines are usually after the operator, e.g.: if (data & ~(XFEATURE_MASK_SHSTK_USER | XFEATURE_MASK_SHSTK_KERNEL)) And doesn't this flow need to check that the bits are actually supported? > return 1; > + > vcpu->arch.ia32_xss = data; > if (vcpu->arch.ia32_xss != host_xss) > add_atomic_switch_msr(vmx, MSR_IA32_XSS, > -- > 2.17.1 >