summaryrefslogtreecommitdiffstats
path: root/sys/arch/sparc
diff options
context:
space:
mode:
authorguenther <guenther@openbsd.org>2012-08-07 05:16:53 +0000
committerguenther <guenther@openbsd.org>2012-08-07 05:16:53 +0000
commitfc5727155be1f5cfbba1fc7ca5d88b4656d9314c (patch)
treedd9b8fd2a3b476f9ed4bcbea968c071cb701b739 /sys/arch/sparc
parentkill sc->promisc (diff)
downloadwireguard-openbsd-fc5727155be1f5cfbba1fc7ca5d88b4656d9314c.tar.xz
wireguard-openbsd-fc5727155be1f5cfbba1fc7ca5d88b4656d9314c.zip
Move the common bits of syscall invocation and return handling into
an MI file, <sys/syscall_mi.h>, correcting inconsistencies and the handling when copyin() of arguments fails. Tested on i386, amd64, sparc64, and alpha (thanks naddy@) Any issues with other platforms will be fixed in tree. header name from millert@; ok miod@
Diffstat (limited to 'sys/arch/sparc')
-rw-r--r--sys/arch/sparc/sparc/trap.c51
1 files changed, 11 insertions, 40 deletions
diff --git a/sys/arch/sparc/sparc/trap.c b/sys/arch/sparc/sparc/trap.c
index d659e228cb1..61e67dd8cdd 100644
--- a/sys/arch/sparc/sparc/trap.c
+++ b/sys/arch/sparc/sparc/trap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: trap.c,v 1.59 2012/04/11 14:38:55 mikeb Exp $ */
+/* $OpenBSD: trap.c,v 1.60 2012/08/07 05:16:54 guenther Exp $ */
/* $NetBSD: trap.c,v 1.58 1997/09/12 08:55:01 pk Exp $ */
/*
@@ -60,13 +60,8 @@
#include <sys/signal.h>
#include <sys/wait.h>
#include <sys/syscall.h>
+#include <sys/syscall_mi.h>
#include <sys/syslog.h>
-#ifdef KTRACE
-#include <sys/ktrace.h>
-#endif
-
-#include "systrace.h"
-#include <dev/systrace.h>
#include <uvm/uvm_extern.h>
@@ -1015,33 +1010,20 @@ syscall(code, tf, pc)
if (i > nap) { /* usually false */
if (i > 8)
panic("syscall nargs");
- error = copyin((caddr_t)tf->tf_out[6] +
+ if ((error = copyin((caddr_t)tf->tf_out[6] +
offsetof(struct frame, fr_argx),
- (caddr_t)&args.i[nap], (i - nap) * sizeof(register_t));
- if (error) {
-#ifdef KTRACE
- if (KTRPOINT(p, KTR_SYSCALL))
- ktrsyscall(p, code,
- callp->sy_argsize, args.i);
-#endif
+ &args.i[nap], (i - nap) * sizeof(register_t))))
goto bad;
- }
i = nap;
}
- copywords(ap, args.i, i * sizeof(register_t));
+ if (error == 0)
+ copywords(ap, args.i, i * sizeof(register_t));
}
-#ifdef KTRACE
- if (KTRPOINT(p, KTR_SYSCALL))
- ktrsyscall(p, code, callp->sy_argsize, args.i);
-#endif
+
rval[0] = 0;
rval[1] = tf->tf_out[1];
-#if NSYSTRACE > 0
- if (ISSET(p->p_flag, P_SYSTRACE))
- error = systrace_redirect(code, p, &args, rval);
- else
-#endif
- error = (*callp->sy_call)(p, &args, rval);
+
+ error = mi_syscall(p, code, callp, args.i, rval);
switch (error) {
case 0:
@@ -1081,11 +1063,7 @@ syscall(code, tf, pc)
break;
}
- userret(p);
-#ifdef KTRACE
- if (KTRPOINT(p, KTR_SYSRET))
- ktrsysret(p, code, error, rval[0]);
-#endif
+ mi_syscall_return(p, code, error, rval);
share_fpu(p, tf);
}
@@ -1106,12 +1084,5 @@ child_return(arg)
tf->tf_out[1] = 0;
tf->tf_psr &= ~PSR_C;
- userret(p);
-#ifdef KTRACE
- if (KTRPOINT(p, KTR_SYSRET))
- ktrsysret(p,
- (p->p_flag & P_THREAD) ? SYS___tfork :
- (p->p_p->ps_flags & PS_PPWAIT) ? SYS_vfork : SYS_fork,
- 0, 0);
-#endif
+ mi_child_return(p);
}