mirror of
https://github.com/RGBCube/serenity
synced 2025-05-28 05:15:07 +00:00
Kernel: Pass "shared" flag to Region constructor
Before this change, we would sometimes map a region into the address space with !is_shared(), and then moments later call set_shared(true). I found this very confusing while debugging, so this patch makes us pass the initial shared flag to the Region constructor, ensuring that it's in the correct state by the time we first map the region.
This commit is contained in:
parent
1898aa8cd4
commit
5dae85afe7
10 changed files with 21 additions and 20 deletions
|
@ -163,7 +163,7 @@ Region* Process::allocate_region(VirtualAddress vaddr, size_t size, const String
|
|||
return allocate_region(range, name, prot, strategy);
|
||||
}
|
||||
|
||||
Region* Process::allocate_region_with_vmobject(const Range& range, NonnullRefPtr<VMObject> vmobject, size_t offset_in_vmobject, const String& name, int prot)
|
||||
Region* Process::allocate_region_with_vmobject(const Range& range, NonnullRefPtr<VMObject> vmobject, size_t offset_in_vmobject, const String& name, int prot, bool shared)
|
||||
{
|
||||
ASSERT(range.is_valid());
|
||||
size_t end_in_vmobject = offset_in_vmobject + range.size();
|
||||
|
@ -180,18 +180,18 @@ Region* Process::allocate_region_with_vmobject(const Range& range, NonnullRefPtr
|
|||
return nullptr;
|
||||
}
|
||||
offset_in_vmobject &= PAGE_MASK;
|
||||
auto& region = add_region(Region::create_user_accessible(this, range, move(vmobject), offset_in_vmobject, name, prot_to_region_access_flags(prot)));
|
||||
auto& region = add_region(Region::create_user_accessible(this, range, move(vmobject), offset_in_vmobject, name, prot_to_region_access_flags(prot), true, shared));
|
||||
if (!region.map(page_directory()))
|
||||
return nullptr;
|
||||
return ®ion;
|
||||
}
|
||||
|
||||
Region* Process::allocate_region_with_vmobject(VirtualAddress vaddr, size_t size, NonnullRefPtr<VMObject> vmobject, size_t offset_in_vmobject, const String& name, int prot)
|
||||
Region* Process::allocate_region_with_vmobject(VirtualAddress vaddr, size_t size, NonnullRefPtr<VMObject> vmobject, size_t offset_in_vmobject, const String& name, int prot, bool shared)
|
||||
{
|
||||
auto range = allocate_range(vaddr, size);
|
||||
if (!range.is_valid())
|
||||
return nullptr;
|
||||
return allocate_region_with_vmobject(range, move(vmobject), offset_in_vmobject, name, prot);
|
||||
return allocate_region_with_vmobject(range, move(vmobject), offset_in_vmobject, name, prot, shared);
|
||||
}
|
||||
|
||||
bool Process::deallocate_region(Region& region)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue