summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrans Kaashoek <[email protected]>2018-10-02 08:36:02 -0400
committerFrans Kaashoek <[email protected]>2018-10-02 08:40:01 -0400
commitd448fd5e6cb6595d70172195afaee56c5097e4ed (patch)
tree3158dba2a9553ebafd4dd4e5fcc7d470078136f9
parenta42b7d5dbb8b88aa1fb4dc508600a272c494e3f5 (diff)
downloadxv6-labs-d448fd5e6cb6595d70172195afaee56c5097e4ed.tar.gz
xv6-labs-d448fd5e6cb6595d70172195afaee56c5097e4ed.tar.bz2
xv6-labs-d448fd5e6cb6595d70172195afaee56c5097e4ed.zip
Simplify by freeing user part of addres pace in one page increments. This
undoes commit ffe444 and 052e18, which skipped page directories, but was tailored to two-level page table. Undoing doesn't seem to affect boottime for xv6 visibly.
-rw-r--r--mmu.h4
-rw-r--r--vm.c4
2 files changed, 2 insertions, 6 deletions
diff --git a/mmu.h b/mmu.h
index 544de31..fdc9924 100644
--- a/mmu.h
+++ b/mmu.h
@@ -95,7 +95,6 @@ struct segdesc {
#define NPDENTRIES 512 // # directory entries per page directory
#define PGSIZE 4096 // bytes mapped by a page
#define PGSHIFT 12 // offset of PTX in a linear address
-#define PDXSHIFT 21 // offset of PDX in a linear address
#define PXMASK 0x1FF
#define PXSHIFT(n) (PGSHIFT+(9*(n)))
@@ -103,9 +102,6 @@ struct segdesc {
#define PX(n, va) ((((uint64) (va)) >> PXSHIFT(n)) & PXMASK)
#define L_PML4 3
-// construct virtual address from indexes and offset
-#define PGADDR(d, t, o) ((uint64)((d) << PDXSHIFT | (t) << PGSHIFT | (o)))
-
#define PGROUNDUP(sz) (((sz)+PGSIZE-1) & ~(PGSIZE-1))
#define PGROUNDDOWN(a) (((a)) & ~(PGSIZE-1))
diff --git a/vm.c b/vm.c
index 9279748..444ec6d 100644
--- a/vm.c
+++ b/vm.c
@@ -305,7 +305,7 @@ deallocuvm(pde_t *pml4, uint64 oldsz, uint64 newsz)
for(; a < oldsz; a += PGSIZE){
pte = walkpgdir(pml4, (char*)a, 0);
if(!pte)
- a = PGADDR(PDX(a) + 1, 0, 0) - PGSIZE;
+ continue;
else if((*pte & PTE_P) != 0){
pa = PTE_ADDR(*pte);
if(pa == 0)
@@ -327,7 +327,7 @@ freelevel(pde_t *pgtab, int level) {
if (level > 0) {
for(i = 0; i < NPDENTRIES; i++) {
if(pgtab[i] & PTE_P){
- pd = (pdpe_t*)P2V(PTE_ADDR(pgtab[i]));
+ pd = (pde_t*)P2V(PTE_ADDR(pgtab[i]));
freelevel(pd, level-1);
}
}