]> www.infradead.org Git - users/jedix/linux-maple.git/commit
powerpc/vdso: Wire up getrandom() vDSO implementation on VDSO32
authorChristophe Leroy <christophe.leroy@csgroup.eu>
Mon, 2 Sep 2024 19:17:21 +0000 (21:17 +0200)
committerJason A. Donenfeld <Jason@zx2c4.com>
Fri, 13 Sep 2024 15:28:36 +0000 (17:28 +0200)
commit53cee505ae0c4d19a2c894501a363782410c4a29
tree58390daf2f6a47ae4990b96e35e22d82826f0b35
parenta6b67eb09963af29991625862cbb4f56b85954ed
powerpc/vdso: Wire up getrandom() vDSO implementation on VDSO32

To be consistent with other VDSO functions, the function is called
__kernel_getrandom()

__arch_chacha20_blocks_nostack() fonction is implemented basically
with 32 bits operations. It performs 4 QUARTERROUND operations in
parallele. There are enough registers to avoid using the stack:

On input:
r3: output bytes
r4: 32-byte key input
r5: 8-byte counter input/output
r6: number of 64-byte blocks to write to output

During operation:
stack: pointer to counter (r5) and non-volatile registers (r14-131)
r0: counter of blocks (initialised with r6)
r4: Value '4' after key has been read, used for indexing
r5-r12: key
r14-r15: block counter
r16-r31: chacha state

At the end:
r0, r6-r12: Zeroised
r5, r14-r31: Restored

Performance on powerpc 885 (using kernel selftest):
~# ./vdso_test_getrandom bench-single
   vdso: 25000000 times in 62.938002291 seconds
   libc: 25000000 times in 535.581916866 seconds
syscall: 25000000 times in 531.525042806 seconds

Performance on powerpc 8321 (using kernel selftest):
~# ./vdso_test_getrandom bench-single
   vdso: 25000000 times in 16.899318858 seconds
   libc: 25000000 times in 131.050596522 seconds
syscall: 25000000 times in 129.794790389 seconds

This first patch adds support for VDSO32. As selftests cannot easily
be generated only for VDSO32, and because the following patch brings
support for VDSO64 anyway, this patch opts out all code in
__arch_chacha20_blocks_nostack() so that vdso_test_chacha will not
fail to compile and will not crash on PPC64/PPC64LE, allthough the
selftest itself will fail.

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Acked-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
13 files changed:
arch/powerpc/Kconfig
arch/powerpc/include/asm/mman.h
arch/powerpc/include/asm/vdso/getrandom.h [new file with mode: 0644]
arch/powerpc/include/asm/vdso/vsyscall.h
arch/powerpc/include/asm/vdso_datapage.h
arch/powerpc/kernel/asm-offsets.c
arch/powerpc/kernel/vdso/Makefile
arch/powerpc/kernel/vdso/getrandom.S [new file with mode: 0644]
arch/powerpc/kernel/vdso/vdso32.lds.S
arch/powerpc/kernel/vdso/vgetrandom-chacha.S [new file with mode: 0644]
arch/powerpc/kernel/vdso/vgetrandom.c [new file with mode: 0644]
tools/arch/powerpc/vdso [new symlink]
tools/testing/selftests/vDSO/Makefile