Skip to content

Commit ead5084

Browse files
mrutland-armtytso
authored andcommitted
arm64: add credited/trusted RNG support
Currently arm64 doesn't initialize the primary CRNG in a (potentially) trusted manner as we only detect the presence of the RNG once secondary CPUs are up. Now that the core RNG code distinguishes the early initialization of the primary CRNG, we can implement arch_get_random_seed_long_early() to support this. This patch does so. Signed-off-by: Mark Rutland <[email protected]> Cc: Catalin Marinas <[email protected]> Cc: Mark Brown <[email protected]> Cc: Theodore Ts'o <[email protected]> Cc: Will Deacon <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Theodore Ts'o <[email protected]>
1 parent 253d319 commit ead5084

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

arch/arm64/include/asm/archrandom.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
#ifdef CONFIG_ARCH_RANDOM
66

7+
#include <linux/bug.h>
8+
#include <linux/kernel.h>
79
#include <linux/random.h>
810
#include <asm/cpufeature.h>
911

@@ -66,6 +68,18 @@ static inline bool __init __early_cpu_has_rndr(void)
6668
return (ftr >> ID_AA64ISAR0_RNDR_SHIFT) & 0xf;
6769
}
6870

71+
static inline bool __init __must_check
72+
arch_get_random_seed_long_early(unsigned long *v)
73+
{
74+
WARN_ON(system_state != SYSTEM_BOOTING);
75+
76+
if (!__early_cpu_has_rndr())
77+
return false;
78+
79+
return __arm64_rndr(v);
80+
}
81+
#define arch_get_random_seed_long_early arch_get_random_seed_long_early
82+
6983
#else
7084

7185
static inline bool __arm64_rndr(unsigned long *v) { return false; }

0 commit comments

Comments
 (0)