[PATCH] x86, FPU: Fix FPU initialization

From: Borislav Petkov
Date: Wed Apr 10 2013 - 15:37:03 EST


c70293d0e3fe ("x86: Get rid of ->hard_math and all the FPU asm
fu") converted the FPU detection code to C. Yours truly, in his
overzealousness, used static_cpu_has() too early, before alternatives
have run, leading to the checks in fpu_init() to fail and fpu_init() to
set CR0.EM.

This, in turn, lead to an early NULL ptr due to
a chicken-and-an-egg issue (full details here:
http://lkml.kernel.org/r/20130410161122.GI6857@xxxxxxx).

Fix it back to the normal CPU feature checks.

Signed-off-by: Borislav Petkov <bp@xxxxxxx>
---
arch/x86/kernel/i387.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/i387.c b/arch/x86/kernel/i387.c
index 3a6455304c8d..b0928898bf54 100644
--- a/arch/x86/kernel/i387.c
+++ b/arch/x86/kernel/i387.c
@@ -163,7 +163,7 @@ void __cpuinit fpu_init(void)
unsigned long cr4_mask = 0;

#ifndef CONFIG_MATH_EMULATION
- if (!static_cpu_has(X86_FEATURE_FPU)) {
+ if (!cpu_has_fpu) {
pr_emerg("No FPU found and no math emulation present\n");
pr_emerg("Giving up\n");
for (;;)
@@ -179,7 +179,7 @@ void __cpuinit fpu_init(void)

cr0 = read_cr0();
cr0 &= ~(X86_CR0_TS|X86_CR0_EM); /* clear TS and EM */
- if (!static_cpu_has(X86_FEATURE_FPU))
+ if (!cpu_has_fpu)
cr0 |= X86_CR0_EM;
write_cr0(cr0);

--
1.8.2.135.g7b592fa


--
Regards/Gruss,
Boris.

Sent from a fat crate under my desk. Formatting is fine.
--
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/