x86, fpu: correct the asm constraints for fxsave, unbreak mxcsr.daz
authorH.J. Lu <hjl.tools@gmail.com>
Fri, 26 Jul 2013 16:11:56 +0000 (09:11 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 11 Aug 2013 22:38:43 +0000 (15:38 -0700)
commit7f72cb082501852ae9ebe403efef2ebb0437ff57
treee37574e9a6a93eb7fd95c93dc58bec446d2f03ce
parent5cbff87c00cf1b8e3a077465e4ec501dd21651c8
x86, fpu: correct the asm constraints for fxsave, unbreak mxcsr.daz

commit eaa5a990191d204ba0f9d35dbe5505ec2cdd1460 upstream.

GCC will optimize mxcsr_feature_mask_init in arch/x86/kernel/i387.c:

memset(&fx_scratch, 0, sizeof(struct i387_fxsave_struct));
asm volatile("fxsave %0" : : "m" (fx_scratch));
mask = fx_scratch.mxcsr_mask;
if (mask == 0)
mask = 0x0000ffbf;

to

memset(&fx_scratch, 0, sizeof(struct i387_fxsave_struct));
asm volatile("fxsave %0" : : "m" (fx_scratch));
mask = 0x0000ffbf;

since asm statement doesn’t say it will update fx_scratch.  As the
result, the DAZ bit will be cleared.  This patch fixes it. This bug
dates back to at least kernel 2.6.12.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/x86/kernel/i387.c