mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-11-01 23:18:21 +00:00
vmm: make fork use copy-on-write
This commit is contained in:
+4
-9
@@ -352,9 +352,8 @@ bool vmm_pagefault(void *addr, bool user, int actions) {
|
|||||||
printf("vmm: out of memory to do copy on write on address space\n");
|
printf("vmm: out of memory to do copy on write on address space\n");
|
||||||
status = false;
|
status = false;
|
||||||
} else {
|
} else {
|
||||||
// this assert should always succeed, here just to make sure
|
|
||||||
memcpy(MAKE_HHDM(newphys), MAKE_HHDM(oldphys), PAGE_SIZE);
|
memcpy(MAKE_HHDM(newphys), MAKE_HHDM(oldphys), PAGE_SIZE);
|
||||||
__assert(arch_mmu_map(_cpu()->vmmctx->pagetable, newphys, addr, range->mmuflags));
|
arch_mmu_remap(_cpu()->vmmctx->pagetable, newphys, addr, range->mmuflags);
|
||||||
pmm_release(oldphys);
|
pmm_release(oldphys);
|
||||||
status = true;
|
status = true;
|
||||||
}
|
}
|
||||||
@@ -556,14 +555,10 @@ vmmcontext_t *vmm_fork(vmmcontext_t *oldcontext) {
|
|||||||
if (phys == NULL)
|
if (phys == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
void *palloc = pmm_allocpage(PMM_SECTION_DEFAULT);
|
if (arch_mmu_map(newcontext->pagetable, phys, vaddr, newrange->mmuflags & ~ARCH_MMU_FLAGS_WRITE) == false)
|
||||||
if (palloc == NULL)
|
|
||||||
goto error;
|
goto error;
|
||||||
|
pmm_hold(phys);
|
||||||
if (arch_mmu_map(newcontext->pagetable, palloc, vaddr, newrange->mmuflags) == false)
|
arch_mmu_remap(oldcontext->pagetable, phys, vaddr, newrange->mmuflags & ~ARCH_MMU_FLAGS_WRITE);
|
||||||
goto error;
|
|
||||||
|
|
||||||
memcpy(MAKE_HHDM(palloc), MAKE_HHDM(phys), PAGE_SIZE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
range = range->next;
|
range = range->next;
|
||||||
|
|||||||
Reference in New Issue
Block a user