From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Jan Beulich" Subject: Re: [V3 PATCH 6/9] x86/hvm: pkeys, add xstate support for pkeys Date: Fri, 11 Dec 2015 02:36:51 -0700 Message-ID: <566AA74302000078000BE88C@prv-mh.provo.novell.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> Content-Disposition: inline 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 Cc: kevin.tian@intel.com, wei.liu2@citrix.com, ian.campbell@citrix.com, stefano.stabellini@eu.citrix.com, george.dunlap@eu.citrix.com, andrew.cooper3@citrix.com, ian.jackson@eu.citrix.com, xen-devel@lists.xen.org, jun.nakajima@intel.com, keir@xen.org List-Id: xen-devel@lists.xenproject.org >>> On 07.12.15 at 10:16, wrote: > --- 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) > { > if ( !((1ul << xfeature_idx) & xfeature_mask) ) > return NULL; > > - return xsave + xstate_comp_offsets[xfeature_idx]; > + if ( xsave_area_compressed(xsave) ) > + return xsave + xstate_comp_offsets[xfeature_idx]; > + else > + return xsave + xstate_offsets[xfeature_idx]; For constructs like this I'd really like to ask to avoid as much of the redundancy as possible. The most compact form would probably be return xsave + (xsave_area_compressed(xsave) ? xstate_comp_offsets : xstate_offsets)[xfeature_idx]; But at the very least the "else" should go away. Jan