Received: by 2002:ac0:950c:0:0:0:0:0 with SMTP id f12csp830658imc; Sun, 10 Mar 2019 23:41:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqz/I2ihYn/6eD3qORpWnf5T1a6yOBuvflRHq/3Fln7JDj8hCtKKtjJLzWyaQ/2jVY9Y3DAt X-Received: by 2002:a62:5385:: with SMTP id h127mr31137260pfb.10.1552286507827; Sun, 10 Mar 2019 23:41:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552286507; cv=none; d=google.com; s=arc-20160816; b=mN705cQcZiA0i8WRfKkGjUpTb7lni/baBKbTMUN0RRmDjOBaBl6IZaZwOtr22r1mgX RcAPlA9L74MMVPZzUovtQ+fI6ScbTrNYQmmhmY9xooTAxlSTa9sP+9oqdcKlQT8ldC8c v13kgFlwS15AKOmZIQEmaTol+/izM1s8g1WK0TC9d3jfiVkFqXi5nsDyMUI7k/zRXsc3 CEjM/rOXR2xWmVbpfylFjG9t1PYm0Mv1pO1w8fttL8dW9Szbdilw1T3uImb1AoycfJlK azu8/+VzVqdVrvzDT5Tk+Vp63P9NMpZzxX5erMMlyOzRHocnj7Qy1GWXBa5hkjVBXgh9 fcxg== 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=esekA9gCHN5epcLdFDCb8AjYDatYQLoFzTY/BVSy0bY=; b=uKVry0+OWTYqYAI0hcyRFjb2rGuL9S8kgYNLOBg0fwf/cbNcKY2QPUYJOk2qeP/7Hi OCv+Bs+cT8Tj0iQRFoeeHPt/Pz9XOs8gTIB/b3cQDK0BYvCFT6W0IrLb09eGjYIMZM7H L8kWX4x3hAcr9nTIYUkdW2uhsQ/GeT8lrMd3GWcwU8TOGovgBeMTZF8ODEwJeJIMBGDB 0O+/XurdsSZo2BE4sfetkXC2Tf3azwpQC0OSpSbsXnWJouuIoSD64ADwm2PAz38ijum+ vJguCohQxNm0sILOPoBKiDPZv+bhNPax5Qz+THeVgrLSIq8lmtguR5wYfvVoXJM3ZAir NU9g== 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 n3si4203693pgv.458.2019.03.10.23.41.31; Sun, 10 Mar 2019 23:41:47 -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 S1726605AbfCKGlL (ORCPT + 99 others); Mon, 11 Mar 2019 02:41:11 -0400 Received: from mga01.intel.com ([192.55.52.88]:35936 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725866AbfCKGlL (ORCPT ); Mon, 11 Mar 2019 02:41:11 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Mar 2019 23:41:10 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,467,1544515200"; d="scan'208";a="306108854" Received: from local-michael-cet-test.sh.intel.com (HELO localhost) ([10.239.159.128]) by orsmga005.jf.intel.com with ESMTP; 10 Mar 2019 23:41:08 -0700 Date: Sun, 10 Mar 2019 21:35:29 +0800 From: Yang Weijiang To: Paolo Bonzini Cc: Sean Christopherson , rkrcmar@redhat.com, jmattson@google.com, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, mst@redhat.com, yu-cheng.yu@intel.com, Zhang Yi Z Subject: Re: [PATCH v3 7/8] KVM:X86: Add XSS bit 11 and 12 support for CET xsaves/xrstors. Message-ID: <20190310133528.GA24796@local-michael-cet-test.sh.intel.com> References: <20190225132716.6982-1-weijiang.yang@intel.com> <20190225132716.6982-8-weijiang.yang@intel.com> <20190228162512.GG6166@linux.intel.com> <20190228084404.GD12006@local-michael-cet-test.sh.intel.com> <20190310122030.GB24065@local-michael-cet-test.sh.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190310122030.GB24065@local-michael-cet-test.sh.intel.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Mar 10, 2019 at 08:20:30PM +0800, Yang Weijiang wrote: > On Fri, Mar 08, 2019 at 12:32:04PM +0100, Paolo Bonzini wrote: > > On 28/02/19 09:44, Yang Weijiang wrote: > > >>> if (!vmx_xsaves_supported()) > > >>> return 1; > > >>> + > > >>> /* > > >>> - * The only supported bit as of Skylake is bit 8, but > > >>> - * it is not supported on KVM. > > >>> + * Check bits being set are supported in KVM. > > >> I'd drop the comment altogether, it's pretty obvious from the code that > > >> were checking which bits are supported. > > > you won't see these redundancies in next version ;) > > >>> */ > > >>> - if (data != 0) > > >>> + if (data & ~kvm_supported_xss()) > > >>> return 1; > > > > You should instead check this against CPUID[0xD, 1].EDX:ECX. If CET is > > disabled in CPUID, the guest should not be able to set it in MSR_IA32_CSS. > > > > Paolo > Thanks, OK, will change it. Hi, Paolo, How about change kvm_supported_xss() as below so that CPUID[0xd,1] check is implied in host_xss contents, vmx_supported_xss() now just returns host_xss in vmx.c. The purpose of this change is to make XSS data check common for other XSS based features. +u64 kvm_supported_xss(void) +{ + return KVM_SUPPORTED_XSS & kvm_x86_ops->vmx_supported_xss(); +} +