mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 10:58:12 +00:00
Kernel: Track user accessibility per Region.
Region now has is_user_accessible(), which informs the memory manager how to map these pages. Previously, we were just passing a "bool user_allowed" to various functions and I'm not at all sure that any of that was correct. All the Region constructors are now hidden, and you must go through one of these helpers to construct a region: - Region::create_user_accessible(...) - Region::create_kernel_only(...) That ensures that we don't accidentally create a Region without specifying user accessibility. :^)
This commit is contained in:
parent
4547a301c4
commit
5b2447a27b
6 changed files with 73 additions and 30 deletions
|
@ -99,19 +99,19 @@ Region* Process::allocate_region(VirtualAddress vaddr, size_t size, const String
|
|||
auto range = allocate_range(vaddr, size);
|
||||
if (!range.is_valid())
|
||||
return nullptr;
|
||||
m_regions.append(adopt(*new Region(range, move(name), prot_to_region_access_flags(prot))));
|
||||
m_regions.append(Region::create_user_accessible(range, name, prot_to_region_access_flags(prot)));
|
||||
MM.map_region(*this, m_regions.last());
|
||||
if (commit)
|
||||
m_regions.last().commit();
|
||||
return &m_regions.last();
|
||||
}
|
||||
|
||||
Region* Process::allocate_file_backed_region(VirtualAddress vaddr, size_t size, RefPtr<Inode>&& inode, const String& name, int prot)
|
||||
Region* Process::allocate_file_backed_region(VirtualAddress vaddr, size_t size, NonnullRefPtr<Inode> inode, const String& name, int prot)
|
||||
{
|
||||
auto range = allocate_range(vaddr, size);
|
||||
if (!range.is_valid())
|
||||
return nullptr;
|
||||
m_regions.append(adopt(*new Region(range, move(inode), name, prot_to_region_access_flags(prot))));
|
||||
m_regions.append(Region::create_user_accessible(range, inode, name, prot_to_region_access_flags(prot)));
|
||||
MM.map_region(*this, m_regions.last());
|
||||
return &m_regions.last();
|
||||
}
|
||||
|
@ -122,7 +122,7 @@ Region* Process::allocate_region_with_vmo(VirtualAddress vaddr, size_t size, Non
|
|||
if (!range.is_valid())
|
||||
return nullptr;
|
||||
offset_in_vmo &= PAGE_MASK;
|
||||
m_regions.append(adopt(*new Region(range, move(vmo), offset_in_vmo, name, prot_to_region_access_flags(prot))));
|
||||
m_regions.append(Region::create_user_accessible(range, move(vmo), offset_in_vmo, name, prot_to_region_access_flags(prot)));
|
||||
MM.map_region(*this, m_regions.last());
|
||||
return &m_regions.last();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue