diff options
author | cinap_lenrek <cinap_lenrek@felloff.net> | 2014-07-14 06:02:21 +0200 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2014-07-14 06:02:21 +0200 |
commit | 655ec332a714d3e5cc6aace798daf832e17e001e (patch) | |
tree | 90234eaf806722bf1fc54b298226128ce50f2b91 /sys/src/9/port/segment.c | |
parent | e53511ef4c7d4db443543506e74e4de537da5475 (diff) |
devproc: fix proccrlmemio bugs
dont kill the calling process when demand load fails if fixfault()
is called from devproc. this happens when you delete the binary
of a running process and try to debug the process accessing uncached
pages thru /proc/$pid/mem file.
fixes to procctlmemio():
- fix missed unlock as txt2data() can error
- make sure the segment isnt freed by taking a reference (under p->seglock)
- access the page with segment locked (see comment)
- get rid of the segment stealer lock
other stuff:
- move txt2data() and data2txt() to segment.c
- add procpagecount() function
- make return type mcounseg() to ulong
Diffstat (limited to 'sys/src/9/port/segment.c')
-rw-r--r-- | sys/src/9/port/segment.c | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/sys/src/9/port/segment.c b/sys/src/9/port/segment.c index 75098a590..17efff622 100644 --- a/sys/src/9/port/segment.c +++ b/sys/src/9/port/segment.c @@ -452,10 +452,11 @@ ibrk(uintptr addr, int seg) /* * called with s locked */ -int +ulong mcountseg(Segment *s) { - int i, j, pages; + ulong pages; + int i, j; Page *pg; pages = 0; @@ -736,3 +737,33 @@ segclock(uintptr pc) } } +Segment* +txt2data(Segment *s) +{ + Segment *ps; + + ps = newseg(SG_DATA, s->base, s->size); + ps->image = s->image; + incref(ps->image); + ps->fstart = s->fstart; + ps->flen = s->flen; + ps->flushme = 1; + qunlock(s); + putseg(s); + qlock(ps); + return ps; +} + +Segment* +data2txt(Segment *s) +{ + Segment *ps; + + ps = newseg(SG_TEXT, s->base, s->size); + ps->image = s->image; + incref(ps->image); + ps->fstart = s->fstart; + ps->flen = s->flen; + ps->flushme = 1; + return ps; +} |