Flush the TLB after modifying page tables.

This is a very inefficient naive implementation, but it gets us going.
Mapping tasks in and out of a shared address space now totally works.
This commit is contained in:
Andreas Kling 2018-10-23 11:03:56 +02:00
parent 56ed448424
commit 98f76f0153
3 changed files with 11 additions and 2 deletions

View file

@ -156,6 +156,14 @@ byte* MemoryManager::quickMapOnePage(PhysicalAddress physicalAddress)
return (byte*)(4 * MB);
}
void MemoryManager::flushTLB()
{
asm volatile(
"mov %cr3, %eax\n"
"mov %eax, %cr3\n"
);
}
bool MemoryManager::unmapRegion(Task& task, Task::Region& region)
{
auto& zone = *region.zone;
@ -169,6 +177,7 @@ bool MemoryManager::unmapRegion(Task& task, Task::Region& region)
// kprintf("MM: >> Unmapped L%x => P%x <<\n", laddr, zone.m_pages[i].get());
}
flushTLB();
return true;
}
@ -194,6 +203,7 @@ bool MemoryManager::mapRegion(Task& task, Task::Region& region)
//kprintf("MM: >> Mapped L%x => P%x <<\n", laddr, zone.m_pages[i].get());
}
flushTLB();
return true;
}

View file

@ -60,6 +60,7 @@ private:
~MemoryManager();
void initializePaging();
void flushTLB();
void protectMap(LinearAddress, size_t length);
void identityMap(LinearAddress, size_t length);

View file

@ -168,8 +168,6 @@ static void init_stage2()
}
#endif
//auto* idTask = Task::create("/bin/id", (uid_t)209, (gid_t)1985);
auto* shTask = Task::create("/bin/sh", (uid_t)100, (gid_t)100);
//new Task(motd_main, "motd", IPC::Handle::MotdTask, Task::Ring0);