Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-3]: src/sys/arch/i386/i386 Pull up following revision(s) (request...



details:   https://anonhg.NetBSD.org/src/rev/8068ec265e29
branches:  netbsd-3
changeset: 577341:8068ec265e29
user:      tron <tron%NetBSD.org@localhost>
date:      Tue Oct 11 21:04:19 2005 +0000

description:
Pull up following revision(s) (requested by christos in ticket #880):
        sys/arch/i386/i386/vector.S: revision 1.20
        sys/arch/i386/i386/trap.c: revision 1.205
handle MMX faults as floating exceptions. Tested by Hauke Fath; matlab
passes all its regression suite without panicking the kernel.

diffstat:

 sys/arch/i386/i386/trap.c   |  48 +++++++++++++++++++++++++++++++++++++++++++-
 sys/arch/i386/i386/vector.S |   6 +++-
 2 files changed, 50 insertions(+), 4 deletions(-)

diffs (118 lines):

diff -r 638089278fc7 -r 8068ec265e29 sys/arch/i386/i386/trap.c
--- a/sys/arch/i386/i386/trap.c Tue Oct 11 21:02:33 2005 +0000
+++ b/sys/arch/i386/i386/trap.c Tue Oct 11 21:04:19 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: trap.c,v 1.204 2005/03/04 06:01:52 mycroft Exp $       */
+/*     $NetBSD: trap.c,v 1.204.2.1 2005/10/11 21:04:19 tron Exp $      */
 
 /*-
  * Copyright (c) 1998, 2000, 2005 The NetBSD Foundation, Inc.
@@ -75,7 +75,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.204 2005/03/04 06:01:52 mycroft Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.204.2.1 2005/10/11 21:04:19 tron Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -126,6 +126,7 @@
 
 #include "npx.h"
 
+static __inline int xmm_si_code(struct lwp *);
 void trap(struct trapframe *);
 void trap_tss(struct i386tss *, int, int);
 #if defined(I386_CPU)
@@ -199,6 +200,45 @@
        trap(&tf);
 }
 
+static __inline int
+xmm_si_code(struct lwp *l)
+{
+       uint32_t mxcsr, mask;
+
+       if (!i386_use_fxsave) {
+#ifdef DIAGNOSTIC
+               panic("SSE FP Exception, but no SSE");
+#endif
+               return 0;
+       }
+       mxcsr = l->l_addr->u_pcb.pcb_savefpu.sv_xmm.sv_env.en_mxcsr;
+
+       /*
+         * Since we only have a single status and control register,
+        * we use the exception mask bits to mask disabled exceptions
+        */
+       mask = ~((mxcsr & __INITIAL_MXCSR__) >> 7) & 0xff;
+        switch (mask & mxcsr) {
+       case EN_SW_INVOP:
+               return FPE_FLTINV;
+       case EN_SW_DENORM:
+       case EN_SW_PRECLOSS:
+               return FPE_FLTRES;
+       case EN_SW_ZERODIV:
+               return FPE_FLTDIV;
+       case EN_SW_OVERFLOW:
+               return FPE_FLTOVF;
+       case EN_SW_UNDERFLOW:
+               return FPE_FLTUND;
+       case EN_SW_DATACHAIN:
+               return FPE_FLTSUB;
+       case 0:
+       default:
+               return 0;
+        }
+}
+
+
 /*
  * trap(frame):
  *     Exception, fault, and trap interface to BSD kernel. This
@@ -486,6 +526,7 @@
 #endif
        }
 
+       case T_XMM|T_USER:
        case T_BOUND|T_USER:
        case T_OFLOW|T_USER:
        case T_DIVIDE|T_USER:
@@ -494,6 +535,9 @@
                ksi.ksi_signo = SIGFPE;
                ksi.ksi_addr = (void *)frame->tf_eip;
                switch (type) {
+               case T_XMM|T_USER:
+                       ksi.ksi_code = xmm_si_code(l);
+                       break;
                case T_BOUND|T_USER:
                case T_OFLOW|T_USER:
                        ksi.ksi_code = FPE_FLTOVF;
diff -r 638089278fc7 -r 8068ec265e29 sys/arch/i386/i386/vector.S
--- a/sys/arch/i386/i386/vector.S       Tue Oct 11 21:02:33 2005 +0000
+++ b/sys/arch/i386/i386/vector.S       Tue Oct 11 21:04:19 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vector.S,v 1.17.10.1 2005/08/24 21:46:31 tron Exp $    */
+/*     $NetBSD: vector.S,v 1.17.10.2 2005/10/11 21:04:19 tron Exp $    */
 
 /*
  * Copyright 2002 (c) Wasabi Systems, Inc.
@@ -791,7 +791,9 @@
 IDTVEC(trap11)
        TRAP(T_ALIGNFLT)
 IDTVEC(trap12)
+       ZTRAP(T_MCA)
 IDTVEC(trap13)
+       ZTRAP(T_XMM)
 IDTVEC(trap14)
 IDTVEC(trap15)
 IDTVEC(trap16)
@@ -804,7 +806,7 @@
 IDTVEC(trap1d)
 IDTVEC(trap1e)
 IDTVEC(trap1f)
-       /* 18 - 31 reserved for future exp */
+       /* 20 - 31 reserved for future exp */
        ZTRAP(T_RESERVED)
 
 IDTVEC(exceptions)



Home | Main Index | Thread Index | Old Index