Commit | Line | Data |
---|---|---|
1353ebb4 | 1 | /* |
1353ebb4 JF |
2 | * Copyright (C) 1994 Linus Torvalds |
3 | * | |
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> | |
91eb1b79 | 12 | #include <asm/bugs.h> |
1353ebb4 | 13 | #include <asm/processor.h> |
7ebad705 | 14 | #include <asm/processor-flags.h> |
1353ebb4 JF |
15 | #include <asm/i387.h> |
16 | #include <asm/msr.h> | |
17 | #include <asm/paravirt.h> | |
18 | #include <asm/alternative.h> | |
19 | ||
1353ebb4 JF |
20 | static int __init no_387(char *s) |
21 | { | |
22 | boot_cpu_data.hard_math = 0; | |
7ebad705 | 23 | write_cr0(X86_CR0_TS | X86_CR0_EM | X86_CR0_MP | read_cr0()); |
1353ebb4 JF |
24 | return 1; |
25 | } | |
26 | ||
27 | __setup("no387", no_387); | |
28 | ||
29 | static double __initdata x = 4195835.0; | |
30 | static double __initdata y = 3145727.0; | |
31 | ||
32 | /* | |
33 | * This used to check for exceptions.. | |
34 | * However, it turns out that to support that, | |
35 | * the XMM trap handlers basically had to | |
36 | * be buggy. So let's have a correct XMM trap | |
37 | * handler, and forget about printing out | |
38 | * some status at boot. | |
39 | * | |
40 | * We should really only care about bugs here | |
41 | * anyway. Not features. | |
42 | */ | |
43 | static void __init check_fpu(void) | |
44 | { | |
e0d22d03 KH |
45 | s32 fdiv_bug; |
46 | ||
1353ebb4 JF |
47 | if (!boot_cpu_data.hard_math) { |
48 | #ifndef CONFIG_MATH_EMULATION | |
c767a54b JP |
49 | pr_emerg("No coprocessor found and no math emulation present\n"); |
50 | pr_emerg("Giving up\n"); | |
1353ebb4 JF |
51 | for (;;) ; |
52 | #endif | |
53 | return; | |
54 | } | |
55 | ||
3e7cf5b0 SS |
56 | kernel_fpu_begin(); |
57 | ||
bfe4bb15 MV |
58 | /* |
59 | * trap_init() enabled FXSR and company _before_ testing for FP | |
60 | * problems here. | |
61 | * | |
62 | * Test for the divl bug.. | |
63 | */ | |
1353ebb4 JF |
64 | __asm__("fninit\n\t" |
65 | "fldl %1\n\t" | |
66 | "fdivl %2\n\t" | |
67 | "fmull %2\n\t" | |
68 | "fldl %1\n\t" | |
69 | "fsubp %%st,%%st(1)\n\t" | |
70 | "fistpl %0\n\t" | |
71 | "fwait\n\t" | |
72 | "fninit" | |
e0d22d03 | 73 | : "=m" (*&fdiv_bug) |
1353ebb4 | 74 | : "m" (*&x), "m" (*&y)); |
e0d22d03 | 75 | |
3e7cf5b0 SS |
76 | kernel_fpu_end(); |
77 | ||
e0d22d03 | 78 | boot_cpu_data.fdiv_bug = fdiv_bug; |
1353ebb4 | 79 | if (boot_cpu_data.fdiv_bug) |
c767a54b | 80 | pr_warn("Hmm, FPU with FDIV bug\n"); |
1353ebb4 JF |
81 | } |
82 | ||
1353ebb4 JF |
83 | /* |
84 | * Check whether we are able to run this kernel safely on SMP. | |
85 | * | |
e5bb8ad8 | 86 | * - i386 is no longer supported. |
1353ebb4 JF |
87 | * - In order to run on anything without a TSC, we need to be |
88 | * compiled for a i486. | |
593f4a78 | 89 | */ |
1353ebb4 JF |
90 | |
91 | static void __init check_config(void) | |
92 | { | |
e5bb8ad8 | 93 | if (boot_cpu_data.x86 < 4) |
1353ebb4 | 94 | panic("Kernel requires i486+ for 'invlpg' and other features"); |
1353ebb4 JF |
95 | } |
96 | ||
97 | ||
98 | void __init check_bugs(void) | |
99 | { | |
100 | identify_boot_cpu(); | |
101 | #ifndef CONFIG_SMP | |
c767a54b | 102 | pr_info("CPU: "); |
1353ebb4 JF |
103 | print_cpu_info(&boot_cpu_data); |
104 | #endif | |
105 | check_config(); | |
bfe4bb15 MV |
106 | init_utsname()->machine[1] = |
107 | '0' + (boot_cpu_data.x86 > 6 ? 6 : boot_cpu_data.x86); | |
1353ebb4 | 108 | alternative_instructions(); |
304bceda SS |
109 | |
110 | /* | |
111 | * kernel_fpu_begin/end() in check_fpu() relies on the patched | |
112 | * alternative instructions. | |
113 | */ | |
114 | check_fpu(); | |
1353ebb4 | 115 | } |