xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: "Jan Beulich" <JBeulich@suse.com>
To: Shuai Ruan <shuai.ruan@linux.intel.com>
Cc: andrew.cooper3@citrix.com, keir@xen.org, xen-devel@lists.xen.org
Subject: Re: [PATCH V6 2/2] x86/xsaves: fix overwriting between non-lazy/lazy xsaves
Date: Tue, 29 Mar 2016 09:00:38 -0600	[thread overview]
Message-ID: <56FAB4B602000078000E0F41@prv-mh.provo.novell.com> (raw)
In-Reply-To: <1458808173-23279-3-git-send-email-shuai.ruan@linux.intel.com>

>>> On 24.03.16 at 09:29, <shuai.ruan@linux.intel.com> wrote:
> The offset at which components xsaved by xsave[sc] are not fixed.
> So when when a save with v->fpu_dirtied set is followed by one
> with v->fpu_dirtied clear, non-lazy xsave[sc] may overwriting data
> written by the lazy one.
> 
> The solution is when using_xsave_compact is enabled and taking xcr0_accum into
> consideration, if guest has ever used XSTATE_LAZY & ~XSTATE_FP_SSE
> (XSTATE_FP_SSE will be excluded beacause xsave will write XSTATE_FP_SSE
> part in legacy region of xsave area which is fixed, saving XSTATE_FS_SSE
> will not cause overwriting problem), vcpu_xsave_mask will return XSTATE_ALL.
> Otherwise vcpu_xsave_mask will return XSTATE_NONLAZY.
> 
> This may cause overhead save on lazy states which will cause performance
> impact. After doing some performance tests on xsavec and xsaveopt
> (suggested by jan), the results show xsaveopt performs better than xsavec.
> So hypervisor will not use xsavec anymore.
> 
> xsaves will be used until supervised state is instroduced in hypervisor.

"xsaves will not be used ... introduced ..." I suppose?

> @@ -223,13 +223,15 @@ void compress_xsave_states(struct vcpu *v, const void *src, unsigned int size)
>      u64 xstate_bv = ((const struct xsave_struct *)src)->xsave_hdr.xstate_bv;
>      u64 valid;
>  
> -    if ( !cpu_has_xsaves && !cpu_has_xsavec )
> +    ASSERT(!xsave_area_compressed(src));
> +
> +    if ( !(v->arch.xcr0_accum & XSTATE_XSAVES_ONLY) &&
> +         !xsave_area_compressed(src) )

Considering the ASSERT(), what's this second half of the conditional
good for?

> @@ -368,19 +371,29 @@ void xrstor(struct vcpu *v, uint64_t mask)
>          switch ( __builtin_expect(ptr->fpu_sse.x[FPU_WORD_SIZE_OFFSET], 8) )
>          {
>              BUILD_BUG_ON(sizeof(faults) != 4); /* Clang doesn't support %z in asm. */
> -#define XRSTOR(pfx) \
> -        alternative_io("1: .byte " pfx "0x0f,0xae,0x2f\n" \
> +#define _xrstor(xrstor_ins) \
> +        asm volatile ( "1: .byte "xrstor_ins"\n" \

Blanks around xrstor_ins please. Also please consider naming the
macro parameter just "insn".

>                         "3:\n" \
>                         "   .section .fixup,\"ax\"\n" \
>                         "2: incl %[faults]\n" \
>                         "   jmp 3b\n" \
>                         "   .previous\n" \
> -                       _ASM_EXTABLE(1b, 2b), \
> -                       ".byte " pfx "0x0f,0xc7,0x1f\n", \
> -                       X86_FEATURE_XSAVES, \
> -                       ASM_OUTPUT2([mem] "+m" (*ptr), [faults] "+g" (faults)), \
> -                       [lmask] "a" (lmask), [hmask] "d" (hmask), \
> -                       [ptr] "D" (ptr))
> +                       _ASM_EXTABLE(1b, 2b) \
> +                       : [mem] "+m" (*ptr), [faults] "+g" (faults) \
> +                       : [lmask] "a" (lmask), [hmask] "d" (hmask), \
> +                         [ptr] "D" (ptr) )
> +
> +#define XRSTOR(pfx) \
> +        if ( v->arch.xcr0_accum & XSTATE_XSAVES_ONLY ) \
> +        { \
> +            if ( unlikely(!(ptr->xsave_hdr.xcomp_bv \
> +                            & XSTATE_COMPACTION_ENABLED)) ) \
> +                ptr->xsave_hdr.xcomp_bv |= ptr->xsave_hdr.xstate_bv \
> +                                           | XSTATE_COMPACTION_ENABLED; \

In both cases above the operator in a split line belongs on the
previous one.

> +                _xrstor(pfx "0x0f,0xc7,0x1f"); /* xrstors */ \

Indentation.

Jan


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

  reply	other threads:[~2016-03-29 15:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-24  8:29 [PATCH V6 0/2] xsaves bug fix Shuai Ruan
2016-03-24  8:29 ` [PATCH V6 1/2] x86/xsaves: calculate the comp_offsets base on xcomp_bv Shuai Ruan
2016-03-29 14:35   ` Jan Beulich
2016-03-30  5:48     ` Shuai Ruan
2016-03-24  8:29 ` [PATCH V6 2/2] x86/xsaves: fix overwriting between non-lazy/lazy xsaves Shuai Ruan
2016-03-29 15:00   ` Jan Beulich [this message]
2016-03-30  5:46     ` 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=56FAB4B602000078000E0F41@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).