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).
10 #include <linux/init.h>
11 #include <linux/utsname.h>
13 #include <asm/processor.h>
14 #include <asm/processor-flags.h>
17 #include <asm/paravirt.h>
18 #include <asm/alternative.h>
20 static int __init
no_halt(char *s
)
22 boot_cpu_data
.hlt_works_ok
= 0;
26 __setup("no-hlt", no_halt
);
28 <<<<<<< HEAD
:arch
/x86
/kernel
/cpu
/bugs
.c
29 static int __init
mca_pentium(char *s
)
35 __setup("mca-pentium", mca_pentium
);
38 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:arch
/x86
/kernel
/cpu
/bugs
.c
39 static int __init
no_387(char *s
)
41 boot_cpu_data
.hard_math
= 0;
42 write_cr0(X86_CR0_TS
| X86_CR0_EM
| X86_CR0_MP
| read_cr0());
46 __setup("no387", no_387
);
48 static double __initdata x
= 4195835.0;
49 static double __initdata y
= 3145727.0;
52 * This used to check for exceptions..
53 * However, it turns out that to support that,
54 * the XMM trap handlers basically had to
55 * be buggy. So let's have a correct XMM trap
56 * handler, and forget about printing out
57 * some status at boot.
59 * We should really only care about bugs here
60 * anyway. Not features.
62 static void __init
check_fpu(void)
64 if (!boot_cpu_data
.hard_math
) {
65 #ifndef CONFIG_MATH_EMULATION
66 printk(KERN_EMERG
"No coprocessor found and no math emulation present.\n");
67 printk(KERN_EMERG
"Giving up.\n");
73 /* trap_init() enabled FXSR and company _before_ testing for FP problems here. */
74 /* Test for the divl bug.. */
80 "fsubp %%st,%%st(1)\n\t"
84 : "=m" (*&boot_cpu_data
.fdiv_bug
)
85 : "m" (*&x
), "m" (*&y
));
86 if (boot_cpu_data
.fdiv_bug
)
87 printk("Hmm, FPU with FDIV bug.\n");
90 static void __init
check_hlt(void)
92 if (paravirt_enabled())
95 printk(KERN_INFO
"Checking 'hlt' instruction... ");
96 if (!boot_cpu_data
.hlt_works_ok
) {
108 * Most 386 processors have a bug where a POPAD can lock the
109 * machine even from user space.
112 static void __init
check_popad(void)
114 #ifndef CONFIG_X86_POPAD_OK
115 int res
, inp
= (int) &res
;
117 printk(KERN_INFO
"Checking for popad bug... ");
118 __asm__
__volatile__(
119 "movl $12345678,%%eax; movl $0,%%edi; pusha; popa; movl (%%edx,%%edi),%%ecx "
123 /* If this fails, it means that any user program may lock the CPU hard. Too bad. */
124 if (res
!= 12345678) printk( "Buggy.\n" );
125 else printk( "OK.\n" );
130 * Check whether we are able to run this kernel safely on SMP.
132 * - In order to run on a i386, we need to be compiled for i386
133 * (for due to lack of "invlpg" and working WP on a i386)
134 * - In order to run on anything without a TSC, we need to be
135 * compiled for a i486.
136 * - In order to support the local APIC on a buggy Pentium machine,
137 * we need to be compiled with CONFIG_X86_GOOD_APIC disabled,
138 * which happens implicitly if compiled for a Pentium or lower
139 * (unless an advanced selection of CPU features is used) as an
140 * otherwise config implies a properly working local APIC without
141 * the need to do extra reads from the APIC.
144 static void __init
check_config(void)
147 * We'd better not be a i386 if we're configured to use some
148 * i486+ only features! (WP works in supervisor mode and the
149 * new "invlpg" and "bswap" instructions)
151 #if defined(CONFIG_X86_WP_WORKS_OK) || defined(CONFIG_X86_INVLPG) || defined(CONFIG_X86_BSWAP)
152 if (boot_cpu_data
.x86
== 3)
153 panic("Kernel requires i486+ for 'invlpg' and other features");
157 * If we configured ourselves for a TSC, we'd better have one!
159 #ifdef CONFIG_X86_TSC
161 panic("Kernel compiled for Pentium+, requires TSC feature!");
165 * If we were told we had a good local APIC, check for buggy Pentia,
166 * i.e. all B steppings and the C2 stepping of P54C when using their
167 * integrated APIC (see 11AP erratum in "Pentium Processor
168 * Specification Update").
170 #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86_GOOD_APIC)
171 if (boot_cpu_data
.x86_vendor
== X86_VENDOR_INTEL
173 && boot_cpu_data
.x86
== 5
174 && boot_cpu_data
.x86_model
== 2
175 && (boot_cpu_data
.x86_mask
< 6 || boot_cpu_data
.x86_mask
== 11))
176 panic("Kernel compiled for PMMX+, assumes a local APIC without the read-before-write bug!");
181 void __init
check_bugs(void)
186 print_cpu_info(&boot_cpu_data
);
192 init_utsname()->machine
[1] = '0' + (boot_cpu_data
.x86
> 6 ? 6 : boot_cpu_data
.x86
);
193 alternative_instructions();