Kernel: RDRAND on i386 is called twice with 32 bit register

This commit is contained in:
Bananymous 2024-03-22 12:58:38 +02:00
parent 45cea14165
commit d920785256
1 changed files with 13 additions and 1 deletions

View File

@ -20,7 +20,19 @@ namespace Kernel
if (ecx & CPUID::ECX_RDRND)
{
asm volatile("rdrand %0" : "=a"(s_rand_seed));
#if ARCH(x86_64)
asm volatile("rdrand %0" : "=r"(s_rand_seed));
#elif ARCH(i386)
uint32_t lo, hi;
asm volatile(
"rdrand %[lo];"
"rdrand %[hi];"
: [lo]"=r"(lo), [hi]"=r"(hi)
);
s_rand_seed = ((uint64_t)hi << 32) | lo;
#else
#error
#endif
dprintln("RNG seeded by RDRAND");
}
else