All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86: determine MXCSR mask in all cases
@ 2020-05-18 13:16 Jan Beulich
  2020-05-18 13:43 ` Andrew Cooper
  0 siblings, 1 reply; 2+ messages in thread
From: Jan Beulich @ 2020-05-18 13:16 UTC (permalink / raw)
  To: xen-devel; +Cc: Andrew Cooper, Wei Liu, Roger Pau Monné

For its use(s) by the emulator to be correct in all cases, the filling
of the variable needs to be independent of XSAVE availability. As
there's no suitable function in i387.c to put the logic in, keep it in
xstate_init(), arrange for the function to be called unconditionally,
and pull the logic ahead of all return paths there.

Fixes: 9a4496a35b20 ("x86emul: support {,V}{LD,ST}MXCSR")
Signed-off-by: Jan Beulich <jbeulich@suse.com>

--- a/xen/arch/x86/cpu/common.c
+++ b/xen/arch/x86/cpu/common.c
@@ -488,8 +488,7 @@ void identify_cpu(struct cpuinfo_x86 *c)
 
 	/* Now the feature flags better reflect actual CPU features! */
 
-	if ( cpu_has_xsave )
-		xstate_init(c);
+	xstate_init(c);
 
 #ifdef NOISY_CAPS
 	printk(KERN_DEBUG "CPU: After all inits, caps:");
--- a/xen/arch/x86/xstate.c
+++ b/xen/arch/x86/xstate.c
@@ -588,6 +588,18 @@ void xstate_init(struct cpuinfo_x86 *c)
     u32 eax, ebx, ecx, edx;
     u64 feature_mask;
 
+    if ( bsp )
+    {
+        static typeof(current->arch.xsave_area->fpu_sse) __initdata ctxt;
+
+        asm ( "fxsave %0" : "=m" (ctxt) );
+        if ( ctxt.mxcsr_mask )
+            mxcsr_mask = ctxt.mxcsr_mask;
+    }
+
+    if ( !cpu_has_xsave )
+        return;
+
     if ( (bsp && !use_xsave) ||
          boot_cpu_data.cpuid_level < XSTATE_CPUID )
     {
@@ -611,8 +623,6 @@ void xstate_init(struct cpuinfo_x86 *c)
 
     if ( bsp )
     {
-        static typeof(current->arch.xsave_area->fpu_sse) __initdata ctxt;
-
         xfeature_mask = feature_mask;
         /*
          * xsave_cntxt_size is the max size required by enabled features.
@@ -621,10 +631,6 @@ void xstate_init(struct cpuinfo_x86 *c)
         xsave_cntxt_size = _xstate_ctxt_size(feature_mask);
         printk("xstate: size: %#x and states: %#"PRIx64"\n",
                xsave_cntxt_size, xfeature_mask);
-
-        asm ( "fxsave %0" : "=m" (ctxt) );
-        if ( ctxt.mxcsr_mask )
-            mxcsr_mask = ctxt.mxcsr_mask;
     }
     else
     {


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] x86: determine MXCSR mask in all cases
  2020-05-18 13:16 [PATCH] x86: determine MXCSR mask in all cases Jan Beulich
@ 2020-05-18 13:43 ` Andrew Cooper
  0 siblings, 0 replies; 2+ messages in thread
From: Andrew Cooper @ 2020-05-18 13:43 UTC (permalink / raw)
  To: Jan Beulich, xen-devel; +Cc: Wei Liu, Roger Pau Monné

On 18/05/2020 14:16, Jan Beulich wrote:
> For its use(s) by the emulator to be correct in all cases, the filling
> of the variable needs to be independent of XSAVE availability. As
> there's no suitable function in i387.c to put the logic in, keep it in
> xstate_init(), arrange for the function to be called unconditionally,
> and pull the logic ahead of all return paths there.
>
> Fixes: 9a4496a35b20 ("x86emul: support {,V}{LD,ST}MXCSR")
> Signed-off-by: Jan Beulich <jbeulich@suse.com>

Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-05-18 13:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-18 13:16 [PATCH] x86: determine MXCSR mask in all cases Jan Beulich
2020-05-18 13:43 ` Andrew Cooper

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.