aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBorislav Petkov <bp@suse.de>2016-07-26 05:51:38 -0400
committerIngo Molnar <mingo@kernel.org>2016-07-26 13:32:57 -0400
commitefaad554b4ffae1840a2759e09e21325ddbc8b05 (patch)
tree13ab8f1c60d3877a25152a4245398d27c8bab317
parenteb06158ee1457a27fcc981a37f23b50f19015a8a (diff)
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>
-rw-r--r--arch/x86/kernel/cpu/microcode/intel.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/arch/x86/kernel/cpu/microcode/intel.c b/arch/x86/kernel/cpu/microcode/intel.c
index 6515c802346a..0f97ae93441b 100644
--- a/arch/x86/kernel/cpu/microcode/intel.c
+++ b/arch/x86/kernel/cpu/microcode/intel.c
@@ -793,10 +793,10 @@ void __init load_ucode_intel_bsp(void)
793void load_ucode_intel_ap(void) 793void load_ucode_intel_ap(void)
794{ 794{
795 struct ucode_blobs *blobs_p; 795 struct ucode_blobs *blobs_p;
796 unsigned long *ptrs, start = 0;
796 struct mc_saved_data *mcs; 797 struct mc_saved_data *mcs;
797 struct ucode_cpu_info uci; 798 struct ucode_cpu_info uci;
798 enum ucode_state ret; 799 enum ucode_state ret;
799 unsigned long *ptrs;
800 800
801#ifdef CONFIG_X86_32 801#ifdef CONFIG_X86_32
802 mcs = (struct mc_saved_data *)__pa_nodebug(&mc_saved_data); 802 mcs = (struct mc_saved_data *)__pa_nodebug(&mc_saved_data);
@@ -815,8 +815,20 @@ void load_ucode_intel_ap(void)
815 if (!mcs->num_saved) 815 if (!mcs->num_saved)
816 return; 816 return;
817 817
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
818 collect_cpu_info_early(&uci); 830 collect_cpu_info_early(&uci);
819 ret = load_microcode(mcs, ptrs, blobs_p->start, &uci); 831 ret = load_microcode(mcs, ptrs, start, &uci);
820 if (ret != UCODE_OK) 832 if (ret != UCODE_OK)
821 return; 833 return;
822 834