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.
This commit is contained in:
Frans Kaashoek 2018-10-02 08:36:02 -04:00
parent a42b7d5dbb
commit d448fd5e6c
2 changed files with 2 additions and 6 deletions

4
mmu.h
View file

@ -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))

4
vm.c
View file

@ -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);
}
}