+ thread_act = current_thread();
+ uthread = get_bsdthread_info(thread_act);
+
+ if (!(uthread->uu_flag & UT_VFORK))
+ proc = (struct proc *)get_bsdtask_info(current_task());
+ else
+ proc = current_proc();
+
+ /* Make sure there is a process associated with this task */
+ if (proc == NULL) {
+ regs->save_r3 = (long long)EPERM;
+ /* set the "pc" to execute cerror routine */
+ regs->save_srr0 -= 4;
+ task_terminate_internal(current_task());
+ thread_exception_return();
+ /* NOTREACHED */
+ }
+
+ /*
+ * Delayed binding of thread credential to process credential, if we
+ * are not running with an explicitly set thread credential.
+ */
+ kauth_cred_uthread_update(uthread, proc);
+
+ callp = (code >= NUM_SYSENT) ? &sysent[63] : &sysent[code];
+
+ if (callp->sy_narg != 0) {
+ void *regsp;
+ sy_munge_t *mungerp;
+
+ if (IS_64BIT_PROCESS(proc)) {
+ /* XXX Turn 64 bit unsafe calls into nosys() */
+ if (callp->sy_flags & UNSAFE_64BIT) {
+ callp = &sysent[63];
+ goto unsafe;
+ }
+ mungerp = callp->sy_arg_munge64;
+ }
+ else {
+ mungerp = callp->sy_arg_munge32;
+ }
+ if ( !flavor) {
+ regsp = (void *) ®s->save_r3;
+ } else {
+ /* indirect system call consumes an argument so only 7 are supported */
+ if (callp->sy_narg > 7) {
+ callp = &sysent[63];
+ goto unsafe;
+ }
+ regsp = (void *) ®s->save_r4;
+ }
+ /* call syscall argument munger to copy in arguments (see xnu/bsd/dev/ppc/munge.s) */
+ (*mungerp)(regsp, (void *) &uthread->uu_arg[0]);
+ }