mirror of
https://github.com/justinian/jsix.git
synced 2025-12-09 16:04:32 -08:00
[kernel] Ensure all VMA sizes are multiples of page size
Using a 0 address in vma_create_map or vma_map would run into issues if VMAs had sizes that didn't end on page boundaries. Since any size that's not a multiples of the page size is a lie, make vm_area's ctor enforce page sizing.
This commit is contained in:
@@ -10,7 +10,7 @@ namespace obj {
|
||||
using mem::frame_size;
|
||||
|
||||
vm_area::vm_area(size_t size, util::bitset32 flags) :
|
||||
m_size {size},
|
||||
m_size {mem::page_count(size) * mem::frame_size},
|
||||
m_flags {flags},
|
||||
m_spaces {m_vector_static, 0, static_size},
|
||||
kobject {kobject::type::vma}
|
||||
@@ -34,6 +34,10 @@ void
|
||||
vm_area::remove_from(vm_space *space)
|
||||
{
|
||||
m_spaces.remove_swap(space);
|
||||
|
||||
// If we were keeping this space around after its refcount
|
||||
// dropped to zero because it was mapped, check if we should
|
||||
// clean it up now.
|
||||
if (!m_spaces.count() && !handle_count())
|
||||
delete this;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user