[PATCH 5.14 062/151] x86/fpu: Mask out the invalid MXCSR bits properly

From
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Date
2021-10-18 13:54:08
Also in
lkml
Reply to
Greg Kroah-Hartman, 2021-10-18
From: Borislav Petkov <redacted>

commit b2381acd3fd9bacd2c63f53b2c610c89959b31cc upstream.

This is a fix for the fix (yeah, /facepalm).

The correct mask to use is not the negation of the MXCSR_MASK but the
actual mask which contains the supported bits in the MXCSR register.

Reported and debugged by Ville Syrjälä [off-list ref]

Fixes: d298b03506d3 ("x86/fpu: Restore the masking out of reserved MXCSR bits")
Signed-off-by: Borislav Petkov <redacted>
Tested-by: Ville Syrjälä <redacted>
Tested-by: Ser Olmy <redacted>
Cc: <redacted>
Link: https://lore.kernel.org/r/YWgYIYXLriayyezv@intel.com (local)
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 arch/x86/kernel/fpu/signal.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
--- a/arch/x86/kernel/fpu/signal.c
+++ b/arch/x86/kernel/fpu/signal.c
@@ -385,7 +385,7 @@ static int __fpu_restore_sig(void __user
 				return -EINVAL;
 		} else {
 			/* Mask invalid bits out for historical reasons (broken hardware). */
-			fpu->state.fxsave.mxcsr &= ~mxcsr_feature_mask;
+			fpu->state.fxsave.mxcsr &= mxcsr_feature_mask;
 		}
 
 		/* Enforce XFEATURE_MASK_FPSSE when XSAVE is enabled */

Thread (167 messages) 167 messages, 10 authors, last reply 2021-10-19
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help