All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] efi/libstub: fix building loongarch32 without zboot enabled
@ 2026-11-26 10:14 ` Dmitry Antipov
  0 siblings, 0 replies; 5+ messages in thread
From: Dmitry Antipov @ 2026-11-26 10:14 UTC (permalink / raw)
  To: Ard Biesheuvel
  Cc: Paul Walmsley, Palmer Dabbelt, Albert Ou, Huacai Chen,
	WANG Xuerui, linux-efi, linux-riscv, loongarch, Dmitry Antipov,
	kernel test robot

Kernel test robot has reported the following error observed on loongarch:

loongarch64-linux-ld: ./drivers/firmware/efi/libstub/lib-cmdline.stub.o: in function `__efistub_.L47':
__efistub_cmdline.c:(.init.text+0x258): undefined reference to `__efistub___ashldi3'
loongarch64-linux-ld: __efistub_cmdline.c:(.init.text+0x268): undefined reference to `__efistub___lshrdi3'

Since this happens with CONFIG_EFI_GENERIC_STUB enabled but
CONFIG_EFI_ZBOOT disabled, tweak loongarch32 build to hook
extra library objects on the former rather than latter. And
this quirk seems no longer neeeded on riscv32 because it has
architecture-specific implementations of ashldi3() and lsrdi3()
which are aliased to corresponding EFI stubs via
arch/riscv/kernel/image-vars.h.

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: Dmitry Antipov <dmantipov@yandex.ru>
---
 drivers/firmware/efi/libstub/Makefile | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware/efi/libstub/Makefile
index bbab12b8eb4b..77f0d3047b95 100644
--- a/drivers/firmware/efi/libstub/Makefile
+++ b/drivers/firmware/efi/libstub/Makefile
@@ -97,11 +97,11 @@ CFLAGS_zboot-decompress-gzip.o	+= -I$(srctree)/lib/zlib_inflate
 zboot-obj-$(CONFIG_KERNEL_ZSTD)	:= zboot-decompress-zstd.o lib-xxhash.o
 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)
-lib-$(CONFIG_EFI_ZBOOT)		+= zboot.o $(zboot-obj-y)
+extra-loongarch-obj-$(CONFIG_32BIT)	:= lib-ashldi3.o lib-lshrdi3.o
+extra-obj-$(CONFIG_LOONGARCH)	+= $(extra-loongarch-obj-y)
+lib-$(CONFIG_EFI_GENERIC_STUB)	+= $(extra-obj-y)
+
+lib-$(CONFIG_EFI_ZBOOT)		+= zboot.o
 
 lib-$(CONFIG_UNACCEPTED_MEMORY) += unaccepted_memory.o bitmap.o find.o
 
-- 
2.56.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH] efi/libstub: fix building loongarch32 without zboot enabled
@ 2026-11-26 10:14 ` Dmitry Antipov
  0 siblings, 0 replies; 5+ messages in thread
From: Dmitry Antipov @ 2026-11-26 10:14 UTC (permalink / raw)
  To: Ard Biesheuvel
  Cc: Paul Walmsley, Palmer Dabbelt, Albert Ou, Huacai Chen,
	WANG Xuerui, linux-efi, linux-riscv, loongarch, Dmitry Antipov,
	kernel test robot

Kernel test robot has reported the following error observed on loongarch:

loongarch64-linux-ld: ./drivers/firmware/efi/libstub/lib-cmdline.stub.o: in function `__efistub_.L47':
__efistub_cmdline.c:(.init.text+0x258): undefined reference to `__efistub___ashldi3'
loongarch64-linux-ld: __efistub_cmdline.c:(.init.text+0x268): undefined reference to `__efistub___lshrdi3'

Since this happens with CONFIG_EFI_GENERIC_STUB enabled but
CONFIG_EFI_ZBOOT disabled, tweak loongarch32 build to hook
extra library objects on the former rather than latter. And
this quirk seems no longer neeeded on riscv32 because it has
architecture-specific implementations of ashldi3() and lsrdi3()
which are aliased to corresponding EFI stubs via
arch/riscv/kernel/image-vars.h.

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: Dmitry Antipov <dmantipov@yandex.ru>
---
 drivers/firmware/efi/libstub/Makefile | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware/efi/libstub/Makefile
index bbab12b8eb4b..77f0d3047b95 100644
--- a/drivers/firmware/efi/libstub/Makefile
+++ b/drivers/firmware/efi/libstub/Makefile
@@ -97,11 +97,11 @@ CFLAGS_zboot-decompress-gzip.o	+= -I$(srctree)/lib/zlib_inflate
 zboot-obj-$(CONFIG_KERNEL_ZSTD)	:= zboot-decompress-zstd.o lib-xxhash.o
 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)
