Source-Changes-HG archive

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

[src/trunk]: src/sys/compat/mach Illegal instruction exceptions



details:   https://anonhg.NetBSD.org/src/rev/70c60b6d168a
branches:  trunk
changeset: 555433:70c60b6d168a
user:      manu <manu%NetBSD.org@localhost>
date:      Mon Nov 17 13:20:06 2003 +0000

description:
Illegal instruction exceptions
Warning on non-supported exception in task_set_exception_ports
Implementation of task_get_exception_ports

diffstat:

 sys/compat/mach/mach_exec.h   |   4 ++--
 sys/compat/mach/mach_notify.c |  26 ++++++++++++++++++++++++--
 sys/compat/mach/mach_notify.h |   4 +++-
 sys/compat/mach/mach_task.c   |  42 +++++++++++++++++++++++++++++++++++++-----
 4 files changed, 66 insertions(+), 10 deletions(-)

diffs (168 lines):

diff -r 660061aa28bd -r 70c60b6d168a sys/compat/mach/mach_exec.h
--- a/sys/compat/mach/mach_exec.h       Mon Nov 17 12:53:47 2003 +0000
+++ b/sys/compat/mach/mach_exec.h       Mon Nov 17 13:20:06 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mach_exec.h,v 1.19 2003/06/29 22:29:34 fvdl Exp $       */
+/*     $NetBSD: mach_exec.h,v 1.20 2003/11/17 13:20:06 manu Exp $       */
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -56,7 +56,7 @@
        struct mach_port *med_bootstrap;/* task bootstrap port */
        struct mach_port *med_kernel;   /* task kernel port */
        struct mach_port *med_host;     /* task host port */
-       struct mach_port *med_exc[MACH_EXC_MAX];        /* Exception ports */
+       struct mach_port *med_exc[MACH_EXC_MAX + 1];    /* Exception ports */
 
        int med_dirty_thid;             /* Thread id not yet initialized */
        int med_suspend;                /* Suspend semaphore */
diff -r 660061aa28bd -r 70c60b6d168a sys/compat/mach/mach_notify.c
--- a/sys/compat/mach/mach_notify.c     Mon Nov 17 12:53:47 2003 +0000
+++ b/sys/compat/mach/mach_notify.c     Mon Nov 17 13:20:06 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mach_notify.c,v 1.3 2003/11/17 01:52:14 manu Exp $ */
+/*     $NetBSD: mach_notify.c,v 1.4 2003/11/17 13:20:06 manu Exp $ */
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mach_notify.c,v 1.3 2003/11/17 01:52:14 manu Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mach_notify.c,v 1.4 2003/11/17 13:20:06 manu Exp $");
 
 #include "opt_ktrace.h"
 #include "opt_compat_mach.h" /* For COMPAT_MACH in <sys/ktrace.h> */
@@ -420,6 +420,28 @@
                            ksi->ksi_signo, ksi->ksi_code);
                        break;
                }
+               break;
+
+       case SIGILL:
+               switch (ksi->ksi_code) {
+               case ILL_ILLOPC:
+               case ILL_ILLOPN:
+               case ILL_ILLADR:
+               case ILL_ILLTRP:
+                       code[0] = MACH_ILL_ILLOPC;
+                       code[1] = (long)ksi->ksi_addr;
+                       break;
+               case ILL_PRVOPC:
+               case ILL_PRVREG:
+                       code[0] = MACH_ILL_PRVOPC;
+                       code[1] = (long)ksi->ksi_addr;
+                       break;
+               default:
+                       printf("untranslated siginfo signo %d, code %d\n", 
+                           ksi->ksi_signo, ksi->ksi_code);
+                       break;
+               }
+               break;
 
        default:
                printf("untranslated siginfo signo %d, code %d\n", 
diff -r 660061aa28bd -r 70c60b6d168a sys/compat/mach/mach_notify.h
--- a/sys/compat/mach/mach_notify.h     Mon Nov 17 12:53:47 2003 +0000
+++ b/sys/compat/mach/mach_notify.h     Mon Nov 17 13:20:06 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mach_notify.h,v 1.3 2003/11/17 01:52:14 manu Exp $ */
+/*     $NetBSD: mach_notify.h,v 1.4 2003/11/17 13:20:06 manu Exp $ */
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -111,6 +111,8 @@
 #define MACH_BUS_ADRALN                1
 #define MACH_SEGV_MAPERR       2
 #define MACH_TRAP_BRKPT                1
+#define MACH_ILL_ILLOPC                2
+#define MACH_ILL_PRVOPC                3
 
 /* Exception behaviors and associated messages Id */
 
diff -r 660061aa28bd -r 70c60b6d168a sys/compat/mach/mach_task.c
--- a/sys/compat/mach/mach_task.c       Mon Nov 17 12:53:47 2003 +0000
+++ b/sys/compat/mach/mach_task.c       Mon Nov 17 13:20:06 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mach_task.c,v 1.34 2003/11/17 01:52:14 manu Exp $ */
+/*     $NetBSD: mach_task.c,v 1.35 2003/11/17 13:20:06 manu Exp $ */
 
 /*-
  * Copyright (c) 2002-2003 The NetBSD Foundation, Inc.
@@ -39,7 +39,7 @@
 #include "opt_compat_darwin.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mach_task.c,v 1.34 2003/11/17 01:52:14 manu Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mach_task.c,v 1.35 2003/11/17 13:20:06 manu Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -348,16 +348,40 @@
        struct lwp *l = args->l;
        size_t *msglen = args->rsize;
        struct mach_emuldata *med;
+       struct mach_right *mr;
+       int i, j, count;
 
        med = l->l_proc->p_emuldata;
 
-       uprintf("Unimplemented mach_task_get_exception_ports\n");
+       /* It always return an array of 32 ports even if only 9 can be used */
+       count = sizeof(rep->rep_old_handler) / sizeof(rep->rep_old_handler[0]);
 
        rep->rep_msgh.msgh_bits =
-           MACH_MSGH_REPLY_LOCAL_BITS(MACH_MSG_TYPE_MOVE_SEND_ONCE);
+           MACH_MSGH_REPLY_LOCAL_BITS(MACH_MSG_TYPE_MOVE_SEND_ONCE) |
+           MACH_MSGH_BITS_COMPLEX;
        rep->rep_msgh.msgh_size = sizeof(*rep) - sizeof(rep->rep_trailer);
        rep->rep_msgh.msgh_local_port = req->req_msgh.msgh_local_port;
        rep->rep_msgh.msgh_id = req->req_msgh.msgh_id + 100;
+       rep->rep_body.msgh_descriptor_count = count;
+       rep->rep_masks_count = count;
+
+       j = 0;
+       for (i = 0; i <= MACH_EXC_MAX; i++) {
+               if (med->med_exc[i] == NULL)
+                       continue;
+
+               mr = mach_right_get(med->med_exc[i], l, MACH_PORT_TYPE_SEND, 0);
+
+               rep->rep_old_handler[j].name = mr->mr_name;
+               rep->rep_old_handler[j].disposition = 0x11; 
+               rep->rep_old_handler[j].type = 0;
+               rep->rep_masks[j] = 1 << i;
+               rep->rep_old_behaviors[j] = (int)mr->mr_port->mp_data >> 16;
+               rep->rep_old_flavors[j] = (int)mr->mr_port->mp_data & 0xff;
+
+               j++;
+       }
+
        rep->rep_trailer.msgh_trailer_size = 8;
 
        *msglen = sizeof(*rep);
@@ -396,7 +420,7 @@
                med->med_exc[MACH_EXC_BAD_ACCESS] = mp;
        if (req->req_mask & MACH_EXC_MASK_BAD_INSTRUCTION)
                med->med_exc[MACH_EXC_BAD_INSTRUCTION] = mp;
-       if (req->req_mask & MACH_EXC_MASK_ARITHMETIC)
+       if (req->req_mask & MACH_EXC_MASK_ARITHMETIC) 
                med->med_exc[MACH_EXC_ARITHMETIC] = mp;
        if (req->req_mask & MACH_EXC_MASK_EMULATION)
                med->med_exc[MACH_EXC_EMULATION] = mp;
@@ -411,6 +435,14 @@
        if (req->req_mask & MACH_EXC_MASK_RPC_ALERT)
                med->med_exc[MACH_EXC_RPC_ALERT] = mp;
 
+#ifdef DEBUG_MACH
+       if (req->req_mask & (MACH_EXC_ARITHMETIC | MACH_EXC_EMULATION |
+           MACH_EXC_MASK_SOFTWARE | MACH_EXC_MASK_SYSCALL |
+           MACH_EXC_MASK_MACH_SYSCALL | MACH_EXC_RPC_ALERT)) 
+               printf("mach_set_exception_ports: some exceptions are "
+                   "not supported (mask %x)\n", req->req_mask);
+#endif
+
        rep->rep_msgh.msgh_bits =
            MACH_MSGH_REPLY_LOCAL_BITS(MACH_MSG_TYPE_MOVE_SEND_ONCE);
        rep->rep_msgh.msgh_size = sizeof(*rep) - sizeof(rep->rep_trailer);



Home | Main Index | Thread Index | Old Index