All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Jan Beulich <JBeulich@suse.com>,
	xen-devel <xen-devel@lists.xenproject.org>
Cc: Wei Liu <wei.liu2@citrix.com>
Subject: Re: [PATCH 1/2] x86: flush high xstate CPUID sub-leaves to zero
Date: Wed, 1 Jun 2016 16:30:45 +0100	[thread overview]
Message-ID: <574EFFA5.7050906@citrix.com> (raw)
In-Reply-To: <574F15F402000078000F07F9@prv-mh.provo.novell.com>

On 01/06/16 16:05, Jan Beulich wrote:
> In line with other recent changes, these should be fully white listed,
> requiring us to zero them until the obtain a meaning we support.
>
> Without XSAVE support, all xstate sub-leaves should be zero.
>
> Also move away from checking host XSAVE support - we really ought to
> consider the guest flag for that purpose.
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>

Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>, with one suggestion

>
> --- a/xen/arch/x86/hvm/hvm.c
> +++ b/xen/arch/x86/hvm/hvm.c
> @@ -3433,7 +3433,13 @@ void hvm_cpuid(unsigned int input, unsig
>          *edx = v->vcpu_id * 2;
>          break;
>  
> -    case 0xd:
> +    case XSTATE_CPUID:
> +        hvm_cpuid(1, NULL, NULL, &_ecx, NULL);
> +        if ( !(_ecx & cpufeat_mask(X86_FEATURE_XSAVE)) || count >= 63 )
> +        {
> +            *eax = *ebx = *ecx = *edx = 0;
> +            break;
> +        }
>          /* EBX value of main leaf 0 depends on enabled xsave features */
>          if ( count == 0 && v->arch.xcr0 ) 
>          {
> --- a/xen/arch/x86/traps.c
> +++ b/xen/arch/x86/traps.c
> @@ -928,6 +928,8 @@ void pv_cpuid(struct cpu_user_regs *regs
>  
>      switch ( leaf )
>      {
> +        uint32_t tmp;
> +
>      case 0x00000001:
>          c &= pv_featureset[FEATURESET_1c];
>          d &= pv_featureset[FEATURESET_1d];
> @@ -1085,14 +1087,19 @@ void pv_cpuid(struct cpu_user_regs *regs
>          break;
>  
>      case XSTATE_CPUID:
> -        if ( !cpu_has_xsave )
> +        if ( !((!is_control_domain(currd) && !is_hardware_domain(currd)

I would recommend extra brackets on this line, to avoid the possible
mis-interpretation of !is_control_domain(currd) &&
(!is_hardware_domain(currd) ? ...

> +                ? ({
> +                    uint32_t ecx;
> +
> +                    domain_cpuid(currd, 1, 0, &tmp, &tmp, &ecx, &tmp);
> +                    ecx & pv_featureset[FEATURESET_1c];
> +                  })
> +                : cpuid_ecx(1)) & cpufeat_mask(X86_FEATURE_XSAVE)) ||
> +             subleaf >= 63 )

This is rather nasty code.  I am glad that my longterm plans involve
removing it all.

~Andrew

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

  reply	other threads:[~2016-06-01 15:30 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-01 14:57 [PATCH 0/2] x86: xstate CPUID guest output adjustments Jan Beulich
2016-06-01 15:05 ` [PATCH 1/2] x86: flush high xstate CPUID sub-leaves to zero Jan Beulich
2016-06-01 15:30   ` Andrew Cooper [this message]
2016-06-01 15:45   ` Wei Liu
2016-06-01 15:06 ` [PATCH 2/2] x86/HVM: don't calculate XSTATE area sizes in software Jan Beulich
2016-06-01 15:35   ` Andrew Cooper
2016-06-01 15:47     ` Wei Liu
2016-06-01 15:50     ` Jan Beulich
2016-06-01 15:57       ` Wei Liu

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=574EFFA5.7050906@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=JBeulich@suse.com \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xenproject.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.