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 static int __init no_387(char *s)
30 boot_cpu_data.hard_math = 0;
31 write_cr0(X86_CR0_TS | X86_CR0_EM | X86_CR0_MP | read_cr0());
35 __setup("no387", no_387);
37 static double __initdata x = 4195835.0;
38 static double __initdata y = 3145727.0;
41 * This used to check for exceptions..
42 * However, it turns out that to support that,
43 * the XMM trap handlers basically had to
44 * be buggy. So let's have a correct XMM trap
45 * handler, and forget about printing out
46 * some status at boot.
48 * We should really only care about bugs here
49 * anyway. Not features.
51 static void __init check_fpu(void)
53 if (!boot_cpu_data.hard_math) {
54 #ifndef CONFIG_MATH_EMULATION
55 printk(KERN_EMERG "No coprocessor found and no math emulation present.\n");
56 printk(KERN_EMERG "Giving up.\n");
63 * trap_init() enabled FXSR and company _before_ testing for FP
66 * Test for the divl bug..
73 "fsubp %%st,%%st(1)\n\t"
77 : "=m" (*&boot_cpu_data.fdiv_bug)
78 : "m" (*&x), "m" (*&y));
79 if (boot_cpu_data.fdiv_bug)
80 printk("Hmm, FPU with FDIV bug.\n");
83 static void __init check_hlt(void)
85 if (paravirt_enabled())
88 printk(KERN_INFO "Checking 'hlt' instruction... ");
89 if (!boot_cpu_data.hlt_works_ok) {
101 * Most 386 processors have a bug where a POPAD can lock the
102 * machine even from user space.
105 static void __init check_popad(void)
107 #ifndef CONFIG_X86_POPAD_OK
108 int res, inp = (int) &res;
110 printk(KERN_INFO "Checking for popad bug... ");
111 __asm__ __volatile__(
112 "movl $12345678,%%eax; movl $0,%%edi; pusha; popa; movl (%%edx,%%edi),%%ecx "
117 * If this fails, it means that any user program may lock the
128 * Check whether we are able to run this kernel safely on SMP.
130 * - In order to run on a i386, we need to be compiled for i386
131 * (for due to lack of "invlpg" and working WP on a i386)
132 * - In order to run on anything without a TSC, we need to be
133 * compiled for a i486.
134 * - In order to support the local APIC on a buggy Pentium machine,
135 * we need to be compiled with CONFIG_X86_GOOD_APIC disabled,
136 * which happens implicitly if compiled for a Pentium or lower
137 * (unless an advanced selection of CPU features is used) as an
138 * otherwise config implies a properly working local APIC without
139 * the need to do extra reads from the APIC.
142 static void __init check_config(void)
145 * We'd better not be a i386 if we're configured to use some
146 * i486+ only features! (WP works in supervisor mode and the
147 * new "invlpg" and "bswap" instructions)
149 #if defined(CONFIG_X86_WP_WORKS_OK) || defined(CONFIG_X86_INVLPG) || \
150 defined(CONFIG_X86_BSWAP)
151 if (boot_cpu_data.x86 == 3)
152 panic("Kernel requires i486+ for 'invlpg' and other features");
156 * If we were told we had a good local APIC, check for buggy Pentia,
157 * i.e. all B steppings and the C2 stepping of P54C when using their
158 * integrated APIC (see 11AP erratum in "Pentium Processor
159 * Specification Update").
161 #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86_GOOD_APIC)
162 if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL
164 && boot_cpu_data.x86 == 5
165 && boot_cpu_data.x86_model == 2
166 && (boot_cpu_data.x86_mask < 6 || boot_cpu_data.x86_mask == 11))
167 panic("Kernel compiled for PMMX+, assumes a local APIC without the read-before-write bug!");
172 void __init check_bugs(void)
177 print_cpu_info(&boot_cpu_data);
183 init_utsname()->machine[1] =
184 '0' + (boot_cpu_data.x86 > 6 ? 6 : boot_cpu_data.x86);
185 alternative_instructions();