diff --git a/sys/src/9/port/devproc.c b/sys/src/9/port/devproc.c index 425cbc962..85bcbcdee 100644 --- a/sys/src/9/port/devproc.c +++ b/sys/src/9/port/devproc.c @@ -138,7 +138,7 @@ Cmdtab proccmd[] = { }; /* Segment type from portdat.h */ -static char *sname[]={ "Text", "Data", "Bss", "Stack", "Shared", "Phys", "Fixed", }; +static char *sname[]={ "Text", "Data", "Bss", "Stack", "Shared", "Phys", "Fixed", "Sticky" }; /* * Qids are, in path: diff --git a/sys/src/9/port/devsegment.c b/sys/src/9/port/devsegment.c index f1221b9cc..baa39846e 100644 --- a/sys/src/9/port/devsegment.c +++ b/sys/src/9/port/devsegment.c @@ -284,6 +284,8 @@ segmentread(Chan *c, void *a, long n, vlong voff) if((g->s->type&SG_TYPE) == SG_FIXED) snprint(buf, sizeof(buf), "va %#p %#p fixed %#p\n", g->s->base, g->s->top-g->s->base, g->s->map[0]->pages[0]->pa); + else if((g->s->type&SG_TYPE) == SG_STICKY) + snprint(buf, sizeof(buf), "va %#p %#p sticky\n", g->s->base, g->s->top-g->s->base); else snprint(buf, sizeof(buf), "va %#p %#p\n", g->s->base, g->s->top-g->s->base); return readstr(voff, a, n, buf); @@ -331,6 +333,20 @@ segmentwrite(Chan *c, void *a, long n, vlong voff) if(!iseve()) error(Eperm); g->s = fixedseg(va, len/BY2PG); + } else if(cb->nf >= 4 && strcmp(cb->f[3], "sticky") == 0){ + Segment *s; + + if(!iseve()) + error(Eperm); + s = newseg(SG_STICKY, va, len/BY2PG); + if(waserror()){ + putseg(s); + nexterror(); + } + for(; va < s->top; va += BY2PG) + segpage(s, newpage(1, nil, va)); + poperror(); + g->s = s; } else g->s = newseg(SG_SHARED, va, len/BY2PG); } else diff --git a/sys/src/9/port/fault.c b/sys/src/9/port/fault.c index a5e80336c..8180747e4 100644 --- a/sys/src/9/port/fault.c +++ b/sys/src/9/port/fault.c @@ -270,6 +270,8 @@ fixfault(Segment *s, uintptr addr, int read) copypage(old, *pg); putpage(old); } + /* wet floor */ + case SG_STICKY: /* Never paged out */ mmuphys = PPN((*pg)->pa) | PTEWRITE | PTEVALID; (*pg)->modref = PG_MOD|PG_REF; break; diff --git a/sys/src/9/port/portdat.h b/sys/src/9/port/portdat.h index 17901b31d..66db9f441 100644 --- a/sys/src/9/port/portdat.h +++ b/sys/src/9/port/portdat.h @@ -368,6 +368,7 @@ enum SG_SHARED = 04, SG_PHYSICAL = 05, SG_FIXED = 06, + SG_STICKY = 07, SG_RONLY = 0040, /* Segment is read only */ SG_CEXEC = 0100, /* Detach at exec */ diff --git a/sys/src/9/port/proc.c b/sys/src/9/port/proc.c index 3b391252f..5a530395f 100644 --- a/sys/src/9/port/proc.c +++ b/sys/src/9/port/proc.c @@ -1595,6 +1595,7 @@ killbig(char *why) case SG_SHARED: case SG_PHYSICAL: case SG_FIXED: + case SG_STICKY: continue; } qlock(s); diff --git a/sys/src/9/port/segment.c b/sys/src/9/port/segment.c index f675ac1c5..bc16c3333 100644 --- a/sys/src/9/port/segment.c +++ b/sys/src/9/port/segment.c @@ -155,6 +155,7 @@ dupseg(Segment **seg, int segno, int share) case SG_SHARED: case SG_PHYSICAL: case SG_FIXED: + case SG_STICKY: goto sameseg; case SG_STACK: @@ -499,6 +500,7 @@ mfreeseg(Segment *s, uintptr start, ulong pages) switch(s->type&SG_TYPE){ case SG_PHYSICAL: case SG_FIXED: + case SG_STICKY: return; } diff --git a/sys/src/9/port/sysproc.c b/sys/src/9/port/sysproc.c index 46f8f536f..ee6f2b937 100644 --- a/sys/src/9/port/sysproc.c +++ b/sys/src/9/port/sysproc.c @@ -773,6 +773,7 @@ syssegbrk(va_list list) case SG_STACK: case SG_PHYSICAL: case SG_FIXED: + case SG_STICKY: error(Ebadarg); default: return ibrk(va_arg(list, uintptr), i);