All of lore.kernel.org
 help / color / mirror / Atom feed
From: Shuai Ruan <shuai.ruan@linux.intel.com>
To: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: kevin.tian@intel.com, wei.liu2@citrix.com,
	Ian.Campbell@citrix.com, stefano.stabellini@eu.citrix.com,
	jun.nakajima@intel.com, eddie.dong@intel.com,
	ian.jackson@eu.citrix.com, xen-devel@lists.xen.org,
	jbeulich@suse.com, keir@xen.org
Subject: Re: [PATCH V3 3/6] x86/xsaves: enable xsaves/xrstors for hvm guest
Date: Wed, 12 Aug 2015 19:17:49 +0800	[thread overview]
Message-ID: <26107.0027169355$1439378269@news.gmane.org> (raw)
In-Reply-To: <55C9C274.40307@citrix.com>

On Tue, Aug 11, 2015 at 10:37:56AM +0100, Andrew Cooper wrote:
> On 11/08/15 08:59, Shuai Ruan wrote:
> > On Fri, Aug 07, 2015 at 02:04:51PM +0100, Andrew Cooper wrote:
> >> On 07/08/15 09:22, Shuai Ruan wrote:
> >>>>>  void hvm_cpuid(unsigned int input, unsigned int *eax, unsigned int *ebx,
> >>>>>                                     unsigned int *ecx, unsigned int *edx)
> >>>>>  {
> >>>>> @@ -4456,6 +4460,34 @@ void hvm_cpuid(unsigned int input, unsigned int *eax, unsigned int *ebx,
> >>>>>                      *ebx = _eax + _ebx;
> >>>>>              }
> >>>>>          }
> >>>>> +        if ( count == 1 )
> >>>>> +        {
> >>>>> +            if ( cpu_has_xsaves )
> >>>>> +            {
> >>>>> +                *ebx = XSTATE_AREA_MIN_SIZE;
> >>>>> +                if ( v->arch.xcr0 | v->arch.msr_ia32_xss )
> >>>>> +                    for ( sub_leaf = 2; sub_leaf < 63; sub_leaf++ )
> >>>>> +                    {
> >>>>> +                        if ( !((v->arch.xcr0 | v->arch.msr_ia32_xss)
> >>>>> +			   & (1ULL << sub_leaf)) )
> >>>>> +                            continue;
> >>>>> +                        domain_cpuid(d, input, sub_leaf, &_eax, &_ebx, &_ecx,
> >>>>> +                                     &_edx);
> >>>>> +                        *ebx =  *ebx + _eax;
> >>>>> +                    }
> >>>>> +            }
> >>>>> +            else
> >>>>> +            {
> >>>>> +                *eax &= ~XSAVES;
> >>>>> +                *ebx = *ecx = *edx = 0;
> >>>>> +            }
> >>>>> +            if ( !cpu_has_xgetbv1 )
> >>>>> +                *eax &= ~XGETBV1;
> >>>>> +            if ( !cpu_has_xsavec )
> >>>>> +                *eax &= ~XSAVEC;
> >>>>> +            if ( !cpu_has_xsaveopt )
> >>>>> +                *eax &= ~XSAVEOPT;
> >>>>> +        }
> >>>> Urgh - I really need to get domain cpuid fixed in Xen.  This is
> >>>> currently making a very bad situation a little worse.
> >>>>
> >>> In patch 4, I expose the xsaves/xsavec/xsaveopt and need to check
> >>> whether the hardware supoort it. What's your suggestion about this?
> >> Calling into domain_cpuid() in the loop is not useful as nothing will
> >> set the subleaves up.  As a first pass, reading from
> >> xstate_{offsets,sizes} will be better than nothing, as it will at least
> > What do you mean by xstate_{offsets,sizes}?
> 
> Shorthand for xstate_offsets xstate_sizes, per the standard shell expansion.
> 
You mean xstate_offsets xstate_sizes I introduced in patch 5.
> >> match reality until the domain is migrated.
> >>
> > For CPUID(eax=0dh) with subleaf 1, the value of ebx will change
> > according to the v->arch.xcr0 | v->arch.msr_ia32_xss. So add
> > code in hvm_cpuid function is the best way I can think of. Your
> > suggestions :)?
> 
> Which is liable to change on different hardware.  Once a vm has
> migrated, Xen may not legitimately execute another cpuid instruction as
> part of emulating guest cpuid, as it is not necessarily accurate.
> 
> Xen currently does not currently have proper cpuid encapsulation, which
> causes host-specific details to leak into guests across migrate.  I have
> a longterm plan to fix it, but it is not simple or quick to do.
> 
> In this case, reading from xstate_{offsets,sizes} is better than
> nothing, but will need fixing in the longterm.
> 
Ok, I will fix this in next version.
> ~Andrew
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> http://lists.xen.org/xen-devel
> 

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

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-05  1:57 [PATCH V3 0/6] add xsaves/xrstors support Shuai Ruan
2015-08-05  1:57 ` [PATCH V3 1/6] x86/xsaves: enable xsaves/xrstors for pv guest Shuai Ruan
2015-08-05 17:51   ` Andrew Cooper
2015-08-07  8:00     ` Shuai Ruan
     [not found]     ` <20150807080008.GA2976@shuai.ruan@linux.intel.com>
2015-08-07 12:44       ` Andrew Cooper
2015-08-11  7:50         ` Shuai Ruan
     [not found]         ` <20150811075039.GA14406@shuai.ruan@linux.intel.com>
2015-08-11 10:24           ` Andrew Cooper
2015-08-12  3:01             ` Shuai Ruan
2015-08-05  1:57 ` [PATCH V3 2/6] x86/xsaves: enable xsaves/xrstors in xen Shuai Ruan
2015-08-05 17:57   ` Andrew Cooper
2015-08-05  1:57 ` [PATCH V3 3/6] x86/xsaves: enable xsaves/xrstors for hvm guest Shuai Ruan
2015-08-05 18:17   ` Andrew Cooper
2015-08-07  8:22     ` Shuai Ruan
     [not found]     ` <20150807082244.GB2976@shuai.ruan@linux.intel.com>
2015-08-07 13:04       ` Andrew Cooper
2015-08-11  7:59         ` Shuai Ruan
     [not found]         ` <20150811075909.GB14406@shuai.ruan@linux.intel.com>
2015-08-11  9:37           ` Andrew Cooper
2015-08-12 11:17             ` Shuai Ruan [this message]
2015-08-05  1:57 ` [PATCH V3 4/6] libxc: expose xsaves/xgetbv1/xsavec to " Shuai Ruan
2015-08-05  8:37   ` Ian Campbell
2015-08-07  8:23     ` Shuai Ruan
2015-08-05  1:57 ` [PATCH V3 5/6] x86/xsaves: support compact format for hvm save/restore Shuai Ruan
2015-08-05 18:45   ` Andrew Cooper
     [not found]     ` <20150811080143.GC14406@shuai.ruan@linux.intel.com>
2015-08-11  9:27       ` Andrew Cooper
2015-08-12 11:23         ` Shuai Ruan
2015-08-05  1:57 ` [PATCH V3 6/6] x86/xsaves: detect xsaves/xgetbv1 in xen Shuai Ruan
2015-08-05 16:38 ` [PATCH V3 0/6] add xsaves/xrstors support Andrew Cooper
2015-08-07  8:25   ` 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='26107.0027169355$1439378269@news.gmane.org' \
    --to=shuai.ruan@linux.intel.com \
    --cc=Ian.Campbell@citrix.com \
    --cc=andrew.cooper3@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=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.