Thread (26 messages) flat view 26 messages, 4 authors, 2021-06-18

Re: [PATCH 07/11] powerpc: Add support for microwatt's hardware random number generator

From: Michael Ellerman <mpe@ellerman.id.au>
Date: 2021-06-16 13:16:32

Nicholas Piggin [off-list ref] writes:
Excerpts from Paul Mackerras's message of June 15, 2021 9:02 am:
quoted
This is accessed using the DARN instruction and should probably be
done more generically.

Signed-off-by: Paul Mackerras <redacted>
---
 arch/powerpc/include/asm/archrandom.h     | 12 +++++-
 arch/powerpc/platforms/microwatt/Kconfig  |  1 +
 arch/powerpc/platforms/microwatt/Makefile |  2 +-
 arch/powerpc/platforms/microwatt/rng.c    | 48 +++++++++++++++++++++++
 4 files changed, 61 insertions(+), 2 deletions(-)
 create mode 100644 arch/powerpc/platforms/microwatt/rng.c
diff --git a/arch/powerpc/include/asm/archrandom.h b/arch/powerpc/include/asm/archrandom.h
index 9a53e29680f4..e8ae0f7740f9 100644
--- a/arch/powerpc/include/asm/archrandom.h
+++ b/arch/powerpc/include/asm/archrandom.h
@@ -8,12 +8,22 @@
 
 static inline bool __must_check arch_get_random_long(unsigned long *v)
 {
+	if (ppc_md.get_random_seed)
+		return ppc_md.get_random_seed(v);
+
 	return false;
 }
 
 static inline bool __must_check arch_get_random_int(unsigned int *v)
 {
-	return false;
+	unsigned long val;
+	bool rc;
+
+	rc = arch_get_random_long(&val);
+	if (rc)
+		*v = val;
+
+	return rc;
 }
 
I would be happier if you didn't change this (or at least put it in its 
own patch explaining why it's not going to slow down other platforms).
It would essentially be a revert of 01c9348c7620 ("powerpc: Use hardware
RNG for arch_get_random_seed_* not arch_get_random_*")

Which would be ironic :)

cheers
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help