Skip to content

Commit d761f3e

Browse files
committed
Merge branch 'x86-microcode-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 microcode updates from Thomas Gleixner: - more work to make the microcode loader robust - a fix for the micro code load precedence - fixes for initrd loading with randomized memory - less printk noise on SMP machines * 'x86-microcode-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/asm, x86/microcode: Add __PAGE_OFFSET_BASE define on 32-bit x86/microcode/intel: Fix initrd loading with CONFIG_RANDOMIZE_MEMORY=y x86/microcode: Remove unused symbol exports x86/microcode/intel: Do not issue microcode updates messages on each CPU Documentation/microcode: Document some aspects for more clarity x86/microcode/AMD: Make amd_ucode_patch[] static x86/microcode/intel: Unexport save_mc_for_early() x86/microcode/intel: Rename load_microcode_early() to find_microcode_patch() x86/microcode: Propagate save_microcode_in_initrd() retval x86/microcode: Get rid of find_cpio_data()'s dummy offset arg lib/cpio: Make find_cpio_data()'s offset arg optional x86/microcode: Fix suspend to RAM with builtin microcode x86/microcode: Fix loading precedence
2 parents b325e04 + 4a1a8e1 commit d761f3e

File tree

11 files changed

+198
-160
lines changed

11 files changed

+198
-160
lines changed

Documentation/x86/early-microcode.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@ Builtin microcode
4545
=================
4646

4747
We can also load builtin microcode supplied through the regular firmware
48-
builtin method CONFIG_FIRMWARE_IN_KERNEL. Here's an example:
48+
builtin method CONFIG_FIRMWARE_IN_KERNEL. Only 64-bit is currently
49+
supported.
50+
51+
Here's an example:
4952

5053
CONFIG_FIRMWARE_IN_KERNEL=y
5154
CONFIG_EXTRA_FIRMWARE="intel-ucode/06-3a-09 amd-ucode/microcode_amd_fam15h.bin"

arch/x86/include/asm/microcode.h

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -133,40 +133,14 @@ static inline unsigned int x86_cpuid_family(void)
133133
#ifdef CONFIG_MICROCODE
134134
extern void __init load_ucode_bsp(void);
135135
extern void load_ucode_ap(void);
136-
extern int __init save_microcode_in_initrd(void);
137136
void reload_early_microcode(void);
138137
extern bool get_builtin_firmware(struct cpio_data *cd, const char *name);
139138
#else
140139
static inline void __init load_ucode_bsp(void) { }
141140
static inline void load_ucode_ap(void) { }
142-
static inline int __init save_microcode_in_initrd(void) { return 0; }
143141
static inline void reload_early_microcode(void) { }
144142
static inline bool
145143
get_builtin_firmware(struct cpio_data *cd, const char *name) { return false; }
146144
#endif
147145

148-
static inline unsigned long get_initrd_start(void)
149-
{
150-
#ifdef CONFIG_BLK_DEV_INITRD
151-
return initrd_start;
152-
#else
153-
return 0;
154-
#endif
155-
}
156-
157-
static inline unsigned long get_initrd_start_addr(void)
158-
{
159-
#ifdef CONFIG_BLK_DEV_INITRD
160-
#ifdef CONFIG_X86_32
161-
unsigned long *initrd_start_p = (unsigned long *)__pa_nodebug(&initrd_start);
162-
163-
return (unsigned long)__pa_nodebug(*initrd_start_p);
164-
#else
165-
return get_initrd_start();
166-
#endif
167-
#else /* CONFIG_BLK_DEV_INITRD */
168-
return 0;
169-
#endif
170-
}
171-
172146
#endif /* _ASM_X86_MICROCODE_H */

arch/x86/include/asm/microcode_amd.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ extern int apply_microcode_amd(int cpu);
6262
extern enum ucode_state load_microcode_amd(int cpu, u8 family, const u8 *data, size_t size);
6363

6464
#define PATCH_MAX_SIZE PAGE_SIZE
65-
extern u8 amd_ucode_patch[PATCH_MAX_SIZE];
6665

6766
#ifdef CONFIG_MICROCODE_AMD
6867
extern void __init load_ucode_amd_bsp(unsigned int family);

