summaryrefslogtreecommitdiff
path: root/sys/arch/hp300
diff options
context:
space:
mode:
authorPhilip Guenthe <guenther@cvs.openbsd.org>2012-08-07 05:16:55 +0000
committerPhilip Guenthe <guenther@cvs.openbsd.org>2012-08-07 05:16:55 +0000
commit12210e5877035f0692aab9774dbc74ddc3b6fa9c (patch)
treebadcd4eba202fa3c274761b45d718bd4c00b1f00 /sys/arch/hp300
parent226d3b621ef34ce3bc45fefccf44913d47bd0d1d (diff)
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/hp300')
-rw-r--r--sys/arch/hp300/hp300/trap.c53
1 files changed, 14 insertions, 39 deletions
diff --git a/sys/arch/hp300/hp300/trap.c b/sys/arch/hp300/hp300/trap.c
index d299aa6b140..79dd088277f 100644
--- a/sys/arch/hp300/hp300/trap.c
+++ b/sys/arch/hp300/hp300/trap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: trap.c,v 1.60 2011/11/16 20:50:18 deraadt Exp $ */
+/* $OpenBSD: trap.c,v 1.61 2012/08/07 05:16:53 guenther Exp $ */
/* $NetBSD: trap.c,v 1.57 1998/02/16 20:58:31 thorpej Exp $ */
/*
@@ -70,11 +70,9 @@
#include <sys/signalvar.h>
#include <sys/resourcevar.h>
#include <sys/syscall.h>
+#include <sys/syscall_mi.h>
#include <sys/syslog.h>
#include <sys/user.h>
-#ifdef KTRACE
-#include <sys/ktrace.h>
-#endif
#include <m68k/frame.h>
@@ -85,9 +83,6 @@
#include <machine/reg.h>
#include <machine/intr.h>
-#include "systrace.h"
-#include <dev/systrace.h>
-
#include <uvm/uvm_extern.h>
#include <uvm/uvm_pmap.h>
@@ -949,8 +944,8 @@ syscall(code, frame)
/*
* Code is first argument, followed by actual args.
*/
- if (copyin(params, &code, sizeof(register_t)) != 0)
- code = -1;
+ if ((error = copyin(params, &code, sizeof(register_t))))
+ goto bad;
params += sizeof(int);
/*
* XXX sigreturn requires special stack manipulation
@@ -967,9 +962,9 @@ syscall(code, frame)
*/
if (callp != sysent)
break;
- if (copyin(params + _QUAD_LOWWORD * sizeof(int), &code,
- sizeof(register_t)) != 0)
- code = -1;
+ if ((error = copyin(params + _QUAD_LOWWORD * sizeof(int),
+ &code, sizeof(register_t))))
+ goto bad;
params += sizeof(quad_t);
break;
default:
@@ -980,27 +975,14 @@ syscall(code, frame)
else
callp += code;
argsize = callp->sy_argsize;
- if (argsize)
- error = copyin(params, (caddr_t)args, argsize);
- else
- error = 0;
-#ifdef SYSCALL_DEBUG
- scdebug_call(p, code, args);
-#endif
-#ifdef KTRACE
- if (KTRPOINT(p, KTR_SYSCALL))
- ktrsyscall(p, code, argsize, args);
-#endif
- if (error)
+ if (argsize && (error = copyin(params, args, argsize)))
goto bad;
+
rval[0] = 0;
rval[1] = frame.f_regs[D1];
-#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, rval);
+
switch (error) {
case 0:
frame.f_regs[D0] = rval[0];
@@ -1018,7 +1000,7 @@ syscall(code, frame)
/* nothing to do */
break;
default:
-bad:
+ bad:
if (p->p_emul->e_errno)
error = p->p_emul->e_errno[error];
frame.f_regs[D0] = error;
@@ -1026,12 +1008,5 @@ bad:
break;
}
-#ifdef SYSCALL_DEBUG
- scdebug_ret(p, code, error, rval);
-#endif
- userret(p);
-#ifdef KTRACE
- if (KTRPOINT(p, KTR_SYSRET))
- ktrsysret(p, code, error, rval[0]);
-#endif
+ mi_syscall_return(p, code, error, rval);
}