-lib-$(CONFIG_EFI_ZBOOT)		+= zboot.o $(zboot-obj-y)
+extra-loongarch-obj-$(CONFIG_32BIT)	:= lib-ashldi3.o lib-lshrdi3.o
+extra-obj-$(CONFIG_LOONGARCH)	+= $(extra-loongarch-obj-y)
+lib-$(CONFIG_EFI_GENERIC_STUB)	+= $(extra-obj-y)
+
+lib-$(CONFIG_EFI_ZBOOT)		+= zboot.o
 
 lib-$(CONFIG_UNACCEPTED_MEMORY) += unaccepted_memory.o bitmap.o find.o
 
-- 
2.56.1


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] efi/libstub: fix building loongarch32 without zboot enabled
  2026-11-26 10:14 ` Dmitry Antipov
  (?)
@ 2026-11-26 10:26 ` sashiko-bot
  -1 siblings, 0 replies; 5+ messages in thread
From: sashiko-bot @ 2026-11-26 10:26 UTC (permalink / raw)
  To: Dmitry Antipov, Ard Biesheuvel
  Cc: Paul Walmsley, Palmer Dabbelt, Albert Ou, Huacai Chen,
	WANG Xuerui, linux-efi, kernel test robot

Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [High] efi/libstub: dropping $(zboot-obj-y) breaks all
  CONFIG_EFI_ZBOOT builds
- [High] efi/libstub: removing shift helpers breaks riscv32
  CONFIG_EFI_ZBOOT link
- [High] efi/libstub: removing lib-clz_ctz.o breaks ZSTD
  CONFIG_EFI_ZBOOT link
--

commit 903c012d44a1b7b277bbfa82862bc5644c32ea38
Author: Dmitry Antipov <dmantipov@yandex.ru>

efi/libstub: fix building loongarch32 without zboot enabled

This commit moves loongarch32 shift helper library objects from
CONFIG_EFI_ZBOOT to CONFIG_EFI_GENERIC_STUB and removes the riscv and
loongarch zboot helper objects from drivers/firmware/efi/libstub/Makefile.

> diff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware/efi/libstub/Makefile
> index 0c5fbc21d2a29..6b569b648e374 100644
> --- a/drivers/firmware/efi/libstub/Makefile
> +++ b/drivers/firmware/efi/libstub/Makefile
> @@ -97,11 +97,11 @@ CFLAGS_zboot-decompress-gzip.o	+= -I$(srctree)/lib/zlib_inflate
>  zboot-obj-$(CONFIG_KERNEL_ZSTD)	:= zboot-decompress-zstd.o lib-xxhash.o
>  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)

[Severity: High]
Does removing lib-ashldi3.o and lib-lshrdi3.o on 32-bit RISC-V break
linking vmlinuz.efi.elf when CONFIG_EFI_ZBOOT is enabled, regressing
442082297e3d ("riscv: fix building compressed EFI image")?

The aliases in arch/riscv/kernel/image-vars.h are only included in
vmlinux.lds.S when linking vmlinux.  Makefile.zboot links vmlinuz.efi.elf
as a standalone binary using zboot.lds and
drivers/firmware/efi/libstub/lib.a, where efi_zboot_entry() ->
efi_handle_cmdline() -> memparse() still needs __efistub___ashldi3 and
__efistub___lshrdi3.

[Severity: High]
Does dropping lib-clz_ctz.o for CONFIG_RISCV and CONFIG_LOONGARCH break
CONFIG_EFI_ZBOOT builds with CONFIG_KERNEL_ZSTD=y?

zboot-decompress-zstd.c uses __builtin_ctz* and __builtin_clz* via
lib/zstd/common/bits.h.  On RISC-V without Zbb and on 32-bit LoongArch,
the compiler emits calls to __ctz* and __clz* that remain unresolved when
linking vmlinuz.efi.elf against drivers/firmware/efi/libstub/lib.a.

> -lib-$(CONFIG_EFI_ZBOOT)		+= zboot.o $(zboot-obj-y)
> +extra-loongarch-obj-$(CONFIG_32BIT)	:= lib-ashldi3.o lib-lshrdi3.o
> +extra-obj-$(CONFIG_LOONGARCH)	+= $(extra-loongarch-obj-y)
> +lib-$(CONFIG_EFI_GENERIC_STUB)	+= $(extra-obj-y)
> +
> +lib-$(CONFIG_EFI_ZBOOT)		+= zboot.o

[Severity: High]
Does removing $(zboot-obj-y) from lib-$(CONFIG_EFI_ZBOOT) break all
CONFIG_EFI_ZBOOT builds?

zboot-obj-y holds zboot-decompress-gzip.o or zboot-decompress-zstd.o and
lib-xxhash.o, so dropping $(zboot-obj-y) leaves
__efistub_efi_zboot_decompress_init and __efistub_efi_zboot_decompress
undefined when linking vmlinuz.efi.elf from zboot.o.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261126101452.590895-1-dmantipov@yandex.ru?part=1

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] efi/libstub: fix building loongarch32 without zboot enabled
  2026-11-26 10:14 ` Dmitry Antipov
@ 2026-11-26 10:27   ` Ard Biesheuvel
  -1 siblings, 0 replies; 5+ messages in thread