arch/x86/include/asm/microcode_intel.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,4 @@ static inline int __init save_microcode_in_initrd_intel(void) { return -EINVAL;
7070
static inline void reload_ucode_intel(void) {}
7171
#endif
7272

73-
#ifdef CONFIG_HOTPLUG_CPU
74-
extern int save_mc_for_early(u8 *mc);
75-
#else
76-
static inline int save_mc_for_early(u8 *mc) { return 0; }
77-
#endif
7873
#endif /* _ASM_X86_MICROCODE_INTEL_H */

arch/x86/include/asm/page_32_types.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
* If you want more physical memory than this then see the CONFIG_HIGHMEM4G
1414
* and CONFIG_HIGHMEM64G options in the kernel configuration.
1515
*/
16-
#define __PAGE_OFFSET _AC(CONFIG_PAGE_OFFSET, UL)
16+
#define __PAGE_OFFSET_BASE _AC(CONFIG_PAGE_OFFSET, UL)
17+
#define __PAGE_OFFSET __PAGE_OFFSET_BASE
1718

1819
#define __START_KERNEL_map __PAGE_OFFSET
1920

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

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -56,24 +56,24 @@ static u8 *container;
5656
static size_t container_size;
5757

5858
static u32 ucode_new_rev;
59-
u8 amd_ucode_patch[PATCH_MAX_SIZE];
59+
static u8 amd_ucode_patch[PATCH_MAX_SIZE];
6060
static u16 this_equiv_id;
6161

6262
static struct cpio_data ucode_cpio;
6363

64-
/*
65-
* Microcode patch container file is prepended to the initrd in cpio format.
66-
* See Documentation/x86/early-microcode.txt
67-
*/
68-
static __initdata char ucode_path[] = "kernel/x86/microcode/AuthenticAMD.bin";
69-
7064
static struct cpio_data __init find_ucode_in_initrd(void)
7165
{
72-
long offset = 0;
66+
#ifdef CONFIG_BLK_DEV_INITRD
7367
char *path;
7468
void *start;
7569
size_t size;
7670

71+
/*
72+
* Microcode patch container file is prepended to the initrd in cpio
73+
* format. See Documentation/x86/early-microcode.txt
74+
*/
75+
static __initdata char ucode_path[] = "kernel/x86/microcode/AuthenticAMD.bin";
76+
7777
#ifdef CONFIG_X86_32
7878
struct boot_params *p;
7979

@@ -89,9 +89,12 @@ static struct cpio_data __init find_ucode_in_initrd(void)
8989
path = ucode_path;
9090
start = (void *)(boot_params.hdr.ramdisk_image + PAGE_OFFSET);
9191
size = boot_params.hdr.ramdisk_size;
92-
#endif
92+
#endif /* !CONFIG_X86_32 */
9393

94-
return find_cpio_data(path, start, size, &offset);
94+
return find_cpio_data(path, start, size, NULL);
95+
#else
96+
return (struct cpio_data){ NULL, 0, "" };
97+
#endif
9598
}
9699

97100
static size_t compute_container_size(u8 *data, u32 total_size)
@@ -289,11 +292,11 @@ void __init load_ucode_amd_bsp(unsigned int family)
289292
size = &ucode_cpio.size;
290293
#endif
291294

292-
cp = find_ucode_in_initrd();
293-
if (!cp.data) {
294-
if (!load_builtin_amd_microcode(&cp, family))
295-
return;
296-
}
295+
if (!load_builtin_amd_microcode(&cp, family))
296+
cp = find_ucode_in_initrd();
297+
298+
if (!(cp.data && cp.size))
299+
return;
297300

298301
*data = cp.data;
299302
*size = cp.size;

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ static bool dis_ucode_ldr;
6060
static DEFINE_MUTEX(microcode_mutex);
6161

6262
struct ucode_cpu_info ucode_cpu_info[NR_CPUS];
63-
EXPORT_SYMBOL_GPL(ucode_cpu_info);
6463

6564
/*
6665
* Operations that are run on a target cpu:
@@ -175,24 +174,24 @@ void load_ucode_ap(void)
175174
}
176175
}
177176

178-
int __init save_microcode_in_initrd(void)
177+
static int __init save_microcode_in_initrd(void)
179178
{
180179
struct cpuinfo_x86 *c = &boot_cpu_data;
181180

182181
switch (c->x86_vendor) {
183182
case X86_VENDOR_INTEL:
184183
if (c->x86 >= 6)
185-
save_microcode_in_initrd_intel();
184+
return save_microcode_in_initrd_intel();
186185
break;
187186
case X86_VENDOR_AMD:
188187
if (c->x86 >= 0x10)
189-
save_microcode_in_initrd_amd();
188+
return save_microcode_in_initrd_amd();
190189
break;
191190
default:
192191
break;
193192
}
194193

195-
return 0;
194+
return -EINVAL;
196195
}
197196

198197
void reload_early_microcode(void)
@@ -691,4 +690,5 @@ int __init microcode_init(void)
691690
return error;
692691

693692
}
693+
fs_initcall(save_microcode_in_initrd);
694694
late_initcall(microcode_init);

0 commit comments

Comments
 (0)