Kernel: Set up Regions before adding them to a Process's AddressSpace

This reduces the amount of time in which not fully-initialized Regions
are present inside an AddressSpace's region tree.
This commit is contained in:
Idan Horowitz 2022-02-10 19:55:10 +02:00
parent d9d3362722
commit 57bce8ab97
Notes: sideshowbarker 2024-07-17 19:01:40 +09:00
2 changed files with 10 additions and 12 deletions

View file

@ -106,8 +106,8 @@ ErrorOr<FlatPtr> Process::sys$fork(RegisterState& regs)
for (auto& region : address_space().regions()) {
dbgln_if(FORK_DEBUG, "fork: cloning Region({}) '{}' @ {}", region, region->name(), region->vaddr());
auto region_clone = TRY(region->try_clone());
TRY(region_clone->map(child->address_space().page_directory(), Memory::ShouldFlushTLB::No));
auto* child_region = TRY(child->address_space().add_region(move(region_clone)));
TRY(child_region->map(child->address_space().page_directory(), Memory::ShouldFlushTLB::No));
if (region == m_master_tls_region.unsafe_ptr())
child->m_master_tls_region = child_region;