mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 04:17:35 +00:00
Kernel: Clean up a bunch of wrong-looking Region/VMObject code
Since a Region is merely a "window" onto a VMObject, it can both begin and end at a distance from the VMObject's boundaries. Therefore, we should always be computing indices into a VMObject's physical page array by adding the Region's "first_page_index()". There was a whole bunch of code that forgot to do that. This fixes many wrong behaviors for Regions that start part-way into a VMObject.
This commit is contained in:
parent
fe455c5ac4
commit
a221cddeec
2 changed files with 25 additions and 23 deletions
|
@ -87,16 +87,17 @@ int Region::commit()
|
|||
#ifdef MM_DEBUG
|
||||
dbgprintf("MM: commit %u pages in Region %p (VMO=%p) at V%p\n", vmobject().page_count(), this, &vmobject(), vaddr().get());
|
||||
#endif
|
||||
for (size_t i = first_page_index(); i <= last_page_index(); ++i) {
|
||||
if (!vmobject().physical_pages()[i].is_null())
|
||||
for (size_t i = 0; i < page_count(); ++i) {
|
||||
auto& vmobject_physical_page_entry = vmobject().physical_pages()[first_page_index() + i];
|
||||
if (!vmobject_physical_page_entry.is_null())
|
||||
continue;
|
||||
auto physical_page = MM.allocate_user_physical_page(MemoryManager::ShouldZeroFill::Yes);
|
||||
if (!physical_page) {
|
||||
kprintf("MM: commit was unable to allocate a physical page\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
vmobject().physical_pages()[i] = move(physical_page);
|
||||
remap_page(i - first_page_index());
|
||||
vmobject_physical_page_entry = move(physical_page);
|
||||
remap_page(i);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue