From: Charlie Jenkins <thecharlesjenkins@gmail.com>
To: Dmitry Antipov <dmantipov@yandex.ru>
Cc: Andy Shevchenko <andriy.shevchenko@intel.com>,
Andrew Morton <akpm@linux-foundation.org>,
Paul Walmsley <pjw@kernel.org>,
Palmer Dabbelt <palmer@dabbelt.com>,
Albert Ou <aou@eecs.berkeley.edu>,
Ard Biesheuvel <ardb@kernel.org>,
linux-riscv@lists.infradead.org,
kernel test robot <lkp@intel.com>
Subject: Re: [PATCH v2 1/2] riscv: add platform-specific double word shifts for riscv32
Date: Fri, 10 Apr 2026 12:30:14 -0700 [thread overview]
Message-ID: <20260410193014.GA817331@inky.localdomain> (raw)
In-Reply-To: <cd37e33a200e05f96830f8edf313b0651572c32f.camel@yandex.ru>
On Fri, Apr 10, 2026 at 01:49:31PM +0300, Dmitry Antipov wrote:
> On Thu, 2026-04-09 at 16:22 -0700, Charlie Jenkins wrote:
>
> > However, this change causes the libstub to bypass these new functions
> > you have introduced. lib-ashldi3.o and lib-lshrdi3.o use the following
> > rule to compile the generic arch libs:
> >
> > $(obj)/lib-%.o: $(srctree)/lib/%.c FORCE
> > $(call if_changed_rule,cc_o_c)
> >
> > This is specifically for the efi libstub, the regular kernel (like in
> > your test case in the next patch) will use these newly introduced
> > functions.
> >
> > One solution is to use this change instead:
> >
> > diff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware/efi/libstub/Makefile
> > index e386ffd009b7..775c34d80179 100644
> > --- a/drivers/firmware/efi/libstub/Makefile
> > +++ b/drivers/firmware/efi/libstub/Makefile
> > @@ -96,7 +96,7 @@ 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-obj-$(CONFIG_RISCV) += lib-clz_ctz.o lib-ashldi3.o
> > +zboot-obj-$(CONFIG_RISCV) += lib-clz_ctz.o ../../../../arch/riscv/lib/ashldi3.o ../../../../arch/riscv/lib/lshrdi3.o
> > lib-$(CONFIG_EFI_ZBOOT) += zboot.o $(zboot-obj-y)
> >
> > lib-$(CONFIG_UNACCEPTED_MEMORY) += unaccepted_memory.o bitmap.o find.o
> >
> > This will link against the correct shifting libraries.
>
> 1) This seems wrong for riscv64 which can have CONFIG_EFI_ZBOOT=y as
> well but doesn't need these 64-on-32 quirks.
>
> 2) IIUC EFI stub executes just once before the kernel is booting, so it
> doesn't seem too critical to link arch-specific (optimized) things
> against it.
>
> So I'm voting for something like:
>
> diff --git a/drivers/firmware/efi/Kconfig b/drivers/firmware/efi/Kconfig
> index 29e0729299f5..55fb5a20aa25 100644
> --- a/drivers/firmware/efi/Kconfig
> +++ b/drivers/firmware/efi/Kconfig
> @@ -85,6 +85,10 @@ config EFI_ZBOOT
> provided that the loader implements the decompression algorithm.
> (The compression algorithm used is described in the zboot header)
>
> +config EFI_ZBOOT_EXTRAS
> + bool
> + default y if RISCV && 32BIT
> +
> config EFI_ARMSTUB_DTB_LOADER
> bool "Enable the DTB loader"
> depends on EFI_GENERIC_STUB && !RISCV && !LOONGARCH
> diff --git a/drivers/firmware/efi/libstub/Makefile
> b/drivers/firmware/efi/libstub/Makefile
> index f83301a19dc5..8f199b99d0f6 100644
> --- a/drivers/firmware/efi/libstub/Makefile
> +++ b/drivers/firmware/efi/libstub/Makefile
> @@ -96,7 +96,8 @@ 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-obj-$(CONFIG_RISCV) += lib-clz_ctz.o lib-ashldi3.o lib-lshrdi3.o
> +zboot-obj-extras-$(CONFIG_EFI_ZBOOT_EXTRAS) += lib-ashldi3.o lib-lshrdi3.o
> +zboot-obj-$(CONFIG_RISCV) += lib-clz_ctz.o $(zboot-obj-extras-y)
> lib-$(CONFIG_EFI_ZBOOT) += zboot.o $(zboot-obj-y)
>
> lib-$(CONFIG_UNACCEPTED_MEMORY) += unaccepted_memory.o bitmap.o find.o
>
> Kindly ask you to test this. And it will be even more helpful if you can test
> building an running riscv64 as well :-).
I agree with this solution. With this patch applied, I have tested
EFI booting on riscv32 and riscv64. Thanks for putting this together.
You can add my tags assuming this patch is applied in the next
version.
Tested-by: Charlie Jenkins <thecharlesjenkins@gmail.com>
Reviewed-by: Charlie Jenkins <thecharlesjenkins@gmail.com>
>
> Dmitry
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
next prev parent reply other threads:[~2026-04-10 19:30 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-07 5:28 [PATCH 0/2] add riscv32 double-word shifts and library test Dmitry Antipov
2026-04-07 5:28 ` [PATCH 1/2] riscv: add platform-specific double word shifts for riscv32 Dmitry Antipov
2026-04-07 5:28 ` [PATCH 2/2] lib: kunit: add tests for __ashldi3(), __ashrdi3(), and __lshrdi3() Dmitry Antipov
2026-04-08 19:41 ` Andy Shevchenko
2026-04-09 3:38 ` [PATCH v2 0/2] add riscv32 double-word shifts and library test Dmitry Antipov
2026-04-09 3:38 ` [PATCH v2 1/2] riscv: add platform-specific double word shifts for riscv32 Dmitry Antipov
2026-04-09 23:22 ` Charlie Jenkins
2026-04-10 10:49 ` Dmitry Antipov
2026-04-10 19:30 ` Charlie Jenkins [this message]
2026-04-09 3:38 ` [PATCH v2 2/2] lib: kunit: add tests for __ashldi3(), __ashrdi3(), and __lshrdi3() Dmitry Antipov
2026-04-09 21:02 ` Charlie Jenkins
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=20260410193014.GA817331@inky.localdomain \
--to=thecharlesjenkins@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=andriy.shevchenko@intel.com \
--cc=aou@eecs.berkeley.edu \
--cc=ardb@kernel.org \
--cc=dmantipov@yandex.ru \
--cc=linux-riscv@lists.infradead.org \
--cc=lkp@intel.com \
--cc=palmer@dabbelt.com \
--cc=pjw@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