diff options
| author | Borislav Petkov <bp@alien8.de> | 2016-08-17 07:33:14 -0400 |
|---|---|---|
| committer | Ingo Molnar <mingo@kernel.org> | 2016-08-18 04:06:49 -0400 |
| commit | 88b2f634028f1f38dcc3d412e10ff1f224976daa (patch) | |
| tree | c2be232a02aee4e6b591249bed13d98256c86546 /arch/x86/kernel/cpu/microcode | |
| parent | 3684b03d8e9a889eda94ee74421959a9d55e5e19 (diff) | |
x86/microcode/AMD: Fix initrd loading with CONFIG_RANDOMIZE_MEMORY=y
Similar to:
efaad554b4ff ("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>
Diffstat (limited to 'arch/x86/kernel/cpu/microcode')
| -rw-r--r-- | arch/x86/kernel/cpu/microcode/amd.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/arch/x86/kernel/cpu/microcode/amd.c b/arch/x86/kernel/cpu/microcode/amd.c index 27a0228c9cae..b816971f5da4 100644 --- a/arch/x86/kernel/cpu/microcode/amd.c +++ b/arch/x86/kernel/cpu/microcode/amd.c | |||
| @@ -355,6 +355,7 @@ void load_ucode_amd_ap(void) | |||
| 355 | unsigned int cpu = smp_processor_id(); | 355 | unsigned int cpu = smp_processor_id(); |
| 356 | struct equiv_cpu_entry *eq; | 356 | struct equiv_cpu_entry *eq; |
| 357 | struct microcode_amd *mc; | 357 | struct microcode_amd *mc; |
| 358 | u8 *cont = container; | ||
| 358 | u32 rev, eax; | 359 | u32 rev, eax; |
| 359 | u16 eq_id; | 360 | u16 eq_id; |
| 360 | 361 | ||
| @@ -371,8 +372,11 @@ void load_ucode_amd_ap(void) | |||
| 371 | if (check_current_patch_level(&rev, false)) | 372 | if (check_current_patch_level(&rev, false)) |
| 372 | return; | 373 | return; |
| 373 | 374 | ||
| 375 | /* Add CONFIG_RANDOMIZE_MEMORY offset. */ | ||
| 376 | cont += PAGE_OFFSET - __PAGE_OFFSET_BASE; | ||
| 377 | |||
| 374 | eax = cpuid_eax(0x00000001); | 378 | eax = cpuid_eax(0x00000001); |
| 375 | eq = (struct equiv_cpu_entry *)(container + CONTAINER_HDR_SZ); | 379 | eq = (struct equiv_cpu_entry *)(cont + CONTAINER_HDR_SZ); |
| 376 | 380 | ||
| 377 | eq_id = find_equiv_id(eq, eax); | 381 | eq_id = find_equiv_id(eq, eax); |
| 378 | if (!eq_id) | 382 | if (!eq_id) |
| @@ -434,6 +438,9 @@ int __init save_microcode_in_initrd_amd(void) | |||
| 434 | else | 438 | else |
| 435 | container = cont_va; | 439 | container = cont_va; |
| 436 | 440 | ||
| 441 | /* Add CONFIG_RANDOMIZE_MEMORY offset. */ | ||
| 442 | container += PAGE_OFFSET - __PAGE_OFFSET_BASE; | ||
| 443 | |||
| 437 | eax = cpuid_eax(0x00000001); | 444 | eax = cpuid_eax(0x00000001); |
| 438 | eax = ((eax >> 8) & 0xf) + ((eax >> 20) & 0xff); | 445 | eax = ((eax >> 8) & 0xf) + ((eax >> 20) & 0xff); |
| 439 | 446 | ||
