From 25015cf0252d1a4a0c532f391a314e343a5022dd Mon Sep 17 00:00:00 2001 From: "H.J. Lu" 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 --- 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