Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 1 Sep 2012 15:55:14 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject:   svn commit: r239994 - stable/9/sys/i386/isa
Message-ID:  <201209011555.q81FtEEA033983@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Sat Sep  1 15:55:14 2012
New Revision: 239994
URL: http://svn.freebsd.org/changeset/base/239994

Log:
  MFC r238677:
  Stop clearing x87 exceptions in the #MF handler.

Modified:
  stable/9/sys/i386/isa/npx.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/i386/isa/npx.c
==============================================================================
--- stable/9/sys/i386/isa/npx.c	Sat Sep  1 15:53:26 2012	(r239993)
+++ stable/9/sys/i386/isa/npx.c	Sat Sep  1 15:55:14 2012	(r239994)
@@ -583,21 +583,21 @@ static char fpetable[128] = {
 };
 
 /*
- * Preserve the FP status word, clear FP exceptions, then generate a SIGFPE.
+ * Read the FP status and control words, then generate si_code value
+ * for SIGFPE.  The error code chosen will be one of the
+ * FPE_... macros.  It will be sent as the second argument to old
+ * BSD-style signal handlers and as "siginfo_t->si_code" (second
+ * argument) to SA_SIGINFO signal handlers.
  *
- * Clearing exceptions is necessary mainly to avoid IRQ13 bugs.  We now
- * depend on longjmp() restoring a usable state.  Restoring the state
- * or examining it might fail if we didn't clear exceptions.
+ * Some time ago, we cleared the x87 exceptions with FNCLEX there.
+ * Clearing exceptions was necessary mainly to avoid IRQ13 bugs.  The
+ * usermode code which understands the FPU hardware enough to enable
+ * the exceptions, can also handle clearing the exception state in the
+ * handler.  The only consequence of not clearing the exception is the
+ * rethrow of the SIGFPE on return from the signal handler and
+ * reexecution of the corresponding instruction.
  *
- * The error code chosen will be one of the FPE_... macros. It will be
- * sent as the second argument to old BSD-style signal handlers and as
- * "siginfo_t->si_code" (second argument) to SA_SIGINFO signal handlers.
- *
- * XXX the FP state is not preserved across signal handlers.  So signal
- * handlers cannot afford to do FP unless they preserve the state or
- * longjmp() out.  Both preserving the state and longjmp()ing may be
- * destroyed by IRQ13 bugs.  Clearing FP exceptions is not an acceptable
- * solution for signals other than SIGFPE.
+ * For XMM traps, the exceptions were never cleared.
  */
 int
 npxtrap()
@@ -623,9 +623,6 @@ npxtrap()
 		fnstcw(&control);
 		fnstsw(&status);
 	}
-
-	if (PCPU_GET(fpcurthread) == curthread)
-		fnclex();
 	critical_exit();
 	return (fpetable[status & ((~control & 0x3f) | 0x40)]);
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201209011555.q81FtEEA033983>