]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
x86/fpu: Factor out FPU bug checks into fpu/bugs.c
authorIngo Molnar <mingo@kernel.org>
Sun, 26 Apr 2015 12:48:08 +0000 (14:48 +0200)
committerIngo Molnar <mingo@kernel.org>
Tue, 19 May 2015 13:47:45 +0000 (15:47 +0200)
Create separate fpu/bugs.c code so that if we read generic FPU code
we don't have to wade through all the bugcheck related code first.

Reviewed-by: Borislav Petkov <bp@alien8.de>
Cc: Andy Lutomirski <luto@amacapital.net>
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/Makefile
arch/x86/kernel/fpu/bugs.c [new file with mode: 0644]
arch/x86/kernel/fpu/init.c

index 50464a716b87c707b16c76ea839db0467d4f1c82..2020a2b7a597b17736ea07e4a6c3105dcb91e23b 100644 (file)
@@ -2,4 +2,4 @@
 # Build rules for the FPU support code:
 #
 
-obj-y                          += init.o core.o xsave.o
+obj-y                          += init.o bugs.o core.o xsave.o
diff --git a/arch/x86/kernel/fpu/bugs.c b/arch/x86/kernel/fpu/bugs.c
new file mode 100644 (file)
index 0000000..400a3d7
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * x86 FPU bug checks:
+ */
+#include <asm/fpu/internal.h>
+
+/*
+ * Boot time CPU/FPU FDIV bug detection code:
+ */
+
+static double __initdata x = 4195835.0;
+static double __initdata y = 3145727.0;
+
+/*
+ * This used to check for exceptions..
+ * However, it turns out that to support that,
+ * the XMM trap handlers basically had to
+ * be buggy. So let's have a correct XMM trap
+ * handler, and forget about printing out
+ * some status at boot.
+ *
+ * We should really only care about bugs here
+ * anyway. Not features.
+ */
+static void __init check_fpu(void)
+{
+       s32 fdiv_bug;
+
+       kernel_fpu_begin();
+
+       /*
+        * trap_init() enabled FXSR and company _before_ testing for FP
+        * problems here.
+        *
+        * Test for the divl bug: http://en.wikipedia.org/wiki/Fdiv_bug
+        */
+       __asm__("fninit\n\t"
+               "fldl %1\n\t"
+               "fdivl %2\n\t"
+               "fmull %2\n\t"
+               "fldl %1\n\t"
+               "fsubp %%st,%%st(1)\n\t"
+               "fistpl %0\n\t"
+               "fwait\n\t"
+               "fninit"
+               : "=m" (*&fdiv_bug)
+               : "m" (*&x), "m" (*&y));
+
+       kernel_fpu_end();
+
+       if (fdiv_bug) {
+               set_cpu_bug(&boot_cpu_data, X86_BUG_FDIV);
+               pr_warn("Hmm, FPU with FDIV bug\n");
+       }
+}
+
+void fpu__init_check_bugs(void)
+{
+       /*
+        * kernel_fpu_begin/end() in check_fpu() relies on the patched
+        * alternative instructions.
+        */
+       if (cpu_has_fpu)
+               check_fpu();
+}
index 69cdadd49ddf50fb8648361b48faf7fd0208ffbc..63cd1703d25c3ed522e3731604e770dcd6a1db34 100644 (file)
@@ -4,66 +4,6 @@
 #include <asm/fpu/internal.h>
 #include <asm/tlbflush.h>
 
-/*
- * Boot time CPU/FPU FDIV bug detection code:
- */
-
-static double __initdata x = 4195835.0;
-static double __initdata y = 3145727.0;
-
-/*
- * This used to check for exceptions..
- * However, it turns out that to support that,
- * the XMM trap handlers basically had to
- * be buggy. So let's have a correct XMM trap
- * handler, and forget about printing out
- * some status at boot.
- *
- * We should really only care about bugs here
- * anyway. Not features.
- */
-static void __init check_fpu(void)
-{
-       s32 fdiv_bug;
-
-       kernel_fpu_begin();
-
-       /*
-        * trap_init() enabled FXSR and company _before_ testing for FP
-        * problems here.
-        *
-        * Test for the divl bug: http://en.wikipedia.org/wiki/Fdiv_bug
-        */
-       __asm__("fninit\n\t"
-               "fldl %1\n\t"
-               "fdivl %2\n\t"
-               "fmull %2\n\t"
-               "fldl %1\n\t"
-               "fsubp %%st,%%st(1)\n\t"
-               "fistpl %0\n\t"
-               "fwait\n\t"
-               "fninit"
-               : "=m" (*&fdiv_bug)
-               : "m" (*&x), "m" (*&y));
-
-       kernel_fpu_end();
-
-       if (fdiv_bug) {
-               set_cpu_bug(&boot_cpu_data, X86_BUG_FDIV);
-               pr_warn("Hmm, FPU with FDIV bug\n");
-       }
-}
-
-void fpu__init_check_bugs(void)
-{
-       /*
-        * kernel_fpu_begin/end() in check_fpu() relies on the patched
-        * alternative instructions.
-        */
-       if (cpu_has_fpu)
-               check_fpu();
-}
-
 /*
  * The earliest FPU detection code:
  */