xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Shuai Ruan <shuai.ruan@linux.intel.com>
To: Jan Beulich <JBeulich@suse.com>
Cc: andrew.cooper3@citrix.com, keir@xen.org, xen-devel@lists.xen.org
Subject: Re: [PATCH V7 3/3] x86/xsaves: ebx may return wrong value using CPUID eax=0xdh, ecx =1
Date: Wed, 6 Apr 2016 15:01:01 +0800	[thread overview]
Message-ID: <3306.7504097291$1459925986@news.gmane.org> (raw)
In-Reply-To: <5703940C02000078000E3105@prv-mh.provo.novell.com>

On Tue, Apr 05, 2016 at 02:31:40AM -0600, Jan Beulich wrote:
> >>> On 31.03.16 at 10:57, <shuai.ruan@linux.intel.com> wrote:
> > Refer to SDM 13.4.3 Extended Region of an XSAVE Area. The value return
> 
> No section numbers please - they tend to change.
> 
> > by ecx[1] with cpuid function 0xdh and sub-fucntion i (i>1) indicates
> 
> Either "0xd" or "0dh". And "function".
> 
> > --- a/xen/arch/x86/traps.c
> > +++ b/xen/arch/x86/traps.c
> > @@ -1020,6 +1020,18 @@ void pv_cpuid(struct cpu_user_regs *regs)
> >              a &= (boot_cpu_data.x86_capability[cpufeat_word(X86_FEATURE_XSAVEOPT)] &
> >                    ~cpufeat_mask(X86_FEATURE_XSAVES));
> >              b = c = d = 0;
> > +            if ( cpu_has_xsavec )
> > +            {
> > +                b = XSTATE_AREA_MIN_SIZE;
> 
> Is this really correct namely when curr->arch.xcr0 == 0? If not, the
> if() below should perhaps be combined with the if() above (and then
> the same would apply to hvm_cpuid()).
> 
> > +                if ( curr->arch.xcr0 )
> > +                    for( subleaf = 2; subleaf < 63; subleaf++ )
> > +                        if ( (1ULL << subleaf) & curr->arch.xcr0 )
> 
> The first if() is redundant with this second one. If you really
> mean to avoid the loop, then please also only check bits
> 2..62 in the first if().
> 
Ok for all comments above.

Another question is whether we should add this in pv_cpuid() or not.
(which we have discussed in the previous thread).

Refer to SDM Volume 1 
"13.2 ENUMERATION OF CPU SUPPORT FOR XSAVE INSTRUCTIONS AND XSAVE-
SUPPORTED FEATURES"
— CPUID function 0DH, sub-function 1.
...
"EBX enumerates the size (in bytes) required by the XSAVES instruction
 for an XSAVE area containing all
 the state components corresponding to bits currently set in XCR0 |
 IA32_XSS."

From the descriptions above, EBX only be used when XSAVES is enabled.
So I think we should not deal with pv_cpuid() here. 
Any comments ?

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

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

  reply	other threads:[~2016-04-06  7:01 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-31  8:57 [PATCH V7 0/3] xsaves bug fix Shuai Ruan
2016-03-31  8:57 ` [PATCH V7 1/3] x86/xsaves: fix overwriting between non-lazy/lazy xsaves Shuai Ruan
2016-04-04 15:51   ` Jan Beulich
2016-04-05  5:30     ` Shuai Ruan
     [not found]     ` <20160405053023.GA16876@shuai.ruan@linux.intel.com>
2016-04-05  7:17       ` Jan Beulich
2016-04-05  7:29         ` Shuai Ruan
2016-04-25  6:51   ` Jan Beulich
2016-04-29  1:36     ` Shuai Ruan
     [not found]     ` <20160429013616.GB4359@shuai.ruan@linux.intel.com>
2016-04-29  7:05       ` Jan Beulich
2016-03-31  8:57 ` [PATCH V7 2/3] x86/xsaves: fix two remained issues Shuai Ruan
2016-04-04 16:03   ` Jan Beulich
2016-03-31  8:57 ` [PATCH V7 3/3] x86/xsaves: ebx may return wrong value using CPUID eax=0xdh, ecx =1 Shuai Ruan
2016-04-05  8:31   ` Jan Beulich
2016-04-06  7:01     ` Shuai Ruan [this message]
     [not found]     ` <20160406070034.GA26357@shuai.ruan@linux.intel.com>
2016-04-07  0:29       ` Jan Beulich

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='3306.7504097291$1459925986@news.gmane.org' \
    --to=shuai.ruan@linux.intel.com \
    --cc=JBeulich@suse.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=keir@xen.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).