[PATCH kexec-tools v3] arm-zImage: prepare for more malloc requirements of zstd
Andreas Kemnade
andreas at kemnade.info
Tue Sep 22 03:25:59 PDT 2026
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 at armlinux.org.uk>
Signed-off-by: Andreas Kemnade <andreas at kemnade.info>
---
To: kexec at lists.infradead.org
To: Andrew Morton <akpm at linux-foundation.org>
To: Baoquan He <baoquan.he at linux.dev>
To: Mike Rapoport <rppt at kernel.org>
To: Pasha Tatashin <pasha.tatashin at soleen.com>
To: Pratyush Yadav <pratyush at kernel.org>
To: Simon Horman <horms at kernel.org>
Cc: Russell King <linux at armlinux.org.uk>
Cc: j.neuschaefer at 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
---
kexec/arch/arm/kexec-zImage-arm.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/kexec/arch/arm/kexec-zImage-arm.c b/kexec/arch/arm/kexec-zImage-arm.c
index 8b474dd..6c3bf27 100644
--- a/kexec/arch/arm/kexec-zImage-arm.c
+++ b/kexec/arch/arm/kexec-zImage-arm.c
@@ -131,6 +131,8 @@ struct zimage_tag {
struct zimage_krnl_size {
uint32_t size_ptr;
uint32_t bss_size;
+ uint32_t text_offset;
+ uint32_t malloc_size;
} krnl_size;
} u;
};
@@ -663,9 +665,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);
---
base-commit: 43c5cba85ad23cc69c423527d9587c59b89fa437
change-id: 20260912-malloc-fix-31a13574cb84
Best regards,
--
Andreas Kemnade <andreas at kemnade.info>
More information about the kexec
mailing list