Port-amd64 archive

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

trap.c lossage (SIGILL)



Hi folks,

i've comitted the following patch to fix the bad address returned in the
siginfo for the SIGILL signal on i386.

There were also some concerns though about the preservation of the %cs2
register in i386/amd64's trap.c since it is not stored in the trapframe. Would
it be a good idea to review/reaudit trap.c ?

With regards,
Reinoud


Tested and comitted patch for i386:
Index: trap.c
===================================================================
RCS file: /cvsroot/src/sys/arch/i386/i386/trap.c,v
retrieving revision 1.261
retrieving revision 1.262
diff -u -r1.261 -r1.262
--- trap.c      3 Apr 2011 22:29:26 -0000       1.261
+++ trap.c      7 Sep 2011 09:24:55 -0000       1.262
@@ -1,4 +1,4 @@
-/*     $NetBSD: trap.c,v 1.261 2011/04/03 22:29:26 dyoung Exp $        */
+/*     $NetBSD: trap.c,v 1.262 2011/09/07 09:24:55 reinoud Exp $       */
 
 /*-
  * Copyright (c) 1998, 2000, 2005, 2006, 2007, 2008 The NetBSD Foundation,
  * Inc.
@@ -68,7 +68,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.261 2011/04/03 22:29:26 dyoung Exp
$");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.262 2011/09/07 09:24:55 reinoud Exp
$");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -542,7 +542,7 @@
        case T_FPOPFLT|T_USER:          /* coprocessor operand fault */
                KSI_INIT_TRAP(&ksi);
                ksi.ksi_signo = SIGILL;
-               ksi.ksi_addr = (void *)rcr2();
+               ksi.ksi_addr = (void *) frame->tf_eip;
                switch (type) {
                case T_PRIVINFLT|T_USER:
                        ksi.ksi_code = ILL_PRVOPC;
------------

Proposed (untested) patch for amd64:
Index: trap.c
===================================================================
RCS file: /cvsroot/src/sys/arch/amd64/amd64/trap.c,v
retrieving revision 1.66
diff -u -p -r1.66 trap.c
--- trap.c      3 Apr 2011 22:29:25 -0000       1.66
+++ trap.c      7 Sep 2011 11:52:38 -0000
@@ -404,7 +404,7 @@ copyfault:
                KSI_INIT_TRAP(&ksi);
                ksi.ksi_signo = SIGILL;
                ksi.ksi_trap = type & ~T_USER;
-               ksi.ksi_addr = (void *)rcr2();
+               ksi.ksi_addr = (void *) frame->tf_rip;
                switch (type) {
                case T_PRIVINFLT|T_USER:
                        ksi.ksi_code = ILL_PRVOPC;
------------



Home | Main Index | Thread Index | Old Index