mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ping Li <leeonion.muyu@gmail.com>
To: catalin.marinas@arm.com, will@kernel.org, palmer@dabbelt.com,
	pjw@kernel.org
Cc: mark.rutland@arm.com, alex@ghiti.fr,
	emil.renner.berthing@canonical.com, masahiroy@kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org,
	u-boot@lists.denx.de, Ping Li <leeonion.muyu@gmail.com>
Subject: [PATCH 0/2] arm64,riscv: boot: emit standard LZ4 frame for Image.lz4
Date: Tue, 24 Nov 2026 14:56:48 +0800	[thread overview]
Message-ID: <20261124065650.1968930-1-leeonion.muyu@gmail.com> (raw)

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 format, and all of its users - the self-extracting images of
arm, mips, parisc, s390 and x86, and the lz4-compressed initramfs -
keep working through the *_with_size variants and plain cmd_lz4.

arm64 and riscv also build Image.lz4 with the plain cmd_lz4, but a
compressed boot image on these two architectures is not decompressed
by the kernel itself - it is handed to the bootloader.  U-Boot, which
implements this via the 'booti' 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.  U-Boot's own host tooling (binman) likewise emits
standard frames.

So the Image.lz4 targets of 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.

Bootloaders that decompress the legacy format 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.

Testing:
 - Verified that the lz4 invocation used by the new rules emits the
   standard frame magic (04 22 4d 18) and round-trips with the lz4
   CLI, while the old rule emits the legacy magic (02 21 4c 18).
 - No full kernel build environment was available for either arch
   here; the rule changes are mechanical.  Boot testing on real
   hardware, especially on riscv, would be appreciated.

Related: an arm64 'make install' fix that recognises all compressed
image formats is under review at
https://lore.kernel.org/all/20261119041945.3624785-1-leeonion.muyu@gmail.com/

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 | 9 ++++++++-
 arch/riscv/boot/Makefile | 9 ++++++++-
 2 files changed, 16 insertions(+), 2 deletions(-)


base-commit: aebb7274476403040d582c61478df8f4a7bf9cd3
-- 
2.34.1


             reply	other threads:[~2026-11-24  6:56 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-24  6:56 Ping Li [this message]
2026-11-24  6:56 ` [PATCH 1/2] arm64: " Ping Li
2026-11-24  6:56 ` [PATCH 2/2] riscv: " Ping Li

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=20261124065650.1968930-1-leeonion.muyu@gmail.com \
    --to=leeonion.muyu@gmail.com \
    --cc=alex@ghiti.fr \
    --cc=catalin.marinas@arm.com \
    --cc=emil.renner.berthing@canonical.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=mark.rutland@arm.com \
    --cc=masahiroy@kernel.org \
    --cc=palmer@dabbelt.com \
    --cc=pjw@kernel.org \
    --cc=u-boot@lists.denx.de \
    --cc=will@kernel.org \
    /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

all inboxes | Powered by JetHome®