1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 19:37:35 +00:00

Give each task its own page directory.

This isn't finished but I'll commit as I go. We need to get to where context
switching only needs to change CR3 and everything's ready to go.

My basic idea is:
- The first 4 kB is off-limits. This catches null dereferences.
- Up to the 4 MB mark is identity-mapped and kernel-only.
- The rest is available to everyone!

While the first 4 MB is only available to the kernel, it's still mapped in
every process, for convenience when entering the kernel.
This commit is contained in:
Andreas Kling 2018-11-01 09:01:51 +01:00
parent cddd2f37e9
commit 1da0a7c949
7 changed files with 47 additions and 15 deletions

View file

@ -408,6 +408,9 @@ Task::Task(String&& name, uid_t uid, gid_t gid, pid_t parentPID, RingLevel ring,
, m_tty(tty)
, m_parentPID(parentPID)
{
m_pageDirectory = (dword*)kmalloc_page_aligned(4096);
MM.populatePageDirectory(*this);
if (tty) {
m_fileHandles.append(tty->open(O_RDONLY)); // stdin
m_fileHandles.append(tty->open(O_WRONLY)); // stdout
@ -449,7 +452,7 @@ Task::Task(String&& name, uid_t uid, gid_t gid, pid_t parentPID, RingLevel ring,
m_tss.ss = ss;
m_tss.cs = cs;
m_tss.cr3 = MM.pageDirectoryBase().get();
m_tss.cr3 = (dword)m_pageDirectory;
if (isRing0()) {
// FIXME: This memory is leaked.