mirror of
https://github.com/RGBCube/serenity
synced 2025-05-28 19:55:10 +00:00
Kernel/aarch64: Add TimeManagement fallback entropy source to Random.cpp
The emulated aarch64 CPU does not contain the RNG cpu feature, so the random number generator was not seeded. This commit adds a fallback to use TimeManagement as a entropy source, such that get_good_random_bytes works, which is needed for running the first userspace application on aarch64.
This commit is contained in:
parent
5781d58fe8
commit
5aba83e6ba
1 changed files with 8 additions and 1 deletions
|
@ -68,7 +68,14 @@ UNMAP_AFTER_INIT KernelRng::KernelRng()
|
|||
add_random_event(Aarch64::Asm::read_rndrrs(), i % 32);
|
||||
}
|
||||
} else {
|
||||
dmesgln("KernelRng: No entropy source available!");
|
||||
// Fallback to TimeManagement as entropy
|
||||
dmesgln("KernelRng: Using bad entropy source TimeManagement");
|
||||
auto current_time = static_cast<u64>(TimeManagement::the().now().to_milliseconds());
|
||||
for (size_t i = 0; i < pool_count * reseed_threshold; ++i) {
|
||||
add_random_event(current_time, i % 32);
|
||||
current_time *= 0x574au;
|
||||
current_time += 0x40b2u;
|
||||
}
|
||||
}
|
||||
#else
|
||||
dmesgln("KernelRng: No entropy source available!");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue