Commit 7f72cb08 authored by H.J. Lu's avatar H.J. Lu Committed by Greg Kroah-Hartman

x86, fpu: correct the asm constraints for fxsave, unbreak mxcsr.daz

commit eaa5a990 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: default avatarH. Peter Anvin <hpa@linux.intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 5cbff87c
...@@ -132,7 +132,7 @@ static void __cpuinit mxcsr_feature_mask_init(void) ...@@ -132,7 +132,7 @@ static void __cpuinit mxcsr_feature_mask_init(void)
clts(); clts();
if (cpu_has_fxsr) { if (cpu_has_fxsr) {
memset(&fx_scratch, 0, sizeof(struct i387_fxsave_struct)); memset(&fx_scratch, 0, sizeof(struct i387_fxsave_struct));
asm volatile("fxsave %0" : : "m" (fx_scratch)); asm volatile("fxsave %0" : "+m" (fx_scratch));
mask = fx_scratch.mxcsr_mask; mask = fx_scratch.mxcsr_mask;
if (mask == 0) if (mask == 0)
mask = 0x0000ffbf; mask = 0x0000ffbf;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment