xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: "Jan Beulich" <jbeulich@suse.com>
To: shuai.ruan@linux.intel.com
Cc: andrew.cooper3@citrix.com, keir@xen.org, xen-devel@lists.xen.org
Subject: Re: [V3] x86/xsaves: fix overwriting between non-lazy/lazy xsaves
Date: Wed, 09 Mar 2016 03:25:58 -0700	[thread overview]
Message-ID: <56DFFA3602000078000E42D4@prv-mh.provo.novell.com> (raw)
In-Reply-To: <20160309094650.GA23774@shuai.ruan@linux.intel.com>

>>> Shuai Ruan <shuai.ruan@linux.intel.com> 03/09/16 10:49 AM >>>
>On Tue, Mar 08, 2016 at 03:16:29AM -0700, Jan Beulich wrote:
>> >>> On 08.03.16 at 08:19, <shuai.ruan@linux.intel.com> wrote:
>> > --- a/xen/arch/x86/domctl.c
>> > +++ b/xen/arch/x86/domctl.c
>> > @@ -922,7 +922,7 @@ long arch_do_domctl(
>> >                  ret = -EFAULT;
>> >  
>> >              offset += sizeof(v->arch.xcr0_accum);
>> > -            if ( !ret && (cpu_has_xsaves || cpu_has_xsavec) )
>> > +            if ( !ret && cpu_has_xsaves )
>> 
>> ... here (and similarly elsewhere) you shouldn't make the code
>> continue to depend on the raw CPU feature, but you should have
>> a variable (or could be a #define for now) indicating whether we're
>> actively using compressed state areas. For the purpose of
>> alternative patching, the most suitable thing likely would be a
>> synthetic CPU feature.
>> 
>what I think to do here is 
>Add 
>#define X86_FEATURE_XSAVE_COMPACT (3*32 +17) /* use compacted xsave area */
>and
>#define cpu_has_xsave_compact   (boot_cpu_has(X86_FEATURE_XSAVE_COMPACT) \
>&& boot_cpu_has(X86_FEATURE_XSAVES)

There shouldn't be any combination of conditions here. Just make sure you
never set the made up feature flag. I'd also call the thing "using_xsave_compact"
or some such, rather than "cpu_has_...".

>I have another thing needs your opintions.
>
>Should we expose xsave[sc] to guest os (hvm guest)? (for nowdays ,linux guest can use
>xsaves, I think we should expose xsave[sc] to hvm guest). It means xen can only use 
>xsaves when cpu_has_xsave_compact is true, and hvm guest can use xsave[sc] if 
>cpu_has_xsaves/cpu_has_xsavec is true.

I see no reason why we shouldn't expose it. There's no direct connection
between us avoiding their use and a guest being allowed to make use of them.

Btw., one more thing: Can't the exclusion of FP and SSE states in the logic
determining which state set to save be extended to also include YMM? If saved,
YMM will also always live at a fixed place (an ASSERT() or BUG_ON() to verify
would of course be desirable). And if the guest didn't touch YMM registers, the
respective bit in the mask won't be set anyway.

Jan


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

  parent reply	other threads:[~2016-03-09 10:25 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-08  7:19 [V3] x86/xsaves: fix overwriting between non-lazy/lazy xsaves Shuai Ruan
2016-03-08 10:16 ` Jan Beulich
2016-03-09  9:46   ` Shuai Ruan
     [not found]   ` <20160309094650.GA23774@shuai.ruan@linux.intel.com>
2016-03-09 10:25     ` Jan Beulich [this message]
2016-03-09 12:33       ` Shuai Ruan
     [not found]       ` <20160309123322.GA16645@shuai.ruan@linux.intel.com>
2016-03-09 13:41         ` 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=56DFFA3602000078000E42D4@prv-mh.provo.novell.com \
    --to=jbeulich@suse.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=keir@xen.org \
    --cc=shuai.ruan@linux.intel.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 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).