From: Yang Weijiang Subject: Re: [PATCH v3 7/8] KVM:X86: Add XSS bit 11 and 12 support for CET xsaves/xrstors. Date: Tue, 12 Mar 2019 22:30:10 +0800 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 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 To: Paolo Bonzini Return-path: Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org List-Id: kvm.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.