mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-04 05:20:30 +00:00
Kernel: Add g_cpu_supports_rdseed
CPUs which support RDRAND do not necessarily support RDSEED. This introduces a flag g_cpu_supports_rdseed which is set appropriately by CPUID. This causes Haswell CPUs in particular (and probably a lot of AMD chips) to now fail to boot with #2634, rather than an illegal instruction. It seems like the KernelRng needs either an initial reseed call or more random events added before the first call to get_good_random, but I don't feel qualified to make that kind of change.
This commit is contained in:
parent
ebbcef926a
commit
4fa6301523
Notes:
sideshowbarker
2024-07-19 05:21:50 +09:00
Author: https://github.com/3541 🔰 Commit: https://github.com/SerenityOS/serenity/commit/4fa6301523b Pull-request: https://github.com/SerenityOS/serenity/pull/2641
3 changed files with 4 additions and 1 deletions
|
@ -714,6 +714,7 @@ bool g_cpu_supports_nx;
|
|||
bool g_cpu_supports_pae;
|
||||
bool g_cpu_supports_pge;
|
||||
bool g_cpu_supports_rdrand;
|
||||
bool g_cpu_supports_rdseed;
|
||||
bool g_cpu_supports_smap;
|
||||
bool g_cpu_supports_smep;
|
||||
bool g_cpu_supports_sse;
|
||||
|
@ -736,6 +737,7 @@ void cpu_detect()
|
|||
g_cpu_supports_smap = (extended_features.ebx() & (1 << 20));
|
||||
g_cpu_supports_smep = (extended_features.ebx() & (1 << 7));
|
||||
g_cpu_supports_umip = (extended_features.ecx() & (1 << 2));
|
||||
g_cpu_supports_rdseed = (extended_features.ebx() & (1 << 18));
|
||||
}
|
||||
|
||||
void cpu_setup()
|
||||
|
|
|
@ -588,6 +588,7 @@ extern bool g_cpu_supports_nx;
|
|||
extern bool g_cpu_supports_pae;
|
||||
extern bool g_cpu_supports_pge;
|
||||
extern bool g_cpu_supports_rdrand;
|
||||
extern bool g_cpu_supports_rdseed;
|
||||
extern bool g_cpu_supports_smap;
|
||||
extern bool g_cpu_supports_smep;
|
||||
extern bool g_cpu_supports_sse;
|
||||
|
|
|
@ -44,7 +44,7 @@ KernelRng& KernelRng::the()
|
|||
|
||||
KernelRng::KernelRng()
|
||||
{
|
||||
if (g_cpu_supports_rdrand) {
|
||||
if (g_cpu_supports_rdseed) {
|
||||
for (size_t i = 0; i < resource().pool_count * resource().reseed_threshold; ++i) {
|
||||
u32 value = 0;
|
||||
asm volatile(
|
||||
|
|
Loading…
Reference in a new issue