From owner-svn-src-stable@FreeBSD.ORG Sat Sep 1 15:57:12 2012 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D6308106566B; Sat, 1 Sep 2012 15:57:12 +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 B6D0F8FC15; Sat, 1 Sep 2012 15:57:12 +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 q81FvC0x034397; Sat, 1 Sep 2012 15:57:12 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q81FvCSk034393; Sat, 1 Sep 2012 15:57:12 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201209011557.q81FvCSk034393@svn.freebsd.org> From: Konstantin Belousov Date: Sat, 1 Sep 2012 15:57:12 +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: r239995 - in stable/9/sys/i386: i386 include isa X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 01 Sep 2012 15:57:13 -0000 Author: kib Date: Sat Sep 1 15:57:12 2012 New Revision: 239995 URL: http://svn.freebsd.org/changeset/base/239995 Log: MFC r238678: Provide siginfo.si_code for floating point errors when error occurs using the SSE math processor. Modified: stable/9/sys/i386/i386/trap.c stable/9/sys/i386/include/npx.h stable/9/sys/i386/isa/npx.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/i386/i386/trap.c ============================================================================== --- stable/9/sys/i386/i386/trap.c Sat Sep 1 15:55:14 2012 (r239994) +++ stable/9/sys/i386/i386/trap.c Sat Sep 1 15:57:12 2012 (r239995) @@ -368,7 +368,7 @@ trap(struct trapframe *frame) case T_ARITHTRAP: /* arithmetic trap */ #ifdef DEV_NPX - ucode = npxtrap(); + ucode = npxtrap_x87(); if (ucode == -1) goto userout; #else @@ -531,7 +531,13 @@ trap(struct trapframe *frame) break; case T_XMMFLT: /* SIMD floating-point exception */ - ucode = 0; /* XXX */ +#if defined(DEV_NPX) && !defined(CPU_DISABLE_SSE) && defined(I686_CPU) + ucode = npxtrap_sse(); + if (ucode == -1) + goto userout; +#else + ucode = 0; +#endif i = SIGFPE; break; } Modified: stable/9/sys/i386/include/npx.h ============================================================================== --- stable/9/sys/i386/include/npx.h Sat Sep 1 15:55:14 2012 (r239994) +++ stable/9/sys/i386/include/npx.h Sat Sep 1 15:57:12 2012 (r239995) @@ -175,7 +175,8 @@ int npxgetregs(struct thread *td); void npxinit(void); void npxsave(union savefpu *addr); void npxsetregs(struct thread *td, union savefpu *addr); -int npxtrap(void); +int npxtrap_x87(void); +int npxtrap_sse(void); void npxuserinited(struct thread *); struct fpu_kern_ctx *fpu_kern_alloc_ctx(u_int flags); void fpu_kern_free_ctx(struct fpu_kern_ctx *ctx); Modified: stable/9/sys/i386/isa/npx.c ============================================================================== --- stable/9/sys/i386/isa/npx.c Sat Sep 1 15:55:14 2012 (r239994) +++ stable/9/sys/i386/isa/npx.c Sat Sep 1 15:57:12 2012 (r239995) @@ -600,12 +600,13 @@ static char fpetable[128] = { * For XMM traps, the exceptions were never cleared. */ int -npxtrap() +npxtrap_x87(void) { u_short control, status; if (!hw_float) { - printf("npxtrap: fpcurthread = %p, curthread = %p, hw_float = %d\n", + printf( + "npxtrap_x87: fpcurthread = %p, curthread = %p, hw_float = %d\n", PCPU_GET(fpcurthread), curthread, hw_float); panic("npxtrap from nowhere"); } @@ -627,6 +628,28 @@ npxtrap() return (fpetable[status & ((~control & 0x3f) | 0x40)]); } +#ifdef CPU_ENABLE_SSE +int +npxtrap_sse(void) +{ + u_int mxcsr; + + if (!hw_float) { + printf( + "npxtrap_sse: 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) + mxcsr = curthread->td_pcb->pcb_save->sv_xmm.sv_env.en_mxcsr; + else + stmxcsr(&mxcsr); + critical_exit(); + return (fpetable[(mxcsr & (~mxcsr >> 7)) & 0x3f]); +} +#endif + /* * Implement device not available (DNA) exception *