From mboxrd@z Thu Jan 1 00:00:00 1970 From: erik quanstrom Date: Mon, 21 Nov 2011 18:01:40 -0500 To: 9fans@9fans.net Message-ID: <054a965bf33866efe585d6863a1c1323@chula.quanstro.net> In-Reply-To: References: <93653898c4ceb27355b5fa1e548176aa@brasstown.quanstro.net> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Subject: Re: [9fans] sysrfork fp bug? Topicbox-Message-UUID: 42e23142-ead7-11e9-9d60-3106f5b1d025 /* don't penalize the child, it hasn't done FP in a note handler. */ p->fpstate = up->fpstate & ~FPillegal; [...] ready(p); sched(); return pid; we do know that fp->state is FPinactive (because of rfork), but it seems like this isn't doing what was intended, and if there are any values on the x87 stack, they could well ... stack, which could lead to eventual fp stack overflow. given this discussion, and some prior cleanup i'm currently using this incantation called from sysrfork in the pc arch dependent code. fp is a FPArch* to accomidate sse or x87. it's a little gross, but i did need some sse instructions at one point on a 386 kernel. eventually the x87 stuff should be killed. /* called from newproc() since newproc() doesn't know about fpstates */ void procfpinit(Proc *p) { p->fpstate = FPinit; p->fpusave = (FPsave*)((uintptr)p->fxsave + 15 & ~15); } /* * set up floating point unit before running new process; that is * turn floating point off and allow the coprocessor not avail. * trap to initialize the x87/sse on an as-needed basis. */ void procsetup(Proc *p) { fp->off(); } /* * "clone" the fpu. assume called from rfork() [sic], assume c api (regs dead * on function call return) [sic, maybe?] so we can get away with discarding the old * fp state by setting the fpstate to FPinit. */ void clonefpu(PFPU *t, PFPU *s) { /* child doesn't inherit fcr, etc.? man page not conclusive */ t->fpstate = FPinit; USED(s); } - erik