x86: Support fully eager FPU context switching

This is controlled on a per-vcpu bases for flexibility.

This is part of XSA-267 / CVE-2018-3665

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
(cherry picked from commit 146dfe9277)
This commit is contained in:
Andrew Cooper committed 2018-06-13 22:01:34 +01:00
1 parent 196932adb2
commit 536d16cbdd
2 files changed
+16 -3

No files matched your search

+13 -3
View File
@@ -211,7 +211,7 @@ void vcpu_restore_fpu_eager(struct vcpu *v)
ASSERT(!is_idle_vcpu(v));
/* Restore nonlazy extended state (i.e. parts not tracked by CR0.TS). */
if ( !v->arch.nonlazy_xstate_used )
if ( !v->arch.fully_eager_fpu && !v->arch.nonlazy_xstate_used )
return;
/* Avoid recursion */
@@ -222,11 +222,19 @@ void vcpu_restore_fpu_eager(struct vcpu *v)
* above) we also need to restore full state, to prevent subsequently
* saving state belonging to another vCPU.
*/
if ( xstate_all(v) )
if ( v->arch.fully_eager_fpu || (v->arch.xsave_area && xstate_all(v)) )
{
fpu_xrstor(v, XSTATE_ALL);
if ( cpu_has_xsave )
fpu_xrstor(v, XSTATE_ALL);
else
fpu_fxrstor(v);
v->fpu_initialised = 1;
v->fpu_dirtied = 1;
/* Xen doesn't need TS set, but the guest might. */
if ( is_pv_vcpu(v) && (v->arch.pv_vcpu.ctrlreg[0] & X86_CR0_TS) )
stts();
}
else
{
@@ -248,6 +256,8 @@ void vcpu_restore_fpu_lazy(struct vcpu *v)
if ( v->fpu_dirtied )
return;
ASSERT(!v->arch.fully_eager_fpu);
if ( cpu_has_xsave )
fpu_xrstor(v, XSTATE_LAZY);
else
+3
View File
@@ -595,6 +595,9 @@ struct arch_vcpu
* and thus should be saved/restored. */
bool_t nonlazy_xstate_used;
/* Restore all FPU state (lazy and non-lazy state) on context switch? */
bool_t fully_eager_fpu;
/*
* The SMAP check policy when updating runstate_guest(v) and the
* secondary system time.
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.