[PATCH v2] RISC-V: vDSO: Wire up getrandom() vDSO implementation
Alexandre Ghiti
alex at ghiti.fr
Wed Jun 4 04:45:18 PDT 2025
Hi Xi,
On 6/3/25 14:48, Xi Ruoyao wrote:
> 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.
I already sent this patch with a few fixes in my second PR for 6.16
(https://git.kernel.org/pub/scm/linux/kernel/git/alexghiti/linux.git/commit/?h=alex-for-next-sbi-3.0-rebase-6.15-rc6&id=dc5240f09bca7b5fc72ad8894d6b9321bce51139)
Can you just send the fix? I'll merge it next week in -rc2.
Thanks,
Alex
>
More information about the linux-riscv
mailing list