diff options
author | Andreas Kling <awesomekling@gmail.com> | 2018-10-23 15:53:11 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2018-10-23 15:53:11 +0200 |
commit | 44045b258cf83a8aa987ca7b2255c1382af060be (patch) | |
tree | 65a97507c4808ff991221091467e4e73f08385fa /Kernel/MemoryManager.cpp | |
parent | 3676214a6288ccaacd8bb29c7ef02c51bb05ff5d (diff) | |
download | serenity-44045b258cf83a8aa987ca7b2255c1382af060be.zip |
Teach MM to flush individual TLB entries only.
Diffstat (limited to 'Kernel/MemoryManager.cpp')
-rw-r--r-- | Kernel/MemoryManager.cpp | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/Kernel/MemoryManager.cpp b/Kernel/MemoryManager.cpp index 0587e51d1c..1ad4c738ff 100644 --- a/Kernel/MemoryManager.cpp +++ b/Kernel/MemoryManager.cpp @@ -92,8 +92,8 @@ void MemoryManager::protectMap(LinearAddress linearAddress, size_t length) pte.setUserAllowed(false); pte.setPresent(false); pte.setWritable(false); + flushTLB(pteAddress); } - flushTLB(); } void MemoryManager::identityMap(LinearAddress linearAddress, size_t length) @@ -106,8 +106,8 @@ void MemoryManager::identityMap(LinearAddress linearAddress, size_t length) pte.setUserAllowed(true); pte.setPresent(true); pte.setWritable(true); + flushTLB(pteAddress); } - flushTLB(); } void MemoryManager::initialize() @@ -155,11 +155,11 @@ byte* MemoryManager::quickMapOnePage(PhysicalAddress physicalAddress) pte.setPhysicalPageBase(physicalAddress.pageBase()); pte.setPresent(true); pte.setWritable(true); - flushTLB(); + flushTLB(LinearAddress(4 * MB)); return (byte*)(4 * MB); } -void MemoryManager::flushTLB() +void MemoryManager::flushEntireTLB() { asm volatile( "mov %cr3, %eax\n" @@ -167,6 +167,11 @@ void MemoryManager::flushTLB() ); } +void MemoryManager::flushTLB(LinearAddress laddr) +{ + asm volatile("invlpg %0": :"m" (*(char*)laddr.get())); +} + bool MemoryManager::unmapRegion(Task& task, Task::Region& region) { auto& zone = *region.zone; @@ -177,10 +182,9 @@ bool MemoryManager::unmapRegion(Task& task, Task::Region& region) pte.setPresent(false); pte.setWritable(false); pte.setUserAllowed(false); - + flushTLB(laddr); // kprintf("MM: >> Unmapped L%x => P%x <<\n", laddr, zone.m_pages[i].get()); } - flushTLB(); return true; } @@ -203,10 +207,9 @@ bool MemoryManager::mapRegion(Task& task, Task::Region& region) pte.setPresent(true); pte.setWritable(true); pte.setUserAllowed(!task.isRing0()); - + flushTLB(laddr); //kprintf("MM: >> Mapped L%x => P%x <<\n", laddr, zone.m_pages[i].get()); } - flushTLB(); return true; } |