summaryrefslogtreecommitdiff
path: root/Kernel/VM/MemoryManager.cpp
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-08-06 07:28:35 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-08-06 07:28:35 +0200
commitda6c8fe3f89677063282d5b1d9d7b9fc13c9051b (patch)
treef1e89fe0b39e47fb10205565af2ab42a3b048d80 /Kernel/VM/MemoryManager.cpp
parent2d7a993db3d3b3ecf441e97cc4307c7aabe8b790 (diff)
downloadserenity-da6c8fe3f89677063282d5b1d9d7b9fc13c9051b.zip
Kernel: On kernel NP fault, always copy into *active* page directory
If we were using a ProcessPagingScope to temporarily go into another process's page tables, things would fall apart when hitting a kernel NP fault, since we'd clone the kernel page directory entry into the *currently active process's* page directory rather than cloning it into the *currently active* page directory.
Diffstat (limited to 'Kernel/VM/MemoryManager.cpp')
-rw-r--r--Kernel/VM/MemoryManager.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/Kernel/VM/MemoryManager.cpp b/Kernel/VM/MemoryManager.cpp
index cca4cf4e32..803f4e13b5 100644
--- a/Kernel/VM/MemoryManager.cpp
+++ b/Kernel/VM/MemoryManager.cpp
@@ -407,9 +407,11 @@ PageFaultResponse MemoryManager::handle_page_fault(const PageFault& fault)
ASSERT(fault.vaddr() != m_quickmap_addr);
if (fault.is_not_present() && fault.vaddr().get() >= 0xc0000000) {
u32 page_directory_index = (fault.vaddr().get() >> 22) & 0x3ff;
- if (kernel_page_directory().entries()[page_directory_index].is_present()) {
- dbgprintf("NP(kernel): copying new kernel mapping for L%x into process\n", fault.vaddr().get());
- current->process().page_directory().entries()[page_directory_index].copy_from({}, kernel_page_directory().entries()[page_directory_index]);
+ auto& kernel_pde = kernel_page_directory().entries()[page_directory_index];
+ if (kernel_pde.is_present()) {
+ dbgprintf("NP(kernel): copying new kernel mapping for L%x into current page directory\n", fault.vaddr().get());
+ auto* current_page_directory = reinterpret_cast<PageDirectoryEntry*>(cpu_cr3());
+ current_page_directory[page_directory_index].copy_from({}, kernel_pde);
flush_tlb(fault.vaddr().page_base());
return PageFaultResponse::Continue;
}