]>
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 double __initdata x = 4195835.0; |
21 | static double __initdata y = 3145727.0; | |
22 | ||
23 | /* | |
24 | * This used to check for exceptions.. | |
25 | * However, it turns out that to support that, | |
26 | * the XMM trap handlers basically had to | |
27 | * be buggy. So let's have a correct XMM trap | |
28 | * handler, and forget about printing out | |
29 | * some status at boot. | |
30 | * | |
31 | * We should really only care about bugs here | |
32 | * anyway. Not features. | |
33 | */ | |
34 | static void __init check_fpu(void) | |
35 | { | |
e0d22d03 KH |
36 | s32 fdiv_bug; |
37 | ||
3e7cf5b0 SS |
38 | kernel_fpu_begin(); |
39 | ||
bfe4bb15 MV |
40 | /* |
41 | * trap_init() enabled FXSR and company _before_ testing for FP | |
42 | * problems here. | |
43 | * | |
93a829e8 | 44 | * Test for the divl bug: http://en.wikipedia.org/wiki/Fdiv_bug |
bfe4bb15 | 45 | */ |
1353ebb4 JF |
46 | __asm__("fninit\n\t" |
47 | "fldl %1\n\t" | |
48 | "fdivl %2\n\t" | |
49 | "fmull %2\n\t" | |
50 | "fldl %1\n\t" | |
51 | "fsubp %%st,%%st(1)\n\t" | |
52 | "fistpl %0\n\t" | |
53 | "fwait\n\t" | |
54 | "fninit" | |
e0d22d03 | 55 | : "=m" (*&fdiv_bug) |
1353ebb4 | 56 | : "m" (*&x), "m" (*&y)); |
e0d22d03 | 57 | |
3e7cf5b0 SS |
58 | kernel_fpu_end(); |
59 | ||
93a829e8 BP |
60 | if (fdiv_bug) { |
61 | set_cpu_bug(&boot_cpu_data, X86_BUG_FDIV); | |
c767a54b | 62 | pr_warn("Hmm, FPU with FDIV bug\n"); |
93a829e8 | 63 | } |
1353ebb4 JF |
64 | } |
65 | ||
1353ebb4 JF |
66 | void __init check_bugs(void) |
67 | { | |
68 | identify_boot_cpu(); | |
69 | #ifndef CONFIG_SMP | |
c767a54b | 70 | pr_info("CPU: "); |
1353ebb4 JF |
71 | print_cpu_info(&boot_cpu_data); |
72 | #endif | |
55a36b65 BP |
73 | |
74 | /* | |
75 | * Check whether we are able to run this kernel safely on SMP. | |
76 | * | |
77 | * - i386 is no longer supported. | |
78 | * - In order to run on anything without a TSC, we need to be | |
79 | * compiled for a i486. | |
80 | */ | |
81 | if (boot_cpu_data.x86 < 4) | |
82 | panic("Kernel requires i486+ for 'invlpg' and other features"); | |
83 | ||
bfe4bb15 MV |
84 | init_utsname()->machine[1] = |
85 | '0' + (boot_cpu_data.x86 > 6 ? 6 : boot_cpu_data.x86); | |
1353ebb4 | 86 | alternative_instructions(); |
304bceda SS |
87 | |
88 | /* | |
89 | * kernel_fpu_begin/end() in check_fpu() relies on the patched | |
90 | * alternative instructions. | |
91 | */ | |
60e019eb PA |
92 | if (cpu_has_fpu) |
93 | check_fpu(); | |
1353ebb4 | 94 | } |