Skip to content

Commit f363938

Browse files
amlutoIngo Molnar
authored andcommitted
x86/fpu: Fix 'no387' regression
After fixing FPU option parsing, we now parse the 'no387' boot option too early: no387 clears X86_FEATURE_FPU before it's even probed, so the boot CPU promptly re-enables it. I suspect it gets even more confused on SMP. Fix the probing code to leave X86_FEATURE_FPU off if it's been disabled by setup_clear_cpu_cap(). Signed-off-by: Andy Lutomirski <[email protected]> Cc: Andy Lutomirski <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Brian Gerst <[email protected]> Cc: Dave Hansen <[email protected]> Cc: Denys Vlasenko <[email protected]> Cc: Fenghua Yu <[email protected]> Cc: H. Peter Anvin <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Oleg Nesterov <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Quentin Casasnovas <[email protected]> Cc: Sai Praneeth Prakhya <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: yu-cheng yu <[email protected]> Fixes: 4f81cba ("x86/fpu: Fix early FPU command-line parsing") Signed-off-by: Ingo Molnar <[email protected]>
1 parent e2857b8 commit f363938

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

arch/x86/kernel/fpu/init.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,15 @@ static void fpu__init_system_early_generic(struct cpuinfo_x86 *c)
7878
cr0 &= ~(X86_CR0_TS | X86_CR0_EM);
7979
write_cr0(cr0);
8080

81-
asm volatile("fninit ; fnstsw %0 ; fnstcw %1"
82-
: "+m" (fsw), "+m" (fcw));
81+
if (!test_bit(X86_FEATURE_FPU, (unsigned long *)cpu_caps_cleared)) {
82+
asm volatile("fninit ; fnstsw %0 ; fnstcw %1"
83+
: "+m" (fsw), "+m" (fcw));
8384

84-
if (fsw == 0 && (fcw & 0x103f) == 0x003f)
85-
set_cpu_cap(c, X86_FEATURE_FPU);
86-
else
87-
clear_cpu_cap(c, X86_FEATURE_FPU);
85+
if (fsw == 0 && (fcw & 0x103f) == 0x003f)
86+
set_cpu_cap(c, X86_FEATURE_FPU);
87+
else
88+
clear_cpu_cap(c, X86_FEATURE_FPU);
89+
}
8890

8991
#ifndef CONFIG_MATH_EMULATION
9092
if (!cpu_has_fpu) {

0 commit comments

Comments
 (0)