]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/3.4.57/x86-fpu-correct-the-asm-constraints-for-fxsave-unbreak-mxcsr.daz.patch
5.1-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 3.4.57 / x86-fpu-correct-the-asm-constraints-for-fxsave-unbreak-mxcsr.daz.patch
CommitLineData
5945a003
GKH
1From eaa5a990191d204ba0f9d35dbe5505ec2cdd1460 Mon Sep 17 00:00:00 2001
2From: "H.J. Lu" <hjl.tools@gmail.com>
3Date: Fri, 26 Jul 2013 09:11:56 -0700
4Subject: x86, fpu: correct the asm constraints for fxsave, unbreak mxcsr.daz
5
6From: "H.J. Lu" <hjl.tools@gmail.com>
7
8commit eaa5a990191d204ba0f9d35dbe5505ec2cdd1460 upstream.
9
10GCC will optimize mxcsr_feature_mask_init in arch/x86/kernel/i387.c:
11
12 memset(&fx_scratch, 0, sizeof(struct i387_fxsave_struct));
13 asm volatile("fxsave %0" : : "m" (fx_scratch));
14 mask = fx_scratch.mxcsr_mask;
15 if (mask == 0)
16 mask = 0x0000ffbf;
17
18to
19
20 memset(&fx_scratch, 0, sizeof(struct i387_fxsave_struct));
21 asm volatile("fxsave %0" : : "m" (fx_scratch));
22 mask = 0x0000ffbf;
23
24since asm statement doesn’t say it will update fx_scratch. As the
25result, the DAZ bit will be cleared. This patch fixes it. This bug
26dates back to at least kernel 2.6.12.
27
28Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
29Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
30
31---
32 arch/x86/kernel/i387.c | 2 +-
33 1 file changed, 1 insertion(+), 1 deletion(-)
34
35--- a/arch/x86/kernel/i387.c
36+++ b/arch/x86/kernel/i387.c
37@@ -132,7 +132,7 @@ static void __cpuinit mxcsr_feature_mask
38 clts();
39 if (cpu_has_fxsr) {
40 memset(&fx_scratch, 0, sizeof(struct i387_fxsave_struct));
41- asm volatile("fxsave %0" : : "m" (fx_scratch));
42+ asm volatile("fxsave %0" : "+m" (fx_scratch));
43 mask = fx_scratch.mxcsr_mask;
44 if (mask == 0)
45 mask = 0x0000ffbf;