From: Ard Biesheuvel @ 2026-11-26 10:27 UTC (permalink / raw)
  To: Dmitry Antipov
  Cc: Paul Walmsley, Palmer Dabbelt, Albert Ou, Huacai Chen,
	WANG Xuerui, linux-efi, linux-riscv, loongarch, kernel test robot



On Thu, 26 Nov 2026, at 11:14, Dmitry Antipov wrote:
> Kernel test robot has reported the following error observed on loongarch:
>
> loongarch64-linux-ld: 
> ./drivers/firmware/efi/libstub/lib-cmdline.stub.o: in function 
> `__efistub_.L47':
> __efistub_cmdline.c:(.init.text+0x258): undefined reference to 
> `__efistub___ashldi3'
> loongarch64-linux-ld: __efistub_cmdline.c:(.init.text+0x268): undefined 
> reference to `__efistub___lshrdi3'
>
> Since this happens with CONFIG_EFI_GENERIC_STUB enabled but
> CONFIG_EFI_ZBOOT disabled, tweak loongarch32 build to hook
> extra library objects on the former rather than latter. And
> this quirk seems no longer neeeded on riscv32 because it has
> architecture-specific implementations of ashldi3() and lsrdi3()
> which are aliased to corresponding EFI stubs via
> arch/riscv/kernel/image-vars.h.
>
> 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: Dmitry Antipov <dmantipov@yandex.ru>
> ---
>  drivers/firmware/efi/libstub/Makefile | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
>

Would this work as well?

--- a/arch/loongarch/kernel/image-vars.h
+++ b/arch/loongarch/kernel/image-vars.h
@@ -8,7 +8,8 @@
 #ifdef CONFIG_EFI_STUB
 
 __efistub_strcmp               = strcmp;
-
+__efistub___lshrdi3            = __lshrdi3;
+__efistub___ashldi3            = __ashldi3;
 #endif
 
 #endif /* __LOONGARCH_KERNEL_IMAGE_VARS_H */

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] efi/libstub: fix building loongarch32 without zboot enabled
@ 2026-11-26 10:27   ` Ard Biesheuvel
  0 siblings, 0 replies; 5+ messages in thread
From: Ard Biesheuvel @ 2026-11-26 10:27 UTC (permalink / raw)
  To: Dmitry Antipov
  Cc: Paul Walmsley, Palmer Dabbelt, Albert Ou, Huacai Chen,
	WANG Xuerui, linux-efi, linux-riscv, loongarch, kernel test robot



On Thu, 26 Nov 2026, at 11:14, Dmitry Antipov wrote:
> Kernel test robot has reported the following error observed on loongarch:
>
> loongarch64-linux-ld: 
> ./drivers/firmware/efi/libstub/lib-cmdline.stub.o: in function 
> `__efistub_.L47':
> __efistub_cmdline.c:(.init.text+0x258): undefined reference to 
> `__efistub___ashldi3'
> loongarch64-linux-ld: __efistub_cmdline.c:(.init.text+0x268): undefined 
> reference to `__efistub___lshrdi3'
>
> Since this happens with CONFIG_EFI_GENERIC_STUB enabled but
> CONFIG_EFI_ZBOOT disabled, tweak loongarch32 build to hook
> extra library objects on the former rather than latter. And
> this quirk seems no longer neeeded on riscv32 because it has
> architecture-specific implementations of ashldi3() and lsrdi3()
> which are aliased to corresponding EFI stubs via
> arch/riscv/kernel/image-vars.h.
>
> 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: Dmitry Antipov <dmantipov@yandex.ru>
> ---
>  drivers/firmware/efi/libstub/Makefile | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
>

Would this work as well?

--- a/arch/loongarch/kernel/image-vars.h
+++ b/arch/loongarch/kernel/image-vars.h
@@ -8,7 +8,8 @@
 #ifdef CONFIG_EFI_STUB
 
 __efistub_strcmp               = strcmp;
-
+__efistub___lshrdi3            = __lshrdi3;
+__efistub___ashldi3            = __ashldi3;
 #endif
 
 #endif /* __LOONGARCH_KERNEL_IMAGE_VARS_H */

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-11-26 10:28 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-26 10:14 [PATCH] efi/libstub: fix building loongarch32 without zboot enabled Dmitry Antipov
2026-11-26 10:14 ` Dmitry Antipov
2026-11-26 10:26 ` sashiko-bot
2026-11-26 10:27 ` Ard Biesheuvel
2026-11-26 10:27   ` Ard Biesheuvel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.