Skip to content

Commit

Permalink
x86/microcode/intel: Fix initrd loading with CONFIG_RANDOMIZE_MEMORY=y
Browse files Browse the repository at this point in the history
CONFIG_RANDOMIZE_MEMORY=y randomizes the physical memmap and thus the
address where the initrd is located. Therefore, we need to add the
offset KASLR put us to in order to find the initrd again on the AP path.

In the future, we will get rid of the initrd address caching and query
the address on both the BSP and AP paths but that would need more work.

Thanks to Nicolai Stange for the good bisection and debugging work.

Reported-and-tested-by: Nicolai Stange <nicstange@gmail.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
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>
Link: http://lkml.kernel.org/r/20160726095138.3470-1-bp@alien8.de
Signed-off-by: Ingo Molnar <mingo@kernel.org>
  • Loading branch information
Borislav Petkov authored and Ingo Molnar committed Jul 26, 2016
1 parent eb06158 commit efaad55
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions arch/x86/kernel/cpu/microcode/intel.c
Original file line number Diff line number Diff line change
Expand Up @@ -793,10 +793,10 @@ void __init load_ucode_intel_bsp(void)
void load_ucode_intel_ap(void)
{
struct ucode_blobs *blobs_p;
unsigned long *ptrs, start = 0;
struct mc_saved_data *mcs;
struct ucode_cpu_info uci;
enum ucode_state ret;
unsigned long *ptrs;

#ifdef CONFIG_X86_32
mcs = (struct mc_saved_data *)__pa_nodebug(&mc_saved_data);
Expand All @@ -815,8 +815,20 @@ void load_ucode_intel_ap(void)
if (!mcs->num_saved)
return;

if (blobs_p->valid) {
start = blobs_p->start;

#ifdef CONFIG_RANDOMIZE_MEMORY
/*
* Pay attention to CONFIG_RANDOMIZE_MEMORY=y as it shuffles
* physmem mapping too and there we have the initrd.
*/
start += PAGE_OFFSET - __PAGE_OFFSET_BASE;
#endif
}

collect_cpu_info_early(&uci);
ret = load_microcode(mcs, ptrs, blobs_p->start, &uci);
ret = load_microcode(mcs, ptrs, start, &uci);
if (ret != UCODE_OK)
return;

Expand Down

0 comments on commit efaad55

Please sign in to comment.