[PATCH 1/2] arm/mm : omit [_text, _stext) from kernel code region

Jungseung Lee js07.lee at samsung.com
Sun Mar 5 21:51:54 PST 2023


The resource reservations in /proc/iomem made for the kernel code did
not reflect the gaps between pagetable and text.

In particular, if the CONFIG_STRICT_KERNEL_RWX option is turned on,
the wrong area is shown as the kernel code area.

Fix it by removing [_text, _stext) from kernel code region.

Before:
04000000-2f7fffff : System RAM
  04008000-04cfffff : Kernel code
  04e00000-05369a27 : Kernel data

After :
04000000-2f7fffff : System RAM
  04100000-04cfffff : Kernel code
  04e00000-05369a27 : Kernel data

Signed-off-by: Jungseung Lee <js07.lee at samsung.com>
---
 arch/arm/kernel/setup.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
index 75cd469..3059860 100644
--- a/arch/arm/kernel/setup.c
+++ b/arch/arm/kernel/setup.c
@@ -865,7 +865,7 @@ static void __init request_standard_resources(const struct machine_desc *mdesc)
 	struct resource *res;
 	u64 i;
 
-	kernel_code.start   = virt_to_phys(_text);
+	kernel_code.start   = virt_to_phys(_stext);
 	kernel_code.end     = virt_to_phys(__init_begin - 1);
 	kernel_data.start   = virt_to_phys(_sdata);
 	kernel_data.end     = virt_to_phys(_end - 1);
@@ -1139,7 +1139,7 @@ void __init setup_arch(char **cmdline_p)
 	if (mdesc->reboot_mode != REBOOT_HARD)
 		reboot_mode = mdesc->reboot_mode;
 
-	setup_initial_init_mm(_text, _etext, _edata, _end);
+	setup_initial_init_mm(_stext, _etext, _edata, _end);
 
 	/* populate cmd_line too for later use, preserving boot_command_line */
 	strlcpy(cmd_line, boot_command_line, COMMAND_LINE_SIZE);
-- 
2.7.4




More information about the linux-arm-kernel mailing list