core/x86_64: Enable the NX bit before using it

Spent an embarrassing amount of time trying to figure out why there was a page fault with "reserved bits set". Turns out, I had set the NX bit without enabling it.
This commit is contained in:
Gabriel 2025-02-15 22:22:04 +01:00
parent 36b9832053
commit f93158645b

View File

@ -5,10 +5,21 @@ const interrupts = @import("interrupts.zig");
pub const PAGE_SIZE = 4096; pub const PAGE_SIZE = 4096;
// FIXME: Check if it's supported first.
fn enableNX() void {
asm volatile (
\\ mov $0xC0000080, %rcx
\\ rdmsr
\\ or $0x800, %eax
\\ wrmsr
);
}
// Initialize platform-specific components. // Initialize platform-specific components.
pub fn platformInit() void { pub fn platformInit() void {
gdt.setupGDT(); gdt.setupGDT();
idt.setupIDT(); idt.setupIDT();
enableNX();
} }
// Initialize platform-specific components just before beginning multitasking. // Initialize platform-specific components just before beginning multitasking.