diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-11-03 20:48:35 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-11-03 21:11:08 +0100 |
commit | 3dce0f23f4d38a6abff2324a0ec3314e0f265a46 (patch) | |
tree | 7e13471321b4e7d1332374581b5575b1dd361e29 /Kernel | |
parent | 2cfc43c9821e1d20c0a320d069cf21f7a5443f6d (diff) | |
download | serenity-3dce0f23f4d38a6abff2324a0ec3314e0f265a46.zip |
Kernel: Regions should be mapped into a PageDirectory, not a Process
This patch changes the parameter to Region::map() to be a PageDirectory
since that matches how we think about the memory model:
Regions are views onto VMObjects, and are mapped into PageDirectories.
Each Process has a PageDirectory. The kernel also has a PageDirectory.
Diffstat (limited to 'Kernel')
-rw-r--r-- | Kernel/Process.cpp | 10 | ||||
-rw-r--r-- | Kernel/VM/MemoryManager.cpp | 2 | ||||
-rw-r--r-- | Kernel/VM/Region.cpp | 4 | ||||
-rw-r--r-- | Kernel/VM/Region.h | 2 |
4 files changed, 9 insertions, 9 deletions
diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp index 383f7e1f96..74a643ee6e 100644 --- a/Kernel/Process.cpp +++ b/Kernel/Process.cpp @@ -122,7 +122,7 @@ Region* Process::allocate_region(VirtualAddress vaddr, size_t size, const String if (!range.is_valid()) return nullptr; m_regions.append(Region::create_user_accessible(range, name, prot_to_region_access_flags(prot))); - m_regions.last().map(*this); + m_regions.last().map(page_directory()); if (commit) m_regions.last().commit(); return &m_regions.last(); @@ -134,7 +134,7 @@ Region* Process::allocate_file_backed_region(VirtualAddress vaddr, size_t size, if (!range.is_valid()) return nullptr; m_regions.append(Region::create_user_accessible(range, inode, name, prot_to_region_access_flags(prot))); - m_regions.last().map(*this); + m_regions.last().map(page_directory()); return &m_regions.last(); } @@ -145,7 +145,7 @@ Region* Process::allocate_region_with_vmo(VirtualAddress vaddr, size_t size, Non return nullptr; offset_in_vmo &= PAGE_MASK; m_regions.append(Region::create_user_accessible(range, move(vmo), offset_in_vmo, name, prot_to_region_access_flags(prot))); - m_regions.last().map(*this); + m_regions.last().map(page_directory()); return &m_regions.last(); } @@ -267,7 +267,7 @@ int Process::sys$munmap(void* addr, size_t size) // And finally we map the new region(s). for (auto* new_region : new_regions) { - new_region->map(*this); + new_region->map(page_directory()); } return 0; } @@ -313,7 +313,7 @@ Process* Process::fork(RegisterDump& regs) dbg() << "fork: cloning Region{" << ®ion << "} '" << region.name() << "' @ " << region.vaddr(); #endif child->m_regions.append(region.clone()); - child->m_regions.last().map(*child); + child->m_regions.last().map(child->page_directory()); if (®ion == m_master_tls_region) child->m_master_tls_region = &child->m_regions.last(); diff --git a/Kernel/VM/MemoryManager.cpp b/Kernel/VM/MemoryManager.cpp index e56d0e97f7..bb3adcfe88 100644 --- a/Kernel/VM/MemoryManager.cpp +++ b/Kernel/VM/MemoryManager.cpp @@ -483,7 +483,7 @@ OwnPtr<Region> MemoryManager::allocate_kernel_region(size_t size, const StringVi region = Region::create_user_accessible(range, name, PROT_READ | PROT_WRITE | PROT_EXEC); else region = Region::create_kernel_only(range, name, PROT_READ | PROT_WRITE | PROT_EXEC); - MM.map_region_at_address(*m_kernel_page_directory, *region, range.base()); + region->map(kernel_page_directory()); // FIXME: It would be cool if these could zero-fill on demand instead. if (should_commit) region->commit(); diff --git a/Kernel/VM/Region.cpp b/Kernel/VM/Region.cpp index 7d79181147..e190135086 100644 --- a/Kernel/VM/Region.cpp +++ b/Kernel/VM/Region.cpp @@ -216,7 +216,7 @@ void Region::unmap(ShouldDeallocateVirtualMemoryRange deallocate_range) release_page_directory(); } -void Region::map(Process& process) +void Region::map(PageDirectory& page_directory) { - MM.map_region_at_address(process.page_directory(), *this, vaddr()); + MM.map_region_at_address(page_directory, *this, vaddr()); } diff --git a/Kernel/VM/Region.h b/Kernel/VM/Region.h index 6c90415bda..cc8c276640 100644 --- a/Kernel/VM/Region.h +++ b/Kernel/VM/Region.h @@ -114,7 +114,7 @@ public: m_access &= ~Access::Write; } - void map(Process&); + void map(PageDirectory&); enum class ShouldDeallocateVirtualMemoryRange { No, Yes, |