9os

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit c8084bd1502fe240906500af6fa58b68f6326fb0
parent fc4a6566987652a6f0b1a68bcbe699b14f6ee96f
Author: Roberto E. Vargas Caballero <roberto.vargas@midokura.com>
Date:   Sat, 19 Nov 2022 08:43:52 +0100

os9: Add virtual address to Page

The virtual address is needed to unmap a page because
it is the value used to locate the page in the page table.

Diffstat:
Minclude/os9/os9.h | 3++-
Msrc/os9/alloc.c | 1+
Msrc/os9/arch/arm64/mmu.c | 2+-
Msrc/os9/hosted/mmu.c | 4++--
Msrc/os9/proc.c | 9++++++---
5 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/include/os9/os9.h b/include/os9/os9.h @@ -106,6 +106,7 @@ struct ref { struct page { int allocated; + uintptr_t va; phyaddr_t pa; struct page *next; }; @@ -279,7 +280,7 @@ extern int debug(void); /* arch mmu.c */ extern int vmap(phyaddr_t, uintptr_t, int); -extern int vunmap(phyaddr_t); +extern int vunmap(phyaddr_t, uintptr_t); /* arch functions */ extern Context *getctx(Context *ctx); diff --git a/src/os9/alloc.c b/src/os9/alloc.c @@ -136,6 +136,7 @@ allocp(phyaddr_t pa) unlock(&pagepool.m); p->pa = pa; + p->va = -1; p->allocated = alloc; p->next = NULL; diff --git a/src/os9/arch/arm64/mmu.c b/src/os9/arch/arm64/mmu.c @@ -263,7 +263,7 @@ vmap(phyaddr_t pa, uintptr_t va, int perm) int -vunmap(phyaddr_t pa) +vunmap(phyaddr_t pa, uintptr_t va)) { /& TODO */ return 0; diff --git a/src/os9/hosted/mmu.c b/src/os9/hosted/mmu.c @@ -10,9 +10,9 @@ vmap(phyaddr_t pa, uintptr_t va, int flags) } int -vunmap(phyaddr_t pa) +vunmap(phyaddr_t pa, uintptr_t va) { - dbg("vunmap %llx\n", (long long) pa); + dbg("vunmap %llx -> %llx\n", (long long) pa, (long long) va); return 0; } diff --git a/src/os9/proc.c b/src/os9/proc.c @@ -117,7 +117,7 @@ unmapseg(Map *mp) mp->va, mp->pa); for (p = mp->pages; p; p = p->next) { - vunmap(p->pa); + vunmap(p->pa, p->va); freep(p); } @@ -155,12 +155,15 @@ mapseg(Map *mp) if ((p = allocp(pa)) == NULL) goto err; + p->va = va; p->next = mp->pages; - mp->pages = p; - if (vmap(p->pa, va, mp->perm) < 0) + if (vmap(p->pa, va, mp->perm) < 0) { + freep(p); goto err; + } + mp->pages = p; pa += PAGESIZE; va += PAGESIZE; }