[PATCH v4 0/4] LoongArch: Implement getrandom() in vDSO

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



For the rationale to implement getrandom() in vDSO see [1].

The vDSO getrandom() needs a stack-less ChaCha20 implementation, so we
need to add architecture-specific code and wire it up with the generic
code.

The implementation is tested with the kernel vDSO selftests, which need
to be adapted as well.  The selftest changes are also included in the
series.

The vdso_test_getrandom bench-single result:

       vdso: 25000000 times in 0.501461533 seconds
       libc: 25000000 times in 6.975149458 seconds
    syscall: 25000000 times in 6.985865529 seconds

The vdso_test_getrandom bench-multi result:

       vdso: 25000000 x 256 times in 28.688809414 seconds
       libc: 25000000 x 256 times in 356.863400242 seconds
       syscall: 25000000 x 256 times in 338.562183570 seconds

[1]:https://lore.kernel.org/all/20240712014009.281406-1-Jason@xxxxxxxxx/

Cc: linux-crypto@xxxxxxxxxxxxxxx
Cc: loongarch@xxxxxxxxxxxxxxx
Cc: Jinyang He <hejinyang@xxxxxxxxxxx>
Cc: Tiezhu Yang <yangtiezhu@xxxxxxxxxxx>
Cc: Arnd Bergmann <arnd@xxxxxxxx>

[v3]->v4:
- Remove LSX implementation, which isn't much faster than the generic
  implementaion.
- Rebase onto crng/random.git:
  - Define __arch_get_k_vdso_rng_data instead of using inline asm to
    provide the _vdso_rng_data symbol in a magic way.
  - Remove memset.S.
  - Use c-getrandom-y to easily include the generic C code.
  - The benchmark results seem better than v3, maybe related to the TLS
    refactoring in random.git.
- Add patches for selftests.

[v2]->v3:
- Add a generic LoongArch implementation for which LSX isn't needed.

v1->v2:
- Properly send the series to the list.

[v3]:https://lore.kernel.org/all/20240816110717.10249-1-xry111@xxxxxxxxxxx/
[v2]:https://lore.kernel.org/all/20240815133357.35829-1-xry111@xxxxxxxxxxx/

Xi Ruoyao (4):
  LoongArch: vDSO: Wire up getrandom() vDSO implementation
  selftests/vDSO: Add --cflags for pkg-config command querying libsodium
  selftests/vDSO: Use KHDR_INCLUDES to locate UAPI headers for
    vdso_test_getrandom
  selftests/vDSO: Enable vdso getrandom tests for LoongArch

 arch/loongarch/Kconfig                      |   1 +
 arch/loongarch/include/asm/vdso/getrandom.h |  47 ++++
 arch/loongarch/include/asm/vdso/vdso.h      |   8 +
 arch/loongarch/include/asm/vdso/vsyscall.h  |  10 +
 arch/loongarch/kernel/asm-offsets.c         |  10 +
 arch/loongarch/kernel/vdso.c                |   2 +
 arch/loongarch/vdso/Makefile                |   6 +
 arch/loongarch/vdso/vdso.lds.S              |   1 +
 arch/loongarch/vdso/vgetrandom-chacha.S     | 239 ++++++++++++++++++++
 arch/loongarch/vdso/vgetrandom.c            |  12 +
 tools/arch/loongarch/vdso                   |   1 +
 tools/testing/selftests/vDSO/Makefile       |   8 +-
 12 files changed, 341 insertions(+), 4 deletions(-)
 create mode 100644 arch/loongarch/include/asm/vdso/getrandom.h
 create mode 100644 arch/loongarch/vdso/vgetrandom-chacha.S
 create mode 100644 arch/loongarch/vdso/vgetrandom.c
 create mode 120000 tools/arch/loongarch/vdso


base-commit: c64dcc01ebf2b7d5a7cb56b5c6a4b6adc2273774
-- 
2.46.0





[Index of Archives]     [Kernel]     [Gnu Classpath]     [Gnu Crypto]     [DM Crypt]     [Netfilter]     [Bugtraq]
  Powered by Linux