From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Han, Huaitong" Subject: Re: [V2 PATCH 1/9] x86/hvm: pkeys, add pkeys support for cpuid handling Date: Thu, 3 Dec 2015 01:53:33 +0000 Message-ID: <1449107618.4187.1.camel@intel.com> References: <1448617923-10884-1-git-send-email-huaitong.han@intel.com> <1448617923-10884-2-git-send-email-huaitong.han@intel.com> <565DFD19.9080002@citrix.com> <565EDEC702000078000BB30C@prv-mh.provo.novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <565EDEC702000078000BB30C@prv-mh.provo.novell.com> Content-Language: en-US Content-ID: <0788DEB8A092384E9D2392818485A2B8@intel.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: "JBeulich@suse.com" Cc: "andrew.cooper3@citrix.com" , "xen-devel@lists.xen.org" List-Id: xen-devel@lists.xenproject.org On Wed, 2015-12-02 at 04:06 -0700, Jan Beulich wrote: > > > ) > > > + *ecx &= ~cpufeat_mask(X86_FEATURE_PKU); > > > + > > > + if ( (count == 0) && cpu_has_pku ) > > > + *ecx |= (v->arch.hvm_vcpu.guest_cr[4] & X86_CR4_PKE) > > > ? > > > + cpufeat_mask(X86_FEATURE_OSPKE) : 0; > > > > This is still buggy. cpu_has_pku has no relevance to whether OSPKE > > becomes visible. > > > > Visibility of OSPKE is determined solely by v > > ->arch.hvm_vcpu.guest_cr[4] > > & X86_CR4_PKE and nothing else. > > Actually I wouldn't mind guarding against the case where the CR4 flag > is wrongly set for whatever reason, but that ought to check the PKU > bit in *ecx, not the host flag. Same applies to the cpu_has_xsave > check - this too should check the guest flag, not the host one. I will add guest_cpuid_has_xxx functions. > > Jan >