mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-03 04:50:29 +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
Notes:
sideshowbarker
2024-07-17 02:28:18 +09:00
Author: https://github.com/FireFox317 Commit: https://github.com/SerenityOS/serenity/commit/5aba83e6ba Pull-request: https://github.com/SerenityOS/serenity/pull/17249 Reviewed-by: https://github.com/linusg Reviewed-by: https://github.com/nico ✅ Reviewed-by: https://github.com/supercomputer7
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…
Reference in a new issue