From owner-freebsd-arch Tue Jan 8 10: 3:44 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 20FE137B41E for ; Tue, 8 Jan 2002 10:02:56 -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 LAA06268; Tue, 8 Jan 2002 11:01:48 -0700 (MST) (envelope-from nate@yogotech.com) Received: (from nate@localhost) by caddis.yogotech.com (8.11.6/8.11.6) id g08I1gZ05091; Tue, 8 Jan 2002 11:01:43 -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: <15419.13318.535192.666599@caddis.yogotech.com> Date: Tue, 8 Jan 2002 11:01:42 -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: <20020108150914.N3450-100000@gamplex.bde.org> References: <15418.17529.641960.608906@caddis.yogotech.com> <20020108150914.N3450-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 > Some software running on post-8086 CPUs might want to use it to > trigger FPU exceptions at the right place (IIRC, using fnop for this > is not as good since it is not a control instruction so using it > clobbers the address of the last FPU instruction, in particular the > address of the instruction that caused the exception if there was > one). fsave is quite different from fnsave since it begins with a > `wait' instruction. So far I'm with you. > > > Manuals (up to at least the 486 one) also say that "wait" instruction > > > is required _after_ FPU instructions if the memory written to by the > > > FPU instruction is read by the CPU. E.g., the wait is required for > > > "fnsave mem; movl mem,%eax", and "fistpl mem; movl mem,%eax" but not > > > for "fnsave mem; frstor mem" or "fstpl mem; fldl mem". I've never > > > seen this rule followed. > > > > The manual I read had something like this, hence the reason for using > > fsave (vs. fnsave). > > fsave puts the wait in precisely the wrong place to affect this. This is don't completely understand, but see below. > > > Using "wait" before an FP control instruction is usually wrong because > > > it prevents the "no-wait" feature of FP control operations from working. > > > It causes any unmasked exceptions to be signaled immediately. > > > > Isn't this a good thing, since if the currently executing thread has > > encountered an exception, it will be signaled during the current > > thread's context? > > No. It breaks instruction sequences like: > > 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. In other words, how do I actually make sure that I receive the exception/trapf for FP errors? Nate To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message