Re: [PATCH v4] s390/iomem: register initrd as an iomem resource when retain_initrd is set
Ilya Leoshkevich <[email protected]>
| Newsgroups | org.kernel.vger.linux-s390 |
|---|---|
| Message-ID | <[email protected]> |
On 8/18/26 19:57, Joseph Cathcart wrote: > Currently, /proc/iomem contains no reference to initrd memory, even > when initrd is retained and still held in RAM. This makes the memory > ranges invisible from userspace, and unusable to programs such as > kexec. (A sysfs bin file is created for initrd, but this doesn't > help programs which need the explicit memory ranges) > > Add initrd to standard_resources[] unconditionally. Add initrd as a > child of iomem_resources only if retain_initrd is specified. > > strstr() could match substrings like "retain_initrd=0" or > "no_retain_initrd", but this is how PPC chose to check for > "retain_initrd" param too. (arch/powerpc/kexec/ranges.c) > > Signed-off-by: Joseph Cathcart <[email protected]> > --- > arch/s390/kernel/setup.c | 22 ++++++++++++++++++++++ > 1 file changed, 22 insertions(+) Checkpatch complains: $ b4 shazam 'https://lore.kernel.org/all/[email protected]/' $ git format-patch -1 --stdout | ./scripts/checkpatch.pl - ERROR: trailing whitespace #58: FILE: arch/s390/kernel/setup.c:513: +^I$ > diff --git a/arch/s390/kernel/setup.c b/arch/s390/kernel/setup.c > index b60284328fe3..373e54ed7519 100644 > --- a/arch/s390/kernel/setup.c > +++ b/arch/s390/kernel/setup.c > @@ -481,15 +481,22 @@ static struct resource bss_resource = { > .flags = IORESOURCE_BUSY | IORESOURCE_SYSTEM_RAM, > }; > > +static struct resource initrd_resource = { > + .name = "initrd", > + .flags = IORESOURCE_BUSY | IORESOURCE_SYSTEM_RAM, > +}; > + > static struct resource __initdata *standard_resources[] = { > &code_resource, > &data_resource, > &bss_resource, > + &initrd_resource, > }; > > static void __init setup_resources(void) > { > struct resource *res, *std_res, *sub_res; > + bool retain_initrd = false; > phys_addr_t start, end; > int j; > u64 i; > @@ -501,6 +508,19 @@ static void __init setup_resources(void) > bss_resource.start = __pa_symbol(__bss_start); > bss_resource.end = __pa_symbol(__bss_stop) - 1; > > + if (IS_ENABLED(CONFIG_BLK_DEV_INITRD)) { > + unsigned long initrd_addr, initrd_size; > + > + if (strstr(boot_command_line, "retain_initrd")) > + retain_initrd = true; > + if (retain_initrd && get_physmem_reserved(RR_INITRD, &initrd_addr, &initrd_size)) { > + initrd_resource.start = initrd_addr; > + initrd_resource.end = initrd_resource.start + initrd_size - 1; > + } else { > + retain_initrd = false; > + } > + } > + > for_each_mem_range(i, &start, &end) { > res = memblock_alloc_or_panic(sizeof(*res), 8); > res->flags = IORESOURCE_BUSY | IORESOURCE_SYSTEM_RAM; > @@ -517,6 +537,8 @@ static void __init setup_resources(void) > > for (j = 0; j < ARRAY_SIZE(standard_resources); j++) { > std_res = standard_resources[j]; > + if (std_res == &initrd_resource && !retain_initrd) > + continue; > if (std_res->start < res->start || > std_res->start > res->end) > continue; Cc: Christian and Alexander. I wonder if it would make sense to move initrd resource creation to do_populate_rootfs(), right after /sys/firmware/initrd creation, enabling this feature on all architectures?