Commit 88b2f634 authored by Borislav Petkov's avatar Borislav Petkov Committed by Ingo Molnar

x86/microcode/AMD: Fix initrd loading with CONFIG_RANDOMIZE_MEMORY=y

Similar to:

  efaad554 ("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: default avatarBrian Gerst <brgerst@gmail.com>
Signed-off-by: default avatarBorislav 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.tnicSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
parent 3684b03d
...@@ -355,6 +355,7 @@ void load_ucode_amd_ap(void) ...@@ -355,6 +355,7 @@ void load_ucode_amd_ap(void)
unsigned int cpu = smp_processor_id(); unsigned int cpu = smp_processor_id();
struct equiv_cpu_entry *eq; struct equiv_cpu_entry *eq;
struct microcode_amd *mc; struct microcode_amd *mc;
u8 *cont = container;
u32 rev, eax; u32 rev, eax;
u16 eq_id; u16 eq_id;
...@@ -371,8 +372,11 @@ void load_ucode_amd_ap(void) ...@@ -371,8 +372,11 @@ void load_ucode_amd_ap(void)
if (check_current_patch_level(&rev, false)) if (check_current_patch_level(&rev, false))
return; return;
/* Add CONFIG_RANDOMIZE_MEMORY offset. */
cont += PAGE_OFFSET - __PAGE_OFFSET_BASE;
eax = cpuid_eax(0x00000001); eax = cpuid_eax(0x00000001);
eq = (struct equiv_cpu_entry *)(container + CONTAINER_HDR_SZ); eq = (struct equiv_cpu_entry *)(cont + CONTAINER_HDR_SZ);
eq_id = find_equiv_id(eq, eax); eq_id = find_equiv_id(eq, eax);
if (!eq_id) if (!eq_id)
...@@ -434,6 +438,9 @@ int __init save_microcode_in_initrd_amd(void) ...@@ -434,6 +438,9 @@ int __init save_microcode_in_initrd_amd(void)
else else
container = cont_va; container = cont_va;
/* Add CONFIG_RANDOMIZE_MEMORY offset. */
container += PAGE_OFFSET - __PAGE_OFFSET_BASE;
eax = cpuid_eax(0x00000001); eax = cpuid_eax(0x00000001);
eax = ((eax >> 8) & 0xf) + ((eax >> 20) & 0xff); eax = ((eax >> 8) & 0xf) + ((eax >> 20) & 0xff);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment