Received: by 2002:ac0:950c:0:0:0:0:0 with SMTP id f12csp2775126imc; Wed, 13 Mar 2019 00:37:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqxcoZNWe5mOnMldoU7I5fcQ3A+/WiFI17bKmwf/ce34iS1e57wz5aPAGJWkh74C4rYmsmer X-Received: by 2002:a17:902:5a41:: with SMTP id f1mr2037411plm.202.1552462630082; Wed, 13 Mar 2019 00:37:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552462630; cv=none; d=google.com; s=arc-20160816; b=M/gRJgWuTQEsvOEhTbnde8+fLM9saJcRe3u4KzZhJXWwpnIDQM/aezEb22tSpvojYP f1EHIPLmCva7yBYt8dP21jbwUcHMCH0+qxYp8VEeiDAFw7DOWOvG9QkV5281D2A3IfoV waxn1AqoPcwXJouzqFAvQuvIXou2eRUL8ZHvJiJEA5uM+xyN5+NWYvM2xYbutVgG5X6z 1XdzfiCYagKXMfMR5Mnv0lwG1/KM3HRy4hamFhTaXtATxcVUFmeewiaNu2N1qTA32lAF bx0824lHWRHf+UjeoxohKaFj/JQyEdjFdBp+bKfuomcoqBSETsS8DxmeEHf5G+NEjCG/ BwCg== 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=cnj4MVnz/dITQVpRWBjgbrKBo6zGAN1jWBws+v/Q3gc=; b=Cjo1eM/s0ijsMwMKgLaFG87Z+EMca/BO3ghj0vf+u/nTp1ekqpiLln9tsu94jEBuU+ K39dhFo8yIB6Q10l1q8qh60KYZQPiridoe/4zXq7fk4eTqwriHxPcBi8GbjJ9cyFQDuV 6FJvESSWK+6AoJn9HYPSgidpAsK9WagEbDK+iTf1TMd/IW3ThYZbomoVg6IkyW0R+lcJ uVqBzkgQLeDJlBnWm50gmQ4xZNBhFbsJ8eiZmPYmHht2FdEYfGRcjXLeuV5alWJaPbai tXUdisFKBNr+aWO054ZzrX5s9vJdD/HEEoKFfer43lQM1vp/U07vgCOv/h0opZi5i70x BEaw== 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 bg4si3711663plb.238.2019.03.13.00.36.54; Wed, 13 Mar 2019 00:37:10 -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 S1726961AbfCMHf4 (ORCPT + 99 others); Wed, 13 Mar 2019 03:35:56 -0400 Received: from mga12.intel.com ([192.55.52.136]:46083 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725888AbfCMHf4 (ORCPT ); Wed, 13 Mar 2019 03:35:56 -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 fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Mar 2019 00:35:55 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,474,1544515200"; d="scan'208";a="126505757" Received: from local-michael-cet-test.sh.intel.com (HELO localhost) ([10.239.159.128]) by orsmga006.jf.intel.com with ESMTP; 13 Mar 2019 00:35:52 -0700 Date: Tue, 12 Mar 2019 22:30:10 +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 , weijiang.yang@intel.com Subject: Re: [PATCH v3 7/8] KVM:X86: Add XSS bit 11 and 12 support for CET xsaves/xrstors. Message-ID: <20190312143010.GA13287@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> <20190310133528.GA24796@local-michael-cet-test.sh.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 Mon, Mar 11, 2019 at 04:32:32PM +0100, Paolo Bonzini wrote: > On 10/03/19 14:35, Yang Weijiang wrote: > >>>> - 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(); > > +} > > + > > > > This is correct; however, you should also check against the *guest*'s > CPUID[0xD, 1].EDX:ECX. > > One possibility is to add a field kvm->guest_supported_xss and update it > in kvm_update_cpuid, then here you do > > if (data & ~kvm->guest_supported_xss) > return 1; > > Thanks, > > Paolo Thanks Paolo, I'll add the change in next version.