vmm: fix destroyrange shared file unmapping

This commit is contained in:
Matheus
2024-06-08 14:03:27 -03:00
parent ea5e53ff91
commit 13b142a91e
2 changed files with 8 additions and 2 deletions
+1
View File
@@ -133,6 +133,7 @@ void pmm_release(void *addr) {
uintmax_t newrefcount = __atomic_sub_fetch(&page->refcount, 1, __ATOMIC_SEQ_CST);
if (newrefcount == 0) {
__assert((page->flags & PAGE_FLAGS_DIRTY) == 0);
MUTEX_ACQUIRE(&freelistmutex, false);
insertinfreelist(page);
if (page->backing == NULL)
+7 -2
View File
@@ -223,15 +223,20 @@ static void destroyrange(vmmrange_t *range, uintmax_t _offset, size_t size, int
if (range->vnode->type == V_TYPE_CHDEV) {
// character device mapping
__assert(VOP_MUNMAP(range->vnode, vaddr, range->offset + offset, mmuflagstovnodeflags(range->mmuflags) | (range->flags & VMM_FLAGS_SHARED ? V_FFLAGS_SHARED : 0), cred) == 0);
} else if (arch_mmu_iswritable(_cpu()->vmmctx->pagetable, vaddr) == false || arch_mmu_isdirty(_cpu()->vmmctx->pagetable, vaddr) == false) {
} else if (arch_mmu_iswritable(_cpu()->vmmctx->pagetable, vaddr) && arch_mmu_isdirty(_cpu()->vmmctx->pagetable, vaddr)) {
// dirty page cache mapping
arch_mmu_unmap(_cpu()->vmmctx->pagetable, vaddr);
vmmcache_makedirty(pmm_getpage(physical));
pmm_release(physical);
} else {
// non dirty page mapping
arch_mmu_unmap(_cpu()->vmmctx->pagetable, vaddr);
pmm_release(physical);
}
} else {
// anonymous or private non character device mapping
pmm_release(physical);
arch_mmu_unmap(_cpu()->vmmctx->pagetable, vaddr);
pmm_release(physical);
}
}