]> xenbits.xensource.com Git - xen.git/commit
x86/xsaves: fix overwriting between non-lazy/lazy xsaves
authorShuai Ruan <shuai.ruan@linux.intel.com>
Tue, 5 Apr 2016 11:23:41 +0000 (13:23 +0200)
committerJan Beulich <jbeulich@suse.com>
Tue, 5 Apr 2016 11:23:41 +0000 (13:23 +0200)
commit4d27280572819ca71b772421394c4c811b1d6abd
treedba962ab04b3d92f26d33de9e7f835052f5fea82
parent9e55a33cc8b8cdf883903661d8d3a6919f2b5292
x86/xsaves: fix overwriting between non-lazy/lazy xsaves

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 not be used until supervised state is introduced in hypervisor.
And XSTATE_XSAVES_ONLY (indicates supervised state is understood in xen)
is introduced, the use of xsaves depend on whether XSTATE_XSAVES_ONLY is set
in xcr0_accum.

Reported-by: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Shuai Ruan <shuai.ruan@linux.intel.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
xen/arch/x86/domain.c
xen/arch/x86/domctl.c
xen/arch/x86/hvm/hvm.c
xen/arch/x86/i387.c
xen/arch/x86/xstate.c
xen/include/asm-x86/xstate.h