Skip to content

Commit a329975

Browse files
keessuryasaimadhu
authored andcommitted
x86/mm: Report actual image regions in /proc/iomem
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 to match the respective calls to free_kernel_image_pages(). Before (booted with "nokaslr" for easier comparison): 00100000-bffd9fff : System RAM 01000000-01e011d0 : Kernel code 01e011d1-025619bf : Kernel data 02a95000-035fffff : Kernel bss After: 00100000-bffd9fff : System RAM 01000000-01e011d0 : Kernel code 02000000-023d4fff : Kernel rodata 02400000-025619ff : Kernel data 02a95000-035fffff : Kernel bss Signed-off-by: Kees Cook <[email protected]> Signed-off-by: Borislav Petkov <[email protected]> Cc: Andy Lutomirski <[email protected]> Cc: Arnd Bergmann <[email protected]> Cc: Dave Hansen <[email protected]> Cc: Dave Young <[email protected]> Cc: David Howells <[email protected]> Cc: Heiko Carstens <[email protected]> Cc: "H. Peter Anvin" <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Juergen Gross <[email protected]> Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: Michael Ellerman <[email protected]> Cc: Michal Simek <[email protected]> Cc: Rick Edgecombe <[email protected]> Cc: Robert Richter <[email protected]> Cc: Segher Boessenkool <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Thomas Lendacky <[email protected]> Cc: Will Deacon <[email protected]> Cc: x86-ml <[email protected]> Cc: Yoshinori Sato <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent 5494c3a commit a329975

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

arch/x86/kernel/setup.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,13 @@ struct boot_params boot_params;
143143
/*
144144
* Machine setup..
145145
*/
146+
static struct resource rodata_resource = {
147+
.name = "Kernel rodata",
148+
.start = 0,
149+
.end = 0,
150+
.flags = IORESOURCE_BUSY | IORESOURCE_SYSTEM_RAM
151+
};
152+
146153
static struct resource data_resource = {
147154
.name = "Kernel data",
148155
.start = 0,
@@ -951,7 +958,9 @@ void __init setup_arch(char **cmdline_p)
951958

952959
code_resource.start = __pa_symbol(_text);
953960
code_resource.end = __pa_symbol(_etext)-1;
954-
data_resource.start = __pa_symbol(_etext);
961+
rodata_resource.start = __pa_symbol(__start_rodata);
962+
rodata_resource.end = __pa_symbol(__end_rodata)-1;
963+
data_resource.start = __pa_symbol(_sdata);
955964
data_resource.end = __pa_symbol(_edata)-1;
956965
bss_resource.start = __pa_symbol(__bss_start);
957966
bss_resource.end = __pa_symbol(__bss_stop)-1;
@@ -1040,6 +1049,7 @@ void __init setup_arch(char **cmdline_p)
10401049

10411050
/* after parse_early_param, so could debug it */
10421051
insert_resource(&iomem_resource, &code_resource);
1052+
insert_resource(&iomem_resource, &rodata_resource);
10431053
insert_resource(&iomem_resource, &data_resource);
10441054
insert_resource(&iomem_resource, &bss_resource);
10451055

0 commit comments

Comments
 (0)