summaryrefslogtreecommitdiff
path: root/Kernel/VM/MemoryManager.cpp
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-12-25 11:44:32 +0100
committerAndreas Kling <awesomekling@gmail.com>2019-12-25 13:35:57 +0100
commitce5f7f6c07aa40137c83b7ceda7e36fc3dd1b2bc (patch)
tree3b3778952cebf63f13e2d160367a7ffd46a3a57f /Kernel/VM/MemoryManager.cpp
parentc22a4301ed0341477295d7ae481b1223d2428eaa (diff)
downloadserenity-ce5f7f6c07aa40137c83b7ceda7e36fc3dd1b2bc.zip
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! :^)
Diffstat (limited to 'Kernel/VM/MemoryManager.cpp')
-rw-r--r--Kernel/VM/MemoryManager.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/Kernel/VM/MemoryManager.cpp b/Kernel/VM/MemoryManager.cpp
index a3e792d6cb..42c33ae181 100644
--- a/Kernel/VM/MemoryManager.cpp
+++ b/Kernel/VM/MemoryManager.cpp
@@ -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"