summaryrefslogtreecommitdiff
path: root/Kernel/Syscalls
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2022-08-23 20:30:12 +0200
committerAndreas Kling <kling@serenityos.org>2022-08-24 14:57:51 +0200
commitda24a937f5a0d647777a5161880625c34fe37234 (patch)
tree939d709f81ca58b452dcf6b9391b44b08006da72 /Kernel/Syscalls
parentd3e8eb591877f7402a9deac627d57dd92b109e5e (diff)
downloadserenity-da24a937f5a0d647777a5161880625c34fe37234.zip
Kernel: Don't wrap AddressSpace's RegionTree in SpinlockProtected
Now that AddressSpace itself is always SpinlockProtected, we don't need to also wrap the RegionTree. Whoever has the AddressSpace locked is free to poke around its tree.
Diffstat (limited to 'Kernel/Syscalls')
-rw-r--r--Kernel/Syscalls/fork.cpp28
1 files changed, 12 insertions, 16 deletions
diff --git a/Kernel/Syscalls/fork.cpp b/Kernel/Syscalls/fork.cpp
index 130a491294..d91df90824 100644
--- a/Kernel/Syscalls/fork.cpp
+++ b/Kernel/Syscalls/fork.cpp
@@ -123,23 +123,19 @@ ErrorOr<FlatPtr> Process::sys$fork(RegisterState& regs)
#endif
TRY(address_space().with([&](auto& parent_space) {
- return child->address_space().with([&](auto& child_space) {
+ return child->address_space().with([&](auto& child_space) -> ErrorOr<void> {
child_space->set_enforces_syscall_regions(parent_space->enforces_syscall_regions());
- return parent_space->region_tree().with([&](auto& parent_region_tree) -> ErrorOr<void> {
- return child_space->region_tree().with([&](auto& child_region_tree) -> ErrorOr<void> {
- for (auto& region : parent_region_tree.regions()) {
- dbgln_if(FORK_DEBUG, "fork: cloning Region '{}' @ {}", region.name(), region.vaddr());
- auto region_clone = TRY(region.try_clone());
- TRY(region_clone->map(child_space->page_directory(), Memory::ShouldFlushTLB::No));
- TRY(child_region_tree.place_specifically(*region_clone, region.range()));
- auto* child_region = region_clone.leak_ptr();
-
- if (&region == m_master_tls_region.unsafe_ptr())
- child->m_master_tls_region = TRY(child_region->try_make_weak_ptr());
- }
- return {};
- });
- });
+ for (auto& region : parent_space->region_tree().regions()) {
+ dbgln_if(FORK_DEBUG, "fork: cloning Region '{}' @ {}", region.name(), region.vaddr());
+ auto region_clone = TRY(region.try_clone());
+ TRY(region_clone->map(child_space->page_directory(), Memory::ShouldFlushTLB::No));
+ TRY(child_space->region_tree().place_specifically(*region_clone, region.range()));
+ auto* child_region = region_clone.leak_ptr();
+
+ if (&region == m_master_tls_region.unsafe_ptr())
+ child->m_master_tls_region = TRY(child_region->try_make_weak_ptr());
+ }
+ return {};
});
}));