1
2
3
4#include <asm/fpu/internal.h>
5
6
7
8
9
10static double __initdata x = 4195835.0;
11static double __initdata y = 3145727.0;
12
13
14
15
16
17
18
19
20
21
22
23
24static void __init check_fpu(void)
25{
26 u32 cr0_saved;
27 s32 fdiv_bug;
28
29
30 cr0_saved = read_cr0();
31 write_cr0(cr0_saved & ~X86_CR0_TS);
32
33 kernel_fpu_begin();
34
35
36
37
38
39
40
41 __asm__("fninit\n\t"
42 "fldl %1\n\t"
43 "fdivl %2\n\t"
44 "fmull %2\n\t"
45 "fldl %1\n\t"
46 "fsubp %%st,%%st(1)\n\t"
47 "fistpl %0\n\t"
48 "fwait\n\t"
49 "fninit"
50 : "=m" (*&fdiv_bug)
51 : "m" (*&x), "m" (*&y));
52
53 kernel_fpu_end();
54
55 write_cr0(cr0_saved);
56
57 if (fdiv_bug) {
58 set_cpu_bug(&boot_cpu_data, X86_BUG_FDIV);
59 pr_warn("Hmm, FPU with FDIV bug\n");
60 }
61}
62
63void __init fpu__init_check_bugs(void)
64{
65
66
67
68
69 if (cpu_has_fpu)
70 check_fpu();
71}
72