mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-28 21:54:40 +03:00
Teach MM to flush individual TLB entries only.
This commit is contained in:
parent
3676214a62
commit
44045b258c
Notes:
sideshowbarker
2024-07-19 18:39:56 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/44045b258cf
@ -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;
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,8 @@ private:
|
||||
~MemoryManager();
|
||||
|
||||
void initializePaging();
|
||||
void flushTLB();
|
||||
void flushEntireTLB();
|
||||
void flushTLB(LinearAddress);
|
||||
|
||||
void protectMap(LinearAddress, size_t length);
|
||||
void identityMap(LinearAddress, size_t length);
|
||||
|
Loading…
Reference in New Issue
Block a user