mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Magnus Lindholm <linmag7@gmail.com>
To: Matt Turner <mattst88@gmail.com>
Cc: Lasse Collin <lasse.collin@tukaani.org>,
	 Richard Henderson <richard.henderson@linaro.org>,
	Nick Terrell <terrelln@fb.com>,  David Sterba <dsterba@suse.com>,
	linux-kernel@vger.kernel.org,  linux-alpha@vger.kernel.org
Subject: Re: [PATCH 3/3] alpha: support the remaining kernel compression formats
Date: Sun, 13 Sep 2026 11:56:35 +0200	[thread overview]
Message-ID: <CA+=Fv5QZnub5grceKRNXrtpXYJzYjkMzGFmdQsUrv94oz82O2Q@mail.gmail.com> (raw)
In-Reply-To: <20260912-alpha-kernel-compression-v1-3-ce9d55330193@gmail.com>

Hi Matt,

On Sat, Sep 12, 2026 at 9:55 PM Matt Turner <mattst88@gmail.com> wrote:
>
> Nothing about the boot stub is specific to gzip, so wire up bzip2, lz4,
> lzma, lzo, xz and zstd as well: select the matching HAVE_KERNEL_*
> symbol, add a suffix-y entry and a compression rule for the piggy-backed
> image, and include the decompressor into the stub's misc.c.
>
> Only gzip's trailer already carries the uncompressed size, so the other
> formats use the _with_size variants; output_len, which vmlinux.scr takes
> from the last 4 bytes of the payload, then works for all of them. The
> stub passes it to __decompress(), which zstd requires.
>
> Signed-off-by: Matt Turner <mattst88@gmail.com>
> ---
>  arch/alpha/Kconfig                  |  6 ++++++
>  arch/alpha/boot/compressed/Makefile | 31 +++++++++++++++++++++++++++++--
>  arch/alpha/boot/compressed/misc.c   | 31 +++++++++++++++++++++++++++++++
>  3 files changed, 66 insertions(+), 2 deletions(-)
>
> diff --git a/arch/alpha/Kconfig b/arch/alpha/Kconfig
> index 2688bb00f175..92cc7bb8d29a 100644
> --- a/arch/alpha/Kconfig
> +++ b/arch/alpha/Kconfig
> @@ -30,7 +30,13 @@ config ALPHA
>         select HAVE_ASM_MODVERSIONS
>         select HAVE_DEBUG_KMEMLEAK
>         select HAVE_GUP_FAST
> +       select HAVE_KERNEL_BZIP2
>         select HAVE_KERNEL_GZIP
> +       select HAVE_KERNEL_LZ4
> +       select HAVE_KERNEL_LZMA
> +       select HAVE_KERNEL_LZO
> +       select HAVE_KERNEL_XZ
> +       select HAVE_KERNEL_ZSTD
>         select HAVE_PAGE_SIZE_8KB
>         select HAVE_PCSPKR_PLATFORM
>         select HAVE_PERF_EVENTS
> diff --git a/arch/alpha/boot/compressed/Makefile b/arch/alpha/boot/compressed/Makefile
> index d826f7e4384d..06deaf51fcfa 100644
> --- a/arch/alpha/boot/compressed/Makefile
> +++ b/arch/alpha/boot/compressed/Makefile
> @@ -5,7 +5,10 @@
>  #
>
>  OBJECTS := head.o misc.o trampoline.o piggy.o
> -targets := vmlinux.lds vmlinux vmlinux.bin vmlinux.bin.gz
> +targets := vmlinux.lds vmlinux vmlinux.bin
> +targets += vmlinux.bin.bz2 vmlinux.bin.gz vmlinux.bin.lz4
> +targets += vmlinux.bin.lzma vmlinux.bin.lzo vmlinux.bin.xz
> +targets += vmlinux.bin.zst
>  targets += $(OBJECTS)
>
>  # The stub runs before the kernel has identified the CPU it booted on, so
> @@ -18,18 +21,42 @@ KBUILD_CFLAGS += -pipe -mno-fp-regs -ffixed-8
>  KBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING -D__DISABLE_EXPORTS
>  KBUILD_CFLAGS += $(CC_FLAGS_DIALECT)
>
> +# zstd's decompressor uses __builtin_ctzll()/__builtin_clzll(). Those are
> +# inline code only with the CIX extension, which the base instruction set
> +# the stub is built for does not have, so they become calls to libgcc's
> +# __ctzdi2/__clzdi2.
> +LIBGCC := $(shell $(CC) -print-libgcc-file-name)
> +
>  LDFLAGS_vmlinux := -X --orphan-handling=warn -T
> -$(obj)/vmlinux: $(obj)/vmlinux.lds $(addprefix $(obj)/, $(OBJECTS)) $(LIBS_Y) FORCE
> +$(obj)/vmlinux: $(obj)/vmlinux.lds $(addprefix $(obj)/, $(OBJECTS)) $(LIBS_Y) $(LIBGCC) FORCE
>         $(call if_changed,ld)
>
>  OBJCOPYFLAGS_vmlinux.bin := -R .comment -R .note -S
>  $(obj)/vmlinux.bin: vmlinux FORCE
>         $(call if_changed,objcopy)
>
> +suffix-$(CONFIG_KERNEL_BZIP2)  := bz2
>  suffix-$(CONFIG_KERNEL_GZIP)   := gz
> +suffix-$(CONFIG_KERNEL_LZ4)    := lz4
> +suffix-$(CONFIG_KERNEL_LZMA)   := lzma
> +suffix-$(CONFIG_KERNELI built the complete series in separate output directories for all
seven supported compression formats using alpha-unknown-linux-gnu-:

    gzip, bzip2, lz4, lzma, lzo, xz and zstd

All seven builds produced statically linked Alpha ELF executables with
the expected entry point and no undefined symbols.

I successfully boot-tested the bzip2, lzma, xz and zstd images on an
AlphaPC 264DP through SRM and aboot 1.0_pre20040408. The bzip2 image
was additionally tested with an external cpio initramfs.

Reviewed-by: Magnus Lindholm <linmag7@gmail.com>
Tested-by: Magnus Lindholm <linmag7@gmail.com>_LZO)    := lzo
> +suffix-$(CONFIG_KERNEL_XZ)     := xz
> +suffix-$(CONFIG_KERNEL_ZSTD)   := zst
>
> +$(obj)/vmlinux.bin.bz2: $(obj)/vmlinux.bin FORCE
> +       $(call if_changed,bzip2_with_size)
>  $(obj)/vmlinux.bin.gz: $(obj)/vmlinux.bin FORCE
>         $(call if_changed,gzip)
> +$(obj)/vmlinux.bin.lz4: $(obj)/vmlinux.bin FORCE
> +       $(call if_changed,lz4_with_size)
> +$(obj)/vmlinux.bin.lzma: $(obj)/vmlinux.bin FORCE
> +       $(call if_changed,lzma_with_size)
> +$(obj)/vmlinux.bin.lzo: $(obj)/vmlinux.bin FORCE
> +       $(call if_changed,lzo_with_size)
> +$(obj)/vmlinux.bin.xz: $(obj)/vmlinux.bin FORCE
> +       $(call if_changed,xzkern_with_size)
> +$(obj)/vmlinux.bin.zst: $(obj)/vmlinux.bin FORCE
> +       $(call if_changed,zstd22_with_size)
>
>  LDFLAGS_piggy.o := -r --format binary --oformat elf64-alpha -T
>  $(obj)/piggy.o: $(obj)/vmlinux.scr $(obj)/vmlinux.bin.$(suffix-y) FORCE
> diff --git a/arch/alpha/boot/compressed/misc.c b/arch/alpha/boot/compressed/misc.c
> index 72998582be68..8ffc546e1a15 100644
> --- a/arch/alpha/boot/compressed/misc.c
> +++ b/arch/alpha/boot/compressed/misc.c
> @@ -23,6 +23,13 @@
>  #define STATIC static
>  #define memzero(s, n) memset((s), 0, (n))
>
> +/*
> + * decompress_unxz.c supplies its own memmove() unless the identifier is
> + * already a macro. arch/alpha/lib/ has a better one and is already on
> + * our link line, so take that instead.
> + */
> +#define memmove memmove
> +
>  extern char input_data[];
>  extern int input_len;
>  /* output_len is inserted by the linker, possibly at an unaligned address */
> @@ -42,10 +49,34 @@ void __noreturn error(char *m)
>                 __halt();
>  }
>
> +#ifdef CONFIG_KERNEL_BZIP2
> +#include "../../../../lib/decompress_bunzip2.c"
> +#endif
> +
>  #ifdef CONFIG_KERNEL_GZIP
>  #include "../../../../lib/decompress_inflate.c"
>  #endif
>
> +#ifdef CONFIG_KERNEL_LZ4
> +#include "../../../../lib/decompress_unlz4.c"
> +#endif
> +
> +#ifdef CONFIG_KERNEL_LZMA
> +#include "../../../../lib/decompress_unlzma.c"
> +#endif
> +
> +#ifdef CONFIG_KERNEL_LZO
> +#include "../../../../lib/decompress_unlzo.c"
> +#endif
> +
> +#ifdef CONFIG_KERNEL_XZ
> +#include "../../../../lib/decompress_unxz.c"
> +#endif
> +
> +#ifdef CONFIG_KERNEL_ZSTD
> +#include "../../../../lib/decompress_unzstd.c"
> +#endif
> +
>  /* Scratch heap for the decompressors, larger than any of them needs. */
>  #define STUB_HEAP_SIZE (4 * 1024 * 1024)
>
>
> --
> 2.54.0
>

