Skip to content

Commit fe05589

Browse files
suryasaimadhuIngo Molnar
authored andcommitted
x86/microcode: Merge the early microcode loader
Merge the early loader functionality into the driver proper. The diff is huge but logically, it is simply moving code from the _early.c files into the main driver. 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 9a2bc33 commit fe05589

File tree

13 files changed

+1399
-1477
lines changed

13 files changed

+1399
-1477
lines changed

arch/x86/Kconfig

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1126,6 +1126,7 @@ config MICROCODE
11261126
bool "CPU microcode loading support"
11271127
default y
11281128
depends on CPU_SUP_AMD || CPU_SUP_INTEL
1129+
depends on BLK_DEV_INITRD
11291130
select FW_LOADER
11301131
---help---
11311132

@@ -1167,24 +1168,6 @@ config MICROCODE_OLD_INTERFACE
11671168
def_bool y
11681169
depends on MICROCODE
11691170

1170-
config MICROCODE_INTEL_EARLY
1171-
bool
1172-
1173-
config MICROCODE_AMD_EARLY
1174-
bool
1175-
1176-
config MICROCODE_EARLY
1177-
bool "Early load microcode"
1178-
depends on MICROCODE && BLK_DEV_INITRD
1179-
select MICROCODE_INTEL_EARLY if MICROCODE_INTEL
1180-
select MICROCODE_AMD_EARLY if MICROCODE_AMD
1181-
default y
1182-
help
1183-
This option provides functionality to read additional microcode data
1184-
at the beginning of initrd image. The data tells kernel to load
1185-
microcode to CPU's as early as possible. No functional change if no
1186-
microcode data is glued to the initrd, therefore it's safe to say Y.
1187-
11881171
config X86_MSR
11891172
tristate "/dev/cpu/*/msr - Model-specific register support"
11901173
---help---

arch/x86/include/asm/microcode.h

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ static inline struct microcode_ops * __init init_amd_microcode(void)
8181
static inline void __exit exit_amd_microcode(void) {}
8282
#endif
8383

84-
#ifdef CONFIG_MICROCODE_EARLY
8584
#define MAX_UCODE_COUNT 128
8685

8786
#define QCHAR(a, b, c, d) ((a) + ((b) << 8) + ((c) << 16) + ((d) << 24))
@@ -156,22 +155,18 @@ static inline unsigned int x86_model(unsigned int sig)
156155
return model;
157156
}
158157

158+
#ifdef CONFIG_MICROCODE
159159
extern void __init load_ucode_bsp(void);
160160
extern void load_ucode_ap(void);
161161
extern int __init save_microcode_in_initrd(void);
162162
void reload_early_microcode(void);
163163
extern bool get_builtin_firmware(struct cpio_data *cd, const char *name);
164164
#else
165-
static inline void __init load_ucode_bsp(void) {}
166-
static inline void load_ucode_ap(void) {}
167-
static inline int __init save_microcode_in_initrd(void)
168-
{
169-
return 0;
170-
}
171-
static inline void reload_early_microcode(void) {}
172-
static inline bool get_builtin_firmware(struct cpio_data *cd, const char *name)
173-
{
174-
return false;
175-
}
165+
static inline void __init load_ucode_bsp(void) { }
166+
static inline void load_ucode_ap(void) { }
167+
static inline int __init save_microcode_in_initrd(void) { return 0; }
168+
static inline void reload_early_microcode(void) { }
169+
static inline bool
170+
get_builtin_firmware(struct cpio_data *cd, const char *name) { return false; }
176171
#endif
177172
#endif /* _ASM_X86_MICROCODE_H */

arch/x86/include/asm/microcode_amd.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ extern enum ucode_state load_microcode_amd(int cpu, u8 family, const u8 *data, s
6464
#define PATCH_MAX_SIZE PAGE_SIZE
6565
extern u8 amd_ucode_patch[PATCH_MAX_SIZE];
6666

67-
#ifdef CONFIG_MICROCODE_AMD_EARLY
67+
#ifdef CONFIG_MICROCODE_AMD
6868
extern void __init load_ucode_amd_bsp(unsigned int family);
6969
extern void load_ucode_amd_ap(void);
7070
extern int __init save_microcode_in_initrd_amd(void);

arch/x86/include/asm/microcode_intel.h

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ extern int has_newer_microcode(void *mc, unsigned int csig, int cpf, int rev);
5757
extern int microcode_sanity_check(void *mc, int print_err);
5858
extern int find_matching_signature(void *mc, unsigned int csig, int cpf);
5959

60-
#ifdef CONFIG_MICROCODE_INTEL_EARLY
60+
#ifdef CONFIG_MICROCODE_INTEL
6161
extern void __init load_ucode_intel_bsp(void);
6262
extern void load_ucode_intel_ap(void);
6363
extern void show_ucode_info_early(void);
@@ -71,13 +71,9 @@ static inline int __init save_microcode_in_initrd_intel(void) { return -EINVAL;
7171
static inline void reload_ucode_intel(void) {}
7272
#endif
7373

74-
#if defined(CONFIG_MICROCODE_INTEL_EARLY) && defined(CONFIG_HOTPLUG_CPU)
74+
#ifdef CONFIG_HOTPLUG_CPU
7575
extern int save_mc_for_early(u8 *mc);
7676
#else
77-
static inline int save_mc_for_early(u8 *mc)
78-
{
79-
return 0;
80-
}
77+
static inline int save_mc_for_early(u8 *mc) { return 0; }
8178
#endif
82-
8379
#endif /* _ASM_X86_MICROCODE_INTEL_H */

arch/x86/kernel/cpu/microcode/Makefile

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,3 @@ microcode-y := core.o
22
obj-$(CONFIG_MICROCODE) += microcode.o
33
microcode-$(CONFIG_MICROCODE_INTEL) += intel.o intel_lib.o
44
microcode-$(CONFIG_MICROCODE_AMD) += amd.o
5-
obj-$(CONFIG_MICROCODE_EARLY) += core_early.o
6-
obj-$(CONFIG_MICROCODE_INTEL_EARLY) += intel_early.o
7-
obj-$(CONFIG_MICROCODE_AMD_EARLY) += amd_early.o

0 commit comments

Comments
 (0)