From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Cooper Subject: Re: [V7 1/4] x86/xsaves: add basic definitions/helpers to support xsaves Date: Tue, 20 Oct 2015 14:26:46 +0100 Message-ID: <56264116.606@citrix.com> References: <1445329285-4425-1-git-send-email-shuai.ruan@linux.intel.com> <1445329285-4425-2-git-send-email-shuai.ruan@linux.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1445329285-4425-2-git-send-email-shuai.ruan@linux.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: Shuai Ruan , xen-devel@lists.xen.org Cc: kevin.tian@intel.com, wei.liu2@citrix.com, Ian.Campbell@citrix.com, stefano.stabellini@eu.citrix.com, eddie.dong@intel.com, ian.jackson@eu.citrix.com, jbeulich@suse.com, jun.nakajima@intel.com, keir@xen.org List-Id: xen-devel@lists.xenproject.org On 20/10/15 09:21, Shuai Ruan wrote: > This patch add basic definitions/helpers which will be used in > later patches. > > Signed-off-by: Shuai Ruan > Reviewed-by: Andrew Cooper > --- > xen/arch/x86/xstate.c | 19 +++++++++++++++++++ > xen/include/asm-x86/hvm/vcpu.h | 1 + > xen/include/asm-x86/msr-index.h | 2 ++ > xen/include/asm-x86/xstate.h | 12 ++++++++++-- > 4 files changed, 32 insertions(+), 2 deletions(-) > > diff --git a/xen/arch/x86/xstate.c b/xen/arch/x86/xstate.c > index 9ddff90..4230066 100644 > --- a/xen/arch/x86/xstate.c > +++ b/xen/arch/x86/xstate.c > @@ -24,6 +24,9 @@ static u32 __read_mostly xsave_cntxt_size; > /* A 64-bit bitmask of the XSAVE/XRSTOR features supported by processor. */ > u64 __read_mostly xfeature_mask; > > +/* Cached xss for fast read */ > +static DEFINE_PER_CPU(uint64_t, xss); > + > /* Cached xcr0 for fast read */ > static DEFINE_PER_CPU(uint64_t, xcr0); > > @@ -60,6 +63,22 @@ uint64_t get_xcr0(void) > return this_cpu(xcr0); > } > > +void set_msr_xss(u64 xss) > +{ > + u64 *this_xss = &this_cpu(xss); > + > + if ( *this_xss != xss ) > + { > + wrmsrl(MSR_IA32_XSS, xss); > + this_cpu(xss) = xss; *this_xss = xss; Using this_cpu() multiple times cannot be optimised by compiler (because of the underlying definition), which is why the optimisation is performed manually by pulling the value out as a pointer. ~Andrew