diff --git a/sys/src/kern/amd64/syscall.c b/sys/src/kern/amd64/syscall.c index a1625d6..33a2b9e 100644 --- a/sys/src/kern/amd64/syscall.c +++ b/sys/src/kern/amd64/syscall.c @@ -236,7 +236,7 @@ syscall(Syscalls scallnr, Ureg* ureg) cycles(&up->kentry); m->syscall++; - up->insyscall = 1; + up->inkernel = 1; up->cursyscall = (Syscalls)scallnr; up->pc = ureg->ip; up->dbgreg = ureg; @@ -344,7 +344,7 @@ syscall(Syscalls scallnr, Ureg* ureg) splx(s); } - up->insyscall = 0; + up->inkernel = 0; up->psstate = 0; up->cursyscall = 0; @@ -444,7 +444,7 @@ sysrforkchild(Proc* child, Proc* parent) /* Things from bottom of syscall which were never executed */ child->psstate = 0; - child->insyscall = 0; + child->inkernel = 0; fpusysrforkchild(child, parent); } diff --git a/sys/src/kern/amd64/trap.c b/sys/src/kern/amd64/trap.c index c71dacd..f80c95d 100644 --- a/sys/src/kern/amd64/trap.c +++ b/sys/src/kern/amd64/trap.c @@ -575,7 +575,8 @@ static void faultamd64(Ureg* ureg, void* _1) { uint64_t addr, arg; - int ftype, user, insyscall; + int ftype, user, inkernel; + Syscalls cursyscall; char buf[ERRMAX]; void (*pt)(Proc*, int, int64_t, int64_t); @@ -606,8 +607,10 @@ faultamd64(Ureg* ureg, void* _1) pt(up, STrap, 0, arg); } - insyscall = up->insyscall; - up->insyscall = 1; + inkernel = up->inkernel; + cursyscall = up->cursyscall; + up->inkernel = 1; + up->cursyscall = 0; if(iskaddr(addr)){ jehanne_print("kaddr %#llux pc %#p\n", addr, ureg->ip); // prflush(); @@ -623,10 +626,13 @@ if(iskaddr(addr)){ fault_types[ftype], addr); proc_check_pages(); postnote(up, 1, buf, NDebug); - if(insyscall) + if(inkernel){ + up->cursyscall = cursyscall; error(buf); + } } - up->insyscall = insyscall; + up->cursyscall = cursyscall; + up->inkernel = inkernel; } /* diff --git a/sys/src/kern/port/awake.c b/sys/src/kern/port/awake.c index 54d64e6..96e7bc7 100644 --- a/sys/src/kern/port/awake.c +++ b/sys/src/kern/port/awake.c @@ -44,7 +44,7 @@ int canwakeup(Syscalls scall) { if(scall == 0){ - /* fault set insyscall to 1 */ + /* on page fault */ return 0; } switch(scall){ diff --git a/sys/src/kern/port/portdat.h b/sys/src/kern/port/portdat.h index b065a29..dcd5316 100644 --- a/sys/src/kern/port/portdat.h +++ b/sys/src/kern/port/portdat.h @@ -608,8 +608,9 @@ struct Proc int64_t pcycles; Profbuf* prof; - int insyscall; - Syscalls cursyscall; + int inkernel; /* either on syscall or fault */ + Syscalls cursyscall; /* zero on fault */ + int32_t blockingfd; /* fd currenly read/written */ QLock debug; /* to access debugging elements of User */ diff --git a/sys/src/kern/port/proc.c b/sys/src/kern/port/proc.c index 794fbd4..b3e3b29 100644 --- a/sys/src/kern/port/proc.c +++ b/sys/src/kern/port/proc.c @@ -568,7 +568,7 @@ newproc(void) p = psalloc(); p->state = Scheding; - p->insyscall = 0; + p->inkernel = 0; p->cursyscall = 0; p->psstate = "New"; p->mach = 0; @@ -714,7 +714,7 @@ sleep(Rendez *r, int (*f)(void*), void *arg) if((*f)(arg) || (up->notepending && !up->notedeferred) - || (up->insyscall && awakeOnBlock(up) && canwakeup(up->cursyscall))){ + || (up->inkernel && awakeOnBlock(up) && canwakeup(up->cursyscall))){ /* * if condition happened or a note is pending * never mind @@ -761,7 +761,7 @@ SleepAwakened: forceclosefgrp(); error(Eintr); } - if(up->insyscall && awakeOnBlock(up) && canwakeup(up->cursyscall)) + if(up->inkernel && awakeOnBlock(up) && canwakeup(up->cursyscall)) goto SleepAwakened; splx(s); @@ -1690,7 +1690,7 @@ accounttime(void) p = m->proc; if(p) { nrun++; - p->time[p->insyscall]++; + p->time[p->inkernel]++; } /* calculate decaying duty cycles */