|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH V6 2/2] x86/xsaves: fix overwriting between non-lazy/lazy xsaves
>>> On 24.03.16 at 09:29, <shuai.ruan@xxxxxxxxxxxxxxx> 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@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |