diff --git a/src/arch/aarch64/kernel/processor.rs b/src/arch/aarch64/kernel/processor.rs index 3a62f128a7..6eb7a43899 100644 --- a/src/arch/aarch64/kernel/processor.rs +++ b/src/arch/aarch64/kernel/processor.rs @@ -1,6 +1,7 @@ use core::arch::asm; use core::{fmt, mem}; +use aarch64_cpu::asm::random::ArmRng; use aarch64_cpu::registers::*; use hermit_sync::{Lazy, OnceCell, without_interrupts}; @@ -196,8 +197,16 @@ impl fmt::Display for CpuFrequency { } } +static RNG: Lazy> = Lazy::new(ArmRng::new); + pub fn seed_entropy() -> Option<[u8; 32]> { - None + let rng = RNG.as_ref()?; + let mut buf = [0u8; 32]; + for word in buf.chunks_mut(8) { + let value = rng.rndr().or(None).unwrap().to_ne_bytes(); + word.copy_from_slice(&value); + } + Some(buf) } /// The halt function stops the processor until the next interrupt arrives