I built the complete series in separate output directories for all
seven supported compression formats:
    gzip, bzip2, lz4, lzma, lzo, xz and zstd

All seven builds produced statically linked Alpha ELF executables with
the expected entry point and no undefined symbols.

I successfully boot-tested the bzip2, lzma, xz and zstd images on an
UP2000+ through SRM and aboot 1.0_pre20040408. The bzip2 image
was additionally tested with an external cpio initramfs.

Reviewed-by: Magnus Lindholm <linmag7@gmail.com>
Tested-by: Magnus Lindholm <linmag7@gmail.com>

  reply	other threads:[~2026-09-13  9:56 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-12 19:55 [PATCH 0/3] alpha: self-extracting compressed kernel images Matt Turner
2026-09-12 19:55 ` [PATCH 1/3] xz: add arch-specific tuning for alpha Matt Turner
2026-09-13  9:45   ` Magnus Lindholm
2026-09-15 19:03   ` Lasse Collin
2026-09-17 17:54     ` Magnus Lindholm
2026-09-12 19:55 ` [PATCH 2/3] alpha: add self-extracting compressed kernel boot stub Matt Turner
2026-09-13  9:47   ` Magnus Lindholm
2026-09-12 19:55 ` [PATCH 3/3] alpha: support the remaining kernel compression formats Matt Turner
2026-09-13  9:56   ` Magnus Lindholm [this message]
2026-09-13  9:57 ` [PATCH 0/3] alpha: self-extracting compressed kernel images Magnus Lindholm
2026-10-15 13:09 ` Maciej W. Rozycki
2026-10-15 13:26   ` John Paul Adrian Glaubitz
2026-10-15 13:37     ` Magnus Lindholm
2026-10-15 13:56       ` John Paul Adrian Glaubitz

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='CA+=Fv5QZnub5grceKRNXrtpXYJzYjkMzGFmdQsUrv94oz82O2Q@mail.gmail.com' \
    --to=linmag7@gmail.com \
    --cc=dsterba@suse.com \
    --cc=lasse.collin@tukaani.org \
    --cc=linux-alpha@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mattst88@gmail.com \
    --cc=richard.henderson@linaro.org \
    --cc=terrelln@fb.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

all inboxes | Powered by JetHome®