vmm: allow vmm_getphysical to return a page held

This commit is contained in:
Matheus
2024-09-18 21:27:36 -03:00
parent 611f13b562
commit c76b37693b
6 changed files with 14 additions and 5 deletions
+4 -1
View File
@@ -655,7 +655,7 @@ bool vmm_pagefault(void *addr, bool user, int actions) {
return status;
}
void *vmm_getphysical(void *addr) {
void *vmm_getphysical(void *addr, bool hold) {
addr = (void *)ROUND_DOWN((uintptr_t)addr, PAGE_SIZE);
vmmspace_t *space = getspace(addr);
@@ -666,6 +666,9 @@ void *vmm_getphysical(void *addr) {
void *physical = arch_mmu_getphysical(current_vmm_context()->pagetable, addr);
if (hold)
pmm_hold(physical);
MUTEX_RELEASE(&space->lock);
return physical + ((uintptr_t)addr - ROUND_DOWN((uintptr_t)addr, PAGE_SIZE));
}