Various mmu cleanups. [rsc] --rw-rw-r-- M 208448 glenda sys 24152 Jan 3 19:54 sys/src/9/pc/mmu.c /n/sourcesdump/2006/0103/plan9/sys/src/9/pc/mmu.c:211,216 - /n/sourcesdump/2006/0104/plan9/sys/src/9/pc/mmu.c:211,217 ulong *pdb; s = splhi(); + m->pdballoc++; if(m->pdbpool == 0){ spllo(); page = newpage(0, 0, 0); /n/sourcesdump/2006/0103/plan9/sys/src/9/pc/mmu.c:234,239 - /n/sourcesdump/2006/0104/plan9/sys/src/9/pc/mmu.c:235,241 { if(islo()) panic("mmupdbfree: islo"); + m->pdbfree++; if(m->pdbcnt >= 10){ p->next = proc->mmufree; proc->mmufree = p; /n/sourcesdump/2006/0103/plan9/sys/src/9/pc/mmu.c:240,245 - /n/sourcesdump/2006/0104/plan9/sys/src/9/pc/mmu.c:242,248 }else{ p->next = m->pdbpool; m->pdbpool = p; + m->pdbcnt++; } } /n/sourcesdump/2006/0103/plan9/sys/src/9/pc/mmu.c:322,331 - /n/sourcesdump/2006/0104/plan9/sys/src/9/pc/mmu.c:325,335 void mmurelease(Proc* proc) { - int s; Page *page, *next; ulong *pdb; + if(islo()) + panic("mmurelease: islo"); taskswitch(PADDR(m->pdb), (ulong)m + BY2PG); if(proc->kmaptable){ if(proc->mmupdb == nil) /n/sourcesdump/2006/0103/plan9/sys/src/9/pc/mmu.c:337,343 - /n/sourcesdump/2006/0104/plan9/sys/src/9/pc/mmu.c:341,346 /* * remove kmaptable from pdb before putting pdb up for reuse. */ - s = splhi(); pdb = tmpmap(proc->mmupdb); if(PPN(pdb[PDX(KMAP)]) != proc->kmaptable->pa) panic("mmurelease: bad kmap pde %#.8lux kmap %#.8lux", /n/sourcesdump/2006/0103/plan9/sys/src/9/pc/mmu.c:344,350 - /n/sourcesdump/2006/0104/plan9/sys/src/9/pc/mmu.c:347,352 pdb[PDX(KMAP)], proc->kmaptable->pa); pdb[PDX(KMAP)] = 0; tmpunmap(pdb); - splx(s); /* * move kmaptable to free list. */ /n/sourcesdump/2006/0103/plan9/sys/src/9/pc/mmu.c:383,389 - /n/sourcesdump/2006/0104/plan9/sys/src/9/pc/mmu.c:385,392 pdb[PDX(MACHADDR)] = m->pdb[PDX(MACHADDR)]; tmpunmap(pdb); up->mmupdb = page; - mmuflushtlb(up->mmupdb->pa); + //XXX should have this m->tss->cr3 = up->mmupdb->pa; + putcr3(up->mmupdb->pa); splx(s); } /n/sourcesdump/2006/0103/plan9/sys/src/9/pc/mmu.c:393,405 - /n/sourcesdump/2006/0104/plan9/sys/src/9/pc/mmu.c:396,407 void putmmu(ulong va, ulong pa, Page*) { - int old, s; + int old; Page *page; if(up->mmupdb == nil) upallocpdb(); - s = splhi(); if(!(vpd[PDX(va)]&PTEVALID)){ if(up->mmufree == 0) page = newpage(0, 0, 0); /n/sourcesdump/2006/0103/plan9/sys/src/9/pc/mmu.c:418,424 - /n/sourcesdump/2006/0104/plan9/sys/src/9/pc/mmu.c:420,427 vpt[VPTX(va)] = pa|PTEUSER|PTEVALID; if(old&PTEVALID) flushpg(va); - splx(s); + if(getcr3() != up->mmupdb->pa) + print("bad cr3 %.8lux %.8lux\n", getcr3(), up->mmupdb->pa); } /* /n/sourcesdump/2006/0103/plan9/sys/src/9/pc/mmu.c:572,578 - /n/sourcesdump/2006/0104/plan9/sys/src/9/pc/mmu.c:575,581 n = (size+4*MB-1) / (4*MB); if((o = findhole(vpdb, vpdbsize, n)) != -1) return VMAP + o*4*MB; - return VMAP + o; + return 0; } n = (size+BY2PG-1) / BY2PG; for(i=0; ipa, i); } } - if(!print) + if(!print){ iprint("%d pages in mach pdbpools\n", n); + for(i=0; ipdballoc, MACHP(i)->pdbfree); + } } void [rsc] --rw-rw-r-- M 208448 glenda sys 13971 Jan 3 19:54 sys/src/9/pc/screen.c /n/sourcesdump/2006/0103/plan9/sys/src/9/pc/screen.c:511,516 - /n/sourcesdump/2006/0104/plan9/sys/src/9/pc/screen.c:511,522 npaddr = paddr-x; nsize = PGROUND(size+x); + /* + * Don't bother trying to map more than 4000x4000x32 = 64MB. + * We only have a 256MB window. + */ + if(nsize > 64*MB) + nsize = 64*MB; scr->vaddr = vmap(npaddr, nsize); if(scr->vaddr == 0) error("cannot allocate vga frame buffer"); [jmk] --rw-rw-r-- M 208448 glenda sys 6583 Jan 3 22:57 sys/src/9/pc/dat.h /n/sourcesdump/2006/0103/plan9/sys/src/9/pc/dat.h:214,219 - /n/sourcesdump/2006/0104/plan9/sys/src/9/pc/dat.h:214,221 int havetsc; int havepge; uvlong tscticks; + int pdballoc; + int pdbfree; vlong mtrrcap; vlong mtrrdef;