mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 05:08:13 +00:00
Kernel: Use RDSEED assembly snippet to seed RNG on Aarch64
There’s similar RDRAND register (encoded as ‘s3_3_c2_c4_0ʼ) to be added if needed. RNG CPU feature on Aarch64 guarantees existence of both RDSEED and RDRAND registers simultaneously—in contrast to x86-64, where respective instructions are independent of each other.
This commit is contained in:
parent
7c8e61f4d1
commit
e1c50b83e1
3 changed files with 26 additions and 0 deletions
|
@ -10,6 +10,8 @@
|
|||
#if ARCH(X86_64)
|
||||
# include <Kernel/Arch/x86_64/Time/HPET.h>
|
||||
# include <Kernel/Arch/x86_64/Time/RTC.h>
|
||||
#elif ARCH(AARCH64)
|
||||
# include <Kernel/Arch/aarch64/ASM_wrapper.h>
|
||||
#endif
|
||||
#include <Kernel/Devices/RandomDevice.h>
|
||||
#include <Kernel/Random.h>
|
||||
|
@ -59,6 +61,15 @@ UNMAP_AFTER_INIT KernelRng::KernelRng()
|
|||
current_time += 0x40b2u;
|
||||
}
|
||||
}
|
||||
#elif ARCH(AARCH64)
|
||||
if (Processor::current().has_feature(CPUFeature::RNG)) {
|
||||
dmesgln("KernelRng: Using RNDRRS as entropy source");
|
||||
for (size_t i = 0; i < pool_count * reseed_threshold; ++i) {
|
||||
add_random_event(Aarch64::Asm::read_rndrrs(), i % 32);
|
||||
}
|
||||
} else {
|
||||
dmesgln("KernelRng: No entropy source available!");
|
||||
}
|
||||
#else
|
||||
dmesgln("KernelRng: No entropy source available!");
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue