3
3
*/
4
4
#include <asm/fpu/internal.h>
5
5
#include <asm/tlbflush.h>
6
+ #include <asm/setup.h>
7
+ #include <asm/cmdline.h>
6
8
7
9
#include <linux/sched.h>
10
+ #include <linux/init.h>
8
11
9
12
/*
10
13
* Initialize the TS bit in CR0 according to the style of context-switches
@@ -270,18 +273,6 @@ static void __init fpu__init_system_xstate_size_legacy(void)
270
273
*/
271
274
static enum { AUTO , ENABLE , DISABLE } eagerfpu = AUTO ;
272
275
273
- static int __init eager_fpu_setup (char * s )
274
- {
275
- if (!strcmp (s , "on" ))
276
- eagerfpu = ENABLE ;
277
- else if (!strcmp (s , "off" ))
278
- eagerfpu = DISABLE ;
279
- else if (!strcmp (s , "auto" ))
280
- eagerfpu = AUTO ;
281
- return 1 ;
282
- }
283
- __setup ("eagerfpu=" , eager_fpu_setup );
284
-
285
276
/*
286
277
* Pick the FPU context switching strategy:
287
278
*/
@@ -315,12 +306,47 @@ static void __init fpu__init_system_ctx_switch(void)
315
306
printk (KERN_INFO "x86/fpu: Using '%s' FPU context switches.\n" , eagerfpu == ENABLE ? "eager" : "lazy" );
316
307
}
317
308
309
+ /*
310
+ * We parse fpu parameters early because fpu__init_system() is executed
311
+ * before parse_early_param().
312
+ */
313
+ static void __init fpu__init_parse_early_param (void )
314
+ {
315
+ /*
316
+ * No need to check "eagerfpu=auto" again, since it is the
317
+ * initial default.
318
+ */
319
+ if (cmdline_find_option_bool (boot_command_line , "eagerfpu=off" ))
320
+ eagerfpu = DISABLE ;
321
+ else if (cmdline_find_option_bool (boot_command_line , "eagerfpu=on" ))
322
+ eagerfpu = ENABLE ;
323
+
324
+ if (cmdline_find_option_bool (boot_command_line , "no387" ))
325
+ setup_clear_cpu_cap (X86_FEATURE_FPU );
326
+
327
+ if (cmdline_find_option_bool (boot_command_line , "nofxsr" )) {
328
+ setup_clear_cpu_cap (X86_FEATURE_FXSR );
329
+ setup_clear_cpu_cap (X86_FEATURE_FXSR_OPT );
330
+ setup_clear_cpu_cap (X86_FEATURE_XMM );
331
+ }
332
+
333
+ if (cmdline_find_option_bool (boot_command_line , "noxsave" ))
334
+ fpu__xstate_clear_all_cpu_caps ();
335
+
336
+ if (cmdline_find_option_bool (boot_command_line , "noxsaveopt" ))
337
+ setup_clear_cpu_cap (X86_FEATURE_XSAVEOPT );
338
+
339
+ if (cmdline_find_option_bool (boot_command_line , "noxsaves" ))
340
+ setup_clear_cpu_cap (X86_FEATURE_XSAVES );
341
+ }
342
+
318
343
/*
319
344
* Called on the boot CPU once per system bootup, to set up the initial
320
345
* FPU state that is later cloned into all processes:
321
346
*/
322
347
void __init fpu__init_system (struct cpuinfo_x86 * c )
323
348
{
349
+ fpu__init_parse_early_param ();
324
350
fpu__init_system_early_generic (c );
325
351
326
352
/*
@@ -344,62 +370,3 @@ void __init fpu__init_system(struct cpuinfo_x86 *c)
344
370
345
371
fpu__init_system_ctx_switch ();
346
372
}
347
-
348
- /*
349
- * Boot parameter to turn off FPU support and fall back to math-emu:
350
- */
351
- static int __init no_387 (char * s )
352
- {
353
- setup_clear_cpu_cap (X86_FEATURE_FPU );
354
- return 1 ;
355
- }
356
- __setup ("no387" , no_387 );
357
-
358
- /*
359
- * Disable all xstate CPU features:
360
- */
361
- static int __init x86_noxsave_setup (char * s )
362
- {
363
- if (strlen (s ))
364
- return 0 ;
365
-
366
- fpu__xstate_clear_all_cpu_caps ();
367
-
368
- return 1 ;
369
- }
370
- __setup ("noxsave" , x86_noxsave_setup );
371
-
372
- /*
373
- * Disable the XSAVEOPT instruction specifically:
374
- */
375
- static int __init x86_noxsaveopt_setup (char * s )
376
- {
377
- setup_clear_cpu_cap (X86_FEATURE_XSAVEOPT );
378
-
379
- return 1 ;
380
- }
381
- __setup ("noxsaveopt" , x86_noxsaveopt_setup );
382
-
383
- /*
384
- * Disable the XSAVES instruction:
385
- */
386
- static int __init x86_noxsaves_setup (char * s )
387
- {
388
- setup_clear_cpu_cap (X86_FEATURE_XSAVES );
389
-
390
- return 1 ;
391
- }
392
- __setup ("noxsaves" , x86_noxsaves_setup );
393
-
394
- /*
395
- * Disable FX save/restore and SSE support:
396
- */
397
- static int __init x86_nofxsr_setup (char * s )
398
- {
399
- setup_clear_cpu_cap (X86_FEATURE_FXSR );
400
- setup_clear_cpu_cap (X86_FEATURE_FXSR_OPT );
401
- setup_clear_cpu_cap (X86_FEATURE_XMM );
402
-
403
- return 1 ;
404
- }
405
- __setup ("nofxsr" , x86_nofxsr_setup );
0 commit comments