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
+2
View File
@@ -200,7 +200,9 @@ static char *args[] = {
#endif
#ifdef SYSCALL_LOGGING
static spinlock_t lock;
#endif
extern size_t freepagecount;
__attribute__((no_caller_saved_registers)) void arch_syscall_log(int syscall, uint64_t a1, uint64_t a2, uint64_t a3, uint64_t a4, uint64_t a5, uint64_t a6) {
#ifdef SYSCALL_LOGGING
+1 -1
View File
@@ -101,7 +101,7 @@ void vmm_unmap(void *addr, size_t size, int flags);
bool vmm_pagefault(void *addr, bool user, int actions);
vmmcontext_t *vmm_newcontext();
void vmm_switchcontext(vmmcontext_t *ctx);
void *vmm_getphysical(void *addr);
void *vmm_getphysical(void *addr, bool hold);
void vmm_apinit();
void vmm_init();
+3 -1
View File
@@ -517,11 +517,13 @@ static int rwblocks(nvmenamespace_t *namespace, void *buffer, uintmax_t lba, siz
size_t docount = (done == 0) ? (PAGE_SIZE - pageoffset) / namespace->blocksize : PAGE_SIZE / namespace->blocksize;
docount = min(docount, count - done);
prp[0] = (uint64_t)vmm_getphysical((void *)((uintptr_t)buffer + done * namespace->blocksize));
prp[0] = (uint64_t)vmm_getphysical((void *)((uintptr_t)buffer + done * namespace->blocksize), true);
__assert(prp[0]);
err = write ? iowrite(namespace, prp, lba + done, docount) : ioread(namespace, prp, lba + done, docount);
pmm_release((void *)prp[0]);
if (err)
break;
+3 -1
View File
@@ -121,11 +121,13 @@ static int vioblk_rw(vioblkdev_t *blkdev, void *buffer, uintmax_t lba, size_t co
size_t docount = (done == 0) ? (PAGE_SIZE - pageoffset) / 512 : PAGE_SIZE / 512;
docount = min(docount, count - done);
void *bufferphys = vmm_getphysical((void *)((uintptr_t)buffer + done * 512));
void *bufferphys = vmm_getphysical((void *)((uintptr_t)buffer + done * 512), true);
__assert(bufferphys);
vioblk_enqueue(blkdev, header, bufferphys, docount * 512, status, write);
pmm_release(bufferphys);
if (*statushhdm) {
err = EIO;
break;
+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));
}
+1 -1
View File
@@ -80,7 +80,7 @@ syscallret_t syscall_futex(context_t *, uint32_t *futexp, int op, uint32_t value
if (ret.errno)
goto cleanup;
uint32_t *physical = vmm_getphysical(futexp);
uint32_t *physical = vmm_getphysical(futexp, false);
futex_t *futex = getfutex(physical);
switch (op) {