Kexec Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Horman <horms@kernel.org>
To: Andreas Kemnade <andreas@kemnade.info>
Cc: Russell King <linux@armlinux.org.uk>,
	kexec@lists.infradead.org, j.neuschaefer@gmx.net,
	Mike Rapoport <rppt@kernel.org>,
	Pratyush Yadav <pratyush@kernel.org>,
	Tom Fitzhenry <tom@tom-fitzhenry.me.uk>,
	Andrew Morton <akpm@linux-foundation.org>,
	Baoquan He <baoquan.he@linux.dev>,
	Pasha Tatashin <pasha.tatashin@soleen.com>
Subject: Re: [PATCH kexec-tools v3] arm-zImage: prepare for more malloc requirements of zstd
Date: Mon, 5 Oct 2026 09:59:48 +0100	[thread overview]
Message-ID: <20261005085948.GC184916@horms.kernel.org> (raw)
In-Reply-To: <20260922-malloc-fix-v3-1-1d61286bde65@kemnade.info>

On Tue, Sep 22, 2026 at 12:25:59PM +0200, Andreas Kemnade wrote:
> As there are plans for zstd in zImage for ARM, which requires more malloc
> size fo, decompression, look at the header for the required size.
> 
> References:
> https://lore.kernel.org/lkml/ZFDMRst2O+RJUYuu@shell.armlinux.org.uk/#t
> https://lore.kernel.org/lkml/20260828-zstd2-v2-0-4d9ce7150877@kemnade.info/
> 
> Suggested-by: Russell King (Oracle) <linux@armlinux.org.uk>
> Signed-off-by: Andreas Kemnade <andreas@kemnade.info>
> ---
> To: kexec@lists.infradead.org
> To: Andrew Morton <akpm@linux-foundation.org>
> To: Baoquan He <baoquan.he@linux.dev>
> To: Mike Rapoport <rppt@kernel.org>
> To: Pasha Tatashin <pasha.tatashin@soleen.com>
> To: Pratyush Yadav <pratyush@kernel.org>
> To: Simon Horman <horms@kernel.org>
> Cc: Russell King <linux@armlinux.org.uk>
> Cc: j.neuschaefer@gmx.net
> ---
> Changes in v3:
> - calculate zImage size requirement before the if (tag) to simplify code
> - Link to v2: https://patch.msgid.link/20260912-malloc-fix-v2-1-eb0c3ca681cd@kemnade.info
> 
> Changes in v2:
> - extract malloc size from zImage header
> - Link to v1: https://patch.msgid.link/20260829094607.689485-1-andreas@kemnade.info

Thanks, and sorry for the delay.

I have applied this as:

[1] arm-zImage: prepare for more malloc requirements of zstd
    https://git.kernel.org/pub/scm/utils/kernel/kexec/kexec-tools.git/commit/?id=e128675241fa


This required a manual merge due to conflicts with the following,
which I had applied just beforehand.

[2] arm: use the zImage tag's real TEXT_OFFSET for kernel placement
    https://git.kernel.org/pub/scm/utils/kernel/kexec/kexec-tools.git/commit/?id=c1a526c87eb1

In particular:

a. The text_offset member no longer needs to be added to struct zimage_tag
   by [1] as it was added by [2].

b. There is some fuzz in the 2nd hunk of [2] as [1] adds some
   logic earlier on in zImage_arm_load().

FTR, the patch I applied is as follows.
If I've messed something up, please let me know.


From e128675241fa7777dcce613a2df191458c320f5b Mon Sep 17 00:00:00 2001
From: Andreas Kemnade <andreas@kemnade.info>
Date: Tue, 22 Sep 2026 12:25:59 +0200
Subject: [PATCH] arm-zImage: prepare for more malloc requirements of zstd

As there are plans for zstd in zImage for ARM, which requires more malloc
size fo, decompression, look at the header for the required size.

References:
https://lore.kernel.org/lkml/ZFDMRst2O+RJUYuu@shell.armlinux.org.uk/#t
https://lore.kernel.org/lkml/20260828-zstd2-v2-0-4d9ce7150877@kemnade.info/

Suggested-by: Russell King (Oracle) <linux@armlinux.org.uk>
Signed-off-by: Andreas Kemnade <andreas@kemnade.info>
Reviewed-by: Tom Fitzhenry <tom@tom-fitzhenry.me.uk>
Tested-by: Tom Fitzhenry <tom@tom-fitzhenry.me.uk>
Signed-off-by: Simon Horman <horms@kernel.org>
---
 kexec/arch/arm/kexec-zImage-arm.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/kexec/arch/arm/kexec-zImage-arm.c b/kexec/arch/arm/kexec-zImage-arm.c
index 892fca0cf09c..b1ee6ca2158b 100644
--- a/kexec/arch/arm/kexec-zImage-arm.c
+++ b/kexec/arch/arm/kexec-zImage-arm.c
@@ -132,6 +132,7 @@ struct zimage_tag {
 			uint32_t size_ptr;
 			uint32_t bss_size;
 			uint32_t text_offset;
+			uint32_t malloc_size;
 		} krnl_size;
 	} u;
 };
@@ -679,9 +680,15 @@ int zImage_arm_load(int argc, char **argv, const char *buf, off_t len,
 
 	/*
 	 * The zImage length does not include its stack (4k) or its
-	 * malloc space (64k).  Include this.
+	 * malloc space.
 	 */
-	len += 0x11000;
+	len += 0x1000;
+
+	/* include malloc space */
+	if (tag && le32_to_cpu(tag->hdr.size) >= 6)
+		len += le32_to_cpu(tag->u.krnl_size.malloc_size);
+	else
+		len += 0x10000;
 
 	dbgprintf("zImage requires 0x%08llx bytes\n", (unsigned long long)len);
 
-- 
2.47.3




      parent reply	other threads:[~2026-10-05  8:59 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-22 10:25 [PATCH kexec-tools v3] arm-zImage: prepare for more malloc requirements of zstd Andreas Kemnade
2026-09-22 12:14 ` Tom Fitzhenry
2026-10-05  8:59 ` Simon Horman [this message]

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=20261005085948.GC184916@horms.kernel.org \
    --to=horms@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=andreas@kemnade.info \
    --cc=baoquan.he@linux.dev \
    --cc=j.neuschaefer@gmx.net \
    --cc=kexec@lists.infradead.org \
    --cc=linux@armlinux.org.uk \
    --cc=pasha.tatashin@soleen.com \
    --cc=pratyush@kernel.org \
    --cc=rppt@kernel.org \
    --cc=tom@tom-fitzhenry.me.uk \
    /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