lkml.org 
[lkml]   [2018]   [Mar]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Date
Subject[PATCH] x86-64: Verify alignment of LOAD segment
Since x86-64 kernel must be aligned to 2MB, refuse to boot kernel if
alignment of LOAD segment isn't multiple of 2MB.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>

--
H.J.
From 25015cf0252d1a4a0c532f391a314e343a5022dd Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Tue, 27 Feb 2018 11:41:35 -0800
Subject: [PATCH] x86-64: Verify alignment of LOAD segment

Since x86-64 kernel must be aligned to 2MB, refuse to boot kernel if
alignment of LOAD segment isn't multiple of 2MB.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
---
arch/x86/boot/compressed/misc.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c
index 98761a1576ce..252fee320816 100644
--- a/arch/x86/boot/compressed/misc.c
+++ b/arch/x86/boot/compressed/misc.c
@@ -309,6 +309,10 @@ static void parse_elf(void *output)

switch (phdr->p_type) {
case PT_LOAD:
+#ifdef CONFIG_X86_64
+ if ((phdr->p_align % 0x200000) != 0)
+ error("Alignment of LOAD segment isn't multiple of 2MB");
+#endif
#ifdef CONFIG_RELOCATABLE
dest = output;
dest += (phdr->p_paddr - LOAD_PHYSICAL_ADDR);
--
2.14.3
\
 
 \ /
  Last update: 2018-03-19 22:09    [W:0.120 / U:0.044 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site