All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Shuai Ruan <shuai.ruan@linux.intel.com>, 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
Subject: Re: [V7 1/4] x86/xsaves: add basic definitions/helpers to support xsaves
Date: Tue, 20 Oct 2015 14:26:46 +0100	[thread overview]
Message-ID: <56264116.606@citrix.com> (raw)
In-Reply-To: <1445329285-4425-2-git-send-email-shuai.ruan@linux.intel.com>

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 <shuai.ruan@linux.intel.com>
> Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
> ---
>  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

  reply	other threads:[~2015-10-20 13:26 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-20  8:21 [V7 0/4] add xsaves/xrstors support Shuai Ruan
2015-10-20  8:21 ` [V7 1/4] x86/xsaves: add basic definitions/helpers to support xsaves Shuai Ruan
2015-10-20 13:26   ` Andrew Cooper [this message]
2015-10-22  4:20     ` Shuai Ruan
2015-10-20  8:21 ` [V7 2/4] x86/xsaves: enable xsaves/xrstors/xsavec in xen Shuai Ruan
2015-10-22 12:13   ` Jan Beulich
2015-10-20  8:21 ` [V7 3/4] x86/xsaves: enable xsaves/xrstors for hvm guest Shuai Ruan
2015-10-22 14:20   ` Jan Beulich
2015-10-22 14:26     ` Andrew Cooper
2015-10-22 14:49       ` Jan Beulich
2015-10-20  8:21 ` [V7 4/4] libxc: expose xsaves/xgetbv1/xsavec to " Shuai Ruan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=56264116.606@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=Ian.Campbell@citrix.com \
    --cc=eddie.dong@intel.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=jbeulich@suse.com \
    --cc=jun.nakajima@intel.com \
    --cc=keir@xen.org \
    --cc=kevin.tian@intel.com \
    --cc=shuai.ruan@linux.intel.com \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.