x86: correctly set nonlazy_xstate_used when loading full state
authorJan Beulich <jbeulich@suse.com>
Mon, 9 Jul 2018 08:51:02 +0000 (10:51 +0200)
committerJan Beulich <jbeulich@suse.com>
Mon, 9 Jul 2018 08:51:02 +0000 (10:51 +0200)
In this case, just like xcr0_accum, nonlazy_xstate_used should always be
set to the intended new value, rather than possibly leaving the flag set
from a prior state load.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
xen/arch/x86/domctl.c
xen/arch/x86/hvm/hvm.c

index 3e9580bcf7274b76e20118af01978956a059ce3a..b9736291b7c497212dcfba513e8ca9b9db454f6f 100644 (file)
@@ -1194,8 +1194,7 @@ long arch_do_domctl(
                 vcpu_pause(v);
                 v->arch.xcr0 = _xcr0;
                 v->arch.xcr0_accum = _xcr0_accum;
-                if ( _xcr0_accum & XSTATE_NONLAZY )
-                    v->arch.nonlazy_xstate_used = 1;
+                v->arch.nonlazy_xstate_used = _xcr0_accum & XSTATE_NONLAZY;
                 compress_xsave_states(v, _xsave_area,
                                       evc->size - PV_XSAVE_HDR_SIZE);
                 vcpu_unpause(v);
index c23983cdff197b32c45fc1a41e959c85c0d3f78d..279cb88e45346c26294967166124936d507d08cc 100644 (file)
@@ -1324,8 +1324,7 @@ static int hvm_load_cpu_xsave_states(struct domain *d, hvm_domain_context_t *h)
 
     v->arch.xcr0 = ctxt->xcr0;
     v->arch.xcr0_accum = ctxt->xcr0_accum;
-    if ( ctxt->xcr0_accum & XSTATE_NONLAZY )
-        v->arch.nonlazy_xstate_used = 1;
+    v->arch.nonlazy_xstate_used = ctxt->xcr0_accum & XSTATE_NONLAZY;
     compress_xsave_states(v, &ctxt->save_area,
                           size - offsetof(struct hvm_hw_cpu_xsave, save_area));