From owner-svn-src-all@FreeBSD.ORG Fri Aug 31 12:01:36 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 5A274106568F; Fri, 31 Aug 2012 12:01:36 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 1B9648FC2A; Fri, 31 Aug 2012 12:01:36 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q7VC1ZNk026669; Fri, 31 Aug 2012 12:01:35 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q7VC1Zc8026667; Fri, 31 Aug 2012 12:01:35 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201208311201.q7VC1Zc8026667@svn.freebsd.org> From: Konstantin Belousov Date: Fri, 31 Aug 2012 12:01:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r239946 - stable/9/sys/amd64/amd64 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 31 Aug 2012 12:01:36 -0000 Author: kib Date: Fri Aug 31 12:01:35 2012 New Revision: 239946 URL: http://svn.freebsd.org/changeset/base/239946 Log: MFC r238668: Stop clearing x87 exceptions in the #MF handler on amd64. Modified: stable/9/sys/amd64/amd64/fpu.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/amd64/amd64/fpu.c ============================================================================== --- stable/9/sys/amd64/amd64/fpu.c Fri Aug 31 11:48:04 2012 (r239945) +++ stable/9/sys/amd64/amd64/fpu.c Fri Aug 31 12:01:35 2012 (r239946) @@ -513,25 +513,21 @@ static char fpetable[128] = { }; /* - * Preserve the FP status word, clear FP exceptions for x87, 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 was necessary mainly to avoid IRQ13 bugs and is - * engraved in our i386 ABI. 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. * - * For SSE exceptions, the exceptions are not cleared. - * - * 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 fputrap_x87(void) @@ -553,7 +549,6 @@ fputrap_x87(void) } else { fnstcw(&control); fnstsw(&status); - fnclex(); } critical_exit();