From: sashiko-bot@kernel.org
To: "Dmitry Antipov" <dmantipov@yandex.ru>,
"Ard Biesheuvel" <ardb@kernel.org>
Cc: "Paul Walmsley" <pjw@kernel.org>,
"Palmer Dabbelt" <palmer@dabbelt.com>,
"Albert Ou" <aou@eecs.berkeley.edu>,
"Huacai Chen" <chenhuacai@kernel.org>,
"WANG Xuerui" <kernel@xen0n.name>,
linux-efi@vger.kernel.org, "kernel test robot" <lkp@intel.com>
Subject: Re: [PATCH v2] efi/libstub: fix building loongarch32 without zboot enabled
Date: Thu, 26 Nov 2026 12:59:44 +0000 [thread overview]
Message-ID: <sashiko-outbox-235550@kernel.org> (raw)
In-Reply-To: <20261126124145.876953-1-dmantipov@yandex.ru>
Thank you for your contribution! Sashiko AI review found 4 potential
issues to consider:
- [High] efi/libstub: dropping $(zboot-obj-y) breaks all
CONFIG_EFI_ZBOOT builds
- [High] efi/libstub: removing shift helpers breaks 32-bit
CONFIG_EFI_ZBOOT link
- [High] efi/libstub: removing lib-clz_ctz.o breaks ZSTD
CONFIG_EFI_ZBOOT link
- [Medium] efi/libstub: loongarch32 aliases shift helpers to
instrumented kernel C code
--
commit 387fa3daffaccbaba76887c4a051e10a5a6deaf6
Author: Dmitry Antipov <dmantipov@yandex.ru>
efi/libstub: fix building loongarch32 without zboot enabled
This commit defines EFI stub symbol aliases for __lshrdi3 and __ashldi3 in
arch/loongarch/kernel/image-vars.h and removes the zboot helper object rules
from drivers/firmware/efi/libstub/Makefile.
> diff --git a/arch/loongarch/kernel/image-vars.h b/arch/loongarch/kernel/image-vars.h
> index e557ebd46c2b3..19202f4f84c2b 100644
> --- a/arch/loongarch/kernel/image-vars.h
> +++ b/arch/loongarch/kernel/image-vars.h
> @@ -8,6 +8,8 @@
> #ifdef CONFIG_EFI_STUB
>
> __efistub_strcmp = strcmp;
> +__efistub___lshrdi3 = __lshrdi3;
> +__efistub___ashldi3 = __ashldi3;
> __efistub_kernel_entry = kernel_entry;
> __efistub_kernel_asize = kernel_asize;
> __efistub_kernel_fsize = kernel_fsize;
[Severity: Medium]
Is it safe for the LoongArch EFI stub to call the core kernel's __lshrdi3()
and __ashldi3() before kernel_entry?
Unlike RISC-V in commit a354b8de9ad6 ("riscv: add platform-specific double
word shifts for riscv32"), which implements these helpers in assembly,
LoongArch selects CONFIG_GENERIC_LIB_ASHLDI3 and CONFIG_GENERIC_LIB_LSHRDI3
and builds the C implementations in lib/ashldi3.c and lib/lshrdi3.c as
normal kernel objects. They are marked notrace, which only suppresses
ftrace, not KCOV, UBSAN, branch profiling or stack-protector
instrumentation.
With CONFIG_KCOV=y, the branches in __ashldi3() and __lshrdi3() call
__sanitizer_cov_trace_pc(), which dereferences current via the $tp register.
When efi_pe_entry() -> efi_handle_cmdline() calls memparse() in the pre-boot
EFI environment before kernel_entry initializes $tp to init_task, that
access crashes before the kernel boots. Building lib-ashldi3.o and
lib-lshrdi3.o in drivers/firmware/efi/libstub/Makefile avoids kernel
instrumentation.
> diff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware/efi/libstub/Makefile
> index bbab12b8eb4b2..bcf2a59816782 100644
> --- a/drivers/firmware/efi/libstub/Makefile
> +++ b/drivers/firmware/efi/libstub/Makefile
> @@ -96,12 +96,7 @@ 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
> 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 break linking vmlinuz.efi.elf
on 32-bit RISC-V and 32-bit LoongArch when CONFIG_EFI_ZBOOT=y?
The __efistub___ashldi3 and __efistub___lshrdi3 aliases in
arch/{riscv,loongarch}/kernel/image-vars.h are only included by
vmlinux.lds.S when linking vmlinux. In
drivers/firmware/efi/libstub/Makefile.zboot, vmlinuz.efi.elf is linked as a
standalone binary with zboot.lds against only vmlinuz.o, zboot-header.o and
drivers/firmware/efi/libstub/lib.a, where efi_zboot_entry() ->
efi_handle_cmdline() still pulls in lib-cmdline.stub.o and leaves
__efistub___ashldi3 and __efistub___lshrdi3 unresolved, reintroducing the
build failure fixed by commit 442082297e3d ("riscv: fix building compressed
EFI image").
[Severity: High]
Does removing lib-clz_ctz.o break linking vmlinuz.efi.elf on RISC-V and
32-bit LoongArch when CONFIG_EFI_ZBOOT=y and CONFIG_KERNEL_ZSTD=y?
zboot-decompress-zstd.c uses __builtin_ctz(), __builtin_clz(),
__builtin_ctzll() and __builtin_clzll() in lib/zstd/common/bits.h, which
emit calls to __efistub___ctz* and __efistub___clz* when target instructions
are not enabled. Because vmlinuz.efi.elf is linked standalone against
drivers/firmware/efi/libstub/lib.a without the kernel's lib/lib.a, dropping
lib-clz_ctz.o leaves those symbols undefined at link time.
> -lib-$(CONFIG_EFI_ZBOOT) += zboot.o $(zboot-obj-y)
> +lib-$(CONFIG_EFI_ZBOOT) += zboot.o
[Severity: High]
Does dropping $(zboot-obj-y) from lib-$(CONFIG_EFI_ZBOOT) break all
CONFIG_EFI_ZBOOT=y builds across every architecture?
Without $(zboot-obj-y), neither zboot-decompress-gzip.stub.o nor
zboot-decompress-zstd.stub.o and lib-xxhash.stub.o are added to
drivers/firmware/efi/libstub/lib.a, so linking vmlinuz.efi.elf fails with
undefined references to __efistub_efi_zboot_decompress_init and
__efistub_efi_zboot_decompress from efi_zboot_entry().
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261126124145.876953-1-dmantipov@yandex.ru?part=1
prev parent reply other threads:[~2026-11-26 12:59 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-26 12:41 [PATCH v2] efi/libstub: fix building loongarch32 without zboot enabled Dmitry Antipov
2026-11-26 12:53 ` Ard Biesheuvel
2026-11-26 13:11 ` Ard Biesheuvel
2026-11-26 13:16 ` Dmitry Antipov
2026-11-26 14:44 ` Ard Biesheuvel
2026-11-26 12:59 ` sashiko-bot [this message]
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=sashiko-outbox-235550@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=aou@eecs.berkeley.edu \
--cc=ardb@kernel.org \
--cc=chenhuacai@kernel.org \
--cc=dmantipov@yandex.ru \
--cc=kernel@xen0n.name \
--cc=linux-efi@vger.kernel.org \
--cc=lkp@intel.com \
--cc=palmer@dabbelt.com \
--cc=pjw@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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;
as well as URLs for NNTP newsgroup(s).