Skip to content

Commit efaad55

Browse files
suryasaimadhuIngo Molnar
authored andcommitted
x86/microcode/intel: Fix initrd loading with CONFIG_RANDOMIZE_MEMORY=y
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>
1 parent eb06158 commit efaad55

File tree

1 file changed

+14
-2
lines changed
  • arch/x86/kernel/cpu/microcode

1 file changed

+14
-2
lines changed

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

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -793,10 +793,10 @@ void __init load_ucode_intel_bsp(void)
793793
void load_ucode_intel_ap(void)
794794
{
795795
struct ucode_blobs *blobs_p;
796+
unsigned long *ptrs, start = 0;
796797
struct mc_saved_data *mcs;
797798
struct ucode_cpu_info uci;
798799
enum ucode_state ret;
799-
unsigned long *ptrs;
800800

801801
#ifdef CONFIG_X86_32
802802
mcs = (struct mc_saved_data *)__pa_nodebug(&mc_saved_data);
@@ -815,8 +815,20 @@ void load_ucode_intel_ap(void)
815815
if (!mcs->num_saved)
816816
return;
817817

818+
if (blobs_p->valid) {
819+
start = blobs_p->start;
820+
821+
#ifdef CONFIG_RANDOMIZE_MEMORY
822+
/*
823+
* Pay attention to CONFIG_RANDOMIZE_MEMORY=y as it shuffles
824+
* physmem mapping too and there we have the initrd.
825+
*/
826+
start += PAGE_OFFSET - __PAGE_OFFSET_BASE;
827+
#endif
828+
}
829+
818830
collect_cpu_info_early(&uci);
819-
ret = load_microcode(mcs, ptrs, blobs_p->start, &uci);
831+
ret = load_microcode(mcs, ptrs, start, &uci);
820832
if (ret != UCODE_OK)
821833
return;
822834

0 commit comments

Comments
 (0)