mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-05 22:52:22 +02: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:
committed by
Linus Groh
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
@@ -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!");
|
||||
|
||||
Reference in New Issue
Block a user