mbox series

[0/9] Wire up getrandom() vDSO implementation on powerpc

Message ID cover.1723817900.git.christophe.leroy@csgroup.eu (mailing list archive)
Headers show
Series Wire up getrandom() vDSO implementation on powerpc | expand

Message

Christophe Leroy Aug. 16, 2024, 2:36 p.m. UTC
This series wires up getrandom() vDSO implementation on powerpc.

Tested on PPC32.

Performance on powerpc 885 (using kernel selftest):
	~# ./vdso_test_getrandom bench-single
	   vdso: 2500000 times in 7.897495392 seconds
	   libc: 2500000 times in 56.091632232 seconds
	syscall: 2500000 times in 55.704851989 seconds

Performance on powerpc 8321 (using kernel selftest):
	~# ./vdso_test_getrandom bench-single
	   vdso: 2500000 times in 2.017183250 seconds
	   libc: 2500000 times in 13.088533630 seconds
	syscall: 2500000 times in 12.952458068 seconds

Only build tested on PPC64.

It doesn't build with CONFIG_COMPAT. This is because unlike
gettimeofday.c, getrandom.c includes a lot of headers from outside
of include/vdso/ . The same work as done by
commit 8c59ab839f52 ("lib/vdso: Enable common headers") needs to
be done on lib/vdso/getrandom.c

Among the few strange things to be clarified, there is the format
on the key passed to __arch_chacha20_blocks_nostack(). In
struct vgetrandom_state it is declared as a table of u32, but in
reality it seems it is a flat storage that needs to be loaded in
reversed byte order, so it should either be defined as a table of
bytes, or as a table of __le32 but not a table of u32.

Christophe Leroy (9):
  powerpc/vdso: Don't discard rela sections
  powerpc/vdso32: Add crtsavres
  vdso: Add __arch_get_k_vdso_rng_data()
  vdso: Add missing c-getrandom-y in Makefile
  vdso: Avoid call to memset() by getrandom
  vdso: Only use MAP_DROPPABLE when VM_DROPPABLE exists
  powerpc: Add little endian variants of LHZX_BE and friends
  powerpc/vdso: Wire up getrandom() vDSO implementation
  selftests: [NOT TO BE MERGED] Modifications for testing VDSO getrandom
    implementation on PPC32

 arch/powerpc/Kconfig                          |   1 +
 arch/powerpc/include/asm/asm-compat.h         |  40 ++-
 arch/powerpc/include/asm/vdso/getrandom.h     |  61 ++++
 arch/powerpc/include/asm/vdso/vsyscall.h      |   7 +
 arch/powerpc/include/asm/vdso_datapage.h      |   2 +
 arch/powerpc/kernel/asm-offsets.c             |   1 +
 arch/powerpc/kernel/vdso/Makefile             |  44 ++-
 arch/powerpc/kernel/vdso/getrandom.S          |  62 ++++
 arch/powerpc/kernel/vdso/gettimeofday.S       |  13 -
 arch/powerpc/kernel/vdso/vdso32.lds.S         |   5 +-
 arch/powerpc/kernel/vdso/vdso64.lds.S         |   5 +-
 arch/powerpc/kernel/vdso/vgetrandom-chacha.S  | 297 ++++++++++++++++++
 arch/powerpc/kernel/vdso/vgetrandom.c         |  12 +
 arch/x86/include/asm/vdso/vsyscall.h          |   7 +
 drivers/char/random.c                         |   5 +-
 include/asm-generic/vdso/vsyscall.h           |   7 +
 include/vdso/limits.h                         |   4 +-
 lib/vdso/Makefile                             |   1 +
 lib/vdso/getrandom.c                          |  18 +-
 tools/testing/selftests/vDSO/Makefile         |   2 +-
 .../selftests/vDSO/vdso_test_getrandom.c      |   6 +-
 21 files changed, 553 insertions(+), 47 deletions(-)
 create mode 100644 arch/powerpc/include/asm/vdso/getrandom.h
 create mode 100644 arch/powerpc/kernel/vdso/getrandom.S
 create mode 100644 arch/powerpc/kernel/vdso/vgetrandom-chacha.S
 create mode 100644 arch/powerpc/kernel/vdso/vgetrandom.c

Comments

Jason A. Donenfeld Aug. 16, 2024, 9:57 p.m. UTC | #1
Hi Christophe,

Thanks for this series. I'm looking forward to taking a close look at
it. I'm currently traveling until the 26th without a laptop and no
email except for lore+lei+mutt on my phone. So I'll review this in about
1 week. But I'm very happy to see it here.

On first glance, patch number 7 isn't okay. If you want this to work on
32bit, find an available bit for VM_DROPPABLE. Otherwise, just do this
64bit-only like many new features.

Jason
Jason A. Donenfeld Aug. 16, 2024, 10:10 p.m. UTC | #2
On Fri, Aug 16, 2024 at 09:57:37PM +0000, Jason A. Donenfeld wrote:
> On first glance, patch number 7 isn't okay. If you want this to work on

Sorry, I meant 6.