All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Jan Beulich <JBeulich@suse.com>
Cc: kevin.tian@intel.com, wei.liu2@citrix.com,
	Ian.Campbell@citrix.com, stefano.stabellini@eu.citrix.com,
	eddie.dong@intel.com, Shuai Ruan <shuai.ruan@linux.intel.com>,
	ian.jackson@eu.citrix.com, xen-devel@lists.xen.org,
	jun.nakajima@intel.com, keir@xen.org
Subject: Re: [PATCH V4 2/4] x86/xsaves: enable xsaves/xrstors in xen
Date: Wed, 26 Aug 2015 13:05:21 +0100	[thread overview]
Message-ID: <55DDAB81.8060001@citrix.com> (raw)
In-Reply-To: <55DDC428020000780009D1B6@prv-mh.provo.novell.com>

On 26/08/15 12:50, Jan Beulich wrote:
>>>> On 26.08.15 at 12:12, <andrew.cooper3@citrix.com> wrote:
>> On 25/08/15 11:54, Shuai Ruan wrote:
>>> --- a/xen/arch/x86/hvm/hvm.c
>>> +++ b/xen/arch/x86/hvm/hvm.c
>>> @@ -2148,8 +2148,12 @@ static int hvm_save_cpu_xsave_states(struct domain *d, hvm_domain_context_t *h)
>>>          ctxt->xfeature_mask = xfeature_mask;
>>>          ctxt->xcr0 = v->arch.xcr0;
>>>          ctxt->xcr0_accum = v->arch.xcr0_accum;
>>> -        memcpy(&ctxt->save_area, v->arch.xsave_area,
>>> -               size - offsetof(struct hvm_hw_cpu_xsave, save_area));
>>> +	if ( cpu_has_xsaves )
>> Stray hard tab.
>>
>>> +            save_xsave_states(v, (void *)&ctxt->save_area,
>>> +                              size - offsetof(struct hvm_hw_cpu_xsave,save_area));
>> These offsetof()s can become far shorter by using offsetof(*ctxt,
>> save_area).
> Are you mixing this up with sizeof()? If anything, offsetof(typeof(),).

Oops sorry yes.  I did mean to include the use of typeof(), which still
makes it shorter.

>
>>> --- a/xen/arch/x86/traps.c
>>> +++ b/xen/arch/x86/traps.c
>>> @@ -936,9 +936,10 @@ void pv_cpuid(struct cpu_user_regs *regs)
>>>          if ( regs->_ecx == 1 )
>>>          {
>>>              a &= XSTATE_FEATURE_XSAVEOPT |
>>> -                 XSTATE_FEATURE_XSAVEC |
>>> -                 (cpu_has_xgetbv1 ? XSTATE_FEATURE_XGETBV1 : 0) |
>>> -                 (cpu_has_xsaves ? XSTATE_FEATURE_XSAVES : 0);
>>> +                 XSTATE_FEATURE_XSAVEC;
>>> +	         /* PV guest will not support xsaves. */
>>> +                 /* (cpu_has_xgetbv1 ? XSTATE_FEATURE_XGETBV1 : 0) |
>>> +                 (cpu_has_xsaves ? XSTATE_FEATURE_XSAVES : 0); */
>> Don't leave this code commented out like this.  Just delete it.
> Agreed, but - mind reminding me again why supporting them for
> PV guests isn't going to work?

xsaves is a cpl0 instruction used to manage state which userspace can't
be trusted to handle alone.  Xen therefore can't trust PV guests to use
it either.

The first of these features is Processor Trace.  A PV guest able to use
xsaves/xrstors would be able to gather trace data of hypervisor
execution, or cause the trace buffers to clobber arbitrary physical memory.

The features covered by MSR_IA32_XSS can safely be exposed to PV guests,
but via a hypercall interface.

~Andrew

  reply	other threads:[~2015-08-26 12:05 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-25 10:54 [PATCH V4 0/4] add xsaves/xrstors support Shuai Ruan
2015-08-25 10:54 ` [PATCH V4 1/4] x86/xsaves: add basic definitions/helpers to support xsaves Shuai Ruan
2015-08-26  9:47   ` Andrew Cooper
2015-08-26 11:41     ` Jan Beulich
2015-08-26 12:53       ` Jan Beulich
2015-08-28  5:34         ` Shuai Ruan
2015-08-28  2:49     ` Shuai Ruan
2015-08-26 12:55   ` Jan Beulich
2015-08-25 10:54 ` [PATCH V4 2/4] x86/xsaves: enable xsaves/xrstors in xen Shuai Ruan
2015-08-26 10:12   ` Andrew Cooper
2015-08-26 11:50     ` Jan Beulich
2015-08-26 12:05       ` Andrew Cooper [this message]
2015-08-26 12:35         ` Jan Beulich
2015-08-28  5:25           ` Shuai Ruan
2015-08-28  5:22     ` Shuai Ruan
2015-08-26 13:06   ` Jan Beulich
2015-08-28 10:54     ` Shuai Ruan
     [not found]     ` <20150828105408.GA18437@shuai.ruan@linux.intel.com>
2015-08-28 11:27       ` Jan Beulich
2015-08-25 10:54 ` [PATCH V4 3/4] x86/xsaves: enable xsaves/xrstors for hvm guest Shuai Ruan
2015-08-26 10:36   ` Andrew Cooper
2015-08-28  2:52     ` Shuai Ruan
2015-08-26 13:14   ` Jan Beulich
2015-08-25 10:54 ` [PATCH V4 4/4] libxc: expose xsaves/xgetbv1/xsavec to " Shuai Ruan
2015-08-26 10:43   ` Andrew Cooper
2015-08-26 12:03     ` 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=55DDAB81.8060001@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=Ian.Campbell@citrix.com \
    --cc=JBeulich@suse.com \
    --cc=eddie.dong@intel.com \
    --cc=ian.jackson@eu.citrix.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.