Skip to content

Commit 88b2f63

Browse files
bp3tk0vIngo Molnar
authored andcommitted
x86/microcode/AMD: Fix initrd loading with CONFIG_RANDOMIZE_MEMORY=y
Similar to: efaad55 ("x86/microcode/intel: Fix initrd loading with CONFIG_RANDOMIZE_MEMORY=y") ... fix microcode loading from the initrd on AMD by adding the randomization offset to the microcode patch container within the initrd. Reported-and-tested-by: Brian Gerst <brgerst@gmail.com> Signed-off-by: Borislav Petkov <bp@suse.de> Cc: Andy Lutomirski <luto@kernel.org> Cc: Borislav Petkov <bp@alien8.de> Cc: Denys Vlasenko <dvlasenk@redhat.com> Cc: H. Peter Anvin <hpa@zytor.com> Cc: Josh Poimboeuf <jpoimboe@redhat.com> Cc: Kees Cook <keescook@chromium.org> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: linux-tip-commits@vger.kernel.org Link: http://lkml.kernel.org/r/20160817113314.GA19221@nazgul.tnic Signed-off-by: Ingo Molnar <mingo@kernel.org>
1 parent 3684b03 commit 88b2f63

File tree

1 file changed

+8
-1
lines changed
  • arch/x86/kernel/cpu/microcode

1 file changed

+8
-1
lines changed

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,7 @@ void load_ucode_amd_ap(void)
355355
unsigned int cpu = smp_processor_id();
356356
struct equiv_cpu_entry *eq;
357357
struct microcode_amd *mc;
358+
u8 *cont = container;
358359
u32 rev, eax;
359360
u16 eq_id;
360361

@@ -371,8 +372,11 @@ void load_ucode_amd_ap(void)
371372
if (check_current_patch_level(&rev, false))
372373
return;
373374

375+
/* Add CONFIG_RANDOMIZE_MEMORY offset. */
376+
cont += PAGE_OFFSET - __PAGE_OFFSET_BASE;
377+
374378
eax = cpuid_eax(0x00000001);
375-
eq = (struct equiv_cpu_entry *)(container + CONTAINER_HDR_SZ);
379+
eq = (struct equiv_cpu_entry *)(cont + CONTAINER_HDR_SZ);
376380

377381
eq_id = find_equiv_id(eq, eax);
378382
if (!eq_id)
@@ -434,6 +438,9 @@ int __init save_microcode_in_initrd_amd(void)
434438
else
435439
container = cont_va;
436440

441+
/* Add CONFIG_RANDOMIZE_MEMORY offset. */
442+
container += PAGE_OFFSET - __PAGE_OFFSET_BASE;
443+
437444
eax = cpuid_eax(0x00000001);
438445
eax = ((eax >> 8) & 0xf) + ((eax >> 20) & 0xff);
439446

0 commit comments

Comments
 (0)