diff options
author | Andreas Kling <kling@serenityos.org> | 2021-02-08 15:45:40 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-02-08 18:27:28 +0100 |
commit | f1b5def8fd48cf09704a6d4151f9002b80354430 (patch) | |
tree | ec7af45dcfb129a0ae9ec434141d84f3faaef885 /Kernel/Thread.cpp | |
parent | b2cba3036ef83d4099d917124ad65efc955a2f68 (diff) | |
download | serenity-f1b5def8fd48cf09704a6d4151f9002b80354430.zip |
Kernel: Factor address space management out of the Process class
This patch adds Space, a class representing a process's address space.
- Each Process has a Space.
- The Space owns the PageDirectory and all Regions in the Process.
This allows us to reorganize sys$execve() so that it constructs and
populates a new Space fully before committing to it.
Previously, we would construct the new address space while still
running in the old one, and encountering an error meant we had to do
tedious and error-prone rollback.
Those problems are now gone, replaced by what's hopefully a set of much
smaller problems and missing cleanups. :^)
Diffstat (limited to 'Kernel/Thread.cpp')
-rw-r--r-- | Kernel/Thread.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/Kernel/Thread.cpp b/Kernel/Thread.cpp index 3a0fba1b4e..2dc0c7d924 100644 --- a/Kernel/Thread.cpp +++ b/Kernel/Thread.cpp @@ -108,7 +108,7 @@ Thread::Thread(NonnullRefPtr<Process> process, NonnullOwnPtr<Region> kernel_stac m_tss.gs = GDT_SELECTOR_TLS | 3; } - m_tss.cr3 = m_process->page_directory().cr3(); + m_tss.cr3 = m_process->space().page_directory().cr3(); m_kernel_stack_base = m_kernel_stack_region->vaddr().get(); m_kernel_stack_top = m_kernel_stack_region->vaddr().offset(default_kernel_stack_size).get() & 0xfffffff8u; @@ -1015,11 +1015,11 @@ KResult Thread::make_thread_specific_region(Badge<Process>) if (!process().m_master_tls_region) return KSuccess; - auto range = process().allocate_range({}, thread_specific_region_size()); + auto range = process().space().allocate_range({}, thread_specific_region_size()); if (!range.has_value()) return ENOMEM; - auto region_or_error = process().allocate_region(range.value(), "Thread-specific", PROT_READ | PROT_WRITE); + auto region_or_error = process().space().allocate_region(range.value(), "Thread-specific", PROT_READ | PROT_WRITE); if (region_or_error.is_error()) return region_or_error.error(); |