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: [V6 4/4] libxc: expose xsaves/xgetbv1/xsavec to hvm guest
Date: Mon, 12 Oct 2015 11:11:38 +0100	[thread overview]
Message-ID: <561B875A.9090101@citrix.com> (raw)
In-Reply-To: <1444630048-19411-5-git-send-email-shuai.ruan@linux.intel.com>

On 12/10/15 07:07, Shuai Ruan wrote:
> This patch exposes xsaves/xgetbv1/xsavec to hvm guest.
> The reserved bits of eax/ebx/ecx/edx must be cleaned up
> when call cpuid(0dh) with leaf 1 or 2..63.
>
> According to the spec the following bits must be reserved:
> For leaf 1, bits 03-04/08-31 of ecx is reserved. Edx is reserved.
> For leaf 2...63, bits 01-31 of ecx is reserved. Edx is reserved.
>
> Acked-by: Ian Campbell <ian.campbell@citrix.com>
> Signed-off-by: Shuai Ruan <shuai.ruan@linux.intel.com>

This patch needs rebasing over c/s bf87f3a "tools/libxc: Improve
efficiency of xc_cpuid_apply_policy()"

> ---
>  tools/libxc/xc_cpuid_x86.c | 16 ++++++++++++----
>  1 file changed, 12 insertions(+), 4 deletions(-)
>
> diff --git a/tools/libxc/xc_cpuid_x86.c b/tools/libxc/xc_cpuid_x86.c
> index e146a3e..b0d6ecc 100644
> --- a/tools/libxc/xc_cpuid_x86.c
> +++ b/tools/libxc/xc_cpuid_x86.c
> @@ -210,6 +210,10 @@ static void intel_xc_cpuid_policy(
>  }
>  
>  #define XSAVEOPT        (1 << 0)
> +#define XSAVEC          (1 << 1)
> +#define XGETBV1         (1 << 2)
> +#define XSAVES          (1 << 3)
> +#define XSS_SUPPORT     (1 << 0)
>  /* Configure extended state enumeration leaves (0x0000000D for xsave) */
>  static void xc_cpuid_config_xsave(
>      xc_interface *xch, domid_t domid, uint64_t xfeature_mask,
> @@ -246,8 +250,9 @@ static void xc_cpuid_config_xsave(
>          regs[1] = 512 + 64; /* FP/SSE + XSAVE.HEADER */
>          break;
>      case 1: /* leaf 1 */
> -        regs[0] &= XSAVEOPT;
> -        regs[1] = regs[2] = regs[3] = 0;
> +        regs[0] &= (XSAVEOPT | XSAVEC | XGETBV1 | XSAVES);

The correct mask here depends on !info->hvm, to hide XSAVES from PV guests.

> +        regs[2] &= xfeature_mask;
> +        regs[3] = 0;
>          break;
>      case 2 ... 63: /* sub-leaves */
>          if ( !(xfeature_mask & (1ULL << input[1])) )
> @@ -255,8 +260,11 @@ static void xc_cpuid_config_xsave(
>              regs[0] = regs[1] = regs[2] = regs[3] = 0;
>              break;
>          }
> -        /* Don't touch EAX, EBX. Also cleanup ECX and EDX */
> -        regs[2] = regs[3] = 0;
> +        /* Don't touch EAX, EBX and cleanup EDX.
> +         * Bit 0 of ECX represent whether sub-leave is supported in IA32_XSS
> +         * msr or supported in XCR0.*/
> +        regs[2] &= XSS_SUPPORT;

No XSS features are currently supported, even in HVM guests.  This
should be unilaterally zero at the moment.

~Andrew

> +        regs[3] = 0;
>          break;
>      }
>  }

      reply	other threads:[~2015-10-12 10:11 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-12  6:07 [V6 0/4] add xsaves/xrstors support Shuai Ruan
2015-10-12  6:07 ` [V6 1/4] x86/xsaves: add basic definitions/helpers to support xsaves Shuai Ruan
2015-10-12  9:25   ` Andrew Cooper
2015-10-13 13:33   ` Jan Beulich
2015-10-12  6:07 ` [V6 2/4] x86/xsaves: enable xsaves/xrstors/xsavec in xen Shuai Ruan
2015-10-12 10:05   ` Andrew Cooper
2015-10-13  7:28     ` Shuai Ruan
2015-10-13 13:49   ` Jan Beulich
2015-10-15  1:58     ` Shuai Ruan
     [not found]     ` <20151015015832.GA11071@shuai.ruan@linux.intel.com>
2015-10-15  6:48       ` Jan Beulich
2015-10-12  6:07 ` [V6 3/4] x86/xsaves: enable xsaves/xrstors for hvm guest Shuai Ruan
2015-10-12  6:07 ` [V6 4/4] libxc: expose xsaves/xgetbv1/xsavec to " Shuai Ruan
2015-10-12 10:11   ` Andrew Cooper [this message]

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=561B875A.9090101@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.