BACKPORT: ARM: 8583/1: mm: fix location of _etext
authorKees Cook <keescook@chromium.org>
Thu, 23 Jun 2016 20:28:47 +0000 (21:28 +0100)
committerAmit Pundir <amit.pundir@linaro.org>
Wed, 14 Sep 2016 08:56:51 +0000 (14:26 +0530)
The _etext position is defined to be the end of the kernel text code,
and should not include any part of the data segments. This interferes
with things that might check memory ranges and expect executable code
up to _etext. Just to be conservative, leave the kernel resource as
it was, using __init_begin instead of _etext as the end mark.

Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Change-Id: Ida514d1359dbe6f782f562ce29b4ba09ae72bfc0
(cherry picked from commit 14c4a533e0996f95a0a64dfd0b6252d788cebc74)
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
arch/arm/kernel/setup.c
arch/arm/kernel/vmlinux.lds.S

index 20edd349d379f22c583438db7fbf52f46e1133ef..bf63b4693457c21e84b8df86c3af69d3745930d8 100644 (file)
@@ -772,7 +772,7 @@ static void __init request_standard_resources(const struct machine_desc *mdesc)
        struct resource *res;
 
        kernel_code.start   = virt_to_phys(_text);
-       kernel_code.end     = virt_to_phys(_etext - 1);
+       kernel_code.end     = virt_to_phys(__init_begin - 1);
        kernel_data.start   = virt_to_phys(_sdata);
        kernel_data.end     = virt_to_phys(_end - 1);
 
index 8b60fde5ce48a628e5d1f2c682d2aa0684ed6642..be2ab6d3b91f67d6b04e0d446776f5475eac4c7b 100644 (file)
@@ -120,6 +120,8 @@ SECTIONS
 #ifdef CONFIG_DEBUG_RODATA
        . = ALIGN(1<<SECTION_SHIFT);
 #endif
+       _etext = .;                     /* End of text section */
+
        RO_DATA(PAGE_SIZE)
 
        . = ALIGN(4);
@@ -150,8 +152,6 @@ SECTIONS
 
        NOTES
 
-       _etext = .;                     /* End of text and rodata section */
-
 #ifndef CONFIG_XIP_KERNEL
 # ifdef CONFIG_ARM_KERNMEM_PERMS
        . = ALIGN(1<<SECTION_SHIFT);