1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 03:27:44 +00:00

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.
This commit is contained in:
Andreas Kling 2022-08-23 20:30:12 +02:00
parent d3e8eb5918
commit da24a937f5
6 changed files with 212 additions and 265 deletions

View file

@ -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();
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 {};
});
});
if (&region == m_master_tls_region.unsafe_ptr())
child->m_master_tls_region = TRY(child_region->try_make_weak_ptr());
}
return {};
});
}));