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 WARN_ONCE(1, "\"no-hlt\" is deprecated, please use \"idle=poll\"\n");
23 boot_cpu_data.hlt_works_ok = 0;
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());
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)
56 if (!boot_cpu_data.hard_math) {
57 #ifndef CONFIG_MATH_EMULATION
58 printk(KERN_EMERG "No coprocessor found and no math emulation present.\n");
59 printk(KERN_EMERG "Giving up.\n");
66 * trap_init() enabled FXSR and company _before_ testing for FP
69 * Test for the divl bug..
76 "fsubp %%st,%%st(1)\n\t"
81 : "m" (*&x), "m" (*&y));
83 boot_cpu_data.fdiv_bug = fdiv_bug;
84 if (boot_cpu_data.fdiv_bug)
85 printk(KERN_WARNING "Hmm, FPU with FDIV bug.\n");
88 static void __init check_hlt(void)
90 if (boot_cpu_data.x86 >= 5 || paravirt_enabled())
93 printk(KERN_INFO "Checking 'hlt' instruction... ");
94 if (!boot_cpu_data.hlt_works_ok) {
102 printk(KERN_CONT "OK.\n");
106 * Most 386 processors have a bug where a POPAD can lock the
107 * machine even from user space.
110 static void __init check_popad(void)
112 #ifndef CONFIG_X86_POPAD_OK
113 int res, inp = (int) &res;
115 printk(KERN_INFO "Checking for popad bug... ");
116 __asm__ __volatile__(
117 "movl $12345678,%%eax; movl $0,%%edi; pusha; popa; movl (%%edx,%%edi),%%ecx "
122 * If this fails, it means that any user program may lock the
126 printk(KERN_CONT "Buggy.\n");
128 printk(KERN_CONT "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.
141 static void __init check_config(void)
144 * We'd better not be a i386 if we're configured to use some
145 * i486+ only features! (WP works in supervisor mode and the
146 * new "invlpg" and "bswap" instructions)
148 #if defined(CONFIG_X86_WP_WORKS_OK) || defined(CONFIG_X86_INVLPG) || \
149 defined(CONFIG_X86_BSWAP)
150 if (boot_cpu_data.x86 == 3)
151 panic("Kernel requires i486+ for 'invlpg' and other features");
156 void __init check_bugs(void)
160 printk(KERN_INFO "CPU: ");
161 print_cpu_info(&boot_cpu_data);
167 init_utsname()->machine[1] =
168 '0' + (boot_cpu_data.x86 > 6 ? 6 : boot_cpu_data.x86);
169 alternative_instructions();