From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Cooper Subject: Re: [V3 PATCH 6/9] x86/hvm: pkeys, add xstate support for pkeys Date: Thu, 10 Dec 2015 18:57:31 +0000 Message-ID: <5669CB1B.3060907@citrix.com> References: <1449479780-19146-1-git-send-email-huaitong.han@intel.com> <1449479780-19146-7-git-send-email-huaitong.han@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1449479780-19146-7-git-send-email-huaitong.han@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: Huaitong Han , jbeulich@suse.com, jun.nakajima@intel.com, eddie.dong@intel.com, kevin.tian@intel.com, george.dunlap@eu.citrix.com, ian.jackson@eu.citrix.com, stefano.stabellini@eu.citrix.com, ian.campbell@citrix.com, wei.liu2@citrix.com, keir@xen.org Cc: xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org On 07/12/15 09:16, Huaitong Han wrote: > This patch adds xstate support for pkeys. > > Signed-off-by: Huaitong Han > --- > xen/arch/x86/xstate.c | 7 +++++-- > xen/include/asm-x86/xstate.h | 4 +++- > 2 files changed, 8 insertions(+), 3 deletions(-) > > diff --git a/xen/arch/x86/xstate.c b/xen/arch/x86/xstate.c > index b65da38..db978c4 100644 > --- a/xen/arch/x86/xstate.c > +++ b/xen/arch/x86/xstate.c > @@ -146,12 +146,15 @@ static void __init setup_xstate_comp(void) > } > } > > -static void *get_xsave_addr(void *xsave, unsigned int xfeature_idx) > +void *get_xsave_addr(void *xsave, unsigned int xfeature_idx) This really should take a struct_xsave *xsave, rather than a void pointer. > { > if ( !((1ul << xfeature_idx) & xfeature_mask) ) > return NULL; Now I look at it, this check is bogus. The check needs to be against the xsave header in the area, rather than Xen's maximum xfeature_mask. A guest might easily have a smaller xcr0 than the maximum Xen is willing to allow, causing the pointer below to be bogus. ~Andrew