sys/i386/isa/npx.c
/*
 * 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.
 *
 * 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.
 *
 * For XMM traps, the exceptions were never cleared.
 */
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.

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.

For XMM traps, the exceptions were never cleared.
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 . 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 . For XMM traps the exceptions were never cleared .
int
npxtrap_x87(void)
{
	u_short control, status;
	if (!hw_float) {
		printf(
	"npxtrap_x87: fpcurthread = %p, curthread = %p, hw_float = %d\n",
		       PCPU_GET(fpcurthread), curthread, hw_float);
		panic("npxtrap from nowhere");
	}
	critical_enter();
	if (PCPU_GET(fpcurthread) != curthread) {
		control = GET_FPU_CW(curthread);
		status = GET_FPU_SW(curthread);
	} else {
		fnstcw(&control);
		fnstsw(&status);
	}
	critical_exit();
	return (fpetable[status & ((~control & 0x3f) | 0x40)]);
}
int npxtrap_x87 ( void ) { u_short control , status ; if ( ! hw_float ) { printf ( " \n " , PCPU_GET ( fpcurthread ) , curthread , hw_float ) ; panic ( " " ) ; } critical_enter ( ) ; if ( PCPU_GET ( fpcurthread ) != curthread ) { control = GET_FPU_CW ( curthread ) ; status = GET_FPU_SW ( curthread ) ; } else { fnstcw ( & control ) ; fnstsw ( & status ) ; } critical_exit ( ) ; return ( fpetable [ status & ( ( ~ control & 0x3f ) | 0x40 ) ] ) ; }
Read the FP status and control words, then generate si_code value
 for SIGFPE.
Read the FP status and control words then generate si_code value for SIGFPE .
/*
	 * Interrupt handling (for another interrupt) may have pushed the
	 * state to memory.  Fetch the relevant parts of the state from
	 * wherever they are.
	 */