]> git.saurik.com Git - apple/xnu.git/blobdiff - bsd/uxkern/ux_exception.c
xnu-4570.51.1.tar.gz
[apple/xnu.git] / bsd / uxkern / ux_exception.c
index dfbe2e5d22ed383ed44457c6e1f8f2d42f917f1c..21bd3eec9535affb2aebfb98e9fd4a0a14633770 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000-2008 Apple Inc. All rights reserved.
+ * Copyright (c) 2000-2016 Apple Inc. All rights reserved.
  *
  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
  * 
@@ -76,8 +76,7 @@ extern mach_msg_return_t mach_msg_send(mach_msg_header_t *msg,
                mach_msg_option_t option, mach_msg_size_t send_size,
                mach_msg_timeout_t send_timeout, mach_port_name_t notify);
 extern thread_t convert_port_to_thread(ipc_port_t port);
-extern void ipc_port_release(ipc_port_t);
-
+extern void ipc_port_release_send(ipc_port_t port);
 
 
 
@@ -90,7 +89,7 @@ static void   ux_exception(int exception, mach_exception_code_t code,
                                mach_exception_subcode_t subcode,
                                int *ux_signal, mach_exception_code_t *ux_code);
 
-#if defined(__x86_64__)
+#if defined(__x86_64__) || defined(__arm64__)
 mach_port_t                    ux_exception_port;
 #else
 mach_port_name_t               ux_exception_port;
@@ -98,8 +97,8 @@ mach_port_name_t              ux_exception_port;
 
 static task_t                  ux_handler_self;
 
-static
-void
+__attribute__((noreturn))
+static void
 ux_handler(void)
 {
     task_t             self = current_task();
@@ -239,7 +238,6 @@ catch_mach_exception_raise(
        task_t                  self = current_task();
        thread_t                th_act;
        ipc_port_t              thread_port;
-       struct task             *sig_task;
        struct proc             *p;
        kern_return_t           result = MACH_MSG_SUCCESS;
        int                     ux_signal = 0;
@@ -257,7 +255,7 @@ catch_mach_exception_raise(
                       (void *) &thread_port) == MACH_MSG_SUCCESS)) {
         if (IPC_PORT_VALID(thread_port)) {
           th_act = convert_port_to_thread(thread_port);
-          ipc_port_release(thread_port);
+          ipc_port_release_send(thread_port);
        } else {
           th_act = THREAD_NULL;
        }
@@ -273,10 +271,9 @@ catch_mach_exception_raise(
            ux_exception(exception, code[0], code[1], &ux_signal, &ucode);
 
            ut = get_bsdthread_info(th_act);
-           sig_task = get_threadtask(th_act);
-           p = (struct proc *) get_bsdtask_info(sig_task);
+           p = proc_findthread(th_act);
 
-           /* Can't deliver a signal without a bsd process */
+           /* Can't deliver a signal without a bsd process reference */
            if (p == NULL) {
                    ux_signal = 0;
                    result = KERN_FAILURE;
@@ -298,15 +295,9 @@ catch_mach_exception_raise(
                    struct sigacts      *ps;
 
                    sp = code[1];
-                   if (ut && (ut->uu_flag & UT_VFORK))
-                           p = ut->uu_proc;
-#if STACK_GROWTH_UP
-                   stack_min = p->user_stack;
-                   stack_max = p->user_stack + MAXSSIZ;
-#else /* STACK_GROWTH_UP */
+
                    stack_max = p->user_stack;
                    stack_min = p->user_stack - MAXSSIZ;
-#endif /* STACK_GROWTH_UP */
                    if (sp >= stack_min &&
                        sp < stack_max) {
                            /*
@@ -342,9 +333,10 @@ catch_mach_exception_raise(
                        ut->uu_exception = exception;
                        //ut->uu_code = code[0]; // filled in by threadsignal
                        ut->uu_subcode = code[1];                       
-                       threadsignal(th_act, ux_signal, code[0]);
+                       threadsignal(th_act, ux_signal, code[0], TRUE);
            }
-
+           if (p != NULL) 
+                   proc_rele(p);
            thread_deallocate(th_act);
        }
        else