summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/arch/alpha/alpha/trap.c55
-rw-r--r--sys/arch/amd64/amd64/trap.c72
-rw-r--r--sys/arch/arm/arm/syscall.c56
-rw-r--r--sys/arch/hp300/hp300/trap.c53
-rw-r--r--sys/arch/hppa/hppa/trap.c79
-rw-r--r--sys/arch/hppa64/hppa64/trap.c46
-rw-r--r--sys/arch/i386/i386/trap.c80
-rw-r--r--sys/arch/m68k/m68k/m68k_machdep.c12
-rw-r--r--sys/arch/m88k/m88k/trap.c135
-rw-r--r--sys/arch/mips64/mips64/trap.c87
-rw-r--r--sys/arch/mvme68k/mvme68k/trap.c49
-rw-r--r--sys/arch/powerpc/powerpc/trap.c83
-rw-r--r--sys/arch/sh/sh/trap.c85
-rw-r--r--sys/arch/solbourne/solbourne/trap.c52
-rw-r--r--sys/arch/sparc/sparc/trap.c51
-rw-r--r--sys/arch/sparc64/sparc64/trap.c83
-rw-r--r--sys/arch/vax/vax/trap.c48
-rw-r--r--sys/kern/kern_xxx.c7
-rw-r--r--sys/sys/syscall_mi.h139
-rw-r--r--sys/sys/systm.h7
20 files changed, 366 insertions, 913 deletions
diff --git a/sys/arch/alpha/alpha/trap.c b/sys/arch/alpha/alpha/trap.c
index b6c4bf00b24..2963ebf0a25 100644
--- a/sys/arch/alpha/alpha/trap.c
+++ b/sys/arch/alpha/alpha/trap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: trap.c,v 1.60 2012/04/11 14:38:55 mikeb Exp $ */
+/* $OpenBSD: trap.c,v 1.61 2012/08/07 05:16:53 guenther Exp $ */
/* $NetBSD: trap.c,v 1.52 2000/05/24 16:48:33 thorpej Exp $ */
/*-
@@ -94,18 +94,13 @@
#include <sys/signalvar.h>
#include <sys/user.h>
#include <sys/syscall.h>
+#include <sys/syscall_mi.h>
#include <sys/buf.h>
#ifndef NO_IEEE
#include <sys/device.h>
#endif
-#ifdef KTRACE
-#include <sys/ktrace.h>
-#endif
#include <sys/ptrace.h>
-#include "systrace.h"
-#include <dev/systrace.h>
-
#include <uvm/uvm_extern.h>
#include <machine/cpu.h>
@@ -578,8 +573,9 @@ syscall(code, framep)
default:
if (nargs > 10) /* XXX */
panic("syscall: too many args (%d)", nargs);
- error = copyin((caddr_t)(alpha_pal_rdusp()), &args[6],
- (nargs - 6) * sizeof(u_long));
+ if ((error = copyin((caddr_t)(alpha_pal_rdusp()), &args[6],
+ (nargs - 6) * sizeof(u_long))))
+ goto bad;
case 6:
args[5] = framep->tf_regs[FRAME_A5];
case 5:
@@ -595,23 +591,11 @@ syscall(code, framep)
case 0:
break;
}
-#ifdef KTRACE
- if (KTRPOINT(p, KTR_SYSCALL))
- ktrsyscall(p, code, callp->sy_argsize, args + hidden);
-#endif
-#ifdef SYSCALL_DEBUG
- scdebug_call(p, code, args + hidden);
-#endif
- if (error == 0) {
- rval[0] = 0;
- rval[1] = 0;
-#if NSYSTRACE > 0
- if (ISSET(p->p_flag, P_SYSTRACE))
- error = systrace_redirect(code, p, args + hidden, rval);
- else
-#endif
- error = (*callp->sy_call)(p, args + hidden, rval);
- }
+
+ rval[0] = 0;
+ rval[1] = 0;
+
+ error = mi_syscall(p, code, callp, args + hidden, rval);
switch (error) {
case 0:
@@ -625,6 +609,7 @@ syscall(code, framep)
case EJUSTRETURN:
break;
default:
+ bad:
if (p->p_emul->e_errno)
error = p->p_emul->e_errno[error];
framep->tf_regs[FRAME_V0] = error;
@@ -632,17 +617,10 @@ syscall(code, framep)
break;
}
-#ifdef SYSCALL_DEBUG
- scdebug_ret(p, code, error, rval);
-#endif
/* Do any deferred user pmap operations. */
PMAP_USERRET(vm_map_pmap(&p->p_vmspace->vm_map));
- userret(p);
-#ifdef KTRACE
- if (KTRPOINT(p, KTR_SYSRET))
- ktrsysret(p, code, error, rval[0]);
-#endif
+ mi_syscall_return(p, code, error, rval);
}
/*
@@ -665,14 +643,7 @@ child_return(arg)
/* Do any deferred user pmap operations. */
PMAP_USERRET(vm_map_pmap(&p->p_vmspace->vm_map));
- 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);
}
/*
diff --git a/sys/arch/amd64/amd64/trap.c b/sys/arch/amd64/amd64/trap.c
index 85c969834db..ec6445b6db4 100644
--- a/sys/arch/amd64/amd64/trap.c
+++ b/sys/arch/amd64/amd64/trap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: trap.c,v 1.28 2012/04/11 14:38:55 mikeb Exp $ */
+/* $OpenBSD: trap.c,v 1.29 2012/08/07 05:16:53 guenther Exp $ */
/* $NetBSD: trap.c,v 1.2 2003/05/04 23:51:56 fvdl Exp $ */
/*-
@@ -77,13 +77,8 @@
#include <sys/acct.h>
#include <sys/kernel.h>
#include <sys/signal.h>
-#ifdef KTRACE
-#include <sys/ktrace.h>
-#endif
#include <sys/syscall.h>
-
-#include "systrace.h"
-#include <dev/systrace.h>
+#include <sys/syscall_mi.h>
#include <uvm/uvm_extern.h>
@@ -494,7 +489,6 @@ syscall(struct trapframe *frame)
int nsys;
size_t argsize, argoff;
register_t code, args[9], rval[2], *argp;
- int lock;
uvmexp.syscalls++;
p = curproc;
@@ -546,43 +540,16 @@ syscall(struct trapframe *frame)
if (argsize > 6) {
argsize -= 6;
params = (caddr_t)frame->tf_rsp + sizeof(register_t);
- error = copyin(params, (caddr_t)&args[6],
- argsize << 3);
- if (error != 0)
+ if ((error = copyin(params, &args[6], argsize << 3)))
goto bad;
}
}
- lock = !(callp->sy_flags & SY_NOLOCK);
-
-#ifdef SYSCALL_DEBUG
- KERNEL_LOCK();
- scdebug_call(p, code, argp);
- KERNEL_UNLOCK();
-#endif
-#ifdef KTRACE
- if (KTRPOINT(p, KTR_SYSCALL)) {
- KERNEL_LOCK();
- ktrsyscall(p, code, callp->sy_argsize, argp);
- KERNEL_UNLOCK();
- }
-#endif
rval[0] = 0;
rval[1] = frame->tf_rdx;
-#if NSYSTRACE > 0
- if (ISSET(p->p_flag, P_SYSTRACE)) {
- KERNEL_LOCK();
- error = systrace_redirect(code, p, argp, rval);
- KERNEL_UNLOCK();
- } else
-#endif
- {
- if (lock)
- KERNEL_LOCK();
- error = (*callp->sy_call)(p, argp, rval);
- if (lock)
- KERNEL_UNLOCK();
- }
+
+ error = mi_syscall(p, code, callp, argp, rval);
+
switch (error) {
case 0:
frame->tf_rax = rval[0];
@@ -607,19 +574,7 @@ syscall(struct trapframe *frame)
break;
}
-#ifdef SYSCALL_DEBUG
- KERNEL_LOCK();
- scdebug_ret(p, code, error, rval);
- KERNEL_UNLOCK();
-#endif
- userret(p);
-#ifdef KTRACE
- if (KTRPOINT(p, KTR_SYSRET)) {
- KERNEL_LOCK();
- ktrsysret(p, code, error, rval[0]);
- KERNEL_UNLOCK();
- }
-#endif
+ mi_syscall_return(p, code, error, rval);
}
void
@@ -634,15 +589,6 @@ child_return(void *arg)
KERNEL_UNLOCK();
- userret(p);
-#ifdef KTRACE
- if (KTRPOINT(p, KTR_SYSRET)) {
- KERNEL_LOCK();
- ktrsysret(p,
- (p->p_flag & P_THREAD) ? SYS___tfork :
- (p->p_p->ps_flags & PS_PPWAIT) ? SYS_vfork : SYS_fork,
- 0, 0);
- KERNEL_UNLOCK();
- }
-#endif
+ mi_child_return(p);
}
+
diff --git a/sys/arch/arm/arm/syscall.c b/sys/arch/arm/arm/syscall.c
index 655139c521a..45ec8ebcfe5 100644
--- a/sys/arch/arm/arm/syscall.c
+++ b/sys/arch/arm/arm/syscall.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: syscall.c,v 1.14 2012/04/11 14:38:55 mikeb Exp $ */
+/* $OpenBSD: syscall.c,v 1.15 2012/08/07 05:16:53 guenther Exp $ */
/* $NetBSD: syscall.c,v 1.24 2003/11/14 19:03:17 scw Exp $ */
/*-
@@ -78,15 +78,10 @@
#include <sys/reboot.h>
#include <sys/signalvar.h>
#include <sys/syscall.h>
+#include <sys/syscall_mi.h>
#include <sys/systm.h>
#include <sys/proc.h>
#include <sys/user.h>
-#ifdef KTRACE
-#include <sys/ktrace.h>
-#endif
-
-#include "systrace.h"
-#include <dev/systrace.h>
#include <uvm/uvm_extern.h>
@@ -102,7 +97,7 @@ swi_handler(trapframe_t *frame)
{
struct proc *p = curproc;
const struct sysent *callp;
- int code, error, orig_error;
+ int code, error;
u_int nap = 4, nargs;
register_t *ap, *args, copyargs[MAXARGS], rval[2];
@@ -139,33 +134,19 @@ swi_handler(trapframe_t *frame)
nargs = callp->sy_argsize / sizeof(register_t);
if (nargs <= nap) {
args = ap;
- error = 0;
} else {
KASSERT(nargs <= MAXARGS);
memcpy(copyargs, ap, nap * sizeof(register_t));
- error = copyin((void *)frame->tf_usr_sp, copyargs + nap,
- (nargs - nap) * sizeof(register_t));
+ if ((error = copyin((void *)frame->tf_usr_sp, copyargs + nap,
+ (nargs - nap) * sizeof(register_t))))
+ goto bad;
args = copyargs;
}
- orig_error = error;
-#ifdef SYSCALL_DEBUG
- scdebug_call(p, code, args);
-#endif
-#ifdef KTRACE
- if (KTRPOINT(p, KTR_SYSCALL))
- ktrsyscall(p, code, callp->sy_argsize, args);
-#endif
- if (error)
- goto bad;
rval[0] = 0;
rval[1] = frame->tf_r1;
-#if NSYSTRACE > 0
- if (ISSET(p->p_flag, P_SYSTRACE))
- orig_error = error = systrace_redirect(code, p, args, rval);
- else
-#endif
- orig_error = error = (*callp->sy_call)(p, args, rval);
+
+ error = mi_syscall(p, code, callp, args, rval);
switch (error) {
case 0:
@@ -192,14 +173,8 @@ swi_handler(trapframe_t *frame)
frame->tf_spsr |= PSR_C_bit; /* carry bit */
break;
}
-#ifdef SYSCALL_DEBUG
- scdebug_ret(p, code, orig_error, rval);
-#endif
- userret(p);
-#ifdef KTRACE
- if (KTRPOINT(p, KTR_SYSRET))
- ktrsysret(p, code, orig_error, rval[0]);
-#endif
+
+ mi_syscall_return(p, code, error, rval);
}
void
@@ -212,14 +187,5 @@ child_return(arg)
frame->tf_r0 = 0;
frame->tf_spsr &= ~PSR_C_bit; /* carry bit */
- 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);
}
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);
}
diff --git a/sys/arch/hppa/hppa/trap.c b/sys/arch/hppa/hppa/trap.c
index 8ebf286f463..7da4b3f4532 100644
--- a/sys/arch/hppa/hppa/trap.c
+++ b/sys/arch/hppa/hppa/trap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: trap.c,v 1.122 2012/04/11 14:38:55 mikeb Exp $ */
+/* $OpenBSD: trap.c,v 1.123 2012/08/07 05:16:53 guenther Exp $ */
/*
* Copyright (c) 1998-2004 Michael Shalayeff
@@ -31,14 +31,12 @@
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/syscall.h>
+#include <sys/syscall_mi.h>
#include <sys/ktrace.h>
#include <sys/proc.h>
#include <sys/signalvar.h>
#include <sys/user.h>
-#include "systrace.h"
-#include <dev/systrace.h>
-
#include <uvm/uvm.h>
#include <machine/autoconf.h>
@@ -659,17 +657,8 @@ child_return(void *arg)
KERNEL_UNLOCK();
ast(p);
- userret(p);
-#ifdef KTRACE
- if (KTRPOINT(p, KTR_SYSRET)) {
- KERNEL_LOCK();
- ktrsysret(p,
- (p->p_flag & P_THREAD) ? SYS___tfork :
- (p->p_p->ps_flags & PS_PPWAIT) ? SYS_vfork : SYS_fork,
- 0, 0);
- KERNEL_UNLOCK();
- }
-#endif
+
+ mi_child_return(p);
}
#ifdef PTRACE
@@ -838,17 +827,14 @@ syscall(struct trapframe *frame)
else
callp += code;
- oerror = error = 0;
if ((argsize = callp->sy_argsize)) {
int i;
for (i = 0, argsize -= argoff * 4;
argsize > 0; i++, argsize -= 4) {
- error = copyin((void *)(frame->tf_sp +
- HPPA_FRAME_ARG(i + 4)), args + i + argoff, 4);
-
- if (error)
- break;
+ if ((error = copyin((void *)(frame->tf_sp +
+ HPPA_FRAME_ARG(i + 4)), args + i + argoff, 4)))
+ goto bad;
}
/*
@@ -860,7 +846,7 @@ syscall(struct trapframe *frame)
* by their normal syscall number, maybe a regress
* test should be used, to watch the behaviour.
*/
- if (!error && argoff < 4) {
+ if (argoff < 4) {
int t;
i = 0;
@@ -884,39 +870,11 @@ syscall(struct trapframe *frame)
}
}
-#ifdef SYSCALL_DEBUG
- KERNEL_LOCK();
- scdebug_call(p, code, args);
- KERNEL_UNLOCK();
-#endif
-#ifdef KTRACE
- if (KTRPOINT(p, KTR_SYSCALL)) {
- KERNEL_LOCK();
- ktrsyscall(p, code, callp->sy_argsize, args);
- KERNEL_UNLOCK();
- }
-#endif
- if (error)
- goto bad;
-
rval[0] = 0;
rval[1] = frame->tf_ret1;
-#if NSYSTRACE > 0
- if (ISSET(p->p_flag, P_SYSTRACE)) {
- KERNEL_LOCK();
- oerror = error = systrace_redirect(code, p, args, rval);
- KERNEL_UNLOCK();
- } else
-#endif
- {
- int nolock = (callp->sy_flags & SY_NOLOCK);
- if (!nolock)
- KERNEL_LOCK();
- oerror = error = (*callp->sy_call)(p, args, rval);
- if (!nolock)
- KERNEL_UNLOCK();
- }
+ oerror = error = mi_syscall(p, code, callp, args, rval);
+
switch (error) {
case 0:
frame->tf_ret0 = rval[0];
@@ -937,20 +895,11 @@ syscall(struct trapframe *frame)
frame->tf_ret1 = 0;
break;
}
-#ifdef SYSCALL_DEBUG
- KERNEL_LOCK();
- scdebug_ret(p, code, oerror, rval);
- KERNEL_UNLOCK();
-#endif
+
ast(p);
- userret(p);
-#ifdef KTRACE
- if (KTRPOINT(p, KTR_SYSRET)) {
- KERNEL_LOCK();
- ktrsysret(p, code, oerror, rval[0]);
- KERNEL_UNLOCK();
- }
-#endif
+
+ mi_syscall_return(p, code, oerror, rval);
+
#ifdef DIAGNOSTIC
if (curcpu()->ci_cpl != oldcpl) {
printf("WARNING: SPL (0x%x) NOT LOWERED ON "
diff --git a/sys/arch/hppa64/hppa64/trap.c b/sys/arch/hppa64/hppa64/trap.c
index 6499e43d94f..f917976a8c5 100644
--- a/sys/arch/hppa64/hppa64/trap.c
+++ b/sys/arch/hppa64/hppa64/trap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: trap.c,v 1.30 2012/04/11 14:38:55 mikeb Exp $ */
+/* $OpenBSD: trap.c,v 1.31 2012/08/07 05:16:53 guenther Exp $ */
/*
* Copyright (c) 2005 Michael Shalayeff
@@ -22,14 +22,12 @@
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/syscall.h>
+#include <sys/syscall_mi.h>
#include <sys/ktrace.h>
#include <sys/proc.h>
#include <sys/signalvar.h>
#include <sys/user.h>
-#include "systrace.h"
-#include <dev/systrace.h>
-
#include <uvm/uvm.h>
#include <machine/autoconf.h>
@@ -551,14 +549,8 @@ child_return(void *arg)
tf->tf_r1 = 0; /* errno */
ast(p);
- 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);
}
void syscall(struct trapframe *frame);
@@ -615,23 +607,11 @@ syscall(struct trapframe *frame)
else
callp += code;
- oerror = error = 0;
-
-#ifdef SYSCALL_DEBUG
- scdebug_call(p, code, args);
-#endif
-#ifdef KTRACE
- if (KTRPOINT(p, KTR_SYSCALL))
- ktrsyscall(p, code, callp->sy_argsize, args);
-#endif
rval[0] = 0;
rval[1] = frame->tf_ret1;
-#if NSYSTRACE > 0
- if (ISSET(p->p_flag, P_SYSTRACE))
- oerror = error = systrace_redirect(code, p, args, rval);
- else
-#endif
- oerror = error = (*callp->sy_call)(p, args, rval);
+
+ oerror = error = mi_syscall(p, code, callp, args, rval);
+
switch (error) {
case 0:
frame->tf_ret0 = rval[0];
@@ -651,15 +631,11 @@ syscall(struct trapframe *frame)
frame->tf_ret1 = 0;
break;
}
-#ifdef SYSCALL_DEBUG
- scdebug_ret(p, code, oerror, rval);
-#endif
+
ast(p);
- userret(p);
-#ifdef KTRACE
- if (KTRPOINT(p, KTR_SYSRET))
- ktrsysret(p, code, oerror, rval[0]);
-#endif
+
+ mi_syscall_return(p, code, oerror, rval);
+
#ifdef DIAGNOSTIC
if (curcpu()->ci_cpl != oldcpl) {
printf("WARNING: SPL (0x%x) NOT LOWERED ON "
diff --git a/sys/arch/i386/i386/trap.c b/sys/arch/i386/i386/trap.c
index 7e8e867c9b7..db4d6b73b67 100644
--- a/sys/arch/i386/i386/trap.c
+++ b/sys/arch/i386/i386/trap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: trap.c,v 1.102 2012/04/11 14:38:55 mikeb Exp $ */
+/* $OpenBSD: trap.c,v 1.103 2012/08/07 05:16:53 guenther Exp $ */
/* $NetBSD: trap.c,v 1.95 1996/05/05 06:50:02 mycroft Exp $ */
/*-
@@ -48,13 +48,8 @@
#include <sys/acct.h>
#include <sys/kernel.h>
#include <sys/signal.h>
-#ifdef KTRACE
-#include <sys/ktrace.h>
-#endif
#include <sys/syscall.h>
-
-#include "systrace.h"
-#include <dev/systrace.h>
+#include <sys/syscall_mi.h>
#include <uvm/uvm_extern.h>
@@ -541,7 +536,7 @@ syscall(struct trapframe *frame)
caddr_t params;
struct sysent *callp;
struct proc *p;
- int orig_error, error, opc, nsys, lock;
+ int orig_error, error, opc, nsys;
register_t code, args[8], rval[2];
#ifdef DIAGNOSTIC
int ocpl = lapic_tpr;
@@ -637,52 +632,16 @@ syscall(struct trapframe *frame)
argsize);
break;
}
- error = 0;
}
else
#endif
- if (argsize)
- error = copyin(params, (caddr_t)args, argsize);
- else
- error = 0;
- orig_error = error;
-
- lock = !(callp->sy_flags & SY_NOLOCK);
-
-#ifdef SYSCALL_DEBUG
- KERNEL_LOCK();
- scdebug_call(p, code, args);
- KERNEL_UNLOCK();
-#endif
-
-#ifdef KTRACE
- if (KTRPOINT(p, KTR_SYSCALL)) {
- KERNEL_LOCK();
- ktrsyscall(p, code, argsize, args);
- KERNEL_UNLOCK();
- }
-#endif
-
- if (error) {
+ if (argsize && (error = copyin(params, args, argsize)))
goto bad;
- }
+
rval[0] = 0;
rval[1] = frame->tf_edx;
-#if NSYSTRACE > 0
- if (ISSET(p->p_flag, P_SYSTRACE)) {
- KERNEL_LOCK();
- orig_error = error = systrace_redirect(code, p, args, rval);
- KERNEL_UNLOCK();
- } else
-#endif
- {
- if (lock)
- KERNEL_LOCK();
- orig_error = error = (*callp->sy_call)(p, args, rval);
- if (lock)
- KERNEL_UNLOCK();
- }
+ orig_error = error = mi_syscall(p, code, callp, args, rval);
switch (error) {
case 0:
@@ -710,19 +669,8 @@ syscall(struct trapframe *frame)
break;
}
-#ifdef SYSCALL_DEBUG
- KERNEL_LOCK();
- scdebug_ret(p, code, orig_error, rval);
- KERNEL_UNLOCK();
-#endif
- userret(p);
-#ifdef KTRACE
- if (KTRPOINT(p, KTR_SYSRET)) {
- KERNEL_LOCK();
- ktrsysret(p, code, orig_error, rval[0]);
- KERNEL_UNLOCK();
- }
-#endif
+ mi_syscall_return(p, code, orig_error, rval);
+
#ifdef DIAGNOSTIC
if (lapic_tpr != ocpl) {
printf("WARNING: SPL (0x%x) NOT LOWERED ON "
@@ -744,15 +692,5 @@ child_return(void *arg)
KERNEL_UNLOCK();
- userret(p);
-#ifdef KTRACE
- if (KTRPOINT(p, KTR_SYSRET)) {
- KERNEL_LOCK();
- ktrsysret(p,
- (p->p_flag & P_THREAD) ? SYS___tfork :
- (p->p_p->ps_flags & PS_PPWAIT) ? SYS_vfork : SYS_fork,
- 0, 0);
- KERNEL_UNLOCK();
- }
-#endif
+ mi_child_return(p);
}
diff --git a/sys/arch/m68k/m68k/m68k_machdep.c b/sys/arch/m68k/m68k/m68k_machdep.c
index 30251fcddd2..e9e42eb266e 100644
--- a/sys/arch/m68k/m68k/m68k_machdep.c
+++ b/sys/arch/m68k/m68k/m68k_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: m68k_machdep.c,v 1.16 2012/04/11 14:38:55 mikeb Exp $ */
+/* $OpenBSD: m68k_machdep.c,v 1.17 2012/08/07 05:16:53 guenther Exp $ */
/* $NetBSD: m68k_machdep.c,v 1.3 1997/06/12 09:57:04 veego Exp $ */
/*-
@@ -35,6 +35,7 @@
#include <sys/exec.h>
#include <sys/proc.h>
#include <sys/syscall.h>
+#include <sys/syscall_mi.h>
#include <sys/ktrace.h>
#include <sys/user.h>
@@ -85,12 +86,5 @@ child_return(arg)
f->f_sr &= ~PSL_C; /* carry bit */
f->f_format = FMT0;
- 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);
}
diff --git a/sys/arch/m88k/m88k/trap.c b/sys/arch/m88k/m88k/trap.c
index 2cad56abb1d..be32edeedde 100644
--- a/sys/arch/m88k/m88k/trap.c
+++ b/sys/arch/m88k/m88k/trap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: trap.c,v 1.80 2012/04/11 14:38:55 mikeb Exp $ */
+/* $OpenBSD: trap.c,v 1.81 2012/08/07 05:16:53 guenther Exp $ */
/*
* Copyright (c) 2004, Miodrag Vallat.
* Copyright (c) 1998 Steve Murphree, Jr.
@@ -51,12 +51,10 @@
#include <sys/signalvar.h>
#include <sys/user.h>
#include <sys/syscall.h>
+#include <sys/syscall_mi.h>
#include <sys/systm.h>
#include <sys/ktrace.h>
-#include "systrace.h"
-#include <dev/systrace.h>
-
#include <uvm/uvm_extern.h>
#include <machine/asm_macro.h>
@@ -1138,7 +1136,6 @@ m88100_syscall(register_t code, struct trapframe *tf)
struct proc *p = curproc;
int error;
register_t args[8], rval[2], *ap;
- int nolock;
uvmexp.syscalls++;
@@ -1181,45 +1178,16 @@ m88100_syscall(register_t code, struct trapframe *tf)
panic("syscall nargs");
if (i > nap) {
bcopy((caddr_t)ap, (caddr_t)args, nap * sizeof(register_t));
- error = copyin((caddr_t)tf->tf_r[31], (caddr_t)(args + nap),
- (i - nap) * sizeof(register_t));
- } else {
+ if ((error = copyin((caddr_t)tf->tf_r[31], args + nap,
+ (i - nap) * sizeof(register_t))))
+ goto bad;
+ } else
bcopy((caddr_t)ap, (caddr_t)args, i * sizeof(register_t));
- error = 0;
- }
- if (error != 0)
- goto bad;
-
-#ifdef SYSCALL_DEBUG
- KERNEL_LOCK();
- scdebug_call(p, code, args);
- KERNEL_UNLOCK();
-#endif
-#ifdef KTRACE
- if (KTRPOINT(p, KTR_SYSCALL)) {
- KERNEL_LOCK();
- ktrsyscall(p, code, callp->sy_argsize, args);
- KERNEL_UNLOCK();
- }
-#endif
rval[0] = 0;
rval[1] = tf->tf_r[3];
-#if NSYSTRACE > 0
- if (ISSET(p->p_flag, P_SYSTRACE)) {
- KERNEL_LOCK();
- error = systrace_redirect(code, p, args, rval);
- KERNEL_UNLOCK();
- } else
-#endif
- {
- nolock = (callp->sy_flags & SY_NOLOCK);
- if (!nolock)
- KERNEL_LOCK();
- error = (*callp->sy_call)(p, args, rval);
- if (!nolock)
- KERNEL_UNLOCK();
- }
+
+ error = mi_syscall(p, code, callp, args, rval);
/*
* system call will look like:
@@ -1267,7 +1235,7 @@ m88100_syscall(register_t code, struct trapframe *tf)
tf->tf_epsr &= ~PSR_C;
break;
default:
-bad:
+ bad:
if (p->p_emul->e_errno)
error = p->p_emul->e_errno[error];
tf->tf_r[2] = error;
@@ -1276,19 +1244,8 @@ bad:
tf->tf_sfip = tf->tf_sfip & ~FIP_E;
break;
}
-#ifdef SYSCALL_DEBUG
- KERNEL_LOCK();
- scdebug_ret(p, code, error, rval);
- KERNEL_UNLOCK();
-#endif
- userret(p);
-#ifdef KTRACE
- if (KTRPOINT(p, KTR_SYSRET)) {
- KERNEL_LOCK();
- ktrsysret(p, code, error, rval[0]);
- KERNEL_UNLOCK();
- }
-#endif
+
+ mi_syscall_return(p, code, error, rval);
}
#endif /* M88100 */
@@ -1302,7 +1259,6 @@ m88110_syscall(register_t code, struct trapframe *tf)
struct proc *p = curproc;
int error;
register_t args[8], rval[2], *ap;
- int nolock;
uvmexp.syscalls++;
@@ -1345,45 +1301,16 @@ m88110_syscall(register_t code, struct trapframe *tf)
panic("syscall nargs");
if (i > nap) {
bcopy((caddr_t)ap, (caddr_t)args, nap * sizeof(register_t));
- error = copyin((caddr_t)tf->tf_r[31], (caddr_t)(args + nap),
- (i - nap) * sizeof(register_t));
- } else {
+ if ((error = copyin((caddr_t)tf->tf_r[31], args + nap,
+ (i - nap) * sizeof(register_t))))
+ goto bad;
+ } else
bcopy((caddr_t)ap, (caddr_t)args, i * sizeof(register_t));
- error = 0;
- }
-
- if (error != 0)
- goto bad;
-#ifdef SYSCALL_DEBUG
- KERNEL_LOCK();
- scdebug_call(p, code, args);
- KERNEL_UNLOCK();
-#endif
-#ifdef KTRACE
- if (KTRPOINT(p, KTR_SYSCALL)) {
- KERNEL_LOCK();
- ktrsyscall(p, code, callp->sy_argsize, args);
- KERNEL_UNLOCK();
- }
-#endif
rval[0] = 0;
rval[1] = tf->tf_r[3];
-#if NSYSTRACE > 0
- if (ISSET(p->p_flag, P_SYSTRACE)) {
- KERNEL_LOCK();
- error = systrace_redirect(code, p, args, rval);
- KERNEL_UNLOCK();
- } else
-#endif
- {
- nolock = (callp->sy_flags & SY_NOLOCK);
- if (!nolock)
- KERNEL_LOCK();
- error = (*callp->sy_call)(p, args, rval);
- if (!nolock)
- KERNEL_UNLOCK();
- }
+
+ error = mi_syscall(p, code, callp, args, rval);
/*
* system call will look like:
@@ -1433,7 +1360,7 @@ m88110_syscall(register_t code, struct trapframe *tf)
m88110_skip_insn(tf);
break;
default:
-bad:
+ bad:
if (p->p_emul->e_errno)
error = p->p_emul->e_errno[error];
tf->tf_r[2] = error;
@@ -1443,19 +1370,7 @@ bad:
break;
}
-#ifdef SYSCALL_DEBUG
- KERNEL_LOCK();
- scdebug_ret(p, code, error, rval);
- KERNEL_UNLOCK();
-#endif
- userret(p);
-#ifdef KTRACE
- if (KTRPOINT(p, KTR_SYSRET)) {
- KERNEL_LOCK();
- ktrsysret(p, code, error, rval[0]);
- KERNEL_UNLOCK();
- }
-#endif
+ mi_syscall_return(p, code, error, rval);
}
#endif /* M88110 */
@@ -1490,18 +1405,8 @@ child_return(arg)
#endif
KERNEL_UNLOCK();
- userret(p);
-#ifdef KTRACE
- if (KTRPOINT(p, KTR_SYSRET)) {
- KERNEL_LOCK();
- ktrsysret(p,
- (p->p_flag & P_THREAD) ? SYS___tfork :
- (p->p_p->ps_flags & PS_PPWAIT) ? SYS_vfork : SYS_fork,
- 0, 0);
- KERNEL_UNLOCK();
- }
-#endif
+ mi_child_return(p);
}
#ifdef PTRACE
diff --git a/sys/arch/mips64/mips64/trap.c b/sys/arch/mips64/mips64/trap.c
index 66725092ad3..c5b73a3b3ba 100644
--- a/sys/arch/mips64/mips64/trap.c
+++ b/sys/arch/mips64/mips64/trap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: trap.c,v 1.81 2012/04/11 14:38:55 mikeb Exp $ */
+/* $OpenBSD: trap.c,v 1.82 2012/08/07 05:16:54 guenther Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@@ -50,12 +50,10 @@
#include <sys/kernel.h>
#include <sys/signalvar.h>
#include <sys/syscall.h>
+#include <sys/syscall_mi.h>
#include <sys/user.h>
#include <sys/buf.h>
#include <sys/device.h>
-#ifdef KTRACE
-#include <sys/ktrace.h>
-#endif
#ifdef PTRACE
#include <sys/ptrace.h>
#endif
@@ -80,9 +78,6 @@
#include <sys/syslog.h>
-#include "systrace.h"
-#include <dev/systrace.h>
-
#define USERMODE(ps) (((ps) & SR_KSU_MASK) == SR_KSU_USER)
const char *trap_type[] = {
@@ -402,7 +397,7 @@ printf("SIG-BUSB @%p pc %p, ra %p\n", trapframe->badvaddr, trapframe->pc, trapfr
struct sysent *callp;
unsigned int code;
unsigned long tpc;
- int numsys;
+ int numsys, error;
struct args {
register_t i[8];
} args;
@@ -439,8 +434,9 @@ printf("SIG-BUSB @%p pc %p, ra %p\n", trapframe->badvaddr, trapframe->pc, trapfr
args.i[4] = locr0->a5;
args.i[5] = locr0->a6;
args.i[6] = locr0->a7;
- i = copyin((void *)locr0->sp,
- &args.i[7], sizeof(register_t));
+ if ((error = copyin((void *)locr0->sp,
+ &args.i[7], sizeof(register_t))))
+ goto bad;
}
break;
@@ -464,8 +460,9 @@ printf("SIG-BUSB @%p pc %p, ra %p\n", trapframe->badvaddr, trapframe->pc, trapfr
args.i[4] = locr0->a5;
args.i[5] = locr0->a6;
args.i[6] = locr0->a7;
- i = copyin((void *)locr0->sp, &args.i[7],
- sizeof(register_t));
+ if ((error = copyin((void *)locr0->sp,
+ &args.i[7], sizeof(register_t))))
+ goto bad;
}
break;
@@ -487,41 +484,18 @@ printf("SIG-BUSB @%p pc %p, ra %p\n", trapframe->badvaddr, trapframe->pc, trapfr
args.i[7] = locr0->a7;
}
}
-#ifdef SYSCALL_DEBUG
- KERNEL_LOCK();
- scdebug_call(p, code, args.i);
- KERNEL_UNLOCK();
-#endif
-#ifdef KTRACE
- if (KTRPOINT(p, KTR_SYSCALL)) {
- KERNEL_LOCK();
- ktrsyscall(p, code, callp->sy_argsize, args.i);
- KERNEL_UNLOCK();
- }
-#endif
+
rval[0] = 0;
rval[1] = locr0->v1;
+
#if defined(DDB) || defined(DEBUG)
trapdebug[TRAPSIZE * ci->ci_cpuid + (trppos[ci->ci_cpuid] == 0 ?
TRAPSIZE : trppos[ci->ci_cpuid]) - 1].code = code;
#endif
-#if NSYSTRACE > 0
- if (ISSET(p->p_flag, P_SYSTRACE)) {
- KERNEL_LOCK();
- i = systrace_redirect(code, p, args.i, rval);
- KERNEL_UNLOCK();
- } else
-#endif
- {
- int nolock = (callp->sy_flags & SY_NOLOCK);
- if (!nolock)
- KERNEL_LOCK();
- i = (*callp->sy_call)(p, &args, rval);
- if (!nolock)
- KERNEL_UNLOCK();
- }
- switch (i) {
+ error = mi_syscall(p, code, callp, args.i, rval);
+
+ switch (error) {
case 0:
locr0->v0 = rval[0];
locr0->v1 = rval[1];
@@ -536,22 +510,14 @@ printf("SIG-BUSB @%p pc %p, ra %p\n", trapframe->badvaddr, trapframe->pc, trapfr
break; /* nothing to do */
default:
- locr0->v0 = i;
+ bad:
+ locr0->v0 = error;
locr0->a3 = 1;
}
-#ifdef SYSCALL_DEBUG
- KERNEL_LOCK();
- scdebug_ret(p, code, i, rval);
- KERNEL_UNLOCK();
-#endif
-#ifdef KTRACE
- if (KTRPOINT(p, KTR_SYSRET)) {
- KERNEL_LOCK();
- ktrsysret(p, code, i, rval[0]);
- KERNEL_UNLOCK();
- }
-#endif
- goto out;
+
+ mi_syscall_return(p, code, error, rval);
+
+ return;
}
case T_BREAK:
@@ -846,18 +812,7 @@ child_return(arg)
KERNEL_UNLOCK();
- userret(p);
-
-#ifdef KTRACE
- if (KTRPOINT(p, KTR_SYSRET)) {
- KERNEL_LOCK();
- ktrsysret(p,
- (p->p_flag & P_THREAD) ? SYS___tfork :
- (p->p_p->ps_flags & PS_PPWAIT) ? SYS_vfork : SYS_fork,
- 0, 0);
- KERNEL_UNLOCK();
- }
-#endif
+ mi_child_return(p);
}
#if defined(DDB) || defined(DEBUG)
diff --git a/sys/arch/mvme68k/mvme68k/trap.c b/sys/arch/mvme68k/mvme68k/trap.c
index 01ae2c3b22f..1a3cefe82fd 100644
--- a/sys/arch/mvme68k/mvme68k/trap.c
+++ b/sys/arch/mvme68k/mvme68k/trap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: trap.c,v 1.75 2011/11/16 20:50:19 deraadt Exp $ */
+/* $OpenBSD: trap.c,v 1.76 2012/08/07 05:16:54 guenther Exp $ */
/*
* Copyright (c) 1995 Theo de Raadt
@@ -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 <machine/db_machdep.h>
#include <machine/cpu.h>
@@ -82,9 +80,6 @@
#include <machine/reg.h>
#include <machine/trap.h>
-#include "systrace.h"
-#include <dev/systrace.h>
-
#include <uvm/uvm_extern.h>
#include <uvm/uvm_pmap.h>
@@ -893,9 +888,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:
@@ -906,27 +901,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];
@@ -944,7 +926,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;
@@ -952,14 +934,7 @@ 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);
}
typedef SLIST_HEAD(,intrhand) intrhand_t;
diff --git a/sys/arch/powerpc/powerpc/trap.c b/sys/arch/powerpc/powerpc/trap.c
index 8f511c76951..e18597f1ce9 100644
--- a/sys/arch/powerpc/powerpc/trap.c
+++ b/sys/arch/powerpc/powerpc/trap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: trap.c,v 1.90 2012/04/11 14:38:55 mikeb Exp $ */
+/* $OpenBSD: trap.c,v 1.91 2012/08/07 05:16:54 guenther Exp $ */
/* $NetBSD: trap.c,v 1.3 1996/10/13 03:31:37 christos Exp $ */
/*
@@ -36,6 +36,7 @@
#include <sys/signalvar.h>
#include <sys/reboot.h>
#include <sys/syscall.h>
+#include <sys/syscall_mi.h>
#include <sys/systm.h>
#include <sys/user.h>
#include <sys/ktrace.h>
@@ -52,9 +53,6 @@
#include <machine/trap.h>
#include <machine/db_machdep.h>
-#include "systrace.h"
-#include <dev/systrace.h>
-
#include <uvm/uvm_extern.h>
#include <ddb/db_extern.h>
@@ -442,53 +440,18 @@ printf("isi iar %x lr %x\n", frame->srr0, frame->lr);
if (argsize > n * sizeof(register_t)) {
bcopy(params, args, n * sizeof(register_t));
- error = copyin(MOREARGS(frame->fixreg[1]),
- args + n, argsize - n * sizeof(register_t));
- if (error) {
-#ifdef KTRACE
- /* Can't get all the arguments! */
- if (KTRPOINT(p, KTR_SYSCALL))
- ktrsyscall(p, code,
- argsize, args);
-#endif
- goto syscall_bad;
- }
+ if ((error = copyin(MOREARGS(frame->fixreg[1]),
+ args + n,
+ argsize - n * sizeof(register_t))))
+ goto bad;
params = args;
}
-#ifdef KTRACE
- if (KTRPOINT(p, KTR_SYSCALL)) {
- KERNEL_LOCK();
- ktrsyscall(p, code, argsize, params);
- KERNEL_UNLOCK();
- }
-#endif
rval[0] = 0;
rval[1] = frame->fixreg[FIRSTARG + 1];
-#ifdef SYSCALL_DEBUG
- KERNEL_LOCK();
- scdebug_call(p, code, params);
- KERNEL_UNLOCK();
-#endif
+ error = mi_syscall(p, code, callp, params, rval);
-
-#if NSYSTRACE > 0
- if (ISSET(p->p_flag, P_SYSTRACE)) {
- KERNEL_LOCK();
- error = systrace_redirect(code, p, params,
- rval);
- KERNEL_UNLOCK();
- } else
-#endif
- {
- nolock = (callp->sy_flags & SY_NOLOCK);
- if (!nolock)
- KERNEL_LOCK();
- error = (*callp->sy_call)(p, params, rval);
- if (!nolock)
- KERNEL_UNLOCK();
- }
switch (error) {
case 0:
frame->fixreg[0] = error;
@@ -506,7 +469,7 @@ printf("isi iar %x lr %x\n", frame->srr0, frame->lr);
/* nothing to do */
break;
default:
-syscall_bad:
+ bad:
if (p->p_emul->e_errno)
error = p->p_emul->e_errno[error];
frame->fixreg[0] = error;
@@ -515,20 +478,10 @@ syscall_bad:
frame->cr |= 0x10000000;
break;
}
-#ifdef SYSCALL_DEBUG
- KERNEL_LOCK();
- scdebug_ret(p, code, error, rval);
- KERNEL_UNLOCK();
-#endif
-#ifdef KTRACE
- if (KTRPOINT(p, KTR_SYSRET)) {
- KERNEL_LOCK();
- ktrsysret(p, code, error, rval[0]);
- KERNEL_UNLOCK();
- }
-#endif
+
+ mi_syscall_return(p, code, error, rval);
+ goto finish;
}
- break;
case EXC_FPU|EXC_USER:
if (ci->ci_fpuproc)
@@ -682,6 +635,7 @@ for (i = 0; i < errnum; i++) {
userret(p);
+finish:
/*
* If someone stole the fpu while we were away, disable it
*/
@@ -716,18 +670,7 @@ child_return(void *arg)
KERNEL_UNLOCK();
- userret(p);
-
-#ifdef KTRACE
- if (KTRPOINT(p, KTR_SYSRET)) {
- KERNEL_LOCK();
- ktrsysret(p,
- (p->p_flag & P_THREAD) ? SYS___tfork :
- (p->p_p->ps_flags & PS_PPWAIT) ? SYS_vfork : SYS_fork,
- 0, 0);
- KERNEL_UNLOCK();
- }
-#endif
+ mi_child_return(p);
}
int
diff --git a/sys/arch/sh/sh/trap.c b/sys/arch/sh/sh/trap.c
index 826dc4b71d3..f3b2dee761f 100644
--- a/sys/arch/sh/sh/trap.c
+++ b/sys/arch/sh/sh/trap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: trap.c,v 1.19 2012/04/11 14:38:55 mikeb Exp $ */
+/* $OpenBSD: trap.c,v 1.20 2012/08/07 05:16:54 guenther Exp $ */
/* $NetBSD: exception.c,v 1.32 2006/09/04 23:57:52 uwe Exp $ */
/* $NetBSD: syscall.c,v 1.6 2006/03/07 07:21:50 thorpej Exp $ */
@@ -89,15 +89,7 @@
#include <sys/resourcevar.h>
#include <sys/signalvar.h>
#include <sys/syscall.h>
-
-#ifdef KTRACE
-#include <sys/ktrace.h>
-#endif
-
-#include "systrace.h"
-#if NSYSTRACE > 0
-#include <dev/systrace.h>
-#endif
+#include <sys/syscall_mi.h>
#include <uvm/uvm_extern.h>
@@ -584,12 +576,11 @@ syscall(struct proc *p, struct trapframe *tf)
args[2] = tf->tf_r7;
if (argsize > 3 * sizeof(int)) {
argsize -= 3 * sizeof(int);
- error = copyin(params, (caddr_t)&args[3],
- argsize);
- } else
- error = 0;
- } else
- error = 0;
+ if ((error = copyin(params, &args[3],
+ argsize)))
+ goto bad;
+ }
+ }
break;
case SYS___syscall:
if (argsize) {
@@ -597,12 +588,11 @@ syscall(struct proc *p, struct trapframe *tf)
args[1] = tf->tf_r7;
if (argsize > 2 * sizeof(int)) {
argsize -= 2 * sizeof(int);
- error = copyin(params, (caddr_t)&args[2],
- argsize);
- } else
- error = 0;
- } else
- error = 0;
+ if ((error = copyin(params, &args[2],
+ argsize)))
+ goto bad;
+ }
+ }
break;
default:
if (argsize) {
@@ -612,36 +602,19 @@ syscall(struct proc *p, struct trapframe *tf)
args[3] = tf->tf_r7;
if (argsize > 4 * sizeof(int)) {
argsize -= 4 * sizeof(int);
- error = copyin(params, (caddr_t)&args[4],
- argsize);
- } else
- error = 0;
- } else
- error = 0;
+ if ((error = copyin(params, &args[4],
+ argsize)))
+ goto bad;
+ }
+ }
break;
}
-#ifdef SYSCALL_DEBUG
- scdebug_call(p, code, args);
-#endif
-#ifdef KTRACE
- if (KTRPOINT(p, KTR_SYSCALL))
- ktrsyscall(p, code, callp->sy_argsize, args);
-#endif
-
- if (error != 0)
- goto bad;
-
rval[0] = 0;
rval[1] = tf->tf_r1;
-#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);
-bad:
+ error = mi_syscall(p, code, callp, args, rval);
+
switch (oerror = error) {
case 0:
tf->tf_r0 = rval[0];
@@ -656,6 +629,7 @@ bad:
/* nothing to do */
break;
default:
+ bad:
if (p->p_emul->e_errno)
error = p->p_emul->e_errno[error];
tf->tf_r0 = error;
@@ -663,14 +637,7 @@ bad:
break;
}
-#ifdef SYSCALL_DEBUG
- scdebug_ret(p, code, oerror, rval);
-#endif
- userret(p);
-#ifdef KTRACE
- if (KTRPOINT(p, KTR_SYSRET))
- ktrsysret(p, code, oerror, rval[0]);
-#endif
+ mi_syscall_return(p, code, oerror, rval);
}
/*
@@ -688,14 +655,6 @@ child_return(void *arg)
tf->tf_r0 = 0;
tf->tf_ssr |= PSL_TBIT; /* This indicates no error. */
- 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);
}
diff --git a/sys/arch/solbourne/solbourne/trap.c b/sys/arch/solbourne/solbourne/trap.c
index d80811eb4db..26be7192169 100644
--- a/sys/arch/solbourne/solbourne/trap.c
+++ b/sys/arch/solbourne/solbourne/trap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: trap.c,v 1.15 2012/04/11 14:38:55 mikeb Exp $ */
+/* $OpenBSD: trap.c,v 1.16 2012/08/07 05:16:54 guenther Exp $ */
/* OpenBSD: trap.c,v 1.42 2004/12/06 20:12:25 miod 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>
@@ -832,33 +827,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:
@@ -898,11 +880,8 @@ 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);
}
@@ -923,12 +902,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);
}
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);
}
diff --git a/sys/arch/sparc64/sparc64/trap.c b/sys/arch/sparc64/sparc64/trap.c
index df20ef0db5e..4e770305213 100644
--- a/sys/arch/sparc64/sparc64/trap.c
+++ b/sys/arch/sparc64/sparc64/trap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: trap.c,v 1.75 2012/04/11 14:38:55 mikeb Exp $ */
+/* $OpenBSD: trap.c,v 1.76 2012/08/07 05:16:54 guenther Exp $ */
/* $NetBSD: trap.c,v 1.73 2001/08/09 01:03:01 eeh 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>
@@ -1228,7 +1223,7 @@ syscall(tf, code, pc)
int64_t *ap;
const struct sysent *callp;
struct proc *p;
- int error = 0, new, lock;
+ int error, new;
register_t args[8];
register_t rval[2];
@@ -1249,8 +1244,6 @@ syscall(tf, code, pc)
callp = p->p_emul->e_sysent;
nsys = p->p_emul->e_nsysent;
- lock = !(callp->sy_flags & SY_NOLOCK);
-
/*
* The first six system call arguments are in the six %o registers.
* Any arguments beyond that are in the `argument extension' area
@@ -1298,50 +1291,28 @@ syscall(tf, code, pc)
if (i > 8)
panic("syscall nargs");
/* Read the whole block in */
- error = copyin((caddr_t)(u_long)tf->tf_out[6] + BIAS +
- offsetof(struct frame64, fr_argx),
- (caddr_t)&args[nap], (i - nap) * sizeof(register_t));
+ if ((error = copyin((caddr_t)(u_long)tf->tf_out[6]
+ + BIAS + offsetof(struct frame64, fr_argx),
+ &args[nap], (i - nap) * sizeof(register_t))))
+ goto bad;
i = nap;
}
- /* It should be faster to do <=6 longword copies than call bcopy */
+ /*
+ * It should be faster to do <= 6 longword copies than
+ * to call bcopy
+ */
for (argp = args; i--;)
*argp++ = *ap++;
-
-#ifdef KTRACE
- if (KTRPOINT(p, KTR_SYSCALL)) {
- KERNEL_LOCK();
- ktrsyscall(p, code, callp->sy_argsize, args);
- KERNEL_UNLOCK();
- }
-#endif
- if (error)
- goto bad;
} else {
error = EFAULT;
goto bad;
}
-#ifdef SYSCALL_DEBUG
- KERNEL_LOCK();
- scdebug_call(p, code, args);
- KERNEL_UNLOCK();
-#endif
rval[0] = 0;
rval[1] = tf->tf_out[1];
-#if NSYSTRACE > 0
- if (ISSET(p->p_flag, P_SYSTRACE)) {
- KERNEL_LOCK();
- error = systrace_redirect(code, p, args, rval);
- KERNEL_UNLOCK();
- } else
-#endif
- {
- if (lock)
- KERNEL_LOCK();
- error = (*callp->sy_call)(p, args, rval);
- if (lock)
- KERNEL_UNLOCK();
- }
+
+ error = mi_syscall(p, code, callp, args, rval);
+
switch (error) {
vaddr_t dest;
case 0:
@@ -1381,19 +1352,7 @@ syscall(tf, code, pc)
break;
}
-#ifdef SYSCALL_DEBUG
- KERNEL_LOCK();
- scdebug_ret(p, code, error, rval);
- KERNEL_UNLOCK();
-#endif
- userret(p);
-#ifdef KTRACE
- if (KTRPOINT(p, KTR_SYSRET)) {
- KERNEL_LOCK();
- ktrsysret(p, code, error, rval[0]);
- KERNEL_UNLOCK();
- }
-#endif
+ mi_syscall_return(p, code, error, rval);
share_fpu(p, tf);
}
@@ -1416,16 +1375,6 @@ child_return(arg)
KERNEL_UNLOCK();
- userret(p);
-#ifdef KTRACE
- if (KTRPOINT(p, KTR_SYSRET)) {
- KERNEL_LOCK();
- ktrsysret(p,
- (p->p_flag & P_THREAD) ? SYS___tfork :
- (p->p_p->ps_flags & PS_PPWAIT) ? SYS_vfork : SYS_fork,
- 0, 0);
- KERNEL_UNLOCK();
- }
-#endif
+ mi_child_return(p);
}
diff --git a/sys/arch/vax/vax/trap.c b/sys/arch/vax/vax/trap.c
index 13b4d32b8fa..e1b7a49528f 100644
--- a/sys/arch/vax/vax/trap.c
+++ b/sys/arch/vax/vax/trap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: trap.c,v 1.44 2012/04/23 19:04:07 miod Exp $ */
+/* $OpenBSD: trap.c,v 1.45 2012/08/07 05:16:54 guenther Exp $ */
/* $NetBSD: trap.c,v 1.47 1999/08/21 19:26:20 matt Exp $ */
/*
* Copyright (c) 1994 Ludd, University of Lule}, Sweden.
@@ -36,13 +36,11 @@
#include <sys/proc.h>
#include <sys/user.h>
#include <sys/syscall.h>
+#include <sys/syscall_mi.h>
#include <sys/systm.h>
#include <sys/signalvar.h>
#include <sys/exec.h>
-#include "systrace.h"
-#include <dev/systrace.h>
-
#include <uvm/uvm_extern.h>
#include <machine/mtpr.h>
@@ -56,9 +54,6 @@
#include <machine/db_machdep.h>
#endif
#include <kern/syscalls.c>
-#ifdef KTRACE
-#include <sys/ktrace.h>
-#endif
#ifdef TRAPDEBUG
volatile int startsysc = 0, faultdebug = 0;
@@ -368,27 +363,12 @@ if(startsysc)printf("trap syscall %s pc %lx, psl %lx, sp %lx, pid %d, frame %p\n
rval[0] = 0;
rval[1] = frame->r1;
if(callp->sy_narg) {
- err = copyin((char *)frame->ap + 4, args, callp->sy_argsize);
- if (err) {
-#ifdef KTRACE
- if (KTRPOINT(p, KTR_SYSCALL))
- ktrsyscall(p, frame->code,
- callp->sy_argsize, args);
-#endif
+ if ((error = copyin((char *)frame->ap + 4, args,
+ callp->sy_argsize)))
goto bad;
- }
}
-#ifdef KTRACE
- if (KTRPOINT(p, KTR_SYSCALL))
- ktrsyscall(p, frame->code, callp->sy_argsize, args);
-#endif
-#if NSYSTRACE > 0
- if (ISSET(p->p_flag, P_SYSTRACE))
- err = systrace_redirect(frame->code, curproc, args, rval);
- else
-#endif
- err = (*callp->sy_call)(curproc, args, rval);
+ err = mi_syscall(p, frame->code, callp, args, rval);
#ifdef TRAPDEBUG
if(startsysc)
@@ -413,17 +393,13 @@ bad:
break;
default:
+ bad:
exptr->r0 = err;
exptr->psl |= PSL_C;
break;
}
- userret(p);
-
-#ifdef KTRACE
- if (KTRPOINT(p, KTR_SYSRET))
- ktrsysret(p, frame->code, err, rval[0]);
-#endif
+ mi_syscall_return(p, frame->code, err, rval);
}
void
@@ -437,13 +413,5 @@ child_return(arg)
frame->r1 = frame->r0 = 0;
frame->psl &= ~PSL_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);
}
diff --git a/sys/kern/kern_xxx.c b/sys/kern/kern_xxx.c
index 2b0331c3378..063385c4be3 100644
--- a/sys/kern/kern_xxx.c
+++ b/sys/kern/kern_xxx.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_xxx.c,v 1.22 2012/07/09 15:43:36 deraadt Exp $ */
+/* $OpenBSD: kern_xxx.c,v 1.23 2012/08/07 05:16:54 guenther Exp $ */
/* $NetBSD: kern_xxx.c,v 1.32 1996/04/22 01:38:41 christos Exp $ */
/*
@@ -83,7 +83,7 @@ __stack_smash_handler(char func[], int damaged)
int scdebug = SCDEBUG_CALLS|SCDEBUG_RETURNS|SCDEBUG_SHOWARGS;
void
-scdebug_call(struct proc *p, register_t code, register_t args[])
+scdebug_call(struct proc *p, register_t code, const register_t args[])
{
struct sysent *sy;
struct emul *em;
@@ -116,7 +116,8 @@ scdebug_call(struct proc *p, register_t code, register_t args[])
}
void
-scdebug_ret(struct proc *p, register_t code, int error, register_t retval[])
+scdebug_ret(struct proc *p, register_t code, int error,
+ const register_t retval[])
{
struct sysent *sy;
struct emul *em;
diff --git a/sys/sys/syscall_mi.h b/sys/sys/syscall_mi.h
new file mode 100644
index 00000000000..8f6071c5b2a
--- /dev/null
+++ b/sys/sys/syscall_mi.h
@@ -0,0 +1,139 @@
+/* $OpenBSD: syscall_mi.h,v 1.1 2012/08/07 05:16:53 guenther Exp $ */
+
+/*
+ * Copyright (c) 1982, 1986, 1989, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)kern_xxx.c 8.2 (Berkeley) 11/14/93
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/proc.h>
+
+#ifdef KTRACE
+#include <sys/ktrace.h>
+#endif
+
+#include "systrace.h"
+#if NSYSTRACE > 0
+#include <dev/systrace.h>
+#endif
+
+
+/*
+ * The MD setup for a system call has been done; here's the MI part.
+ */
+static inline int
+mi_syscall(struct proc *p, register_t code, const struct sysent *callp,
+ register_t *argp, register_t retval[2])
+{
+ int lock = !(callp->sy_flags & SY_NOLOCK);
+ int error;
+
+#ifdef SYSCALL_DEBUG
+ KERNEL_LOCK();
+ scdebug_call(p, code, argp);
+ KERNEL_UNLOCK();
+#endif
+#ifdef KTRACE
+ if (KTRPOINT(p, KTR_SYSCALL)) {
+ KERNEL_LOCK();
+ ktrsyscall(p, code, callp->sy_argsize, argp);
+ KERNEL_UNLOCK();
+ }
+#endif
+
+#if NSYSTRACE > 0
+ if (ISSET(p->p_flag, P_SYSTRACE)) {
+ KERNEL_LOCK();
+ error = systrace_redirect(code, p, argp, retval);
+ KERNEL_UNLOCK();
+ } else
+#endif
+ {
+ if (lock)
+ KERNEL_LOCK();
+ error = (*callp->sy_call)(p, argp, retval);
+ if (lock)
+ KERNEL_UNLOCK();
+ }
+
+ return (error);
+}
+
+/*
+ * Finish MI stuff on return, after the registers have been set
+ */
+static inline void
+mi_syscall_return(struct proc *p, register_t code, int error,
+ const register_t retval[2])
+{
+#ifdef SYSCALL_DEBUG
+ KERNEL_LOCK();
+ scdebug_ret(p, code, error, retval);
+ KERNEL_UNLOCK();
+#endif
+
+ userret(p);
+
+#ifdef KTRACE
+ if (KTRPOINT(p, KTR_SYSRET)) {
+ KERNEL_LOCK();
+ ktrsysret(p, code, error, retval[0]);
+ KERNEL_UNLOCK();
+ }
+#endif
+}
+
+/*
+ * Finish MI stuff for a new process/thread to return
+ */
+static inline void
+mi_child_return(struct proc *p)
+{
+ int code = (p->p_flag & P_THREAD) ? SYS___tfork :
+ (p->p_p->ps_flags & PS_PPWAIT) ? SYS_vfork : SYS_fork;
+
+#ifdef SYSCALL_DEBUG
+ const register_t child_retval[2] = { 0, 1 };
+
+ KERNEL_LOCK();
+ scdebug_ret(p, code, 0, child_retval);
+ KERNEL_UNLOCK();
+#endif
+
+ userret(p);
+
+#ifdef KTRACE
+ if (KTRPOINT(p, KTR_SYSRET)) {
+ KERNEL_LOCK();
+ ktrsysret(p, code, 0, 0);
+ KERNEL_UNLOCK();
+ }
+#endif
+}
diff --git a/sys/sys/systm.h b/sys/sys/systm.h
index 5dd1bfd8766..1c20ea6241f 100644
--- a/sys/sys/systm.h
+++ b/sys/sys/systm.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: systm.h,v 1.91 2012/08/02 03:18:48 guenther Exp $ */
+/* $OpenBSD: systm.h,v 1.92 2012/08/07 05:16:53 guenther Exp $ */
/* $NetBSD: systm.h,v 1.50 1996/06/09 04:55:09 briggs Exp $ */
/*-
@@ -133,8 +133,9 @@ extern struct sysent { /* system call table */
#endif
#if defined(_KERNEL) && defined(SYSCALL_DEBUG)
-void scdebug_call(struct proc *p, register_t code, register_t retval[]);
-void scdebug_ret(struct proc *p, register_t code, int error, register_t retval[]);
+void scdebug_call(struct proc *p, register_t code, const register_t retval[]);
+void scdebug_ret(struct proc *p, register_t code, int error,
+ const register_t retval[]);
#endif /* _KERNEL && SYSCALL_DEBUG */
extern int boothowto; /* reboot flags, from console subsystem */