From eaf91d0f8ef43344ea9b8b030ab1a446211b8d10 Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Tue, 3 Mar 2015 13:08:29 +0100 Subject: kernel: fix physical segment handling ignore physical segments in mcountseg() and mfreeseg(). physical segments are not backed by user pages, and doing putpage() on physical segment pages in mfreeseg() is an error. do now allow physical segemnts to be resized. the segment size is only checked in segattach() to be within the physical segment! ignore physical segments in portcountpagerefs() as pagenumber() does not work on the malloced page structures of a physical segment. get rid of Physseg.pgalloc() and Physseg.pgfree() indirection as this was never used and if theres a need to do more efficient allocation, it should be done in a portable way. --- sys/src/9/port/page.c | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) (limited to 'sys/src/9/port/page.c') diff --git a/sys/src/9/port/page.c b/sys/src/9/port/page.c index dcd701267..0061ed658 100644 --- a/sys/src/9/port/page.c +++ b/sys/src/9/port/page.c @@ -384,23 +384,11 @@ ptealloc(void) void freepte(Segment *s, Pte *p) { - void (*fn)(Page*); - Page **pg, **ptop; + Page **pg; switch(s->type&SG_TYPE) { case SG_PHYSICAL: - fn = s->pseg->pgfree; - ptop = &p->pages[PTEPERTAB]; - if(fn != nil) { - for(pg = p->pages; pg < ptop; pg++) { - if(*pg == nil) - continue; - (*fn)(*pg); - *pg = nil; - } - break; - } - for(pg = p->pages; pg < ptop; pg++) { + for(pg = p->first; pg <= p->last; pg++) { if(*pg != nil) { if(decref(*pg) == 0) free(*pg); @@ -409,11 +397,12 @@ freepte(Segment *s, Pte *p) } break; default: - for(pg = p->first; pg <= p->last; pg++) + for(pg = p->first; pg <= p->last; pg++) { if(*pg != nil) { putpage(*pg); *pg = nil; } + } } free(p); } @@ -483,7 +472,7 @@ portcountpagerefs(ulong *ref, int print) p = proctab(i); for(j=0; jseg[j]; - if(s) + if(s != nil) s->mark = 0; } } @@ -493,6 +482,8 @@ portcountpagerefs(ulong *ref, int print) s = p->seg[j]; if(s == nil || s->mark++) continue; + if((s->type&SG_TYPE) == SG_PHYSICAL) + continue; ns++; for(k=0; kmapsize; k++){ pte = s->map[k]; -- cgit v1.2.3