Skip to content

Commit 9a2bc33

Browse files
suryasaimadhuIngo Molnar
authored andcommitted
x86/microcode: Unmodularize the microcode driver
Make CONFIG_MICROCODE a bool. It was practically a bool already anyway, since early loader was forcing it to =y. Regardless, there's no real reason to have something be a module which gets built-in on the majority of installations out there. And its not like there's noticeable change in functionality - we still can load late microcode - just the module glue disappears. Signed-off-by: Borislav Petkov <[email protected]> Cc: Andy Lutomirski <[email protected]> Cc: Arjan van de Ven <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Brian Gerst <[email protected]> Cc: Dave Jones <[email protected]> Cc: Denys Vlasenko <[email protected]> Cc: H. Peter Anvin <[email protected]> Cc: Len Brown <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Rafael J. Wysocki <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Tony Luck <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent 81ffdcd commit 9a2bc33

File tree

6 files changed

+16
-38
lines changed

6 files changed

+16
-38
lines changed

arch/x86/Kconfig

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1123,7 +1123,8 @@ config X86_REBOOTFIXUPS
11231123
Say N otherwise.
11241124

11251125
config MICROCODE
1126-
tristate "CPU microcode loading support"
1126+
bool "CPU microcode loading support"
1127+
default y
11271128
depends on CPU_SUP_AMD || CPU_SUP_INTEL
11281129
select FW_LOADER
11291130
---help---
@@ -1174,7 +1175,7 @@ config MICROCODE_AMD_EARLY
11741175

11751176
config MICROCODE_EARLY
11761177
bool "Early load microcode"
1177-
depends on MICROCODE=y && BLK_DEV_INITRD
1178+
depends on MICROCODE && BLK_DEV_INITRD
11781179
select MICROCODE_INTEL_EARLY if MICROCODE_INTEL
11791180
select MICROCODE_AMD_EARLY if MICROCODE_AMD
11801181
default y

arch/x86/include/asm/microcode.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@ struct ucode_cpu_info {
5555
};
5656
extern struct ucode_cpu_info ucode_cpu_info[];
5757

58+
#ifdef CONFIG_MICROCODE
59+
int __init microcode_init(void);
60+
#else
61+
static inline int __init microcode_init(void) { return 0; };
62+
#endif
63+
5864
#ifdef CONFIG_MICROCODE_INTEL
5965
extern struct microcode_ops * __init init_intel_microcode(void);
6066
#else

arch/x86/kernel/cpu/microcode/amd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ static struct microcode_ops microcode_amd_ops = {
523523

524524
struct microcode_ops * __init init_amd_microcode(void)
525525
{
526-
struct cpuinfo_x86 *c = &cpu_data(0);
526+
struct cpuinfo_x86 *c = &boot_cpu_data;
527527

528528
if (c->x86_vendor != X86_VENDOR_AMD || c->x86 < 0x10) {
529529
pr_warning("AMD CPU family 0x%x not supported\n", c->x86);

arch/x86/kernel/cpu/microcode/core.c

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -487,9 +487,9 @@ static struct attribute_group cpu_root_microcode_group = {
487487
.attrs = cpu_root_microcode_attrs,
488488
};
489489

490-
static int __init microcode_init(void)
490+
int __init microcode_init(void)
491491
{
492-
struct cpuinfo_x86 *c = &cpu_data(0);
492+
struct cpuinfo_x86 *c = &boot_cpu_data;
493493
int error;
494494

495495
if (paravirt_enabled() || dis_ucode_ldr)
@@ -560,35 +560,3 @@ static int __init microcode_init(void)
560560
return error;
561561

562562
}
563-
module_init(microcode_init);
564-
565-
static void __exit microcode_exit(void)
566-
{
567-
struct cpuinfo_x86 *c = &cpu_data(0);
568-
569-
microcode_dev_exit();
570-
571-
unregister_hotcpu_notifier(&mc_cpu_notifier);
572-
unregister_syscore_ops(&mc_syscore_ops);
573-
574-
sysfs_remove_group(&cpu_subsys.dev_root->kobj,
575-
&cpu_root_microcode_group);
576-
577-
get_online_cpus();
578-
mutex_lock(&microcode_mutex);
579-
580-
subsys_interface_unregister(&mc_cpu_interface);
581-
582-
mutex_unlock(&microcode_mutex);
583-
put_online_cpus();
584-
585-
platform_device_unregister(microcode_pdev);
586-
587-
microcode_ops = NULL;
588-
589-
if (c->x86_vendor == X86_VENDOR_AMD)
590-
exit_amd_microcode();
591-
592-
pr_info("Microcode Update Driver: v" MICROCODE_VERSION " removed.\n");
593-
}
594-
module_exit(microcode_exit);

arch/x86/kernel/cpu/microcode/intel.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ static struct microcode_ops microcode_intel_ops = {
264264

265265
struct microcode_ops * __init init_intel_microcode(void)
266266
{
267-
struct cpuinfo_x86 *c = &cpu_data(0);
267+
struct cpuinfo_x86 *c = &boot_cpu_data;
268268

269269
if (c->x86_vendor != X86_VENDOR_INTEL || c->x86 < 6 ||
270270
cpu_has(c, X86_FEATURE_IA64)) {

arch/x86/kernel/setup.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@
111111
#include <asm/mce.h>
112112
#include <asm/alternative.h>
113113
#include <asm/prom.h>
114+
#include <asm/microcode.h>
114115

115116
/*
116117
* max_low_pfn_mapped: highest direct mapped pfn under 4GB
@@ -1239,6 +1240,8 @@ void __init setup_arch(char **cmdline_p)
12391240
if (efi_enabled(EFI_BOOT))
12401241
efi_apply_memmap_quirks();
12411242
#endif
1243+
1244+
microcode_init();
12421245
}
12431246

12441247
#ifdef CONFIG_X86_32

0 commit comments

Comments
 (0)