Everything should be using the early initrd loading by now.
Unified · Split
| @@ -1350,18 +1350,6 @@ config MICROCODE_AMD · 1349 unmodified lines | |||
| 1350 | If you select this option, microcode patch loading support for AMD | 1350 | If you select this option, microcode patch loading support for AMD |
| 1351 | processors will be enabled. | 1351 | processors will be enabled. |
| 1352 | 1352 | ||
| 1353 | config MICROCODE_OLD_INTERFACE | ||
| 1354 | bool "Ancient loading interface (DEPRECATED)" | ||
| 1355 | default n | ||
| 1356 | depends on MICROCODE | ||
| 1357 | help | ||
| 1358 | DO NOT USE THIS! This is the ancient /dev/cpu/microcode interface | ||
| 1359 | which was used by userspace tools like iucode_tool and microcode.ctl. | ||
| 1360 | It is inadequate because it runs too late to be able to properly | ||
| 1361 | load microcode on a machine and it needs special tools. Instead, you | ||
| 1362 | should've switched to the early loading method with the initrd or | ||
| 1363 | builtin microcode by now: Documentation/x86/microcode.rst | ||
| 1364 | |||
| 1365 | config X86_MSR | 1353 | config X86_MSR |
| 1366 | tristate "/dev/cpu/*/msr - Model-specific register support" | 1354 | tristate "/dev/cpu/*/msr - Model-specific register support" |
| 1367 | help | 1355 | help |
| @@ -373,98 +373,6 @@ static int apply_microcode_on_target(int cpu) · 372 unmodified lines | |||
| 373 | return ret; | 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(µcode_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(µcode_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 = µcode_fops, | ||
| 444 | }; | ||
| 445 | |||
| 446 | static int __init microcode_dev_init(void) | ||
| 447 | { | ||
| 448 | int error; | ||
| 449 | |||
| 450 | error = misc_register(µcode_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(µcode_dev); | ||
| 462 | } | ||
| 463 | #else | ||
| 464 | #define microcode_dev_init() 0 | ||
| 465 | #define microcode_dev_exit() do { } while (0) | ||
| 466 | #endif | ||
| 467 | |||
| 468 | /* fake device for request_firmware */ | 376 | /* fake device for request_firmware */ |
| 469 | static struct platform_device *microcode_pdev; | 377 | static struct platform_device *microcode_pdev; |
| 470 | 378 | ||
| @@ -856,10 +764,6 @@ static int __init microcode_init(void) · 385 unmodified lines | |||
| 856 | goto out_driver; | 764 | goto out_driver; |
| 857 | } | 765 | } |
| 858 | 766 | ||
| 859 | error = microcode_dev_init(); | ||
| 860 | if (error) | ||
| 861 | goto out_ucode_group; | ||
| 862 | |||
| 863 | register_syscore_ops(&mc_syscore_ops); | 767 | register_syscore_ops(&mc_syscore_ops); |
| 864 | cpuhp_setup_state_nocalls(CPUHP_AP_MICROCODE_LOADER, "x86/microcode:starting", | 768 | cpuhp_setup_state_nocalls(CPUHP_AP_MICROCODE_LOADER, "x86/microcode:starting", |
| 865 | mc_cpu_starting, NULL); | 769 | mc_cpu_starting, NULL); |
| @@ -870,10 +774,6 @@ static int __init microcode_init(void) · 4 unmodified lines | |||
| 870 | 774 | ||
| 871 | return 0; | 775 | return 0; |
| 872 | 776 | ||
| 873 | out_ucode_group: | ||
| 874 | sysfs_remove_group(&cpu_subsys.dev_root->kobj, | ||
| 875 | &cpu_root_microcode_group); | ||
| 876 | |||
| 877 | out_driver: | 777 | out_driver: |
| 878 | cpus_read_lock(); | 778 | cpus_read_lock(); |
| 879 | mutex_lock(µcode_mutex); | 779 | mutex_lock(µcode_mutex); |