Linux 3.8-rc7
[cris-mirror.git] / arch / x86 / kernel / cpu / bugs.c
blob92dfec986a48ec97ffb680002f22a56f5a7b9262
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_halt(char *s)
22 WARN_ONCE(1, "\"no-hlt\" is deprecated, please use \"idle=poll\"\n");
23 boot_cpu_data.hlt_works_ok = 0;
24 return 1;
27 __setup("no-hlt", no_halt);
29 static int __init no_387(char *s)
31 boot_cpu_data.hard_math = 0;
32 write_cr0(X86_CR0_TS | X86_CR0_EM | X86_CR0_MP | read_cr0());
33 return 1;
36 __setup("no387", no_387);
38 static double __initdata x = 4195835.0;
39 static double __initdata y = 3145727.0;
42 * This used to check for exceptions..
43 * However, it turns out that to support that,
44 * the XMM trap handlers basically had to
45 * be buggy. So let's have a correct XMM trap
46 * handler, and forget about printing out
47 * some status at boot.
49 * We should really only care about bugs here
50 * anyway. Not features.
52 static void __init check_fpu(void)
54 s32 fdiv_bug;
56 if (!boot_cpu_data.hard_math) {
57 #ifndef CONFIG_MATH_EMULATION
58 pr_emerg("No coprocessor found and no math emulation present\n");
59 pr_emerg("Giving up\n");
60 for (;;) ;
61 #endif
62 return;
65 kernel_fpu_begin();
68 * trap_init() enabled FXSR and company _before_ testing for FP
69 * problems here.
71 * Test for the divl bug..
73 __asm__("fninit\n\t"
74 "fldl %1\n\t"
75 "fdivl %2\n\t"
76 "fmull %2\n\t"
77 "fldl %1\n\t"
78 "fsubp %%st,%%st(1)\n\t"
79 "fistpl %0\n\t"
80 "fwait\n\t"
81 "fninit"
82 : "=m" (*&fdiv_bug)
83 : "m" (*&x), "m" (*&y));
85 kernel_fpu_end();
87 boot_cpu_data.fdiv_bug = fdiv_bug;
88 if (boot_cpu_data.fdiv_bug)
89 pr_warn("Hmm, FPU with FDIV bug\n");
92 static void __init check_hlt(void)
94 if (boot_cpu_data.x86 >= 5 || paravirt_enabled())
95 return;
97 pr_info("Checking 'hlt' instruction... ");
98 if (!boot_cpu_data.hlt_works_ok) {
99 pr_cont("disabled\n");
100 return;
102 halt();
103 halt();
104 halt();
105 halt();
106 pr_cont("OK\n");
110 * Check whether we are able to run this kernel safely on SMP.
112 * - i386 is no longer supported.
113 * - In order to run on anything without a TSC, we need to be
114 * compiled for a i486.
117 static void __init check_config(void)
119 if (boot_cpu_data.x86 < 4)
120 panic("Kernel requires i486+ for 'invlpg' and other features");
124 void __init check_bugs(void)
126 identify_boot_cpu();
127 #ifndef CONFIG_SMP
128 pr_info("CPU: ");
129 print_cpu_info(&boot_cpu_data);
130 #endif
131 check_config();
132 check_hlt();
133 init_utsname()->machine[1] =
134 '0' + (boot_cpu_data.x86 > 6 ? 6 : boot_cpu_data.x86);
135 alternative_instructions();
138 * kernel_fpu_begin/end() in check_fpu() relies on the patched
139 * alternative instructions.
141 check_fpu();