Kernel: Implement MemoryRegion pinning

This allows process to pin a MemoryRegion into users memory space for
syscall duration without allowing user to munmap the region.
This commit is contained in:
2025-04-22 04:30:07 +03:00
parent 808c97020a
commit d54489bbcb
3 changed files with 12 additions and 2 deletions

View File

@@ -13,6 +13,7 @@ namespace Kernel
MemoryRegion::~MemoryRegion()
{
ASSERT(m_pinned_count == 0);
if (m_vaddr)
m_page_table.unmap_range(m_vaddr, m_size);
}

View File

@@ -1806,7 +1806,10 @@ namespace Kernel
const vaddr_t region_s = region->vaddr();
const vaddr_t region_e = region->vaddr() + region->size();
if (vaddr <= region_s && region_e <= vaddr + len)
{
region->wait_not_pinned();
m_mapped_regions.remove(i--);
}
else if (region->overlaps(vaddr, len))
dwarnln("TODO: partial region munmap");
}