staging:iio:adc:ad7606 move to info_mask_(shared_by_type/separate)
[linux/fpc-iii.git] / arch / x86 / kernel / cpu / bugs.c
blobaf6455e3fcc9b9e6f7f1d75b6ee5ce112a689590
1 /*
2 * Copyright (C) 1994 Linus Torvalds
4 * Cyrix stuff, June 1998 by:
5 * - Rafael R. Reilova (moved everything from head.S),
6 * <rreilova@ececs.uc.edu>
7 * - Channing Corn (tests & fixes),
8 * - Andrew D. Balsa (code cleanup).
9 */
10 #include <linux/init.h>
11 #include <linux/utsname.h>
12 #include <asm/bugs.h>
13 #include <asm/processor.h>
14 #include <asm/processor-flags.h>
15 #include <asm/i387.h>
16 #include <asm/msr.h>
17 #include <asm/paravirt.h>
18 #include <asm/alternative.h>
20 static int __init no_387(char *s)
22 boot_cpu_data.hard_math = 0;
23 write_cr0(X86_CR0_TS | X86_CR0_EM | X86_CR0_MP | read_cr0());
24 return 1;
27 __setup("no387", no_387);
29 static double __initdata x = 4195835.0;
30 static double __initdata y = 3145727.0;
33 * This used to check for exceptions..
34 * However, it turns out that to support that,
35 * the XMM trap handlers basically had to
36 * be buggy. So let's have a correct XMM trap
37 * handler, and forget about printing out
38 * some status at boot.
40 * We should really only care about bugs here
41 * anyway. Not features.
43 static void __init check_fpu(void)
45 s32 fdiv_bug;
47 if (!boot_cpu_data.hard_math) {
48 #ifndef CONFIG_MATH_EMULATION
49 pr_emerg("No coprocessor found and no math emulation present\n");
50 pr_emerg("Giving up\n");
51 for (;;) ;
52 #endif
53 return;
56 kernel_fpu_begin();
59 * trap_init() enabled FXSR and company _before_ testing for FP
60 * problems here.
62 * Test for the divl bug..
64 __asm__("fninit\n\t"
65 "fldl %1\n\t"
66 "fdivl %2\n\t"
67 "fmull %2\n\t"
68 "fldl %1\n\t"
69 "fsubp %%st,%%st(1)\n\t"
70 "fistpl %0\n\t"
71 "fwait\n\t"
72 "fninit"
73 : "=m" (*&fdiv_bug)
74 : "m" (*&x), "m" (*&y));
76 kernel_fpu_end();
78 boot_cpu_data.fdiv_bug = fdiv_bug;
79 if (boot_cpu_data.fdiv_bug)
80 pr_warn("Hmm, FPU with FDIV bug\n");
84 * Check whether we are able to run this kernel safely on SMP.
86 * - i386 is no longer supported.
87 * - In order to run on anything without a TSC, we need to be
88 * compiled for a i486.
91 static void __init check_config(void)
93 if (boot_cpu_data.x86 < 4)
94 panic("Kernel requires i486+ for 'invlpg' and other features");
98 void __init check_bugs(void)
100 identify_boot_cpu();
101 #ifndef CONFIG_SMP
102 pr_info("CPU: ");
103 print_cpu_info(&boot_cpu_data);
104 #endif
105 check_config();
106 init_utsname()->machine[1] =
107 '0' + (boot_cpu_data.x86 > 6 ? 6 : boot_cpu_data.x86);
108 alternative_instructions();
111 * kernel_fpu_begin/end() in check_fpu() relies on the patched
112 * alternative instructions.
114 check_fpu();