Kernel: Move CPU feature detection to Arch/x86/CPU.{cpp.h}

We now refuse to boot on machines that don't support PAE since all
of our paging code depends on it.

Also let's only enable SSE and PGE support if the CPU advertises it.
This commit is contained in:
Andreas Kling 2020-01-01 12:56:21 +01:00
commit 5aeaab601e
Notes: sideshowbarker 2024-07-19 10:29:46 +09:00
6 changed files with 70 additions and 44 deletions

View file

@ -283,7 +283,7 @@ void page_fault_handler(RegisterDump regs)
current->process().name().characters(),
current->pid(),
current->tid(),
regs.exception_code & PageFaultFlags::ReservedBitViolation ? "reserved bit violation / " : "",
regs.exception_code & PageFaultFlags::ReservedBitViolation ? "reserved bit violation / " : "",
regs.exception_code & PageFaultFlags::InstructionFetch ? "instruction fetch / " : "",
regs.exception_code & PageFaultFlags::Write ? "write to" : "read from",
fault_address);
@ -543,3 +543,23 @@ void sse_init()
"orl $0x600, %eax\n"
"mov %eax, %cr4\n");
}
bool g_cpu_supports_nx;
bool g_cpu_supports_pae;
bool g_cpu_supports_pge;
bool g_cpu_supports_smep;
bool g_cpu_supports_sse;
void detect_cpu_features()
{
CPUID processor_info(0x1);
g_cpu_supports_pae = (processor_info.edx() & (1 << 6));
g_cpu_supports_pge = (processor_info.edx() & (1 << 13));
g_cpu_supports_sse = (processor_info.edx() & (1 << 25));
CPUID extended_processor_info(0x80000001);
g_cpu_supports_nx = (extended_processor_info.edx() & (1 << 20));
CPUID extended_features(0x7);
g_cpu_supports_smep = (extended_features.ebx() & (1 << 7));
}