mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-04-25 22:13:13 +00:00
Kernel: Use the CPU's NX bit to enforce PROT_EXEC on memory mappings
Now that we have PAE support, we can ask the CPU to crash processes for trying to execute non-executable memory. This is pretty cool! :^)
This commit is contained in:
@@ -167,6 +167,13 @@ void MemoryManager::initialize_paging()
|
||||
"orl $0x20, %eax\n"
|
||||
"mov %eax, %cr4\n");
|
||||
|
||||
// Turn on IA32_EFER.NXE
|
||||
asm volatile(
|
||||
"movl $0xc0000080, %ecx\n"
|
||||
"rdmsr\n"
|
||||
"orl $0x800, %eax\n"
|
||||
"wrmsr\n");
|
||||
|
||||
asm volatile("movl %%eax, %%cr3" ::"a"(kernel_page_directory().cr3()));
|
||||
asm volatile(
|
||||
"movl %%cr0, %%eax\n"
|
||||
|
||||
Reference in New Issue
Block a user