2 * include/asm-i386/bugs.h
4 * Copyright (C) 1994 Linus Torvalds
6 * Cyrix stuff, June 1998 by:
7 * - Rafael R. Reilova (moved everything from head.S),
8 * <rreilova@ececs.uc.edu>
9 * - Channing Corn (tests & fixes),
10 * - Andrew D. Balsa (code cleanup).
14 * This is included by init/main.c to check for architecture-dependent bugs.
17 * void check_bugs(void);
20 #include <linux/init.h>
21 #include <asm/processor.h>
24 #include <asm/paravirt.h>
26 static int __init
no_halt(char *s
)
28 boot_cpu_data
.hlt_works_ok
= 0;
32 __setup("no-hlt", no_halt
);
34 static int __init
mca_pentium(char *s
)
40 __setup("mca-pentium", mca_pentium
);
42 static int __init
no_387(char *s
)
44 boot_cpu_data
.hard_math
= 0;
45 write_cr0(0xE | read_cr0());
49 __setup("no387", no_387
);
51 static double __initdata x
= 4195835.0;
52 static double __initdata y
= 3145727.0;
55 * This used to check for exceptions..
56 * However, it turns out that to support that,
57 * the XMM trap handlers basically had to
58 * be buggy. So let's have a correct XMM trap
59 * handler, and forget about printing out
60 * some status at boot.
62 * We should really only care about bugs here
63 * anyway. Not features.
65 static void __init
check_fpu(void)
67 if (!boot_cpu_data
.hard_math
) {
68 #ifndef CONFIG_MATH_EMULATION
69 printk(KERN_EMERG
"No coprocessor found and no math emulation present.\n");
70 printk(KERN_EMERG
"Giving up.\n");
76 /* trap_init() enabled FXSR and company _before_ testing for FP problems here. */
77 /* Test for the divl bug.. */
83 "fsubp %%st,%%st(1)\n\t"
87 : "=m" (*&boot_cpu_data
.fdiv_bug
)
88 : "m" (*&x
), "m" (*&y
));
89 if (boot_cpu_data
.fdiv_bug
)
90 printk("Hmm, FPU with FDIV bug.\n");
93 static void __init
check_hlt(void)
95 if (paravirt_enabled())
98 printk(KERN_INFO
"Checking 'hlt' instruction... ");
99 if (!boot_cpu_data
.hlt_works_ok
) {
100 printk("disabled\n");
111 * Most 386 processors have a bug where a POPAD can lock the
112 * machine even from user space.
115 static void __init
check_popad(void)
117 #ifndef CONFIG_X86_POPAD_OK
118 int res
, inp
= (int) &res
;
120 printk(KERN_INFO
"Checking for popad bug... ");
121 __asm__
__volatile__(
122 "movl $12345678,%%eax; movl $0,%%edi; pusha; popa; movl (%%edx,%%edi),%%ecx "
126 /* If this fails, it means that any user program may lock the CPU hard. Too bad. */
127 if (res
!= 12345678) printk( "Buggy.\n" );
128 else printk( "OK.\n" );
133 * Check whether we are able to run this kernel safely on SMP.
135 * - In order to run on a i386, we need to be compiled for i386
136 * (for due to lack of "invlpg" and working WP on a i386)
137 * - In order to run on anything without a TSC, we need to be
138 * compiled for a i486.
139 * - In order to support the local APIC on a buggy Pentium machine,
140 * we need to be compiled with CONFIG_X86_GOOD_APIC disabled,
141 * which happens implicitly if compiled for a Pentium or lower
142 * (unless an advanced selection of CPU features is used) as an
143 * otherwise config implies a properly working local APIC without
144 * the need to do extra reads from the APIC.
147 static void __init
check_config(void)
150 * We'd better not be a i386 if we're configured to use some
151 * i486+ only features! (WP works in supervisor mode and the
152 * new "invlpg" and "bswap" instructions)
154 #if defined(CONFIG_X86_WP_WORKS_OK) || defined(CONFIG_X86_INVLPG) || defined(CONFIG_X86_BSWAP)
155 if (boot_cpu_data
.x86
== 3)
156 panic("Kernel requires i486+ for 'invlpg' and other features");
160 * If we configured ourselves for a TSC, we'd better have one!
162 #ifdef CONFIG_X86_TSC
164 panic("Kernel compiled for Pentium+, requires TSC feature!");
168 * If we were told we had a good local APIC, check for buggy Pentia,
169 * i.e. all B steppings and the C2 stepping of P54C when using their
170 * integrated APIC (see 11AP erratum in "Pentium Processor
171 * Specification Update").
173 #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86_GOOD_APIC)
174 if (boot_cpu_data
.x86_vendor
== X86_VENDOR_INTEL
176 && boot_cpu_data
.x86
== 5
177 && boot_cpu_data
.x86_model
== 2
178 && (boot_cpu_data
.x86_mask
< 6 || boot_cpu_data
.x86_mask
== 11))
179 panic("Kernel compiled for PMMX+, assumes a local APIC without the read-before-write bug!");
183 extern void alternative_instructions(void);
185 static void __init
check_bugs(void)
187 identify_cpu(&boot_cpu_data
);
190 print_cpu_info(&boot_cpu_data
);
196 init_utsname()->machine
[1] = '0' + (boot_cpu_data
.x86
> 6 ? 6 : boot_cpu_data
.x86
);
197 alternative_instructions();