summaryrefslogtreecommitdiff
path: root/arch/arm64/kernel/kaslr.c
diff options
context:
space:
mode:
authorMark Brown <broonie@kernel.org>2020-01-21 15:58:53 +0300
committerWill Deacon <will@kernel.org>2020-01-22 12:54:52 +0300
commit2e8e1ea88cbcb19a77b7acb67f6ffe39cc15740c (patch)
tree24b908d1f3608e4bebf845d9b3202d83e5881beb /arch/arm64/kernel/kaslr.c
parent1a50ec0b3b2e9a83f1b1245ea37a853aac2f741c (diff)
downloadlinux-2e8e1ea88cbcb19a77b7acb67f6ffe39cc15740c.tar.xz
arm64: Use v8.5-RNG entropy for KASLR seed
When seeding KALSR on a system where we have architecture level random number generation make use of that entropy, mixing it in with the seed passed by the bootloader. Since this is run very early in init before feature detection is complete we open code rather than use archrandom.h. Signed-off-by: Mark Brown <broonie@kernel.org> Reviewed-by: Mark Rutland <mark.rutland@arm.com> Reviewed-by: Ard Biesheuvel <ardb@kernel.org> Signed-off-by: Will Deacon <will@kernel.org>
Diffstat (limited to 'arch/arm64/kernel/kaslr.c')
-rw-r--r--arch/arm64/kernel/kaslr.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/arch/arm64/kernel/kaslr.c b/arch/arm64/kernel/kaslr.c
index 2a11a962e571..53b8a4ee64ff 100644
--- a/arch/arm64/kernel/kaslr.c
+++ b/arch/arm64/kernel/kaslr.c
@@ -120,6 +120,17 @@ u64 __init kaslr_early_init(u64 dt_phys)
return 0;
}
+ /*
+ * Mix in any entropy obtainable architecturally, open coded
+ * since this runs extremely early.
+ */
+ if (__early_cpu_has_rndr()) {
+ unsigned long raw;
+
+ if (__arm64_rndr(&raw))
+ seed ^= raw;
+ }
+
if (!seed) {
kaslr_status = KASLR_DISABLED_NO_SEED;
return 0;