mbox series

[0/1] arm64: Implement archrandom.h for ARMv8.5-RNG

Message ID 20191019022048.28065-1-richard.henderson@linaro.org (mailing list archive)
Headers show
Series arm64: Implement archrandom.h for ARMv8.5-RNG | expand

Message

Richard Henderson Oct. 19, 2019, 2:20 a.m. UTC
From: Richard Henderson <rth@twiddle.net>

The ARMv8.5-RNG extension adds a hardware random number generator.
The plumbing for this is already present in the kernel; we just
have to take advantage of that.

Possible issues:

When should we use RNDRRS?  For now I use it at boot, when validating
that the implementation can produce a random number, much like other
architectures validate before enabling.  I also use it if RNDR fails.
I don't know if that's a reasonable thing to do; the generic architecture
docs are too vague about what's going on behind the scenes.

I mark ARM64_HAS_RNG as ARM64_CPUCAP_STRICT_BOOT_CPU_FEATURE so that
it is detected early, because crng_initialize() is called early.
I don't know if this is quite the right thing if some hypothetial
big.LITTLE only has the RNG on the big cpus.

Tested with QEMU.


r~


Richard Henderson (1):
  arm64: Implement archrandom.h for ARMv8.5-RNG

 Documentation/arm64/cpu-feature-registers.rst |  2 +
 arch/arm64/include/asm/archrandom.h           | 76 +++++++++++++++++++
 arch/arm64/include/asm/cpucaps.h              |  3 +-
 arch/arm64/include/asm/sysreg.h               |  1 +
 arch/arm64/kernel/cpufeature.c                | 34 +++++++++
 arch/arm64/Kconfig                            | 12 +++
 drivers/char/Kconfig                          |  4 +-
 7 files changed, 129 insertions(+), 3 deletions(-)
 create mode 100644 arch/arm64/include/asm/archrandom.h