All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Shuai Ruan <shuai.ruan@linux.intel.com>, Jan Beulich <JBeulich@suse.com>
Cc: kevin.tian@intel.com, wei.liu2@citrix.com,
	Ian.Campbell@citrix.com, stefano.stabellini@eu.citrix.com,
	ian.jackson@eu.citrix.com, xen-devel@lists.xen.org,
	jun.nakajima@intel.com, keir@xen.org
Subject: Re: [V8 2/4] x86/xsaves: enable xsaves/xrstors/xsavec in xen
Date: Thu, 29 Oct 2015 09:57:41 +0000	[thread overview]
Message-ID: <5631ED95.7050101@citrix.com> (raw)
In-Reply-To: <20151029094702.GA27035@shuai.ruan@linux.intel.com>

On 29/10/15 09:47, Shuai Ruan wrote:
> On Thu, Oct 29, 2015 at 02:59:38AM -0600, Jan Beulich wrote:
>>>>> On 29.10.15 at 08:58, <shuai.ruan@linux.intel.com> wrote:
>>> On Mon, Oct 26, 2015 at 08:03:55AM -0600, Jan Beulich wrote:
>>>>>>> On 23.10.15 at 11:48, <shuai.ruan@linux.intel.com> wrote:
>>>>> This patch uses xsaves/xrstors/xsavec instead of xsaveopt/xrstor
>>>>> to perform the xsave_area switching so that xen itself
>>>>> can benefit from them when available.
>>>>>
>>>>> For xsaves/xrstors/xsavec only use compact format. Add format conversion
>>>>> support when perform guest os migration.
>>>>>
>>>>> Also, pv guest will not support xsaves/xrstors.
>>>>> @@ -343,11 +520,18 @@ void xstate_init(struct cpuinfo_x86 *c)
>>>>>  
>>>>>      /* Mask out features not currently understood by Xen. */
>>>>>      eax &= (cpufeat_mask(X86_FEATURE_XSAVEOPT) |
>>>>> -            cpufeat_mask(X86_FEATURE_XSAVEC));
>>>>> +            cpufeat_mask(X86_FEATURE_XSAVEC) |
>>>>> +            cpufeat_mask(X86_FEATURE_XGETBV1) |
>>>>> +            cpufeat_mask(X86_FEATURE_XSAVES));
>>>>>  
>>>>>      c->x86_capability[X86_FEATURE_XSAVEOPT / 32] = eax;
>>>>>  
>>>>>      BUG_ON(eax != boot_cpu_data.x86_capability[X86_FEATURE_XSAVEOPT / 32]);
>>>>> +
>>>>> +    if ( setup_xstate_features(bsp) )
>>>>> +        BUG();
>>>> BUG()? On the BSP maybe, but APs should simply fail being
>>>> brought up instead of bringing down the whole system.
>>>>
>>> For APs, setup_xsate_features will never return error. Just BSP can
>>> return error as -ENOMEM.
>> This may be the case now, but will whoever ends up editing the
>> function remember to audit the code here?
>>
> Ok.
>>>>> --- a/xen/include/public/arch-x86/hvm/save.h
>>>>> +++ b/xen/include/public/arch-x86/hvm/save.h
>>>>> @@ -140,6 +140,7 @@ struct hvm_hw_cpu {
>>>>>      uint64_t msr_syscall_mask;
>>>>>      uint64_t msr_efer;
>>>>>      uint64_t msr_tsc_aux;
>>>>> +    uint64_t msr_xss;
>>>> You can't extend a public interface structure like this. New MSRs
>>>> shouldn't be saved/restored this way anyway - that's what we
>>>> have struct hvm_msr for.
>>> Yes. I will use the exist function "hvm_save_cpu_msrs" to save this msr. I 
>>> intend to add save msr logic before "ASSERT(ctxt->count <= msr_count_max);" in 
>>> hvm_save_cpu_msrs. Is that Ok ?
>> No, the code belongs in vmx_save_msr() (and its sibling functions).
>>
> Ok.
> For there is no new area added in vmcs for xss_msr, I will use
> "
>     if ( cpu_has_xsaves)
>     {
>         ctxt->msr[ctxt->count].val = v->arch.hvm_vcpu.msr_xss;
>         if ( ctxt->msr[ctxt->count].val )
>              ctxt->msr[ctxt->count++].index = MSR_IA32_XSS;
>     }
> " to save xss_msr. Is it ok to add the save logic between "vmx_vmcs_enter(v);" and "vmx_vmcs_exit(v);" ? Or just add the save logic after "vmx_vmcs_exit(v);" ?

That looks ok (after fixing the whitespace issue in the if)

As it doesn't rely on the vmcs, it would be better to be outside the
enter/exit pair so as to prevent needless holdup of another cpu trying
to get at this vmcs.

You also need to modify vmx_init_msr() to indicate that the maximum
possible count of MSRs has increased.

~Andrew

  parent reply	other threads:[~2015-10-29  9:57 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-23  9:48 [V8 0/4] add xsaves/xrstors support Shuai Ruan
2015-10-23  9:48 ` [V8 1/4] x86/xsaves: add basic definitions/helpers to support xsaves Shuai Ruan
2015-10-23  9:48 ` [V8 2/4] x86/xsaves: enable xsaves/xrstors/xsavec in xen Shuai Ruan
2015-10-26 14:03   ` Jan Beulich
2015-10-27  1:06     ` Shuai Ruan
     [not found]     ` <20151027010626.GA13229@shuai.ruan@linux.intel.com>
2015-10-27  8:13       ` Jan Beulich
2015-10-27  9:01         ` Shuai Ruan
2015-10-29  7:58     ` Shuai Ruan
     [not found]     ` <20151029075857.GA24529@shuai.ruan@linux.intel.com>
2015-10-29  8:59       ` Jan Beulich
2015-10-29  9:47         ` Shuai Ruan
     [not found]         ` <20151029094702.GA27035@shuai.ruan@linux.intel.com>
2015-10-29  9:53           ` Jan Beulich
2015-10-29  9:57           ` Andrew Cooper [this message]
2015-10-23  9:48 ` [V8 3/4] x86/xsaves: enable xsaves/xrstors for hvm guest Shuai Ruan
2015-10-26 14:07   ` Jan Beulich
2015-10-23  9:48 ` [V8 4/4] libxc: expose xsaves/xgetbv1/xsavec to " 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=5631ED95.7050101@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=Ian.Campbell@citrix.com \
    --cc=JBeulich@suse.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.