From: Joseph Cathcart <josephc@linux.ibm.com>
To: linux-s390@vger.kernel.org
Cc: eoin.mcnamara@ibm.com, iii@de.ibm.com,
Joseph Cathcart <josephc@linux.ibm.com>
Subject: [PATCH v1] s390/iomem: register initrd as an iomem resource when retain_initrd is set
Date: Tue, 18 Aug 2026 17:35:59 +0200 [thread overview]
Message-ID: <20260818153559.5700-1-josephc@linux.ibm.com> (raw)
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.
Signed-off-by: Joseph Cathcart <josephc@linux.ibm.com>
---
arch/s390/kernel/setup.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/arch/s390/kernel/setup.c b/arch/s390/kernel/setup.c
index b60284328fe3..a3c57ff40bf8 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,17 @@ static void __init setup_resources(void)
bss_resource.start = __pa_symbol(__bss_start);
bss_resource.end = __pa_symbol(__bss_stop) - 1;
+ if (strstr(boot_command_line, "retain_initrd"))
+ retain_initrd = true;
+ if (IS_ENABLED(CONFIG_BLK_DEV_INITRD) && retain_initrd) {
+ unsigned long initrd_addr, initrd_size;
+
+ if (get_physmem_reserved(RR_INITRD, &initrd_addr, &initrd_size)) {
+ initrd_resource.start = initrd_addr;
+ initrd_resource.end = initrd_resource.start + initrd_size - 1;
+ }
+ }
+
for_each_mem_range(i, &start, &end) {
res = memblock_alloc_or_panic(sizeof(*res), 8);
res->flags = IORESOURCE_BUSY | IORESOURCE_SYSTEM_RAM;
@@ -517,6 +535,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;
--
2.55.0
base commit: 0f23d56f17fdfc7db69d51f64c8b91bbab947aa9
next reply other threads:[~2026-08-18 15:36 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-18 15:35 Joseph Cathcart [this message]
2026-08-18 15:44 ` [PATCH v1] s390/iomem: register initrd as an iomem resource when retain_initrd is set sashiko-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260818153559.5700-1-josephc@linux.ibm.com \
--to=josephc@linux.ibm.com \
--cc=eoin.mcnamara@ibm.com \
--cc=iii@de.ibm.com \
--cc=linux-s390@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox