Re: [tip:x86/urgent] x86/fpu: Fix 'no387' regression

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Mar 09, 2016 at 05:57:39AM -0800, tip-bot for Andy Lutomirski wrote:
> Commit-ID:  f363938c70a04e6bc99023a5e0c44ef7879b903f
> Gitweb:     http://git.kernel.org/tip/f363938c70a04e6bc99023a5e0c44ef7879b903f
> Author:     Andy Lutomirski <luto@xxxxxxxxxx>
> AuthorDate: Thu, 21 Jan 2016 15:24:31 -0800
> Committer:  Ingo Molnar <mingo@xxxxxxxxxx>
> CommitDate: Wed, 9 Mar 2016 13:54:40 +0100
> 
> 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().

...

> diff --git a/arch/x86/kernel/fpu/init.c b/arch/x86/kernel/fpu/init.c
> index 6d9f0a7..d53ab3d 100644
> --- a/arch/x86/kernel/fpu/init.c
> +++ b/arch/x86/kernel/fpu/init.c
> @@ -78,13 +78,15 @@ static void fpu__init_system_early_generic(struct cpuinfo_x86 *c)
>  	cr0 &= ~(X86_CR0_TS | X86_CR0_EM);
>  	write_cr0(cr0);
>  
> -	asm volatile("fninit ; fnstsw %0 ; fnstcw %1"
> -		     : "+m" (fsw), "+m" (fcw));
> +	if (!test_bit(X86_FEATURE_FPU, (unsigned long *)cpu_caps_cleared)) {
> +		asm volatile("fninit ; fnstsw %0 ; fnstcw %1"
> +			     : "+m" (fsw), "+m" (fcw));

I guess we should add another cpufeature interface to do that instead
of testing cpu_caps_cleared directly but I'll send that after the merge
window:

---
diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h
index 50e292a73a7b..63d7d0f5aa65 100644
--- a/arch/x86/include/asm/cpufeature.h
+++ b/arch/x86/include/asm/cpufeature.h
@@ -121,6 +121,10 @@ extern const char * const x86_bug_flags[NBUGINTS*32];
 	set_cpu_cap(&boot_cpu_data, bit);	\
 	set_bit(bit, (unsigned long *)cpu_caps_set);	\
 } while (0)
+#define setup_cpu_feature_enabled(bit)				\
+	cpu_feature_enabled(bit) &&				\
+	!test_bit(bit, (unsigned long *)cpu_caps_cleared) &&	\
+	test_bit(bit, (unsigned long *)cpu_caps_set)
 
 #define cpu_has_fpu		boot_cpu_has(X86_FEATURE_FPU)
 #define cpu_has_pse		boot_cpu_has(X86_FEATURE_PSE)
diff --git a/arch/x86/kernel/fpu/init.c b/arch/x86/kernel/fpu/init.c
index e12cc0ad368e..22dc03ddebe8 100644
--- a/arch/x86/kernel/fpu/init.c
+++ b/arch/x86/kernel/fpu/init.c
@@ -78,7 +78,7 @@ static void fpu__init_system_early_generic(struct cpuinfo_x86 *c)
 	cr0 &= ~(X86_CR0_TS | X86_CR0_EM);
 	write_cr0(cr0);
 
-	if (!test_bit(X86_FEATURE_FPU, (unsigned long *)cpu_caps_cleared)) {
+	if (!setup_cpu_feature_enabled(X86_FEATURE_FPU)) {
 		asm volatile("fninit ; fnstsw %0 ; fnstcw %1"
 			     : "+m" (fsw), "+m" (fcw));
 
-- 
Regards/Gruss,
    Boris.

ECO tip #101: Trim your mails when you reply.
--
To unsubscribe from this list: send the line "unsubscribe linux-tip-commits" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Stable Commits]     [Linux Stable Kernel]     [Linux Kernel]     [Linux USB Devel]     [Linux Video &Media]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux