* [PATCH 0/3] efi/libstub: Fix library dependencies
@ 2026-11-26 15:50 Ard Biesheuvel
2026-11-26 15:50 ` [PATCH 1/3] efi/libstub: loongarch: Provide 64-bit integer shift helpers for 32-bit Ard Biesheuvel
` (2 more replies)
0 siblings, 3 replies; 11+ messages in thread
From: Ard Biesheuvel @ 2026-11-26 15:50 UTC (permalink / raw)
To: linux-efi
Cc: loongarch, Ard Biesheuvel, Dmitry Antipov, Huacai Chen,
WANG Xuerui
From: Ard Biesheuvel <ardb@kernel.org>
Dmitry reports that 32-bit LoongArch builds with EFI_ZBOOT disabled fail
to link, due to missing helpers for 64-bit integer shifts.
Fix this, and while at it, tweak the build so some of these dependencies
can be dropped for the zboot build.
Cc: Dmitry Antipov <dmantipov@yandex.ru>
Cc: Huacai Chen <chenhuacai@kernel.org>
Cc: WANG Xuerui <kernel@xen0n.name>
Ard Biesheuvel (3):
efi/libstub: loongarch: Provide 64-bit integer shift helpers for
32-bit
efi/zboot: Eliminate unused code from the zboot executable
efi/libstub: Provide library helpers only where needed
drivers/firmware/efi/libstub/Makefile | 18 +++++++++++-------
drivers/firmware/efi/libstub/Makefile.zboot | 3 ++-
drivers/firmware/efi/libstub/zboot.lds | 4 ++--
3 files changed, 15 insertions(+), 10 deletions(-)
--
2.56.1.839.g22a8290db9-goog
^ permalink raw reply [flat|nested] 11+ messages in thread* [PATCH 1/3] efi/libstub: loongarch: Provide 64-bit integer shift helpers for 32-bit 2026-11-26 15:50 [PATCH 0/3] efi/libstub: Fix library dependencies Ard Biesheuvel @ 2026-11-26 15:50 ` Ard Biesheuvel 2026-11-26 15:50 ` [PATCH 2/3] efi/zboot: Eliminate unused code from the zboot executable Ard Biesheuvel 2026-11-26 15:50 ` [PATCH 3/3] efi/libstub: Provide library helpers only where needed Ard Biesheuvel 2 siblings, 0 replies; 11+ messages in thread From: Ard Biesheuvel @ 2026-11-26 15:50 UTC (permalink / raw) To: linux-efi Cc: loongarch, Ard Biesheuvel, Dmitry Antipov, Huacai Chen, WANG Xuerui, kernel test robot From: Ard Biesheuvel <ardb@kernel.org> The EFI stub's copy of lib/cmdline.c performs 64-bit shifts in memparse() [which is never actually called from the stub], and so it needs library routines when running on 32-bit CPUs that lack native instructions for this. The LoongArch 32-bit EFI stub build already pulls in the library helpers that are needed for this, but only when CONFIG_EFI_ZBOOT=y, which is not sufficient, given that the same helpers will be needed in the vmlinux build for the builtin copy of the EFI stub. On other architectures, the builtin copy will call vmlinux's versions of those routines, which are exposed to the stub via aliases in the linker script. However, on LoongArch, those are C implementations that may be instrumented and therefore unsuitable for use in the EFI stub. Reported-by: Dmitry Antipov <dmantipov@yandex.ru> Reported-by: kernel test robot <lkp@intel.com> Closes: https://lore.kernel.org/oe-kbuild-all/20261122125352.gAcg5yLx-lkp@intel.com/ Fixes: 442082297e3d ("riscv: fix building compressed EFI image") Signed-off-by: Ard Biesheuvel <ardb@kernel.org> --- drivers/firmware/efi/libstub/Makefile | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware/efi/libstub/Makefile index bbab12b8eb4b..ba6c9e763862 100644 --- a/drivers/firmware/efi/libstub/Makefile +++ b/drivers/firmware/efi/libstub/Makefile @@ -88,7 +88,9 @@ lib-$(CONFIG_ARM64) += kaslr.o arm64.o arm64-stub.o smbios.o lib-$(CONFIG_X86) += x86-stub.o smbios.o lib-$(CONFIG_X86_64) += x86-5lvl.o lib-$(CONFIG_RISCV) += kaslr.o riscv.o riscv-stub.o -lib-$(CONFIG_LOONGARCH) += loongarch.o loongarch-stub.o +lib-loongarch-$(CONFIG_32BIT) += lib-ashldi3.o lib-lshrdi3.o +lib-$(CONFIG_LOONGARCH) += loongarch.o loongarch-stub.o \ + $(lib-loongarch-y) CFLAGS_arm32-stub.o := -DTEXT_OFFSET=$(TEXT_OFFSET) @@ -99,8 +101,7 @@ CFLAGS_zboot-decompress-zstd.o += -I$(srctree)/lib/zstd zboot-riscv-obj-$(CONFIG_32BIT) := lib-ashldi3.o lib-lshrdi3.o zboot-obj-$(CONFIG_RISCV) += lib-clz_ctz.o $(zboot-riscv-obj-y) -zboot-loongarch-obj-$(CONFIG_32BIT) := lib-ashldi3.o lib-lshrdi3.o -zboot-obj-$(CONFIG_LOONGARCH) += lib-clz_ctz.o $(zboot-loongarch-obj-y) +zboot-obj-$(CONFIG_LOONGARCH) += lib-clz_ctz.o lib-$(CONFIG_EFI_ZBOOT) += zboot.o $(zboot-obj-y) lib-$(CONFIG_UNACCEPTED_MEMORY) += unaccepted_memory.o bitmap.o find.o -- 2.56.1.839.g22a8290db9-goog ^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 2/3] efi/zboot: Eliminate unused code from the zboot executable 2026-11-26 15:50 [PATCH 0/3] efi/libstub: Fix library dependencies Ard Biesheuvel 2026-11-26 15:50 ` [PATCH 1/3] efi/libstub: loongarch: Provide 64-bit integer shift helpers for 32-bit Ard Biesheuvel @ 2026-11-26 15:50 ` Ard Biesheuvel 2026-11-26 15:50 ` [PATCH 3/3] efi/libstub: Provide library helpers only where needed Ard Biesheuvel 2 siblings, 0 replies; 11+ messages in thread From: Ard Biesheuvel @ 2026-11-26 15:50 UTC (permalink / raw) To: linux-efi Cc: loongarch, Ard Biesheuvel, Dmitry Antipov, Huacai Chen, WANG Xuerui From: Ard Biesheuvel <ardb@kernel.org> Wire up -ffunction-sections and --gc-sections so that unused functions are dropped from the build. This saves some space, but more importantly, will allow us to get rid of library routines that are never called (64-bit shift on 32-bit, clz/ctz on RISC-V) Signed-off-by: Ard Biesheuvel <ardb@kernel.org> --- drivers/firmware/efi/libstub/Makefile | 2 ++ drivers/firmware/efi/libstub/Makefile.zboot | 3 ++- drivers/firmware/efi/libstub/zboot.lds | 4 ++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware/efi/libstub/Makefile index ba6c9e763862..20b5b77956d1 100644 --- a/drivers/firmware/efi/libstub/Makefile +++ b/drivers/firmware/efi/libstub/Makefile @@ -34,6 +34,8 @@ cflags-$(CONFIG_LOONGARCH) += -fpie cflags-$(CONFIG_EFI_PARAMS_FROM_FDT) += -I$(srctree)/scripts/dtc/libfdt +cflags-$(CONFIG_EFI_ZBOOT) += -ffunction-sections + KBUILD_CFLAGS := $(subst $(CC_FLAGS_FTRACE),,$(cflags-y)) \ -Os -DDISABLE_BRANCH_PROFILING \ -include $(srctree)/include/linux/hidden.h \ diff --git a/drivers/firmware/efi/libstub/Makefile.zboot b/drivers/firmware/efi/libstub/Makefile.zboot index 52baacf3e9d9..3b827e4b571d 100644 --- a/drivers/firmware/efi/libstub/Makefile.zboot +++ b/drivers/firmware/efi/libstub/Makefile.zboot @@ -50,7 +50,8 @@ endif ZBOOT_DEPS := $(obj)/zboot-header.o $(objtree)/drivers/firmware/efi/libstub/lib.a -LDFLAGS_vmlinuz.efi.elf := -T $(srctree)/drivers/firmware/efi/libstub/zboot.lds +LDFLAGS_vmlinuz.efi.elf := -T $(srctree)/drivers/firmware/efi/libstub/zboot.lds \ + --gc-sections $(obj)/vmlinuz.efi.elf: $(obj)/vmlinuz.o $(ZBOOT_DEPS) FORCE $(call if_changed,ld) diff --git a/drivers/firmware/efi/libstub/zboot.lds b/drivers/firmware/efi/libstub/zboot.lds index a785c0123749..f3d4342c8a08 100644 --- a/drivers/firmware/efi/libstub/zboot.lds +++ b/drivers/firmware/efi/libstub/zboot.lds @@ -16,7 +16,7 @@ SECTIONS .rodata : ALIGN(8) { __efistub__gzdata_start = .; - *(.gzdata) + KEEP(*(.gzdata)) __efistub_payload_size = . - 4; __efistub__gzdata_end = .; *(.rodata* .init.rodata* .srodata*) @@ -31,7 +31,7 @@ SECTIONS .sbat : ALIGN(4096) { _sbat = .; - *(.sbat) + KEEP(*(.sbat)) _esbat = ALIGN(4096); . = _esbat; } -- 2.56.1.839.g22a8290db9-goog ^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 3/3] efi/libstub: Provide library helpers only where needed 2026-11-26 15:50 [PATCH 0/3] efi/libstub: Fix library dependencies Ard Biesheuvel 2026-11-26 15:50 ` [PATCH 1/3] efi/libstub: loongarch: Provide 64-bit integer shift helpers for 32-bit Ard Biesheuvel 2026-11-26 15:50 ` [PATCH 2/3] efi/zboot: Eliminate unused code from the zboot executable Ard Biesheuvel @ 2026-11-26 15:50 ` Ard Biesheuvel 2026-11-26 16:22 ` Dmitry Antipov 2026-11-27 2:28 ` Huacai Chen 2 siblings, 2 replies; 11+ messages in thread From: Ard Biesheuvel @ 2026-11-26 15:50 UTC (permalink / raw) To: linux-efi Cc: loongarch, Ard Biesheuvel, Dmitry Antipov, Huacai Chen, WANG Xuerui From: Ard Biesheuvel <ardb@kernel.org> Now that dead stub code is being eliminated by the linker, the only remaining user of the 64-bit left shift and clz/ctz helper routines is ZSTD compression, and only in some cases: - the 64-bit left shift is only needed on 32-bit architectures - the clz/ctz helper is needed on all RISC-V and 32-bit reduced LoongArch Signed-off-by: Ard Biesheuvel <ardb@kernel.org> --- drivers/firmware/efi/libstub/Makefile | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware/efi/libstub/Makefile index 20b5b77956d1..ba6d67e5cd78 100644 --- a/drivers/firmware/efi/libstub/Makefile +++ b/drivers/firmware/efi/libstub/Makefile @@ -98,14 +98,15 @@ CFLAGS_arm32-stub.o := -DTEXT_OFFSET=$(TEXT_OFFSET) zboot-obj-y := zboot-decompress-gzip.o CFLAGS_zboot-decompress-gzip.o += -I$(srctree)/lib/zlib_inflate -zboot-obj-$(CONFIG_KERNEL_ZSTD) := zboot-decompress-zstd.o lib-xxhash.o + +zstd-obj-$(CONFIG_32BIT) := lib-ashldi3.o +zstd-obj-$(CONFIG_RISCV) += lib-clz_ctz.o +zstd-obj-$(CONFIG_32BIT_REDUCED) += lib-clz_ctz.o # loongarch +zboot-obj-$(CONFIG_KERNEL_ZSTD) := zboot-decompress-zstd.o lib-xxhash.o \ + $(zstd-obj-y) CFLAGS_zboot-decompress-zstd.o += -I$(srctree)/lib/zstd -zboot-riscv-obj-$(CONFIG_32BIT) := lib-ashldi3.o lib-lshrdi3.o -zboot-obj-$(CONFIG_RISCV) += lib-clz_ctz.o $(zboot-riscv-obj-y) -zboot-obj-$(CONFIG_LOONGARCH) += lib-clz_ctz.o lib-$(CONFIG_EFI_ZBOOT) += zboot.o $(zboot-obj-y) - lib-$(CONFIG_UNACCEPTED_MEMORY) += unaccepted_memory.o bitmap.o find.o targets := $(lib-y) -- 2.56.1.839.g22a8290db9-goog ^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH 3/3] efi/libstub: Provide library helpers only where needed 2026-11-26 15:50 ` [PATCH 3/3] efi/libstub: Provide library helpers only where needed Ard Biesheuvel @ 2026-11-26 16:22 ` Dmitry Antipov 2026-11-26 16:29 ` Ard Biesheuvel 2026-11-27 2:28 ` Huacai Chen 1 sibling, 1 reply; 11+ messages in thread From: Dmitry Antipov @ 2026-11-26 16:22 UTC (permalink / raw) To: Ard Biesheuvel, linux-efi Cc: loongarch, Ard Biesheuvel, Huacai Chen, WANG Xuerui On 11/26/26 6:50 PM, Ard Biesheuvel wrote: > - the clz/ctz helper is needed on all RISC-V IIUC Zbb-capable cores has native clz/ctz, isn't it? Dmitry ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 3/3] efi/libstub: Provide library helpers only where needed 2026-11-26 16:22 ` Dmitry Antipov @ 2026-11-26 16:29 ` Ard Biesheuvel 0 siblings, 0 replies; 11+ messages in thread From: Ard Biesheuvel @ 2026-11-26 16:29 UTC (permalink / raw) To: Dmitry Antipov, Ard Biesheuvel, linux-efi Cc: loongarch, Huacai Chen, WANG Xuerui On Thu, 26 Nov 2026, at 17:22, Dmitry Antipov wrote: > On 11/26/26 6:50 PM, Ard Biesheuvel wrote: > >> - the clz/ctz helper is needed on all RISC-V > > IIUC Zbb-capable cores has native clz/ctz, isn't it? > Yes but the UEFI spec does not mandate that extension. The kernel proper uses alternatives patching for Zbb, and so the native clz/ctz will be used at runtime, but we cannot rely on it at boot. In any case, this just builds the object in the libstub static library, and so if the compiler never emits the library calls, the code will not be linked in. ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 3/3] efi/libstub: Provide library helpers only where needed 2026-11-26 15:50 ` [PATCH 3/3] efi/libstub: Provide library helpers only where needed Ard Biesheuvel 2026-11-26 16:22 ` Dmitry Antipov @ 2026-11-27 2:28 ` Huacai Chen 2026-11-27 7:13 ` Ard Biesheuvel 1 sibling, 1 reply; 11+ messages in thread From: Huacai Chen @ 2026-11-27 2:28 UTC (permalink / raw) To: Ard Biesheuvel Cc: linux-efi, loongarch, Ard Biesheuvel, Dmitry Antipov, WANG Xuerui Hi, Ard, Does this series wan to solve the same problem as below? https://lore.kernel.org/loongarch/97a95c9d-6736-4eee-ac9d-cbfb47d60492@app.fastmail.com/T/#t On Thu, Nov 26, 2026 at 11:50 PM Ard Biesheuvel <ardb+git@google.com> wrote: > > From: Ard Biesheuvel <ardb@kernel.org> > > Now that dead stub code is being eliminated by the linker, the only > remaining user of the 64-bit left shift and clz/ctz helper routines is > ZSTD compression, and only in some cases: > > - the 64-bit left shift is only needed on 32-bit architectures > - the clz/ctz helper is needed on all RISC-V and 32-bit reduced > LoongArch > > Signed-off-by: Ard Biesheuvel <ardb@kernel.org> > --- > drivers/firmware/efi/libstub/Makefile | 11 ++++++----- > 1 file changed, 6 insertions(+), 5 deletions(-) > > diff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware/efi/libstub/Makefile > index 20b5b77956d1..ba6d67e5cd78 100644 > --- a/drivers/firmware/efi/libstub/Makefile > +++ b/drivers/firmware/efi/libstub/Makefile > @@ -98,14 +98,15 @@ CFLAGS_arm32-stub.o := -DTEXT_OFFSET=$(TEXT_OFFSET) > > zboot-obj-y := zboot-decompress-gzip.o > CFLAGS_zboot-decompress-gzip.o += -I$(srctree)/lib/zlib_inflate > -zboot-obj-$(CONFIG_KERNEL_ZSTD) := zboot-decompress-zstd.o lib-xxhash.o > + > +zstd-obj-$(CONFIG_32BIT) := lib-ashldi3.o > +zstd-obj-$(CONFIG_RISCV) += lib-clz_ctz.o > +zstd-obj-$(CONFIG_32BIT_REDUCED) += lib-clz_ctz.o # loongarch I don't want to use CONFIG_32BIT_REDUCED outside arch/loongarch, can we use CONFIG_LOONGARCH which is similar to RISCV? And it seems the first patch can be folded with this one... Huacai > +zboot-obj-$(CONFIG_KERNEL_ZSTD) := zboot-decompress-zstd.o lib-xxhash.o \ > + $(zstd-obj-y) > CFLAGS_zboot-decompress-zstd.o += -I$(srctree)/lib/zstd > > -zboot-riscv-obj-$(CONFIG_32BIT) := lib-ashldi3.o lib-lshrdi3.o > -zboot-obj-$(CONFIG_RISCV) += lib-clz_ctz.o $(zboot-riscv-obj-y) > -zboot-obj-$(CONFIG_LOONGARCH) += lib-clz_ctz.o > lib-$(CONFIG_EFI_ZBOOT) += zboot.o $(zboot-obj-y) > - > lib-$(CONFIG_UNACCEPTED_MEMORY) += unaccepted_memory.o bitmap.o find.o > > targets := $(lib-y) > -- > 2.56.1.839.g22a8290db9-goog > > ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 3/3] efi/libstub: Provide library helpers only where needed 2026-11-27 2:28 ` Huacai Chen @ 2026-11-27 7:13 ` Ard Biesheuvel 2026-11-27 9:11 ` Ard Biesheuvel 0 siblings, 1 reply; 11+ messages in thread From: Ard Biesheuvel @ 2026-11-27 7:13 UTC (permalink / raw) To: Huacai Chen, Ard Biesheuvel Cc: linux-efi, loongarch, Dmitry Antipov, WANG Xuerui On Fri, 27 Nov 2026, at 03:28, Huacai Chen wrote: > Hi, Ard, > > Does this series wan to solve the same problem as below? > https://lore.kernel.org/loongarch/97a95c9d-6736-4eee-ac9d-cbfb47d60492@app.fastmail.com/T/#t > Yes. > On Thu, Nov 26, 2026 at 11:50 PM Ard Biesheuvel <ardb+git@google.com> wrote: >> >> From: Ard Biesheuvel <ardb@kernel.org> >> >> Now that dead stub code is being eliminated by the linker, the only >> remaining user of the 64-bit left shift and clz/ctz helper routines is >> ZSTD compression, and only in some cases: >> >> - the 64-bit left shift is only needed on 32-bit architectures >> - the clz/ctz helper is needed on all RISC-V and 32-bit reduced >> LoongArch >> >> Signed-off-by: Ard Biesheuvel <ardb@kernel.org> >> --- >> drivers/firmware/efi/libstub/Makefile | 11 ++++++----- >> 1 file changed, 6 insertions(+), 5 deletions(-) >> >> diff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware/efi/libstub/Makefile >> index 20b5b77956d1..ba6d67e5cd78 100644 >> --- a/drivers/firmware/efi/libstub/Makefile >> +++ b/drivers/firmware/efi/libstub/Makefile >> @@ -98,14 +98,15 @@ CFLAGS_arm32-stub.o := -DTEXT_OFFSET=$(TEXT_OFFSET) >> >> zboot-obj-y := zboot-decompress-gzip.o >> CFLAGS_zboot-decompress-gzip.o += -I$(srctree)/lib/zlib_inflate >> -zboot-obj-$(CONFIG_KERNEL_ZSTD) := zboot-decompress-zstd.o lib-xxhash.o >> + >> +zstd-obj-$(CONFIG_32BIT) := lib-ashldi3.o >> +zstd-obj-$(CONFIG_RISCV) += lib-clz_ctz.o >> +zstd-obj-$(CONFIG_32BIT_REDUCED) += lib-clz_ctz.o # loongarch > I don't want to use CONFIG_32BIT_REDUCED outside arch/loongarch, can > we use CONFIG_LOONGARCH which is similar to RISCV? > I could change this to zstd-obj-$(CONFIG_32BIT) := lib-clz_ctz.o zstd-obj-$(CONFIG_RISCV) := lib-clz_ctz.o zstd-obj-$(CONFIG_32BIT) += lib-ashldi3.o if you prefer? LoongArch64 never needs it, right? > And it seems the first patch can be folded with this one... > This is an optimization, the first one is a build fix. ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 3/3] efi/libstub: Provide library helpers only where needed 2026-11-27 7:13 ` Ard Biesheuvel @ 2026-11-27 9:11 ` Ard Biesheuvel 2026-11-27 9:48 ` Ard Biesheuvel 0 siblings, 1 reply; 11+ messages in thread From: Ard Biesheuvel @ 2026-11-27 9:11 UTC (permalink / raw) To: Huacai Chen, Ard Biesheuvel Cc: linux-efi, loongarch, Dmitry Antipov, WANG Xuerui On Fri, 27 Nov 2026, at 08:13, Ard Biesheuvel wrote: > On Fri, 27 Nov 2026, at 03:28, Huacai Chen wrote: >> Hi, Ard, >> >> Does this series wan to solve the same problem as below? >> https://lore.kernel.org/loongarch/97a95c9d-6736-4eee-ac9d-cbfb47d60492@app.fastmail.com/T/#t >> > > Yes. > >> On Thu, Nov 26, 2026 at 11:50 PM Ard Biesheuvel <ardb+git@google.com> wrote: >>> >>> From: Ard Biesheuvel <ardb@kernel.org> >>> >>> Now that dead stub code is being eliminated by the linker, the only >>> remaining user of the 64-bit left shift and clz/ctz helper routines is >>> ZSTD compression, and only in some cases: >>> >>> - the 64-bit left shift is only needed on 32-bit architectures >>> - the clz/ctz helper is needed on all RISC-V and 32-bit reduced >>> LoongArch >>> >>> Signed-off-by: Ard Biesheuvel <ardb@kernel.org> >>> --- >>> drivers/firmware/efi/libstub/Makefile | 11 ++++++----- >>> 1 file changed, 6 insertions(+), 5 deletions(-) >>> >>> diff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware/efi/libstub/Makefile >>> index 20b5b77956d1..ba6d67e5cd78 100644 >>> --- a/drivers/firmware/efi/libstub/Makefile >>> +++ b/drivers/firmware/efi/libstub/Makefile >>> @@ -98,14 +98,15 @@ CFLAGS_arm32-stub.o := -DTEXT_OFFSET=$(TEXT_OFFSET) >>> >>> zboot-obj-y := zboot-decompress-gzip.o >>> CFLAGS_zboot-decompress-gzip.o += -I$(srctree)/lib/zlib_inflate >>> -zboot-obj-$(CONFIG_KERNEL_ZSTD) := zboot-decompress-zstd.o lib-xxhash.o >>> + >>> +zstd-obj-$(CONFIG_32BIT) := lib-ashldi3.o >>> +zstd-obj-$(CONFIG_RISCV) += lib-clz_ctz.o >>> +zstd-obj-$(CONFIG_32BIT_REDUCED) += lib-clz_ctz.o # loongarch ... >> And it seems the first patch can be folded with this one... >> > > This is an optimization, the first one is a build fix. Yes, it does seem that the first patch is superseded by this change, as the left-shift helper is only used in zstd. I'll respin this. ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 3/3] efi/libstub: Provide library helpers only where needed 2026-11-27 9:11 ` Ard Biesheuvel @ 2026-11-27 9:48 ` Ard Biesheuvel 2026-11-27 12:57 ` Ard Biesheuvel 0 siblings, 1 reply; 11+ messages in thread From: Ard Biesheuvel @ 2026-11-27 9:48 UTC (permalink / raw) To: Huacai Chen, Ard Biesheuvel Cc: linux-efi, loongarch, Dmitry Antipov, WANG Xuerui On Fri, 27 Nov 2026, at 10:11, Ard Biesheuvel wrote: > On Fri, 27 Nov 2026, at 08:13, Ard Biesheuvel wrote: >> On Fri, 27 Nov 2026, at 03:28, Huacai Chen wrote: >>> Hi, Ard, >>> >>> Does this series wan to solve the same problem as below? >>> https://lore.kernel.org/loongarch/97a95c9d-6736-4eee-ac9d-cbfb47d60492@app.fastmail.com/T/#t >>> >> >> Yes. >> >>> On Thu, Nov 26, 2026 at 11:50 PM Ard Biesheuvel <ardb+git@google.com> wrote: >>>> >>>> From: Ard Biesheuvel <ardb@kernel.org> >>>> >>>> Now that dead stub code is being eliminated by the linker, the only >>>> remaining user of the 64-bit left shift and clz/ctz helper routines is >>>> ZSTD compression, and only in some cases: >>>> >>>> - the 64-bit left shift is only needed on 32-bit architectures >>>> - the clz/ctz helper is needed on all RISC-V and 32-bit reduced >>>> LoongArch >>>> >>>> Signed-off-by: Ard Biesheuvel <ardb@kernel.org> >>>> --- >>>> drivers/firmware/efi/libstub/Makefile | 11 ++++++----- >>>> 1 file changed, 6 insertions(+), 5 deletions(-) >>>> >>>> diff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware/efi/libstub/Makefile >>>> index 20b5b77956d1..ba6d67e5cd78 100644 >>>> --- a/drivers/firmware/efi/libstub/Makefile >>>> +++ b/drivers/firmware/efi/libstub/Makefile >>>> @@ -98,14 +98,15 @@ CFLAGS_arm32-stub.o := -DTEXT_OFFSET=$(TEXT_OFFSET) >>>> >>>> zboot-obj-y := zboot-decompress-gzip.o >>>> CFLAGS_zboot-decompress-gzip.o += -I$(srctree)/lib/zlib_inflate >>>> -zboot-obj-$(CONFIG_KERNEL_ZSTD) := zboot-decompress-zstd.o lib-xxhash.o >>>> + >>>> +zstd-obj-$(CONFIG_32BIT) := lib-ashldi3.o >>>> +zstd-obj-$(CONFIG_RISCV) += lib-clz_ctz.o >>>> +zstd-obj-$(CONFIG_32BIT_REDUCED) += lib-clz_ctz.o # loongarch > ... >>> And it seems the first patch can be folded with this one... >>> >> >> This is an optimization, the first one is a build fix. > > Yes, it does seem that the first patch is superseded by this change, as > the left-shift helper is only used in zstd. > Hmm the --gc-sections patch does not affect the vmlinux build so the fix in patch #1 needs to stay. But I can drop the loongarch pieces from this hunk, because its libstub.a already carries those objects. ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 3/3] efi/libstub: Provide library helpers only where needed 2026-11-27 9:48 ` Ard Biesheuvel @ 2026-11-27 12:57 ` Ard Biesheuvel 0 siblings, 0 replies; 11+ messages in thread From: Ard Biesheuvel @ 2026-11-27 12:57 UTC (permalink / raw) To: Huacai Chen, Ard Biesheuvel Cc: linux-efi, loongarch, Dmitry Antipov, WANG Xuerui On Fri, 27 Nov 2026, at 10:48, Ard Biesheuvel wrote: > On Fri, 27 Nov 2026, at 10:11, Ard Biesheuvel wrote: >> On Fri, 27 Nov 2026, at 08:13, Ard Biesheuvel wrote: >>> On Fri, 27 Nov 2026, at 03:28, Huacai Chen wrote: >>>> Hi, Ard, >>>> >>>> Does this series wan to solve the same problem as below? >>>> https://lore.kernel.org/loongarch/97a95c9d-6736-4eee-ac9d-cbfb47d60492@app.fastmail.com/T/#t >>>> >>> >>> Yes. >>> >>>> On Thu, Nov 26, 2026 at 11:50 PM Ard Biesheuvel <ardb+git@google.com> wrote: >>>>> >>>>> From: Ard Biesheuvel <ardb@kernel.org> >>>>> >>>>> Now that dead stub code is being eliminated by the linker, the only >>>>> remaining user of the 64-bit left shift and clz/ctz helper routines is >>>>> ZSTD compression, and only in some cases: >>>>> >>>>> - the 64-bit left shift is only needed on 32-bit architectures >>>>> - the clz/ctz helper is needed on all RISC-V and 32-bit reduced >>>>> LoongArch >>>>> >>>>> Signed-off-by: Ard Biesheuvel <ardb@kernel.org> >>>>> --- >>>>> drivers/firmware/efi/libstub/Makefile | 11 ++++++----- >>>>> 1 file changed, 6 insertions(+), 5 deletions(-) >>>>> >>>>> diff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware/efi/libstub/Makefile >>>>> index 20b5b77956d1..ba6d67e5cd78 100644 >>>>> --- a/drivers/firmware/efi/libstub/Makefile >>>>> +++ b/drivers/firmware/efi/libstub/Makefile >>>>> @@ -98,14 +98,15 @@ CFLAGS_arm32-stub.o := -DTEXT_OFFSET=$(TEXT_OFFSET) >>>>> >>>>> zboot-obj-y := zboot-decompress-gzip.o >>>>> CFLAGS_zboot-decompress-gzip.o += -I$(srctree)/lib/zlib_inflate >>>>> -zboot-obj-$(CONFIG_KERNEL_ZSTD) := zboot-decompress-zstd.o lib-xxhash.o >>>>> + >>>>> +zstd-obj-$(CONFIG_32BIT) := lib-ashldi3.o >>>>> +zstd-obj-$(CONFIG_RISCV) += lib-clz_ctz.o >>>>> +zstd-obj-$(CONFIG_32BIT_REDUCED) += lib-clz_ctz.o # loongarch >> ... >>>> And it seems the first patch can be folded with this one... >>>> >>> >>> This is an optimization, the first one is a build fix. >> >> Yes, it does seem that the first patch is superseded by this change, as >> the left-shift helper is only used in zstd. >> > > Hmm the --gc-sections patch does not affect the vmlinux build so the fix > in patch #1 needs to stay. But I can drop the loongarch pieces from this > hunk, because its libstub.a already carries those objects. Finally, I'll keep patch #1 as a fix, and turn this into zstd-riscv-obj-$(CONFIG_32BIT) := lib-ashldi3.o zstd-obj-$(CONFIG_32BIT) := lib-clz_ctz.o zstd-obj-$(CONFIG_RISCV) := lib-clz_ctz.o $(zstd-riscv-obj-y) zstd-obj-y += lib-xxhash.o zboot-obj-$(CONFIG_KERNEL_ZSTD) := zboot-decompress-zstd.o $(zstd-obj-y) ^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2026-11-27 12:57 UTC | newest] Thread overview: 11+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-11-26 15:50 [PATCH 0/3] efi/libstub: Fix library dependencies Ard Biesheuvel 2026-11-26 15:50 ` [PATCH 1/3] efi/libstub: loongarch: Provide 64-bit integer shift helpers for 32-bit Ard Biesheuvel 2026-11-26 15:50 ` [PATCH 2/3] efi/zboot: Eliminate unused code from the zboot executable Ard Biesheuvel 2026-11-26 15:50 ` [PATCH 3/3] efi/libstub: Provide library helpers only where needed Ard Biesheuvel 2026-11-26 16:22 ` Dmitry Antipov 2026-11-26 16:29 ` Ard Biesheuvel 2026-11-27 2:28 ` Huacai Chen 2026-11-27 7:13 ` Ard Biesheuvel 2026-11-27 9:11 ` Ard Biesheuvel 2026-11-27 9:48 ` Ard Biesheuvel 2026-11-27 12:57 ` Ard Biesheuvel
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox