@@ -48,13 +48,7 @@ void fpu__init_cpu(void)
48
48
fpu__init_cpu_xstate ();
49
49
}
50
50
51
- /*
52
- * The earliest FPU detection code.
53
- *
54
- * Set the X86_FEATURE_FPU CPU-capability bit based on
55
- * trying to execute an actual sequence of FPU instructions:
56
- */
57
- static void fpu__init_system_early_generic (struct cpuinfo_x86 * c )
51
+ static bool fpu__probe_without_cpuid (void )
58
52
{
59
53
unsigned long cr0 ;
60
54
u16 fsw , fcw ;
@@ -65,14 +59,21 @@ static void fpu__init_system_early_generic(struct cpuinfo_x86 *c)
65
59
cr0 &= ~(X86_CR0_TS | X86_CR0_EM );
66
60
write_cr0 (cr0 );
67
61
68
- if (! test_bit ( X86_FEATURE_FPU , ( unsigned long * ) cpu_caps_cleared )) {
69
- asm volatile ( "fninit ; fnstsw %0 ; fnstcw %1"
70
- : "+m" ( fsw ), "+m" ( fcw ) );
62
+ asm volatile ( "fninit ; fnstsw %0 ; fnstcw %1" : "+m" ( fsw ), "+m" ( fcw ));
63
+
64
+ pr_info ( "x86/fpu: Probing for FPU: FSW=0x%04hx FCW=0x%04hx\n" , fsw , fcw );
71
65
72
- if (fsw == 0 && (fcw & 0x103f ) == 0x003f )
73
- set_cpu_cap (c , X86_FEATURE_FPU );
66
+ return fsw == 0 && (fcw & 0x103f ) == 0x003f ;
67
+ }
68
+
69
+ static void fpu__init_system_early_generic (struct cpuinfo_x86 * c )
70
+ {
71
+ if (!boot_cpu_has (X86_FEATURE_CPUID ) &&
72
+ !test_bit (X86_FEATURE_FPU , (unsigned long * )cpu_caps_cleared )) {
73
+ if (fpu__probe_without_cpuid ())
74
+ setup_force_cpu_cap (X86_FEATURE_FPU );
74
75
else
75
- clear_cpu_cap ( c , X86_FEATURE_FPU );
76
+ setup_clear_cpu_cap ( X86_FEATURE_FPU );
76
77
}
77
78
78
79
#ifndef CONFIG_MATH_EMULATION
0 commit comments