@@ -373,101 +373,10 @@ static int apply_microcode_on_target(int cpu)
373
373
return ret ;
374
374
}
375
375
376
- #ifdef CONFIG_MICROCODE_OLD_INTERFACE
377
- static int do_microcode_update (const void __user * buf , size_t size )
378
- {
379
- int error = 0 ;
380
- int cpu ;
381
-
382
- for_each_online_cpu (cpu ) {
383
- struct ucode_cpu_info * uci = ucode_cpu_info + cpu ;
384
- enum ucode_state ustate ;
385
-
386
- if (!uci -> valid )
387
- continue ;
388
-
389
- ustate = microcode_ops -> request_microcode_user (cpu , buf , size );
390
- if (ustate == UCODE_ERROR ) {
391
- error = -1 ;
392
- break ;
393
- } else if (ustate == UCODE_NEW ) {
394
- apply_microcode_on_target (cpu );
395
- }
396
- }
397
-
398
- return error ;
399
- }
400
-
401
- static int microcode_open (struct inode * inode , struct file * file )
402
- {
403
- return capable (CAP_SYS_RAWIO ) ? stream_open (inode , file ) : - EPERM ;
404
- }
405
-
406
- static ssize_t microcode_write (struct file * file , const char __user * buf ,
407
- size_t len , loff_t * ppos )
408
- {
409
- ssize_t ret = - EINVAL ;
410
- unsigned long nr_pages = totalram_pages ();
411
-
412
- if ((len >> PAGE_SHIFT ) > nr_pages ) {
413
- pr_err ("too much data (max %ld pages)\n" , nr_pages );
414
- return ret ;
415
- }
416
-
417
- cpus_read_lock ();
418
- mutex_lock (& microcode_mutex );
419
-
420
- if (do_microcode_update (buf , len ) == 0 )
421
- ret = (ssize_t )len ;
422
-
423
- if (ret > 0 )
424
- perf_check_microcode ();
425
-
426
- mutex_unlock (& microcode_mutex );
427
- cpus_read_unlock ();
428
-
429
- return ret ;
430
- }
431
-
432
- static const struct file_operations microcode_fops = {
433
- .owner = THIS_MODULE ,
434
- .write = microcode_write ,
435
- .open = microcode_open ,
436
- .llseek = no_llseek ,
437
- };
438
-
439
- static struct miscdevice microcode_dev = {
440
- .minor = MICROCODE_MINOR ,
441
- .name = "microcode" ,
442
- .nodename = "cpu/microcode" ,
443
- .fops = & microcode_fops ,
444
- };
445
-
446
- static int __init microcode_dev_init (void )
447
- {
448
- int error ;
449
-
450
- error = misc_register (& microcode_dev );
451
- if (error ) {
452
- pr_err ("can't misc_register on minor=%d\n" , MICROCODE_MINOR );
453
- return error ;
454
- }
455
-
456
- return 0 ;
457
- }
458
-
459
- static void __exit microcode_dev_exit (void )
460
- {
461
- misc_deregister (& microcode_dev );
462
- }
463
- #else
464
- #define microcode_dev_init () 0
465
- #define microcode_dev_exit () do { } while (0)
466
- #endif
467
-
468
376
/* fake device for request_firmware */
469
377
static struct platform_device * microcode_pdev ;
470
378
379
+ #ifdef CONFIG_MICROCODE_LATE_LOADING
471
380
/*
472
381
* Late loading dance. Why the heavy-handed stomp_machine effort?
473
382
*
@@ -584,6 +493,9 @@ static int microcode_reload_late(void)
584
493
{
585
494
int ret ;
586
495
496
+ pr_err ("Attempting late microcode loading - it is dangerous and taints the kernel.\n" );
497
+ pr_err ("You should switch to early loading, if possible.\n" );
498
+
587
499
atomic_set (& late_cpus_in , 0 );
588
500
atomic_set (& late_cpus_out , 0 );
589
501
@@ -632,9 +544,14 @@ static ssize_t reload_store(struct device *dev,
632
544
if (ret == 0 )
633
545
ret = size ;
634
546
547
+ add_taint (TAINT_CPU_OUT_OF_SPEC , LOCKDEP_STILL_OK );
548
+
635
549
return ret ;
636
550
}
637
551
552
+ static DEVICE_ATTR_WO (reload );
553
+ #endif
554
+
638
555
static ssize_t version_show (struct device * dev ,
639
556
struct device_attribute * attr , char * buf )
640
557
{
@@ -651,7 +568,6 @@ static ssize_t pf_show(struct device *dev,
651
568
return sprintf (buf , "0x%x\n" , uci -> cpu_sig .pf );
652
569
}
653
570
654
- static DEVICE_ATTR_WO (reload );
655
571
static DEVICE_ATTR (version , 0444 , version_show , NULL) ;
656
572
static DEVICE_ATTR (processor_flags , 0444 , pf_show , NULL) ;
657
573
@@ -804,7 +720,9 @@ static int mc_cpu_down_prep(unsigned int cpu)
804
720
}
805
721
806
722
static struct attribute * cpu_root_microcode_attrs [] = {
723
+ #ifdef CONFIG_MICROCODE_LATE_LOADING
807
724
& dev_attr_reload .attr ,
725
+ #endif
808
726
NULL
809
727
};
810
728
@@ -838,10 +756,7 @@ static int __init microcode_init(void)
838
756
839
757
cpus_read_lock ();
840
758
mutex_lock (& microcode_mutex );
841
-
842
759
error = subsys_interface_register (& mc_cpu_interface );
843
- if (!error )
844
- perf_check_microcode ();
845
760
mutex_unlock (& microcode_mutex );
846
761
cpus_read_unlock ();
847
762
@@ -856,10 +771,6 @@ static int __init microcode_init(void)
856
771
goto out_driver ;
857
772
}
858
773
859
- error = microcode_dev_init ();
860
- if (error )
861
- goto out_ucode_group ;
862
-
863
774
register_syscore_ops (& mc_syscore_ops );
864
775
cpuhp_setup_state_nocalls (CPUHP_AP_MICROCODE_LOADER , "x86/microcode:starting" ,
865
776
mc_cpu_starting , NULL );
@@ -870,10 +781,6 @@ static int __init microcode_init(void)
870
781
871
782
return 0 ;
872
783
873
- out_ucode_group :
874
- sysfs_remove_group (& cpu_subsys .dev_root -> kobj ,
875
- & cpu_root_microcode_group );
876
-
877
784
out_driver :
878
785
cpus_read_lock ();
879
786
mutex_lock (& microcode_mutex );
0 commit comments