Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Andreas Kemnade <andreas@kemnade.info>
To: Russell King <linux@armlinux.org.uk>,
	Nick Terrell <terrelln@fb.com>,  David Sterba <dsterba@suse.com>,
	Nathan Chancellor <nathan@kernel.org>,
	 Nick Desaulniers <ndesaulniers@google.com>,
	 Bill Wendling <morbo@google.com>,
	Justin Stitt <justinstitt@google.com>
Cc: Andreas Kemnade <andreas@kemnade.info>,
	j.neuschaefer@gmx.net,  f.fainelli@gmail.com,
	Tony Lindgren <tony@atomide.com>,
	 linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org,  Linus Walleij <linusw@kernel.org>
Subject: [PATCH v2 3/3] ARM: compressed: Enable ZSTD compression
Date: Fri, 28 Aug 2026 22:32:21 +0200	[thread overview]
Message-ID: <20260828-zstd2-v2-3-4d9ce7150877@kemnade.info> (raw)
In-Reply-To: <20260828-zstd2-v2-0-4d9ce7150877@kemnade.info>

With the previous two commits, it is possible to enable ZSTD
in the decompressor stub for 32-bit ARM.

KASAN logic for XZ is extended for ZSTD, since
the affected functions are also in use.

Measurement was done with clang-19.
Setup was: starting a fastboot image via u-boot,
serial console attached.
Time was measured using ts -s %.s </dev/ttyUSBx | tee logfile
from the last words from u-boot still the first
kernel message. No early serial output was in use.

GTA04 (OMAP3) with something based on omap2plus_defconfig:
     zImage size	time
GZIP 7997 KiB		1.6s
LZMA 5794 KiB		4.6s
ZSTD 6774 KiB		2.7s

Tolino Shine 2 HD (i.MX6SL) with something based on imx_v6_v7_defconfig

GZIP 10499 KiB		 0.9s
LZMA 7611 KiB		 3.8s
ZSTD 8884 KiB		 2.0s

Signed-off-by: Andreas Kemnade <andreas@kemnade.info>
---
 arch/arm/Kconfig                      |  1 +
 arch/arm/boot/compressed/Makefile     |  1 +
 arch/arm/boot/compressed/decompress.c | 11 ++++++++++-
 3 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 9187240a02db5..cf612ee4064c3 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -122,6 +122,7 @@ config ARM
 	select HAVE_KERNEL_LZMA
 	select HAVE_KERNEL_LZO
 	select HAVE_KERNEL_XZ
+	select HAVE_KERNEL_ZSTD
 	select HAVE_KPROBES if !XIP_KERNEL && !CPU_ENDIAN_BE32 && !CPU_V7M
 	select HAVE_KRETPROBES if HAVE_KPROBES
 	select HAVE_LD_DEAD_CODE_DATA_ELIMINATION if (LD_VERSION >= 23600 || LD_IS_LLD) && LD_CAN_USE_KEEP_IN_OVERLAY
diff --git a/arch/arm/boot/compressed/Makefile b/arch/arm/boot/compressed/Makefile
index fa6ee23cd72eb..1c6638e1999ab 100644
--- a/arch/arm/boot/compressed/Makefile
+++ b/arch/arm/boot/compressed/Makefile
@@ -74,6 +74,7 @@ compress-$(CONFIG_KERNEL_LZO)  = lzo_with_size
 compress-$(CONFIG_KERNEL_LZMA) = lzma_with_size
 compress-$(CONFIG_KERNEL_XZ)   = xzkern_with_size
 compress-$(CONFIG_KERNEL_LZ4)  = lz4_with_size
+compress-$(CONFIG_KERNEL_ZSTD)  = zstd22_with_size
 
 libfdt_objs := fdt_rw.o fdt_ro.o fdt_wip.o fdt.o
 
diff --git a/arch/arm/boot/compressed/decompress.c b/arch/arm/boot/compressed/decompress.c
index b0352f379277f..5f82c0c754fa5 100644
--- a/arch/arm/boot/compressed/decompress.c
+++ b/arch/arm/boot/compressed/decompress.c
@@ -47,15 +47,24 @@ extern char * strchrnul(const char *, int);
 #include "../../../../lib/decompress_unlzma.c"
 #endif
 
-#ifdef CONFIG_KERNEL_XZ
+#if defined(CONFIG_KERNEL_XZ) || defined(CONFIG_KERNEL_ZSTD)
 /* Prevent KASAN override of string helpers in decompressor */
 #undef memmove
 #define memmove memmove
 #undef memcpy
 #define memcpy memcpy
+#undef memset
+#define memset memset
+#endif
+
+#ifdef CONFIG_KERNEL_XZ
 #include "../../../../lib/decompress_unxz.c"
 #endif
 
+#ifdef CONFIG_KERNEL_ZSTD
+#include "../../../../lib/decompress_unzstd.c"
+#endif
+
 #ifdef CONFIG_KERNEL_LZ4
 #include "../../../../lib/decompress_unlz4.c"
 #endif

-- 
2.47.3



      parent reply	other threads:[~2026-08-28 20:33 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-28 20:32 [PATCH v2 0/3] ARM ZSTD boot compression Andreas Kemnade
2026-08-28 20:32 ` [PATCH v2 1/3] ARM: compressed: Pass the actual output length to the decompressor Andreas Kemnade
2026-08-28 20:32 ` [PATCH v2 2/3] ARM: compressed: Bump MALLOC_SIZE to 128 KiB Andreas Kemnade
2026-08-28 20:32 ` Andreas Kemnade [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=20260828-zstd2-v2-3-4d9ce7150877@kemnade.info \
    --to=andreas@kemnade.info \
    --cc=dsterba@suse.com \
    --cc=f.fainelli@gmail.com \
    --cc=j.neuschaefer@gmx.net \
    --cc=justinstitt@google.com \
    --cc=linusw@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=morbo@google.com \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=terrelln@fb.com \
    --cc=tony@atomide.com \
    /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