[PATCH v2 3/3] ARM: compressed: Enable ZSTD compression
From: Andreas Kemnade <andreas@kemnade.info>
Date: 2026-08-28 20:33:15
Also in:
lkml
Subsystem:
arm port, the rest · Maintainers:
Russell King, Linus Torvalds
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