* [PATCH 1/2] arm/mm : omit [_text, _stext) from kernel code region [not found] <CGME20230306061055epcas1p1f7718c46c10f84845e086f9ce9f9a41f@epcas1p1.samsung.com> @ 2023-03-06 5:51 ` Jungseung Lee 2023-03-06 5:51 ` [PATCH 2/2] arm/mm : Report actual image regions in /proc/iomem Jungseung Lee 2023-03-06 11:06 ` [PATCH 1/2] arm/mm : omit [_text, _stext) from kernel code region Russell King (Oracle) 0 siblings, 2 replies; 7+ messages in thread From: Jungseung Lee @ 2023-03-06 5:51 UTC (permalink / raw) To: rmk+kernel, linus.walleij, amit.kachhap, ardb, linux-arm-kernel, linux-kernel, keescook, js07.lee, js07.lee 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@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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/2] arm/mm : Report actual image regions in /proc/iomem 2023-03-06 5:51 ` [PATCH 1/2] arm/mm : omit [_text, _stext) from kernel code region Jungseung Lee @ 2023-03-06 5:51 ` Jungseung Lee 2023-03-06 11:10 ` Russell King (Oracle) 2023-03-06 11:06 ` [PATCH 1/2] arm/mm : omit [_text, _stext) from kernel code region Russell King (Oracle) 1 sibling, 1 reply; 7+ messages in thread From: Jungseung Lee @ 2023-03-06 5:51 UTC (permalink / raw) To: rmk+kernel, linus.walleij, amit.kachhap, ardb, linux-arm-kernel, linux-kernel, keescook, js07.lee, js07.lee The resource reservations in /proc/iomem made for the kernel image did not reflect the gaps between text, rodata, and data. Add the "rodata" resource and update the start/end calculations. Before : 04000000-2f7fffff : System RAM 04100000-04cfffff : Kernel code 04e00000-05369a27 : Kernel data After : 04000000-2f7fffff : System RAM 04100000-049fffff : Kernel code 04a00000-04cb2fff : Kernel rodata 04e00000-05369a27 : Kernel data Signed-off-by: Jungseung Lee <js07.lee@samsung.com> --- arch/arm/kernel/setup.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c index 3059860..85af967 100644 --- a/arch/arm/kernel/setup.c +++ b/arch/arm/kernel/setup.c @@ -181,6 +181,12 @@ static struct resource mem_res[] = { .flags = IORESOURCE_SYSTEM_RAM }, { + .name = "Kernel rodata", + .start = 0, + .end = 0, + .flags = IORESOURCE_SYSTEM_RAM + }, + { .name = "Kernel data", .start = 0, .end = 0, @@ -188,9 +194,10 @@ static struct resource mem_res[] = { } }; -#define video_ram mem_res[0] -#define kernel_code mem_res[1] -#define kernel_data mem_res[2] +#define video_ram mem_res[0] +#define kernel_code mem_res[1] +#define kernel_rodata mem_res[2] +#define kernel_data mem_res[3] static struct resource io_res[] = { { @@ -866,7 +873,9 @@ static void __init request_standard_resources(const struct machine_desc *mdesc) u64 i; kernel_code.start = virt_to_phys(_stext); - kernel_code.end = virt_to_phys(__init_begin - 1); + kernel_code.end = virt_to_phys(_etext - 1); + kernel_rodata.start = virt_to_phys(__start_rodata); + kernel_rodata.end = virt_to_phys(__end_rodata - 1); kernel_data.start = virt_to_phys(_sdata); kernel_data.end = virt_to_phys(_end - 1); @@ -912,6 +921,9 @@ static void __init request_standard_resources(const struct machine_desc *mdesc) if (kernel_code.start >= res->start && kernel_code.end <= res->end) request_resource(res, &kernel_code); + if (kernel_rodata.start >= res->start && + kernel_rodata.end <= res->end) + request_resource(res, &kernel_rodata); if (kernel_data.start >= res->start && kernel_data.end <= res->end) request_resource(res, &kernel_data); -- 2.7.4 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] arm/mm : Report actual image regions in /proc/iomem 2023-03-06 5:51 ` [PATCH 2/2] arm/mm : Report actual image regions in /proc/iomem Jungseung Lee @ 2023-03-06 11:10 ` Russell King (Oracle) 2023-03-06 12:14 ` Jungseung Lee 0 siblings, 1 reply; 7+ messages in thread From: Russell King (Oracle) @ 2023-03-06 11:10 UTC (permalink / raw) To: Jungseung Lee Cc: linus.walleij, amit.kachhap, ardb, linux-arm-kernel, linux-kernel, keescook, js07.lee On Mon, Mar 06, 2023 at 02:51:55PM +0900, Jungseung Lee wrote: > The resource reservations in /proc/iomem made for the kernel image did > not reflect the gaps between text, rodata, and data. > Add the "rodata" resource and update the start/end calculations. > > Before : > 04000000-2f7fffff : System RAM > 04100000-04cfffff : Kernel code > 04e00000-05369a27 : Kernel data > > After : > 04000000-2f7fffff : System RAM > 04100000-049fffff : Kernel code > 04a00000-04cb2fff : Kernel rodata > 04e00000-05369a27 : Kernel data NAK. This is API, and programs do read and parse this file. It is important that this file reports these parameters in a similar way to other architectures. Other architectures do not split up the individual regions. -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last! _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 7+ messages in thread
* RE: [PATCH 2/2] arm/mm : Report actual image regions in /proc/iomem 2023-03-06 11:10 ` Russell King (Oracle) @ 2023-03-06 12:14 ` Jungseung Lee 2023-03-06 12:28 ` Russell King (Oracle) 0 siblings, 1 reply; 7+ messages in thread From: Jungseung Lee @ 2023-03-06 12:14 UTC (permalink / raw) To: 'Russell King (Oracle)' Cc: linus.walleij, amit.kachhap, ardb, linux-arm-kernel, linux-kernel, keescook, js07.lee Hi, Russell > -----Original Message----- > From: Russell King (Oracle) <linux@armlinux.org.uk> > Sent: Monday, March 6, 2023 8:10 PM > To: Jungseung Lee <js07.lee@samsung.com> > Cc: linus.walleij@linaro.org; amit.kachhap@arm.com; ardb@kernel.org; > linux-arm-kernel@lists.infradead.org; linux-kernel@vger.kernel.org; > keescook@chromium.org; js07.lee@gmail.com > Subject: Re: [PATCH 2/2] arm/mm : Report actual image regions in > /proc/iomem > > On Mon, Mar 06, 2023 at 02:51:55PM +0900, Jungseung Lee wrote: > > The resource reservations in /proc/iomem made for the kernel image > > did not reflect the gaps between text, rodata, and data. > > Add the "rodata" resource and update the start/end calculations. > > > > Before : > > 04000000-2f7fffff : System RAM > > 04100000-04cfffff : Kernel code > > 04e00000-05369a27 : Kernel data > > > > After : > > 04000000-2f7fffff : System RAM > > 04100000-049fffff : Kernel code > > 04a00000-04cb2fff : Kernel rodata > > 04e00000-05369a27 : Kernel data > > NAK. This is API, and programs do read and parse this file. It is > important that this file reports these parameters in a similar way to > other architectures. Other architectures do not split up the > individual regions. > Sounds like an important point, but I failed to find which programs use it as an API. Could you tell me which program uses it as an API? In fact, x86 architecture also split up the individual regions in this way. In addition, most architectures separate the "Kernel bss" area, but arm does not. > -- > RMK's Patch system: https://protect2.fireeye.com/v1/url?k=e44d6839- > 85c67d00-e44ce376-000babffae10-dcec955b544dea43&q=1&e=b53fe1bc-de29- > 4c29-a20d- > e39d10be6f3e&u=https%3A%2F%2Fwww.armlinux.org.uk%2Fdeveloper%2Fpatches > %2F > FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last! _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] arm/mm : Report actual image regions in /proc/iomem 2023-03-06 12:14 ` Jungseung Lee @ 2023-03-06 12:28 ` Russell King (Oracle) 2023-03-06 13:00 ` Ard Biesheuvel 0 siblings, 1 reply; 7+ messages in thread From: Russell King (Oracle) @ 2023-03-06 12:28 UTC (permalink / raw) To: Jungseung Lee Cc: linus.walleij, amit.kachhap, ardb, linux-arm-kernel, linux-kernel, keescook, js07.lee On Mon, Mar 06, 2023 at 09:14:23PM +0900, Jungseung Lee wrote: > Hi, Russell > > > -----Original Message----- > > From: Russell King (Oracle) <linux@armlinux.org.uk> > > Sent: Monday, March 6, 2023 8:10 PM > > To: Jungseung Lee <js07.lee@samsung.com> > > Cc: linus.walleij@linaro.org; amit.kachhap@arm.com; ardb@kernel.org; > > linux-arm-kernel@lists.infradead.org; linux-kernel@vger.kernel.org; > > keescook@chromium.org; js07.lee@gmail.com > > Subject: Re: [PATCH 2/2] arm/mm : Report actual image regions in > > /proc/iomem > > > > On Mon, Mar 06, 2023 at 02:51:55PM +0900, Jungseung Lee wrote: > > > The resource reservations in /proc/iomem made for the kernel image > > > did not reflect the gaps between text, rodata, and data. > > > Add the "rodata" resource and update the start/end calculations. > > > > > > Before : > > > 04000000-2f7fffff : System RAM > > > 04100000-04cfffff : Kernel code > > > 04e00000-05369a27 : Kernel data > > > > > > After : > > > 04000000-2f7fffff : System RAM > > > 04100000-049fffff : Kernel code > > > 04a00000-04cb2fff : Kernel rodata > > > 04e00000-05369a27 : Kernel data > > > > NAK. This is API, and programs do read and parse this file. It is > > important that this file reports these parameters in a similar way to > > other architectures. Other architectures do not split up the > > individual regions. > > > > Sounds like an important point, but I failed to find which programs use it > as an API. Could you tell me which program uses it as an API? > > In fact, x86 architecture also split up the individual regions in this way. > In addition, most architectures separate the "Kernel bss" area, but arm does > not. Take a look at kexec-tools - that certainly does parse /proc/iomem looking for entries such as "Kernel code" and "Kernel data". It's fine for an architecture to decide to do something else if it started to do it early on, but not when something has been established for decades. -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last! _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] arm/mm : Report actual image regions in /proc/iomem 2023-03-06 12:28 ` Russell King (Oracle) @ 2023-03-06 13:00 ` Ard Biesheuvel 0 siblings, 0 replies; 7+ messages in thread From: Ard Biesheuvel @ 2023-03-06 13:00 UTC (permalink / raw) To: Russell King (Oracle) Cc: Jungseung Lee, linus.walleij, amit.kachhap, linux-arm-kernel, linux-kernel, keescook, js07.lee On Mon, 6 Mar 2023 at 13:28, Russell King (Oracle) <linux@armlinux.org.uk> wrote: > > On Mon, Mar 06, 2023 at 09:14:23PM +0900, Jungseung Lee wrote: > > Hi, Russell > > > > > -----Original Message----- > > > From: Russell King (Oracle) <linux@armlinux.org.uk> > > > Sent: Monday, March 6, 2023 8:10 PM > > > To: Jungseung Lee <js07.lee@samsung.com> > > > Cc: linus.walleij@linaro.org; amit.kachhap@arm.com; ardb@kernel.org; > > > linux-arm-kernel@lists.infradead.org; linux-kernel@vger.kernel.org; > > > keescook@chromium.org; js07.lee@gmail.com > > > Subject: Re: [PATCH 2/2] arm/mm : Report actual image regions in > > > /proc/iomem > > > > > > On Mon, Mar 06, 2023 at 02:51:55PM +0900, Jungseung Lee wrote: > > > > The resource reservations in /proc/iomem made for the kernel image > > > > did not reflect the gaps between text, rodata, and data. > > > > Add the "rodata" resource and update the start/end calculations. > > > > > > > > Before : > > > > 04000000-2f7fffff : System RAM > > > > 04100000-04cfffff : Kernel code > > > > 04e00000-05369a27 : Kernel data > > > > > > > > After : > > > > 04000000-2f7fffff : System RAM > > > > 04100000-049fffff : Kernel code > > > > 04a00000-04cb2fff : Kernel rodata > > > > 04e00000-05369a27 : Kernel data > > > > > > NAK. This is API, and programs do read and parse this file. It is > > > important that this file reports these parameters in a similar way to > > > other architectures. Other architectures do not split up the > > > individual regions. > > > > > > > Sounds like an important point, but I failed to find which programs use it > > as an API. Could you tell me which program uses it as an API? > > > > In fact, x86 architecture also split up the individual regions in this way. > > In addition, most architectures separate the "Kernel bss" area, but arm does > > not. > > Take a look at kexec-tools - that certainly does parse /proc/iomem > looking for entries such as "Kernel code" and "Kernel data". > > It's fine for an architecture to decide to do something else if it > started to do it early on, but not when something has been established > for decades. > Agree with Russell here. It would be helpful if you could explain why you think this needs to be changed. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] arm/mm : omit [_text, _stext) from kernel code region 2023-03-06 5:51 ` [PATCH 1/2] arm/mm : omit [_text, _stext) from kernel code region Jungseung Lee 2023-03-06 5:51 ` [PATCH 2/2] arm/mm : Report actual image regions in /proc/iomem Jungseung Lee @ 2023-03-06 11:06 ` Russell King (Oracle) 1 sibling, 0 replies; 7+ messages in thread From: Russell King (Oracle) @ 2023-03-06 11:06 UTC (permalink / raw) To: Jungseung Lee Cc: linus.walleij, amit.kachhap, ardb, linux-arm-kernel, linux-kernel, keescook, js07.lee On Mon, Mar 06, 2023 at 02:51:54PM +0900, Jungseung Lee wrote: > 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 And why do you think this is correct? Isn't the head text, which isn't discarded and is located at 0x04008000, still part of kernel code? -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last! _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2023-03-06 13:02 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <CGME20230306061055epcas1p1f7718c46c10f84845e086f9ce9f9a41f@epcas1p1.samsung.com>
2023-03-06 5:51 ` [PATCH 1/2] arm/mm : omit [_text, _stext) from kernel code region Jungseung Lee
2023-03-06 5:51 ` [PATCH 2/2] arm/mm : Report actual image regions in /proc/iomem Jungseung Lee
2023-03-06 11:10 ` Russell King (Oracle)
2023-03-06 12:14 ` Jungseung Lee
2023-03-06 12:28 ` Russell King (Oracle)
2023-03-06 13:00 ` Ard Biesheuvel
2023-03-06 11:06 ` [PATCH 1/2] arm/mm : omit [_text, _stext) from kernel code region Russell King (Oracle)
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).