From owner-freebsd-arch Wed Jan 9 16:54: 4 2002 Delivered-To: freebsd-arch@freebsd.org Received: from ns.yogotech.com (ns.yogotech.com [206.127.123.66]) by hub.freebsd.org (Postfix) with ESMTP id 59EE937B417 for ; Wed, 9 Jan 2002 16:53:13 -0800 (PST) Received: from caddis.yogotech.com (caddis.yogotech.com [206.127.123.130]) by ns.yogotech.com (8.9.3/8.9.3) with ESMTP id RAA18259; Wed, 9 Jan 2002 17:52:41 -0700 (MST) (envelope-from nate@yogotech.com) Received: (from nate@localhost) by caddis.yogotech.com (8.11.6/8.11.6) id g0A0qeu21079; Wed, 9 Jan 2002 17:52:40 -0700 (MST) (envelope-from nate) From: Nate Williams MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <15420.58839.954146.527043@caddis.yogotech.com> Date: Wed, 9 Jan 2002 17:52:39 -0700 To: Bruce Evans Cc: Nate Williams , Daniel Eischen , Dan Eischen , Peter Wemm , Archie Cobbs , Alfred Perlstein , Subject: Re: Request for review: getcontext, setcontext, etc In-Reply-To: <20020110114251.S10376-100000@gamplex.bde.org> References: <15420.34931.201187.449640@caddis.yogotech.com> <20020110114251.S10376-100000@gamplex.bde.org> X-Mailer: VM 6.96 under 21.1 (patch 14) "Cuyahoga Valley" XEmacs Lucid Reply-To: nate@yogotech.com (Nate Williams) Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG > > > > > fldz > > > > > fld1 > > > > > fdiv %st,%st(1) # 1.0 / 0.0, exception on this instruction > > > > > # but no trap yet > > > > > fnstsw %ax # no trap yet since this is control instruction > > > > > fnclex # forget about exception; no trap at all since > > > > > # we did only control instructions after the > > > > > # one that cause the exception > > > > > > > > > > > > It is especially wrong for fnsave in context switches because it > > > > > > > causes the signals in the context of the context switcher instead of > > > > > > > in the context of the thread that caused the exception. > > > > > > > > > > > > Which signals are you refering to? > > > > > > > > > > The SIGFPE that you get for `wait'. > > > > > > > > So, when is SIGFPE going to be triggered above, since it appears to be > > > > masked by using fnstw vs. fstw. > > > > > > When the above is interrupted by a signal, and the signal handler wants > > > to switch to another thread, and erroneously saves the context using > > > fsave instead of fnsave. > > > > Assuming I used followed things up with 'fnsave', will the exception be > > triggered by a frstor, and thus the exception will be correctly reported > > by the thread triggering the exception? > > Only on broken systems. Why is reporting a SIGFPE considered broken? This is a valid exception, and it should be reported. I consider a system that doesn't report such exceptions broken, the opposite of what you are stating. > > > > In other words, how do I actually make sure that I receive the > > > > exception/trapf for FP errors? > > > > > > Let the thread (appear to) continue normally by never triggering a trap > > > for the exception if you switch its context. Using fnsave/frstor > > > accomplishes this, except on broken (old) systems where fnsave traps anyway. > > > > Is this broken hardware systems, or broken software systems? (In other > > words, does "broken (old)" imply a bug in hardware or software?) > > Mostly broken hardware. Software can still get the broken behaviour by > using irq13 error reporting, which may still be required for backwards > compatibility. I think W98 would have to use it for DOS mode; I don't > know about native mode. > > See Appendix C of the Intel MMX manual (1997 version at least) for more > details. I don't have the MXX manual, just the x86/87 programming manuals for x86 (X <= 3). Nate To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message