]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
x86/fpu: Make check_fpu() init ordering independent
authorIngo Molnar <mingo@kernel.org>
Tue, 5 May 2015 08:54:04 +0000 (10:54 +0200)
committerIngo Molnar <mingo@kernel.org>
Tue, 19 May 2015 13:47:46 +0000 (15:47 +0200)
check_fpu() currently relies on being called early in the init sequence,
when CR0::TS has not been set up yet.

Save/restore CR0::TS across this function, to make it invariant to
init ordering. This way we'll be able to move the generic FPU setup
routines earlier in the init sequence.

Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
arch/x86/kernel/fpu/bugs.c

index 400a3d713fb204490ff936c43a9fbd590902e22b..449b5f3f4925ad8d16feee3d3f80d9a259dcb4bf 100644 (file)
@@ -23,8 +23,13 @@ static double __initdata y = 3145727.0;
  */
 static void __init check_fpu(void)
 {
+       u32 cr0_saved;
        s32 fdiv_bug;
 
+       /* We might have CR0::TS set already, clear it: */
+       cr0_saved = read_cr0();
+       write_cr0(cr0_saved & ~X86_CR0_TS);
+
        kernel_fpu_begin();
 
        /*
@@ -47,6 +52,8 @@ static void __init check_fpu(void)
 
        kernel_fpu_end();
 
+       write_cr0(cr0_saved);
+
        if (fdiv_bug) {
                set_cpu_bug(&boot_cpu_data, X86_BUG_FDIV);
                pr_warn("Hmm, FPU with FDIV bug\n");