lkml.org 
[lkml]   [2016]   [Aug]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [tip:x86/boot] x86/mm: Enable KASLR for physical mapping memory regions
On Tue, Aug 16, 2016 at 08:31:28PM -0400, Brian Gerst wrote:
> These fixes work for my system.

Thanks Brian.

Ingo, please queue this into x86/urgent.

Thanks!

---
From: Borislav Petkov <bp@suse.de>
Date: Wed, 17 Aug 2016 08:23:29 +0200
Subject: [PATCH] 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: Kees Cook <keescook@chromium.org>
---
arch/x86/kernel/cpu/microcode/amd.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kernel/cpu/microcode/amd.c b/arch/x86/kernel/cpu/microcode/amd.c
index 27a0228c9cae..f43b774d0684 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)
unsigned int cpu = smp_processor_id();
struct equiv_cpu_entry *eq;
struct microcode_amd *mc;
+ u8 *cont;
u32 rev, eax;
u16 eq_id;

@@ -371,8 +372,14 @@ void load_ucode_amd_ap(void)
if (check_current_patch_level(&rev, false))
return;

+ cont = container;
+
+#ifdef CONFIG_RANDOMIZE_MEMORY
+ cont += PAGE_OFFSET - __PAGE_OFFSET_BASE;
+#endif
+
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);
if (!eq_id)
@@ -434,6 +441,10 @@ int __init save_microcode_in_initrd_amd(void)
else
container = cont_va;

+#ifdef CONFIG_RANDOMIZE_MEMORY
+ container += PAGE_OFFSET - __PAGE_OFFSET_BASE;
+#endif
+
eax = cpuid_eax(0x00000001);
eax = ((eax >> 8) & 0xf) + ((eax >> 20) & 0xff);

--
2.8.4
--
Regards/Gruss,
Boris.

ECO tip #101: Trim your mails when you reply.
--

\
 
 \ /
  Last update: 2016-09-17 09:57    [W:0.095 / U:1.868 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site