[Midnightbsd-cvs] src [7977] trunk/sys/i386: provide siginfo.si_code for floating point in SSE on i386
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Thu Sep 15 04:19:08 EDT 2016
Revision: 7977
http://svnweb.midnightbsd.org/src/?rev=7977
Author: laffer1
Date: 2016-09-15 04:19:08 -0400 (Thu, 15 Sep 2016)
Log Message:
-----------
provide siginfo.si_code for floating point in SSE on i386
Modified Paths:
--------------
trunk/sys/i386/i386/trap.c
trunk/sys/i386/include/npx.h
trunk/sys/i386/isa/npx.c
Modified: trunk/sys/i386/i386/trap.c
===================================================================
--- trunk/sys/i386/i386/trap.c 2016-09-15 08:18:36 UTC (rev 7976)
+++ trunk/sys/i386/i386/trap.c 2016-09-15 08:19:08 UTC (rev 7977)
@@ -368,7 +368,7 @@
case T_ARITHTRAP: /* arithmetic trap */
#ifdef DEV_NPX
- ucode = npxtrap();
+ ucode = npxtrap_x87();
if (ucode == -1)
goto userout;
#else
@@ -531,7 +531,13 @@
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: trunk/sys/i386/include/npx.h
===================================================================
--- trunk/sys/i386/include/npx.h 2016-09-15 08:18:36 UTC (rev 7976)
+++ trunk/sys/i386/include/npx.h 2016-09-15 08:19:08 UTC (rev 7977)
@@ -175,7 +175,8 @@
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: trunk/sys/i386/isa/npx.c
===================================================================
--- trunk/sys/i386/isa/npx.c 2016-09-15 08:18:36 UTC (rev 7976)
+++ trunk/sys/i386/isa/npx.c 2016-09-15 08:19:08 UTC (rev 7977)
@@ -600,12 +600,13 @@
* 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 @@
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
*
More information about the Midnightbsd-cvs
mailing list