Check if CPU 0 is active too

This commit is contained in:
Alex 2022-11-17 19:10:21 +02:00
parent 13f93b8e21
commit 35c4c3bbd5
Signed by untrusted user who does not match committer: enderice2
GPG Key ID: EACC3AD603BAB4DD

View File

@ -33,7 +33,7 @@ CPUData *GetCurrentCPU()
CPUData *data = (CPUData *)CPU::x64::rdmsr(CPU::x64::MSR_GS_BASE); CPUData *data = (CPUData *)CPU::x64::rdmsr(CPU::x64::MSR_GS_BASE);
if (data == nullptr && Interrupts::apic[0]) if (data == nullptr && Interrupts::apic[0])
data = &CPUs[((APIC::APIC *)Interrupts::apic[0])->Read(APIC::APIC_ID) >> 24]; data = &CPUs[((APIC::APIC *)Interrupts::apic[0])->Read(APIC::APIC_ID) >> 24];
if (data == nullptr) if (data == nullptr)
return nullptr; // The caller should handle this. return nullptr; // The caller should handle this.
@ -41,7 +41,10 @@ CPUData *GetCurrentCPU()
if (!data->IsActive) if (!data->IsActive)
{ {
error("CPU %d is not active!", data->ID); error("CPU %d is not active!", data->ID);
return &CPUs[0]; if ((&CPUs[0])->IsActive)
return &CPUs[0];
else
return nullptr; // We are in trouble.
} }
assert(data->Checksum == CPU_DATA_CHECKSUM); // This should never happen. assert(data->Checksum == CPU_DATA_CHECKSUM); // This should never happen.
return data; return data;