Kernel: Flush the TLB (page only) when copying in a new kernel mapping

Not flushing the TLB here puts us in an infinite page fault loop.
This commit is contained in:
Andreas Kling 2019-08-04 21:20:34 +02:00
parent 72798519cb
commit b5f1a4ac07
Notes: sideshowbarker 2024-07-19 12:53:20 +09:00
2 changed files with 3 additions and 2 deletions

View file

@ -408,8 +408,9 @@ PageFaultResponse MemoryManager::handle_page_fault(const PageFault& fault)
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()) {
current->process().page_directory().entries()[page_directory_index].copy_from({}, kernel_page_directory().entries()[page_directory_index]);
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]);
flush_tlb(fault.vaddr().page_base());
return PageFaultResponse::Continue;
}
}

View file

@ -28,7 +28,7 @@ public:
u8* as_ptr() { return reinterpret_cast<u8*>(m_address); }
const u8* as_ptr() const { return reinterpret_cast<const u8*>(m_address); }
u32 page_base() const { return m_address & 0xfffff000; }
VirtualAddress page_base() const { return VirtualAddress(m_address & 0xfffff000); }
private:
u32 m_address { 0 };