[PATCH v2 0/2] arm64,riscv: boot: emit standard LZ4 frame for Image.lz4

From: Ping Li

Date: Wed Nov 25 2026 - 22:03:03 EST


The shared cmd_lz4 rule in scripts/Makefile.lib passes -l to the lz4
tool, producing the legacy LZ4 format (magic 0x184C2102). The only
in-kernel lz4 decompressor, lib/decompress_unlz4, understands exactly
this legacy format, and all of its users - the self-extracting images
of other architectures (which compress their payloads with the
*_with_size variants) and the lz4-compressed initramfs - keep working
through the unchanged shared rule.

arm64 and riscv build Image.lz4 with the plain cmd_lz4, but a
compressed boot image on these architectures is handed to the
bootloader, not decompressed by the kernel itself. U-Boot, whose
compressed-kernel path (boot/image.c image_decomp ->
lib/lz4_wrapper.c ulz4fn) only accepts the standard LZ4 frame (magic
0x184D2204) and returns -EPROTONOSUPPORT for anything else, cannot
decompress the Image.lz4 built today. Bootloaders that decompress
legacy lz4 frames do exist in the wild (mkbootimg on Android offers a
separate lz4_legacy option), but U-Boot and its tooling only ever
supported the standard frame.

So both architectures currently produce images that no mainstream
bootloader can decompress. Fix both by emitting the standard frame
through local rules, leaving the shared cmd_lz4 untouched for the
in-kernel users.

Changes in v2:
- Pass -BI so the blocks stay independent regardless of what the lz4
CLI defaults to in the future; deployed U-Boot decoders reject
linked blocks (suggested by Yann Collet).
- -BI was introduced in lz4 v1.9.0 - older lz4 versions reject the
flag but already default to independent blocks, so the rule probes
for -BI support first.

Ping Li (2):
arm64: boot: emit standard LZ4 frame for Image.lz4
riscv: boot: emit standard LZ4 frame for Image.lz4

arch/arm64/boot/Makefile | 20 +++++++++++++++++++-
arch/riscv/boot/Makefile | 20 +++++++++++++++++++-
2 files changed, 38 insertions(+), 2 deletions(-)


base-commit: aebb7274476403040d582c61478df8f4a7bf9cd3
--
2.34.1