[PATCH v2] RISC-V: vDSO: Wire up getrandom() vDSO implementation
Xi Ruoyao
xry111 at xry111.site
Tue Jun 3 05:48:15 PDT 2025
On Fri, 2025-05-23 at 12:06 +0200, Alexandre Ghiti wrote:
> On 5/23/25 10:02, Xi Ruoyao wrote:
> > On Fri, 2025-05-23 at 10:01 +0200, Alexandre Ghiti wrote:
> > > Hi Xi,
> > >
> > > On 4/11/25 10:04, Thomas Weißschuh wrote:
> > > > On Fri, Apr 11, 2025 at 10:46:00AM +0800, Xi Ruoyao wrote:
> > > > > Hook up the generic vDSO implementation to the generic vDSO
> > > > > getrandom
> > > > > implementation by providing the required
> > > > > __arch_chacha20_blocks_nostack
> > > > > and getrandom_syscall implementations. Also wire up the selftests.
> > > > >
> > > > > The benchmark result:
> > > > >
> > > > > vdso: 25000000 times in 2.466341333 seconds
> > > > > libc: 25000000 times in 41.447720005 seconds
> > > > > syscall: 25000000 times in 41.043926672 seconds
> > > > >
> > > > > vdso: 25000000 x 256 times in 162.286219353 seconds
> > > > > libc: 25000000 x 256 times in 2953.855018685 seconds
> > > > > syscall: 25000000 x 256 times in 2796.268546000 seconds
> > > > >
> > > > > Signed-off-by: Xi Ruoyao <xry111 at xry111.site>
> > > > > ---
> > > > >
> > > > > [v1]->v2:
> > > > > - Fix the commit message.
> > > > > - Only build the vDSO getrandom code if CONFIG_VDSO_GETRANDOM, to
> > > > > unbreak RV32 build.
> > > > > - Likewise, only enable the selftest if __riscv_xlen == 64.
> > > > >
> > > > > [v1]:
> > > > > https://lore.kernel.org/all/20250224122541.65045-1-xry111@xry111.site/
> > > > >
> > > > > arch/riscv/Kconfig | 1 +
> > > > > arch/riscv/include/asm/vdso/getrandom.h | 30 +++
> > > > > arch/riscv/kernel/vdso/Makefile | 12 +
> > > > > arch/riscv/kernel/vdso/getrandom.c | 10 +
> > > > > arch/riscv/kernel/vdso/vdso.lds.S | 1 +
> > > > > arch/riscv/kernel/vdso/vgetrandom-chacha.S | 244
> > > > > ++++++++++++++++++
> > > > > .../selftests/vDSO/vgetrandom-chacha.S | 2 +
> > > > > 7 files changed, 300 insertions(+)
> > > > > create mode 100644 arch/riscv/include/asm/vdso/getrandom.h
> > > > > create mode 100644 arch/riscv/kernel/vdso/getrandom.c
> > > > > create mode 100644 arch/riscv/kernel/vdso/vgetrandom-chacha.S
> > > > <snip>
> > > >
> > > > > diff --git a/arch/riscv/kernel/vdso/vdso.lds.S
> > > > > b/arch/riscv/kernel/vdso/vdso.lds.S
> > > > > index 8e86965a8aae..abc69cda0445 100644
> > > > > --- a/arch/riscv/kernel/vdso/vdso.lds.S
> > > > > +++ b/arch/riscv/kernel/vdso/vdso.lds.S
> > > > > @@ -80,6 +80,7 @@ VERSION
> > > > > #ifndef COMPAT_VDSO
> > > > > __vdso_riscv_hwprobe;
> > > > > #endif
> > > > > + __vdso_getrandom;
> > > > For consistency this could be gated behind CONFIG_VDSO_GETRANDOM.
> > >
> > > Nathan sent a fix for this here:
> > >
> > > https://lore.kernel.org/all/20250423-riscv-fix-compat_vdso-lld-v2-1-b7bbbc244501@kernel.org/
> > I've given it an R-b. Do you prefer me to squash the patches and keep
> > the SoB of both I and Nathan?
>
> Hmm I was about to send a new PR today after the CI passes, I mentioned
> Nathan's patch in the squash so he keeps credit for the fix. Unless you
> can send something today, I'll keep my squashed patch.
Palmer has reverted this in for-next and Thomas just informed me another
mistake in the code at https://lore.kernel.org/all/20250603-loongarch-
vdso-syscall-v1-1-6d12d6dfbdd0 at linutronix.de/.
I'll try to sort things up and send v3 in the week.
--
Xi Ruoyao <xry111 at xry111.site>
School of Aerospace Science and Technology, Xidian University
More information about the linux-riscv
mailing list