[PATCH] RISC-V: vDSO: Wire up getrandom() vDSO implementation

Thomas Weißschuh thomas.weissschuh at linutronix.de
Mon Feb 24 06:07:10 PST 2025


Hi!

On Mon, Feb 24, 2025 at 08:25:41PM +0800, Xi Ruoyao wrote:
> Hook up the generic vDSO implementation to the LoongArch vDSO data page

LoongArch?

"to the generic vDSO getrandom implementation"

> by providing the required __arch_chacha20_blocks_nostack,
> __arch_get_k_vdso_rng_data, and getrandom_syscall implementations. Also
> wire up the selftests.
> 
> The benchmark result:
> 
> 	vdso: 25000000 times in 2.560024913 seconds
> 	libc: 25000000 times in 40.960524767 seconds
> 	syscall: 25000000 times in 40.380651864 seconds
> 
> 	vdso: 25000000 x 256 times in 171.830655321 seconds
> 	libc: 25000000 x 256 times in 2913.107080132 seconds
> 	syscall: 25000000 x 256 times in 2692.084323377 seconds
> 
> Note that it depends on Thomas Weißschuh's vDSO generic data storage
> implementation (now in the timers/vdso branch of tip).

The note should be below a "---" line, so it doesn't end up in the commit.

> Signed-off-by: Xi Ruoyao <xry111 at xry111.site>
> ---
>  arch/riscv/Kconfig                            |   1 +
>  arch/riscv/include/asm/vdso/getrandom.h       |  30 +++
>  arch/riscv/kernel/vdso/Makefile               |   7 +-
>  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, 294 insertions(+), 1 deletion(-)
>  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
> 
> diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
> index aa8ea53186c0..6fdd63e15fb4 100644
> --- a/arch/riscv/Kconfig
> +++ b/arch/riscv/Kconfig
> @@ -213,6 +213,7 @@ config RISCV
>  	select THREAD_INFO_IN_TASK
>  	select TRACE_IRQFLAGS_SUPPORT
>  	select UACCESS_MEMCPY if !MMU
> +	select VDSO_GETRANDOM if HAVE_GENERIC_VDSO

Broken alphabetical ordering.

>  	select USER_STACKTRACE_SUPPORT
>  	select ZONE_DMA32 if 64BIT

<snip>



More information about the linux-riscv mailing list