Changes to make ktrace LKM friendly and reduce ifdef KTRACE. Proposed

on tech-kern.
This commit is contained in:
ad 2007-08-15 12:07:23 +00:00
parent 6c8e72c931
commit 63c4506184
56 changed files with 760 additions and 1022 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: syscall.c,v 1.26 2007/03/04 05:59:10 christos Exp $ */
/* $NetBSD: syscall.c,v 1.27 2007/08/15 12:07:23 ad Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@ -94,11 +94,9 @@
* rights to redistribute these changes.
*/
#include "opt_ktrace.h"
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.26 2007/03/04 05:59:10 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.27 2007/08/15 12:07:23 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -106,9 +104,7 @@ __KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.26 2007/03/04 05:59:10 christos Exp $"
#include <sys/user.h>
#include <sys/signal.h>
#include <sys/syscall.h>
#ifdef KTRACE
#include <sys/ktrace.h>
#endif
#include <uvm/uvm_extern.h>
@ -344,9 +340,6 @@ void
child_return(void *arg)
{
struct lwp *l = arg;
#ifdef KTRACE
struct proc *p = l->l_proc;
#endif
/*
* Return values in the frame set by cpu_fork().
@ -354,11 +347,5 @@ child_return(void *arg)
KERNEL_UNLOCK_LAST(l);
userret(l);
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSRET)) {
KERNEL_LOCK(1, l);
ktrsysret(l, SYS_fork, 0, 0);
KERNEL_UNLOCK_LAST(l);
}
#endif
ktrsysret(SYS_fork, 0, 0);
}

View File

@ -1,9 +1,8 @@
/* $NetBSD: linux32_syscall.c,v 1.13 2007/04/26 12:54:17 njoly Exp $ */
/* $NetBSD: linux32_syscall.c,v 1.14 2007/08/15 12:07:23 ad Exp $ */
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: linux32_syscall.c,v 1.13 2007/04/26 12:54:17 njoly Exp $");
__KERNEL_RCSID(0, "$NetBSD: linux32_syscall.c,v 1.14 2007/08/15 12:07:23 ad Exp $");
#include "opt_ktrace.h"
#include "opt_systrace.h"
#include <sys/param.h>
@ -11,12 +10,6 @@ __KERNEL_RCSID(0, "$NetBSD: linux32_syscall.c,v 1.13 2007/04/26 12:54:17 njoly E
#include <sys/proc.h>
#include <sys/user.h>
#include <sys/signal.h>
#ifdef KTRACE
#include <sys/ktrace.h>
#endif
#ifdef SYSTRACE
#include <sys/systrace.h>
#endif
#include <sys/syscall.h>
#include <uvm/uvm_extern.h>
@ -163,10 +156,8 @@ linux32_syscall_fancy(frame)
size_t argsize;
register32_t code, args[8];
register_t rval[2];
#if defined(KTRACE) || defined(SYSTRACE)
int i;
register_t args64[8];
#endif
uvmexp.syscalls++;
l = curlwp;
@ -223,10 +214,7 @@ linux32_syscall_fancy(frame)
printf("linux32 syscall %d bogus argument size %ld",
code, argsize);
error = ENOSYS;
#if defined(KTRACE) || defined(SYSTRACE)
goto out;
#endif
break;
}
}
@ -237,32 +225,17 @@ linux32_syscall_fancy(frame)
#endif
KERNEL_LOCK(1, l);
#if defined(KTRACE) || defined(SYSTRACE)
if (
#ifdef KTRACE
KTRPOINT(p, KTR_SYSCALL) ||
#endif
#ifdef SYSTRACE
ISSET(p->p_flag, PK_SYSTRACE)
#else
0
#endif
) {
for (i = 0; i < (argsize >> 2); i++)
args64[i] = args[i] & 0xffffffff;
/* XXX we need to pass argsize << 1 here? */
if ((error = trace_enter(l, code, code, NULL, args64)) != 0)
goto out;
}
#endif
for (i = 0; i < (argsize >> 2); i++)
args64[i] = args[i] & 0xffffffff;
/* XXX we need to pass argsize << 1 here? */
if ((error = trace_enter(l, code, code, NULL, args64)) != 0)
goto out;
rval[0] = 0;
rval[1] = 0;
error = (*callp->sy_call)(l, args, rval);
#if defined(KTRACE) || defined(SYSTRACE)
out:
#endif
KERNEL_UNLOCK_LAST(l);
switch (error) {
case 0:
@ -287,9 +260,6 @@ out:
break;
}
#if defined(KTRACE) || defined(SYSTRACE)
trace_exit(l, code, args64, rval, error);
#endif
userret(l);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: netbsd32_syscall.c,v 1.17 2007/03/04 14:36:12 yamt Exp $ */
/* $NetBSD: netbsd32_syscall.c,v 1.18 2007/08/15 12:07:23 ad Exp $ */
/*-
* Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@ -37,22 +37,13 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: netbsd32_syscall.c,v 1.17 2007/03/04 14:36:12 yamt Exp $");
#include "opt_ktrace.h"
#include "opt_systrace.h"
__KERNEL_RCSID(0, "$NetBSD: netbsd32_syscall.c,v 1.18 2007/08/15 12:07:23 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/proc.h>
#include <sys/user.h>
#include <sys/signal.h>
#ifdef KTRACE
#include <sys/ktrace.h>
#endif
#ifdef SYSTRACE
#include <sys/systrace.h>
#endif
#include <sys/syscall.h>
#include <uvm/uvm_extern.h>
@ -175,10 +166,8 @@ netbsd32_syscall_fancy(frame)
size_t argsize;
register32_t code, args[8];
register_t rval[2];
#if defined(KTRACE) || defined(SYSTRACE)
int i;
register_t args64[8];
#endif
uvmexp.syscalls++;
l = curlwp;
@ -220,31 +209,16 @@ netbsd32_syscall_fancy(frame)
KERNEL_LOCK(1, l);
#if defined(KTRACE) || defined(SYSTRACE)
if (
#ifdef KTRACE
KTRPOINT(p, KTR_SYSCALL) ||
#endif
#ifdef SYSTRACE
ISSET(p->p_flag, PK_SYSTRACE)
#else
0
#endif
) {
for (i = 0; i < (argsize >> 2); i++)
args64[i] = args[i];
/* XXX we need to pass argsize << 1 here? */
if ((error = trace_enter(l, code, code, NULL, args64)) != 0)
goto out;
}
#endif
for (i = 0; i < (argsize >> 2); i++)
args64[i] = args[i];
/* XXX we need to pass argsize << 1 here? */
if ((error = trace_enter(l, code, code, NULL, args64)) != 0)
goto out;
rval[0] = 0;
rval[1] = 0;
error = (*callp->sy_call)(l, args, rval);
#if defined(KTRACE) || defined(SYSTRACE)
out:
#endif
KERNEL_UNLOCK_LAST(l);
switch (error) {
case 0:
@ -270,9 +244,6 @@ out:
break;
}
#if defined(KTRACE) || defined(SYSTRACE)
trace_exit(l, code, args64, rval, error);
#endif
userret(l);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: syscall.c,v 1.24 2007/03/04 14:36:12 yamt Exp $ */
/* $NetBSD: syscall.c,v 1.25 2007/08/15 12:07:24 ad Exp $ */
/*-
* Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@ -37,9 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.24 2007/03/04 14:36:12 yamt Exp $");
#include "opt_ktrace.h"
__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.25 2007/08/15 12:07:24 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -65,9 +63,6 @@ child_return(void *arg)
{
struct lwp *l = arg;
struct trapframe *tf = l->l_md.md_regs;
#ifdef KTRACE
struct proc *p = l->l_proc;
#endif
tf->tf_rax = 0;
tf->tf_rflags &= ~PSL_C;
@ -75,13 +70,7 @@ child_return(void *arg)
KERNEL_UNLOCK_LAST(l);
userret(l);
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSRET)) {
KERNEL_LOCK(1, l);
ktrsysret(l, SYS_fork, 0, 0);
KERNEL_UNLOCK_LAST(l);
}
#endif
ktrsysret(SYS_fork, 0, 0);
}
void

View File

@ -1,4 +1,4 @@
/* $NetBSD: syscall.c,v 1.35 2007/02/18 07:25:35 matt Exp $ */
/* $NetBSD: syscall.c,v 1.36 2007/08/15 12:07:24 ad Exp $ */
/*-
* Copyright (c) 2000, 2003 The NetBSD Foundation, Inc.
@ -76,11 +76,9 @@
* Created : 09/11/94
*/
#include "opt_ktrace.h"
#include <sys/param.h>
__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.35 2007/02/18 07:25:35 matt Exp $");
__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.36 2007/08/15 12:07:24 ad Exp $");
#include <sys/device.h>
#include <sys/errno.h>
@ -90,9 +88,7 @@ __KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.35 2007/02/18 07:25:35 matt Exp $");
#include <sys/syscall.h>
#include <sys/systm.h>
#include <sys/user.h>
#ifdef KTRACE
#include <sys/ktrace.h>
#endif
#include <uvm/uvm_extern.h>
@ -522,9 +518,6 @@ child_return(arg)
{
struct lwp *l = arg;
struct trapframe *frame = l->l_addr->u_pcb.pcb_tf;
#ifdef KTRACE
struct proc *p = l->l_proc;
#endif
frame->tf_r0 = 0;
#ifdef __PROG32
@ -535,11 +528,5 @@ child_return(arg)
KERNEL_UNLOCK_LAST(l);
userret(l);
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSRET)) {
KERNEL_LOCK(1, l);
ktrsysret(l, SYS_fork, 0, 0);
KERNEL_UNLOCK_LAST(l);
}
#endif
ktrsysret(SYS_fork, 0, 0);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: trap.c,v 1.45 2007/05/27 09:41:25 skrll Exp $ */
/* $NetBSD: trap.c,v 1.46 2007/08/15 12:07:24 ad Exp $ */
/*-
* Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
@ -69,23 +69,20 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.45 2007/05/27 09:41:25 skrll Exp $");
__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.46 2007/08/15 12:07:24 ad Exp $");
/* #define INTRDEBUG */
/* #define TRAPDEBUG */
/* #define USERTRACE */
#include "opt_kgdb.h"
#include "opt_ktrace.h"
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/syscall.h>
#include <sys/mutex.h>
#ifdef KTRACE
#include <sys/ktrace.h>
#endif
#include <sys/proc.h>
#include <sys/signalvar.h>
#include <sys/user.h>
@ -927,15 +924,9 @@ void
child_return(void *arg)
{
struct lwp *l = arg;
#ifdef KTRACE
struct proc *p = l->l_proc;
#endif
userret(l, l->l_md.md_regs->tf_iioq_head, 0);
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSRET))
ktrsysret(l, SYS_fork, 0, 0);
#endif
ktrsysret(SYS_fork, 0, 0);
#ifdef DEBUG
frame_sanity_check(0xdead04, 0, l->l_md.md_regs, l);
#endif /* DEBUG */

View File

@ -1,4 +1,4 @@
/* $NetBSD: syscall.c,v 1.45 2007/08/05 10:56:52 ad Exp $ */
/* $NetBSD: syscall.c,v 1.46 2007/08/15 12:07:24 ad Exp $ */
/*-
* Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@ -37,19 +37,16 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.45 2007/08/05 10:56:52 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.46 2007/08/15 12:07:24 ad Exp $");
#include "opt_vm86.h"
#include "opt_ktrace.h"
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/proc.h>
#include <sys/user.h>
#include <sys/signal.h>
#ifdef KTRACE
#include <sys/ktrace.h>
#endif
#include <sys/syscall.h>
#include <sys/syscall_stats.h>
@ -317,9 +314,6 @@ child_return(arg)
{
struct lwp *l = arg;
struct trapframe *tf = l->l_md.md_regs;
#ifdef KTRACE
struct proc *p = l->l_proc;
#endif
tf->tf_eax = 0;
tf->tf_eflags &= ~PSL_C;
@ -327,8 +321,5 @@ child_return(arg)
KERNEL_UNLOCK_LAST(l);
userret(l);
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSRET))
ktrsysret(l, SYS_fork, 0, 0);
#endif
ktrsysret(SYS_fork, 0, 0);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: m68k_syscall.c,v 1.28 2007/03/04 10:56:21 tsutsui Exp $ */
/* $NetBSD: m68k_syscall.c,v 1.29 2007/08/15 12:07:25 ad Exp $ */
/*-
* Portions Copyright (c) 2000 The NetBSD Foundation, Inc.
@ -110,10 +110,9 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: m68k_syscall.c,v 1.28 2007/03/04 10:56:21 tsutsui Exp $");
__KERNEL_RCSID(0, "$NetBSD: m68k_syscall.c,v 1.29 2007/08/15 12:07:25 ad Exp $");
#include "opt_execfmt.h"
#include "opt_ktrace.h"
#include "opt_compat_netbsd.h"
#include "opt_compat_aout_m68k.h"
@ -126,9 +125,7 @@ __KERNEL_RCSID(0, "$NetBSD: m68k_syscall.c,v 1.28 2007/03/04 10:56:21 tsutsui Ex
#include <sys/syscall.h>
#include <sys/syslog.h>
#include <sys/user.h>
#ifdef KTRACE
#include <sys/ktrace.h>
#endif
#include <machine/psl.h>
#include <machine/cpu.h>
@ -450,10 +447,7 @@ child_return(void *arg)
f->f_format = FMT0;
machine_userret(l, f, 0);
#ifdef KTRACE
if (KTRPOINT(l->l_proc, KTR_SYSRET))
ktrsysret(l, SYS_fork, 0, 0);
#endif
ktrsysret(SYS_fork, 0, 0);
}
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: trap.c,v 1.212 2007/05/29 12:03:45 tsutsui Exp $ */
/* $NetBSD: trap.c,v 1.213 2007/08/15 12:07:25 ad Exp $ */
/*
* Copyright (c) 1992, 1993
@ -78,10 +78,9 @@
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.212 2007/05/29 12:03:45 tsutsui Exp $");
__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.213 2007/08/15 12:07:25 ad Exp $");
#include "opt_cputype.h" /* which mips CPU levels do we support? */
#include "opt_ktrace.h"
#include "opt_ddb.h"
#include "opt_kgdb.h"
@ -94,9 +93,7 @@ __KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.212 2007/05/29 12:03:45 tsutsui Exp $");
#include <sys/syscall.h>
#include <sys/user.h>
#include <sys/buf.h>
#ifdef KTRACE
#include <sys/ktrace.h>
#endif
#include <sys/kauth.h>
#include <sys/cpu.h>
@ -183,10 +180,7 @@ child_return(void *arg)
frame->f_regs[_R_V1] = 1;
frame->f_regs[_R_A3] = 0;
userret(l);
#ifdef KTRACE
if (KTRPOINT(l->l_proc, KTR_SYSRET))
ktrsysret(l, SYS_fork, 0, 0);
#endif
ktrsysret(SYS_fork, 0, 0);
}
#ifdef MIPS3_PLUS

View File

@ -1,4 +1,4 @@
/* $NetBSD: trap.c,v 1.82 2007/03/04 06:00:29 christos Exp $ */
/* $NetBSD: trap.c,v 1.83 2007/08/15 12:07:25 ad Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
@ -77,11 +77,10 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.82 2007/03/04 06:00:29 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.83 2007/08/15 12:07:25 ad Exp $");
#include "opt_ddb.h"
#include "opt_kgdb.h"
#include "opt_ktrace.h"
#include "opt_ns381.h"
#include <sys/param.h>
@ -93,9 +92,7 @@ __KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.82 2007/03/04 06:00:29 christos Exp $");
#include <sys/signal.h>
#include <sys/pool.h>
#include <sys/kauth.h>
#ifdef KTRACE
#include <sys/ktrace.h>
#endif
#include <sys/syscall.h>
#ifdef KGDB
#include <sys/kgdb.h>
@ -486,10 +483,7 @@ child_return(void *arg)
l->l_md.md_regs->r_psr &= ~PSL_C;
userret(l, l->l_md.md_regs->r_pc, 0);
#ifdef KTRACE
if (KTRPOINT(l->l_proc, KTR_SYSRET))
ktrsysret(l, SYS_fork, 0, 0);
#endif
ktrsysret(SYS_fork, 0, 0);
}
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: syscall.c,v 1.33 2007/03/04 06:00:38 christos Exp $ */
/* $NetBSD: syscall.c,v 1.34 2007/08/15 12:07:26 ad Exp $ */
/*
* Copyright (C) 2002 Matt Thomas
@ -33,7 +33,6 @@
*/
#include "opt_altivec.h"
#include "opt_ktrace.h"
#include "opt_multiprocessor.h"
/* DO NOT INCLUDE opt_compat_XXX.h */
/* If needed, they will be included by file that includes this one */
@ -43,9 +42,7 @@
#include <sys/reboot.h>
#include <sys/systm.h>
#include <sys/user.h>
#ifdef KTRACE
#include <sys/ktrace.h>
#endif
#include <uvm/uvm_extern.h>
@ -63,15 +60,12 @@
#define EMULNAME(x) (x)
#define EMULNAMEU(x) (x)
__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.33 2007/03/04 06:00:38 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.34 2007/08/15 12:07:26 ad Exp $");
void
child_return(void *arg)
{
struct lwp * const l = arg;
#ifdef KTRACE
struct proc * const p = l->l_proc;
#endif
struct trapframe * const tf = trapframe(l);
KERNEL_UNLOCK_LAST(l);
@ -82,13 +76,7 @@ child_return(void *arg)
tf->srr1 &= ~(PSL_FP|PSL_VEC); /* Disable FP & AltiVec, as we can't
be them. */
l->l_addr->u_pcb.pcb_fpcpu = NULL;
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSRET)) {
KERNEL_LOCK(1, l);
ktrsysret(l, SYS_fork, 0, 0);
KERNEL_UNLOCK_LAST(l);
}
#endif
ktrsysret(SYS_fork, 0, 0);
/* Profiling? XXX */
curcpu()->ci_schedstate.spc_curpriority = l->l_priority;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: exception.c,v 1.38 2007/05/17 14:51:28 yamt Exp $ */
/* $NetBSD: exception.c,v 1.39 2007/08/15 12:07:26 ad Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc. All rights reserved.
@ -79,11 +79,10 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: exception.c,v 1.38 2007/05/17 14:51:28 yamt Exp $");
__KERNEL_RCSID(0, "$NetBSD: exception.c,v 1.39 2007/08/15 12:07:26 ad Exp $");
#include "opt_ddb.h"
#include "opt_kgdb.h"
#include "opt_ktrace.h"
#include <sys/param.h>
#include <sys/systm.h>
@ -93,10 +92,8 @@ __KERNEL_RCSID(0, "$NetBSD: exception.c,v 1.38 2007/05/17 14:51:28 yamt Exp $");
#include <sys/kernel.h>
#include <sys/signal.h>
#include <sys/syscall.h>
#ifdef KTRACE
#include <sys/ktrace.h>
#endif
#ifdef DDB
#include <sh3/db_machdep.h>
#endif
@ -478,19 +475,13 @@ void
child_return(void *arg)
{
struct lwp *l = arg;
#ifdef KTRACE
struct proc *p = l->l_proc;
#endif
struct trapframe *tf = l->l_md.md_regs;
tf->tf_r0 = 0;
tf->tf_ssr |= PSL_TBIT; /* This indicates no error. */
userret(l);
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSRET))
ktrsysret(l, SYS_fork, 0, 0);
#endif
ktrsysret(SYS_fork, 0, 0);
}
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: syscall.c,v 1.13 2007/02/09 21:55:12 ad Exp $ */
/* $NetBSD: syscall.c,v 1.14 2007/08/15 12:07:26 ad Exp $ */
/*
* Copyright (c) 1996
@ -49,9 +49,8 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.13 2007/02/09 21:55:12 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.14 2007/08/15 12:07:26 ad Exp $");
#include "opt_ktrace.h"
#include "opt_sparc_arch.h"
#include "opt_multiprocessor.h"
@ -60,9 +59,7 @@ __KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.13 2007/02/09 21:55:12 ad Exp $");
#include <sys/proc.h>
#include <sys/signal.h>
#include <sys/syscall.h>
#ifdef KTRACE
#include <sys/ktrace.h>
#endif
#include <uvm/uvm_extern.h>
@ -383,22 +380,12 @@ void
child_return(void *arg)
{
struct lwp *l = arg;
#ifdef KTRACE
struct proc *p;
#endif
/*
* Return values in the frame set by cpu_fork().
*/
KERNEL_UNLOCK_LAST(l);
userret(l, l->l_md.md_tf->tf_pc, 0);
#ifdef KTRACE
p = l->l_proc;
if (KTRPOINT(p, KTR_SYSRET)) {
KERNEL_LOCK(1, l);
ktrsysret(l,
(p->p_sflag & PS_PPWAIT) ? SYS_vfork : SYS_fork, 0, 0);
KERNEL_UNLOCK_LAST(l);
}
#endif
ktrsysret((l->l_proc->p_sflag & PS_PPWAIT) ? SYS_vfork : SYS_fork,
0, 0);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: syscall.c,v 1.20 2007/02/17 22:31:39 pavel Exp $ */
/* $NetBSD: syscall.c,v 1.21 2007/08/15 12:07:26 ad Exp $ */
/*-
* Copyright (c) 2005 The NetBSD Foundation, Inc.
@ -86,20 +86,16 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.20 2007/02/17 22:31:39 pavel Exp $");
__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.21 2007/08/15 12:07:26 ad Exp $");
#define NEW_FPSTATE
#include "opt_ktrace.h"
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/proc.h>
#include <sys/user.h>
#include <sys/signal.h>
#ifdef KTRACE
#include <sys/ktrace.h>
#endif
#include <sys/syscall.h>
#include <uvm/uvm_extern.h>
@ -485,20 +481,13 @@ child_return(arg)
void *arg;
{
struct lwp *l = arg;
#ifdef KTRACE
struct proc *p = l->l_proc;
#endif
/*
* Return values in the frame set by cpu_lwp_fork().
*/
KERNEL_UNLOCK_LAST(l);
userret(l, l->l_md.md_tf->tf_pc, 0);
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSRET))
ktrsysret(l,
(p->p_sflag & PS_PPWAIT) ? SYS_vfork : SYS_fork, 0, 0);
#endif
ktrsysret((l->l_proc->p_sflag & PS_PPWAIT) ? SYS_vfork : SYS_fork, 0, 0);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: syscall.c,v 1.5 2007/03/12 02:22:43 matt Exp $ */
/* $NetBSD: syscall.c,v 1.6 2007/08/15 12:07:27 ad Exp $ */
/*
* Copyright (c) 1994 Ludd, University of Lule}, Sweden.
@ -33,7 +33,7 @@
/* All bugs are subject to removal without further notice */
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.5 2007/03/12 02:22:43 matt Exp $");
__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.6 2007/08/15 12:07:27 ad Exp $");
#include "opt_multiprocessor.h"
@ -45,9 +45,7 @@ __KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.5 2007/03/12 02:22:43 matt Exp $");
#include <sys/systm.h>
#include <sys/signalvar.h>
#include <sys/exec.h>
#ifdef KTRACE
#include <sys/ktrace.h>
#endif
#include <sys/pool.h>
#include <uvm/uvm_extern.h>
@ -253,9 +251,5 @@ child_return(void *arg)
KERNEL_UNLOCK_LAST(l);
userret(l, l->l_addr->u_pcb.framep, 0);
#ifdef KTRACE
if (KTRPOINT(l->l_proc, KTR_SYSRET))
ktrsysret(l, SYS_fork, 0, 0);
#endif
ktrsysret(SYS_fork, 0, 0);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: trap.c,v 1.108 2007/03/04 06:01:02 christos Exp $ */
/* $NetBSD: trap.c,v 1.109 2007/08/15 12:07:27 ad Exp $ */
/*
* Copyright (c) 1994 Ludd, University of Lule}, Sweden.
@ -33,10 +33,9 @@
/* All bugs are subject to removal without further notice */
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.108 2007/03/04 06:01:02 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.109 2007/08/15 12:07:27 ad Exp $");
#include "opt_ddb.h"
#include "opt_ktrace.h"
#include "opt_multiprocessor.h"
#include <sys/types.h>
@ -64,9 +63,7 @@ __KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.108 2007/03/04 06:01:02 christos Exp $");
#include <machine/db_machdep.h>
#endif
#include <kern/syscalls.c>
#ifdef KTRACE
#include <sys/ktrace.h>
#endif
#ifdef TRAPDEBUG
volatile int faultdebug = 0;

View File

@ -1,4 +1,4 @@
/* $NetBSD: darwin_iohidsystem.c,v 1.39 2007/07/09 21:10:46 ad Exp $ */
/* $NetBSD: darwin_iohidsystem.c,v 1.40 2007/08/15 12:07:27 ad Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
@ -37,9 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: darwin_iohidsystem.c,v 1.39 2007/07/09 21:10:46 ad Exp $");
#include "opt_ktrace.h"
__KERNEL_RCSID(0, "$NetBSD: darwin_iohidsystem.c,v 1.40 2007/08/15 12:07:27 ad Exp $");
#include "ioconf.h"
#include "wsmux.h"
@ -707,10 +705,7 @@ mach_notify_iohidsystem(struct lwp *l, struct mach_right *mr)
mach_set_trailer(req, sizeof(*req));
#ifdef KTRACE
if (KTRPOINT(l->l_proc, KTR_USER))
(void)ktruser(l, "notify_iohidsystem", NULL, 0, 0);
#endif
ktruser("notify_iohidsystem", NULL, 0, 0);
mr->mr_refcount++;

View File

@ -1,4 +1,4 @@
/* $NetBSD: darwin_ktrace.c,v 1.9 2007/02/09 21:55:16 ad Exp $ */
/* $NetBSD: darwin_ktrace.c,v 1.10 2007/08/15 12:07:27 ad Exp $ */
/*-
* Copyright (c) 2004 The NetBSD Foundation, Inc.
@ -37,9 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: darwin_ktrace.c,v 1.9 2007/02/09 21:55:16 ad Exp $");
#include "opt_ktrace.h"
__KERNEL_RCSID(0, "$NetBSD: darwin_ktrace.c,v 1.10 2007/08/15 12:07:27 ad Exp $");
#include <sys/types.h>
#include <sys/param.h>
@ -60,14 +58,10 @@ __KERNEL_RCSID(0, "$NetBSD: darwin_ktrace.c,v 1.9 2007/02/09 21:55:16 ad Exp $")
int
darwin_sys_utrace(struct lwp *l, void *v, register_t *retval)
{
#if defined(KTRACE)
struct darwin_sys_utrace_args /* {
syscallarg(void *) addr;
syscallarg(size_t) len;
} */ *uap = v;
return ktruser(l, "darwin", SCARG(uap, addr), SCARG(uap, len), 0);
#else
return 0;
#endif
return ktruser("darwin", SCARG(uap, addr), SCARG(uap, len), 0);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: darwin_sysctl.c,v 1.52 2007/06/30 15:31:49 dsl Exp $ */
/* $NetBSD: darwin_sysctl.c,v 1.53 2007/08/15 12:07:28 ad Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@ -37,9 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: darwin_sysctl.c,v 1.52 2007/06/30 15:31:49 dsl Exp $");
#include "opt_ktrace.h"
__KERNEL_RCSID(0, "$NetBSD: darwin_sysctl.c,v 1.53 2007/08/15 12:07:28 ad Exp $");
#include <sys/types.h>
#include <sys/param.h>
@ -51,9 +49,7 @@ __KERNEL_RCSID(0, "$NetBSD: darwin_sysctl.c,v 1.52 2007/06/30 15:31:49 dsl Exp $
#include <sys/proc.h>
#include <sys/malloc.h>
#include <sys/sysctl.h>
#ifdef KTRACE
#include <sys/ktrace.h>
#endif
#include <sys/tty.h>
#include <sys/kauth.h>
@ -318,10 +314,7 @@ darwin_sys___sysctl(struct lwp *l, void *v, register_t *retval)
if (error)
return (error);
#ifdef KTRACE
if (KTRPOINT(l->l_proc, KTR_MIB))
ktrmib(l, name, SCARG(uap, namelen));
#endif
ktrmib(name, SCARG(uap, namelen));
/*
* wire old so that copyout() is less likely to fail?

View File

@ -1,4 +1,4 @@
/* $NetBSD: freebsd_misc.c,v 1.29 2007/03/04 06:01:15 christos Exp $ */
/* $NetBSD: freebsd_misc.c,v 1.30 2007/08/15 12:07:28 ad Exp $ */
/*
* Copyright (c) 1995 Frank van der Linden
@ -36,11 +36,10 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: freebsd_misc.c,v 1.29 2007/03/04 06:01:15 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: freebsd_misc.c,v 1.30 2007/08/15 12:07:28 ad Exp $");
#if defined(_KERNEL_OPT)
#include "opt_ntp.h"
#include "opt_ktrace.h"
#endif
#include <sys/param.h>
@ -51,9 +50,7 @@ __KERNEL_RCSID(0, "$NetBSD: freebsd_misc.c,v 1.29 2007/03/04 06:01:15 christos E
#include <sys/signalvar.h>
#include <sys/malloc.h>
#include <sys/mman.h>
#ifdef KTRACE
#include <sys/ktrace.h>
#endif
#include <sys/syscallargs.h>
@ -212,19 +209,11 @@ freebsd_sys_sigaction4(struct lwp *l, void *v, register_t *retval)
int
freebsd_sys_utrace(struct lwp *l, void *v, register_t *retval)
{
#ifdef KTRACE
struct freebsd_sys_utrace_args /* {
syscallarg(void *) addr;
syscallarg(size_t) len;
} */ *uap = v;
struct proc *p = l->l_proc;
if (!KTRPOINT(p, KTR_USER))
return 0;
return ktruser(l, "FreeBSD utrace", SCARG(uap, addr), SCARG(uap, len),
return ktruser("FreeBSD utrace", SCARG(uap, addr), SCARG(uap, len),
0);
#else
return ENOSYS;
#endif
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: freebsd_sysctl.c,v 1.8 2007/02/09 21:55:16 ad Exp $ */
/* $NetBSD: freebsd_sysctl.c,v 1.9 2007/08/15 12:07:28 ad Exp $ */
/*-
* Copyright (c) 2005 The NetBSD Foundation, Inc.
@ -41,11 +41,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: freebsd_sysctl.c,v 1.8 2007/02/09 21:55:16 ad Exp $");
#if defined(_KERNEL_OPT)
#include "opt_ktrace.h"
#endif
__KERNEL_RCSID(0, "$NetBSD: freebsd_sysctl.c,v 1.9 2007/08/15 12:07:28 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -56,9 +52,7 @@ __KERNEL_RCSID(0, "$NetBSD: freebsd_sysctl.c,v 1.8 2007/02/09 21:55:16 ad Exp $"
#include <sys/malloc.h>
#include <sys/mman.h>
#include <sys/sysctl.h>
#ifdef KTRACE
#include <sys/ktrace.h>
#endif
#include <sys/syscallargs.h>
@ -119,10 +113,7 @@ freebsd_sys_sysctl(l, v, retval)
if (namelen > 0 && name[0] != 0)
return(sys___sysctl(l, v, retval));
#ifdef KTRACE
if (KTRPOINT(l->l_proc, KTR_MIB))
ktrmib(l, name, namelen);
#endif
ktrmib(name, namelen);
/*
* FreeBSD sysctl uses an undocumented set of special OIDs in it's
@ -169,16 +160,8 @@ freebsd_sys_sysctl(l, v, retval)
free(locnew, M_TEMP);
return(error);
}
#ifdef KTRACE
if (!error && KTRPOINT(l->l_proc, KTR_MIB)) {
struct iovec iov;
iov.iov_base = new;
iov.iov_len = newlen + 1;
ktrgenio(l, -1, UIO_WRITE, &iov, newlen + 1, 0);
}
#endif
ktrmibio(-1, UIO_WRITE, new, newlen + 1, error);
error = freebsd_sysctl_name2oid(locnew, oid, &oidlen);
sysctl_unlock(l);
free(locnew, M_TEMP);
@ -190,15 +173,9 @@ freebsd_sys_sysctl(l, v, retval)
MIN(oidlen, *SCARG(uap, oldlenp)));
if (error)
return(error);
#ifdef KTRACE
if (KTRPOINT(l->l_proc, KTR_MIB)) {
struct iovec iov;
ktrmibio(-1, UIO_READ, SCARG(uap, old),
MIN(oidlen, *SCARG(uap, oldlenp)), 0);
iov.iov_base = SCARG(uap, old);
iov.iov_len = MIN(oidlen, *SCARG(uap, oldlenp));
ktrgenio(l, -1, UIO_READ, &iov, iov.iov_len, 0);
}
#endif
error = copyout(&oidlen, SCARG(uap, oldlenp), sizeof(u_int));
return(error);

View File

@ -1,4 +1,4 @@
/* $NetBSD: hpux_net.c,v 1.34 2007/03/04 06:01:15 christos Exp $ */
/* $NetBSD: hpux_net.c,v 1.35 2007/08/15 12:07:29 ad Exp $ */
/*
* Copyright (c) 1990, 1993
@ -82,11 +82,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: hpux_net.c,v 1.34 2007/03/04 06:01:15 christos Exp $");
#if defined(_KERNEL_OPT)
#include "opt_ktrace.h"
#endif
__KERNEL_RCSID(0, "$NetBSD: hpux_net.c,v 1.35 2007/08/15 12:07:29 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -190,9 +186,6 @@ hpux_sys_netioctl(l, v, retval)
int *args, i;
int code;
int error;
#ifdef KTRACE
struct proc *p = l->l_proc;
#endif
args = SCARG(uap, args);
code = SCARG(uap, call) - MINBSDIPCCODE;
@ -200,18 +193,12 @@ hpux_sys_netioctl(l, v, retval)
return (EINVAL);
if ((i = hpuxtobsdipc[code].nargs * sizeof (int)) &&
(error = copyin((void *)args, (void *)uap, (u_int)i))) {
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSCALL))
ktrsyscall(l, code + MINBSDIPCCODE,
code + MINBSDIPCCODE, NULL, (register_t *)uap);
#endif
ktrsyscall(code + MINBSDIPCCODE, code + MINBSDIPCCODE, NULL,
(register_t *)uap);
return (error);
}
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSCALL))
ktrsyscall(l, code + MINBSDIPCCODE,
code + MINBSDIPCCODE, NULL, (register_t *)uap);
#endif
ktrsyscall(code + MINBSDIPCCODE, code + MINBSDIPCCODE, NULL,
(register_t *)uap);
return ((*hpuxtobsdipc[code].rout)(l, uap, retval));
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: linux_commons.c,v 1.6 2007/02/09 21:55:18 ad Exp $ */
/* $NetBSD: linux_commons.c,v 1.7 2007/08/15 12:07:29 ad Exp $ */
/*
* This file includes C files from the common
@ -13,11 +13,10 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(1, "$NetBSD: linux_commons.c,v 1.6 2007/02/09 21:55:18 ad Exp $");
__KERNEL_RCSID(1, "$NetBSD: linux_commons.c,v 1.7 2007/08/15 12:07:29 ad Exp $");
#if defined(_KERNEL_OPT)
#include "opt_sysv.h"
#include "opt_ktrace.h"
#include "opt_nfsserver.h"
#include "fs_nfs.h"
#include "fs_lfs.h"

View File

@ -1,4 +1,4 @@
/* $NetBSD: linux_commons.c,v 1.4 2007/02/09 21:55:18 ad Exp $ */
/* $NetBSD: linux_commons.c,v 1.5 2007/08/15 12:07:29 ad Exp $ */
/*
* This file includes C files from the common
@ -13,11 +13,10 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(1, "$NetBSD: linux_commons.c,v 1.4 2007/02/09 21:55:18 ad Exp $");
__KERNEL_RCSID(1, "$NetBSD: linux_commons.c,v 1.5 2007/08/15 12:07:29 ad Exp $");
#if defined(_KERNEL_OPT)
#include "opt_sysv.h"
#include "opt_ktrace.h"
#include "opt_nfsserver.h"
#include "fs_nfs.h"
#include "fs_lfs.h"

View File

@ -1,4 +1,4 @@
/* $NetBSD: linux_commons.c,v 1.9 2007/06/13 14:31:07 christos Exp $ */
/* $NetBSD: linux_commons.c,v 1.10 2007/08/15 12:07:29 ad Exp $ */
/*
* This file includes C files from the common
@ -13,11 +13,10 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(1, "$NetBSD: linux_commons.c,v 1.9 2007/06/13 14:31:07 christos Exp $");
__KERNEL_RCSID(1, "$NetBSD: linux_commons.c,v 1.10 2007/08/15 12:07:29 ad Exp $");
#if defined(_KERNEL_OPT)
#include "opt_sysv.h"
#include "opt_ktrace.h"
#include "opt_nfsserver.h"
#include "fs_nfs.h"
#include "fs_lfs.h"

View File

@ -1,4 +1,4 @@
/* $NetBSD: linux_socket.c,v 1.76 2007/07/01 18:45:36 dsl Exp $ */
/* $NetBSD: linux_socket.c,v 1.77 2007/08/15 12:07:29 ad Exp $ */
/*-
* Copyright (c) 1995, 1998 The NetBSD Foundation, Inc.
@ -42,10 +42,9 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: linux_socket.c,v 1.76 2007/07/01 18:45:36 dsl Exp $");
__KERNEL_RCSID(0, "$NetBSD: linux_socket.c,v 1.77 2007/08/15 12:07:29 ad Exp $");
#if defined(_KERNEL_OPT)
#include "opt_ktrace.h"
#include "opt_inet.h"
#endif /* defined(_KERNEL_OPT) */
@ -78,9 +77,7 @@ __KERNEL_RCSID(0, "$NetBSD: linux_socket.c,v 1.76 2007/07/01 18:45:36 dsl Exp $"
#include <sys/kauth.h>
#include <sys/syscallargs.h>
#ifdef KTRACE
#include <sys/ktrace.h>
#endif
#include <lib/libkern/libkern.h>
@ -1395,10 +1392,8 @@ linux_get_sa(struct lwp *l, int s, struct mbuf **mp, const struct osockaddr *osa
error, osa, salen));
goto bad;
}
#ifdef KTRACE
if (KTRPOINT(l->l_proc, KTR_USER))
ktrkuser(l, "linux sockaddr", kosa, salen);
#endif
ktrkuser("linux sockaddr", kosa, salen);
bdom = linux_to_bsd_domain(kosa->sa_family);
if (bdom == -1) {
@ -1465,10 +1460,7 @@ linux_get_sa(struct lwp *l, int s, struct mbuf **mp, const struct osockaddr *osa
sa->sa_family = bdom;
sa->sa_len = salen;
m->m_len = salen;
#ifdef KTRACE
if (KTRPOINT(l->l_proc, KTR_USER))
ktrkuser(l, "new sockaddr", kosa, salen);
#endif
ktrkuser("new sockaddr", kosa, salen);
#ifdef DEBUG_LINUX
DPRINTF(("family %d, len = %d [ ", sa->sa_family, sa->sa_len));

View File

@ -1,4 +1,4 @@
/* $NetBSD: linux_socketcall.c,v 1.34 2007/06/02 13:16:19 yamt Exp $ */
/* $NetBSD: linux_socketcall.c,v 1.35 2007/08/15 12:07:30 ad Exp $ */
/*-
* Copyright (c) 1995, 1998 The NetBSD Foundation, Inc.
@ -37,11 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: linux_socketcall.c,v 1.34 2007/06/02 13:16:19 yamt Exp $");
#if defined(_KERNEL_OPT)
#include "opt_ktrace.h"
#endif /* defined(_KERNEL_OPT) */
__KERNEL_RCSID(0, "$NetBSD: linux_socketcall.c,v 1.35 2007/08/15 12:07:30 ad Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@ -62,9 +58,7 @@ __KERNEL_RCSID(0, "$NetBSD: linux_socketcall.c,v 1.34 2007/06/02 13:16:19 yamt E
#include <sys/proc.h>
#include <sys/vnode.h>
#include <sys/device.h>
#ifdef KTRACE
#include <sys/ktrace.h>
#endif
#include <sys/syscallargs.h>
@ -147,12 +141,8 @@ linux_sys_socketcall(l, v, retval)
return error;
}
#ifdef KTRACE
if (KTRPOINT(l->l_proc, KTR_USER))
ktrkuser(l, linux_socketcall[SCARG(uap, what)].name,
&lda, linux_socketcall[SCARG(uap, what)].argsize);
#endif
ktrkuser(linux_socketcall[SCARG(uap, what)].name, &lda,
linux_socketcall[SCARG(uap, what)].argsize);
#ifdef DEBUG_LINUX
/* dump the passed argument data */

View File

@ -1,4 +1,4 @@
/* $NetBSD: linux_sysctl.c,v 1.30 2007/05/10 21:30:15 christos Exp $ */
/* $NetBSD: linux_sysctl.c,v 1.31 2007/08/15 12:07:30 ad Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
@ -41,11 +41,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: linux_sysctl.c,v 1.30 2007/05/10 21:30:15 christos Exp $");
#if defined (_KERNEL_OPT)
#include "opt_ktrace.h"
#endif
__KERNEL_RCSID(0, "$NetBSD: linux_sysctl.c,v 1.31 2007/08/15 12:07:30 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -54,9 +50,7 @@ __KERNEL_RCSID(0, "$NetBSD: linux_sysctl.c,v 1.30 2007/05/10 21:30:15 christos E
#include <sys/mount.h>
#include <sys/sysctl.h>
#include <sys/syscallargs.h>
#ifdef KTRACE
#include <sys/ktrace.h>
#endif
#include <compat/linux/common/linux_types.h>
#include <compat/linux/common/linux_signal.h>
@ -156,10 +150,8 @@ linux_sys___sysctl(struct lwp *l, void *v, register_t *retval)
if (error)
return (error);
#ifdef KTRACE
if (KTRPOINT(l->l_proc, KTR_MIB))
ktrmib(l, name, ls.nlen);
#endif
ktrmib(name, ls.nlen);
/*
* wire old so that copyout() is less likely to fail?
*/

View File

@ -1,4 +1,4 @@
/* $NetBSD: linux32_socketcall.c,v 1.3 2007/06/01 22:42:47 dsl Exp $ */
/* $NetBSD: linux32_socketcall.c,v 1.4 2007/08/15 12:07:30 ad Exp $ */
/*-
* Copyright (c) 2006 Emmanuel Dreyfus, all rights reserved.
@ -31,7 +31,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: linux32_socketcall.c,v 1.3 2007/06/01 22:42:47 dsl Exp $");
__KERNEL_RCSID(0, "$NetBSD: linux32_socketcall.c,v 1.4 2007/08/15 12:07:30 ad Exp $");
#include "opt_ktrace.h"
#include <sys/types.h>
@ -39,9 +39,7 @@ __KERNEL_RCSID(0, "$NetBSD: linux32_socketcall.c,v 1.3 2007/06/01 22:42:47 dsl E
#include <sys/time.h>
#include <sys/proc.h>
#include <sys/ucred.h>
#ifdef KTRACE
#include <sys/ktrace.h>
#endif
#include <compat/netbsd32/netbsd32.h>
#include <compat/netbsd32/netbsd32_syscallargs.h>
@ -106,12 +104,9 @@ linux32_sys_socketcall(l, v, retval)
linux32_socketcall[SCARG(uap, what)].argsize)) != 0)
return error;
#ifdef KTRACE
/* Trace the socket-call arguments as 'GIO' on fd -1 */
if (KTRPOINT(l->l_proc, KTR_USER))
ktrkuser(l, linux32_socketcall[SCARG(uap, what)].name,
&ua, linux32_socketcall[SCARG(uap, what)].argsize);
#endif
ktrkuser(linux32_socketcall[SCARG(uap, what)].name, &ua,
linux32_socketcall[SCARG(uap, what)].argsize);
return linux32_socketcall[SCARG(uap, what)].syscall(l, &ua, retval);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: linux32_sysctl.c,v 1.5 2007/03/18 21:38:32 dsl Exp $ */
/* $NetBSD: linux32_sysctl.c,v 1.6 2007/08/15 12:07:30 ad Exp $ */
/*-
* Copyright (c) 2006 Emmanuel Dreyfus, all rights reserved.
@ -31,9 +31,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: linux32_sysctl.c,v 1.5 2007/03/18 21:38:32 dsl Exp $");
#include "opt_ktrace.h"
__KERNEL_RCSID(0, "$NetBSD: linux32_sysctl.c,v 1.6 2007/08/15 12:07:30 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -42,9 +40,7 @@ __KERNEL_RCSID(0, "$NetBSD: linux32_sysctl.c,v 1.5 2007/03/18 21:38:32 dsl Exp $
#include <sys/mount.h>
#include <sys/sysctl.h>
#include <sys/syscallargs.h>
#ifdef KTRACE
#include <sys/ktrace.h>
#endif
#include <compat/netbsd32/netbsd32.h>
@ -197,10 +193,7 @@ linux32_sys___sysctl(l, v, retval)
ls32.nlen * sizeof(int))) != 0)
return error;
#ifdef KTRACE
if (KTRPOINT(l->l_proc, KTR_MIB))
ktrmib(l, name, ls32.nlen);
#endif
ktrmib(name, ls32.nlen);
if ((error = sysctl_lock(l,
NETBSD32PTR64(ls32.oldval), savelen)) != 0)

View File

@ -1,4 +1,4 @@
/* $NetBSD: mach_message.c,v 1.51 2007/03/12 18:18:29 ad Exp $ */
/* $NetBSD: mach_message.c,v 1.52 2007/08/15 12:07:30 ad Exp $ */
/*-
* Copyright (c) 2002-2003 The NetBSD Foundation, Inc.
@ -37,9 +37,8 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: mach_message.c,v 1.51 2007/03/12 18:18:29 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: mach_message.c,v 1.52 2007/08/15 12:07:30 ad Exp $");
#include "opt_ktrace.h"
#include "opt_compat_mach.h" /* For COMPAT_MACH in <sys/ktrace.h> */
#include "opt_compat_darwin.h"
@ -52,9 +51,7 @@ __KERNEL_RCSID(0, "$NetBSD: mach_message.c,v 1.51 2007/03/12 18:18:29 ad Exp $")
#include <sys/queue.h>
#include <sys/malloc.h>
#include <sys/pool.h>
#ifdef KTRACE
#include <sys/ktrace.h>
#endif
#include <uvm/uvm_extern.h>
#include <uvm/uvm_map.h>
@ -188,11 +185,9 @@ mach_msg_send(l, msg, option, send_size)
goto out1;
}
#ifdef KTRACE
/* Dump the Mach message */
if (KTRPOINT(p, KTR_MMSG))
ktrmmsg(l, (char *)sm, send_size);
#endif
ktrmmsg((char *)sm, send_size);
/*
* Handle rights in the message
*/
@ -595,11 +590,9 @@ mach_msg_recv(l, urm, option, recv_size, timeout, mn)
ret = MACH_RCV_INVALID_DATA;
goto unlock;
}
#ifdef KTRACE
/* Dump the Mach message */
if (KTRPOINT(p, KTR_MMSG))
ktrmmsg(l, (char *)&sr, sizeof(sr));
#endif
ktrmmsg((char *)&sr, sizeof(sr));
goto unlock;
}
@ -654,11 +647,9 @@ mach_msg_recv(l, urm, option, recv_size, timeout, mn)
ret = MACH_RCV_INVALID_DATA;
goto unlock;
}
#ifdef KTRACE
/* Dump the Mach message */
if (KTRPOINT(p, KTR_MMSG))
ktrmmsg(l, (char *)mm->mm_msg, mm->mm_size);
#endif
ktrmmsg((char *)mm->mm_msg, mm->mm_size);
free(mm->mm_msg, M_EMULDATA);
mach_message_put_shlocked(mm); /* decrease mp_count */
@ -984,12 +975,10 @@ mach_ool_copyin(l, uaddr, kaddr, size, flags)
return error;
}
#ifdef KTRACE
if (size > PAGE_SIZE)
size = PAGE_SIZE;
if ((flags & MACH_OOL_TRACE) && KTRPOINT(p, KTR_MOOL))
ktrmool(l, kaddr, size, uaddr);
#endif
if ((flags & MACH_OOL_TRACE))
ktrmool(kaddr, size, uaddr);
*kaddr = kbuf;
return 0;
@ -1037,12 +1026,10 @@ mach_ool_copyout(l, kaddr, uaddr, size, flags)
if ((error = copyout_proc(p, kaddr, (void *)ubuf, size)) != 0)
goto out;
#ifdef KTRACE
if (size > PAGE_SIZE)
size = PAGE_SIZE;
if ((flags & MACH_OOL_TRACE) && KTRPOINT(p, KTR_MOOL))
ktrmool(l, kaddr, size, (void *)ubuf);
#endif
if ((flags & MACH_OOL_TRACE))
ktrmool(kaddr, size, (void *)ubuf);
out:
if (flags & MACH_OOL_FREE)

View File

@ -1,4 +1,4 @@
/* $NetBSD: mach_vm.c,v 1.55 2007/03/04 06:01:25 christos Exp $ */
/* $NetBSD: mach_vm.c,v 1.56 2007/08/15 12:07:30 ad Exp $ */
/*-
* Copyright (c) 2002-2003 The NetBSD Foundation, Inc.
@ -36,10 +36,8 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include "opt_ktrace.h"
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: mach_vm.c,v 1.55 2007/03/04 06:01:25 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: mach_vm.c,v 1.56 2007/08/15 12:07:30 ad Exp $");
#include <sys/types.h>
#include <sys/param.h>
@ -781,10 +779,8 @@ mach_vm_read(args)
return mach_msg_error(args, EFAULT);
}
#ifdef KTRACE
if (KTRPOINT(l->l_proc, KTR_MOOL) && error == 0)
ktrmool(l, tbuf, size, (void *)va);
#endif
if (error == 0)
ktrmool(tbuf, size, (void *)va);
free(tbuf, M_WAITOK);
@ -806,9 +802,6 @@ mach_vm_write(args)
mach_vm_write_request_t *req = args->smsg;
mach_vm_write_reply_t *rep = args->rmsg;
size_t *msglen = args->rsize;
#ifdef KTRACE
struct lwp *l = args->l;
#endif
struct lwp *tl = args->tl;
size_t size;
void *addr;
@ -841,10 +834,8 @@ mach_vm_write(args)
return mach_msg_error(args, EFAULT);
}
#ifdef KTRACE
if (KTRPOINT(l->l_proc, KTR_MOOL) && error == 0)
ktrmool(l, tbuf, size, (void *)addr);
#endif
if (error == 0)
ktrmool(tbuf, size, (void *)addr);
free(tbuf, M_WAITOK);

View File

@ -1,4 +1,4 @@
/* $NetBSD: netbsd32_fs.c,v 1.45 2007/06/30 15:31:50 dsl Exp $ */
/* $NetBSD: netbsd32_fs.c,v 1.46 2007/08/15 12:07:31 ad Exp $ */
/*
* Copyright (c) 1998, 2001 Matthew R. Green
@ -29,11 +29,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: netbsd32_fs.c,v 1.45 2007/06/30 15:31:50 dsl Exp $");
#if defined(_KERNEL_OPT)
#include "opt_ktrace.h"
#endif
__KERNEL_RCSID(0, "$NetBSD: netbsd32_fs.c,v 1.46 2007/08/15 12:07:31 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -151,9 +147,7 @@ dofilereadv32(l, fd, fp, iovp, iovcnt, offset, flags, retval)
struct iovec aiov[UIO_SMALLIOV];
long i, cnt, error = 0;
u_int iovlen;
#ifdef KTRACE
struct iovec *ktriov = NULL;
#endif
/* note: can't use iovlen until iovcnt is validated */
iovlen = iovcnt * sizeof(struct iovec);
@ -193,15 +187,15 @@ dofilereadv32(l, fd, fp, iovp, iovcnt, offset, flags, retval)
}
iov++;
}
#ifdef KTRACE
/*
* if tracing, save a copy of iovec
*/
if (KTRPOINT(l->l_proc, KTR_GENIO)) {
if (ktrpoint(KTR_GENIO)) {
ktriov = malloc(iovlen, M_TEMP, M_WAITOK);
memcpy((void *)ktriov, (void *)auio.uio_iov, iovlen);
}
#endif
cnt = auio.uio_resid;
error = (*fp->f_ops->fo_read)(fp, offset, &auio, fp->f_cred, flags);
if (error)
@ -209,14 +203,12 @@ dofilereadv32(l, fd, fp, iovp, iovcnt, offset, flags, retval)
error == EINTR || error == EWOULDBLOCK))
error = 0;
cnt -= auio.uio_resid;
#ifdef KTRACE
if (KTRPOINT(l->l_proc, KTR_GENIO))
if (error == 0) {
ktrgenio(l, fd, UIO_READ, ktriov, cnt,
error);
if (ktriov != NULL) {
ktrgeniov(fd, UIO_READ, ktriov, cnt, error);
free(ktriov, M_TEMP);
}
#endif
*retval = cnt;
done:
if (needfree)
@ -273,9 +265,7 @@ dofilewritev32(l, fd, fp, iovp, iovcnt, offset, flags, retval)
struct proc *p = l->l_proc;
long i, cnt, error = 0;
u_int iovlen;
#ifdef KTRACE
struct iovec *ktriov = NULL;
#endif
/* note: can't use iovlen until iovcnt is validated */
iovlen = iovcnt * sizeof(struct iovec);
@ -315,15 +305,15 @@ dofilewritev32(l, fd, fp, iovp, iovcnt, offset, flags, retval)
}
iov++;
}
#ifdef KTRACE
/*
* if tracing, save a copy of iovec
*/
if (KTRPOINT(p, KTR_GENIO)) {
if (ktrpoint(KTR_GENIO)) {
ktriov = malloc(iovlen, M_TEMP, M_WAITOK);
memcpy((void *)ktriov, (void *)auio.uio_iov, iovlen);
}
#endif
cnt = auio.uio_resid;
error = (*fp->f_ops->fo_write)(fp, offset, &auio, fp->f_cred, flags);
if (error) {
@ -337,14 +327,10 @@ dofilewritev32(l, fd, fp, iovp, iovcnt, offset, flags, retval)
}
}
cnt -= auio.uio_resid;
#ifdef KTRACE
if (KTRPOINT(p, KTR_GENIO))
if (error == 0) {
ktrgenio(l, fd, UIO_WRITE, ktriov, cnt,
error);
if (ktriov != NULL) {
ktrgenio(fd, UIO_WRITE, ktriov, cnt, error);
free(ktriov, M_TEMP);
}
#endif
*retval = cnt;
done:
if (needfree)

View File

@ -1,4 +1,4 @@
/* $NetBSD: netbsd32_ioctl.c,v 1.34 2007/05/30 00:00:59 christos Exp $ */
/* $NetBSD: netbsd32_ioctl.c,v 1.35 2007/08/15 12:07:31 ad Exp $ */
/*
* Copyright (c) 1998, 2001 Matthew R. Green
@ -33,11 +33,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: netbsd32_ioctl.c,v 1.34 2007/05/30 00:00:59 christos Exp $");
#if defined(_KERNEL_OPT)
#include "opt_ktrace.h"
#endif
__KERNEL_RCSID(0, "$NetBSD: netbsd32_ioctl.c,v 1.35 2007/08/15 12:07:31 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -55,9 +51,7 @@ __KERNEL_RCSID(0, "$NetBSD: netbsd32_ioctl.c,v 1.34 2007/05/30 00:00:59 christos
#include <sys/ttycom.h>
#include <sys/mount.h>
#include <sys/syscallargs.h>
#ifdef KTRACE
#include <sys/ktrace.h>
#endif
#ifdef __sparc__
#include <dev/sun/fbio.h>
@ -440,15 +434,8 @@ printf("netbsd32_ioctl(%d, %x, %x): %s group %c base %d len %d\n",
free(memp32, M_IOCTLOPS);
goto out;
}
#ifdef KTRACE
if (KTRPOINT(p, KTR_GENIO)) {
struct iovec iov;
iov.iov_base = SCARG_P32(uap, data);
iov.iov_len = size32;
ktrgenio(l, SCARG(uap, fd), UIO_WRITE, &iov,
size32, 0);
}
#endif
ktrgenio(SCARG(uap, fd), UIO_WRITE, SCARG_P32(uap, data),
size32, 0);
} else
*(void **)data32 = SCARG_P32(uap, data);
} else if ((com&IOC_OUT) && size32)
@ -589,15 +576,8 @@ printf("netbsd32_ioctl(%d, %x, %x): %s group %c base %d len %d\n",
*/
if (error == 0 && (com&IOC_OUT) && size32) {
error = copyout(data32, SCARG_P32(uap, data), size32);
#ifdef KTRACE
if (KTRPOINT(p, KTR_GENIO)) {
struct iovec iov;
iov.iov_base = SCARG_P32(uap, data);
iov.iov_len = size32;
ktrgenio(l, SCARG(uap, fd), UIO_READ, &iov,
size32, error);
}
#endif
ktrgenio(SCARG(uap, fd), UIO_READ, SCARG_P32(uap, data),
size32, error);
}
/* if we malloced data, free it here */

View File

@ -1,4 +1,4 @@
/* $NetBSD: netbsd32_netbsd.c,v 1.125 2007/07/14 15:47:27 dsl Exp $ */
/* $NetBSD: netbsd32_netbsd.c,v 1.126 2007/08/15 12:07:31 ad Exp $ */
/*
* Copyright (c) 1998, 2001 Matthew R. Green
@ -29,11 +29,10 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: netbsd32_netbsd.c,v 1.125 2007/07/14 15:47:27 dsl Exp $");
__KERNEL_RCSID(0, "$NetBSD: netbsd32_netbsd.c,v 1.126 2007/08/15 12:07:31 ad Exp $");
#if defined(_KERNEL_OPT)
#include "opt_ddb.h"
#include "opt_ktrace.h"
#include "opt_ntp.h"
#include "opt_compat_netbsd.h"
#include "opt_compat_43.h"
@ -666,7 +665,6 @@ netbsd32_profil(l, v, retval)
return (sys_profil(l, &ua, retval));
}
#ifdef KTRACE
int
netbsd32_ktrace(l, v, retval)
struct lwp *l;
@ -687,7 +685,6 @@ netbsd32_ktrace(l, v, retval)
NETBSD32TO64_UAP(pid);
return (sys_ktrace(l, &ua, retval));
}
#endif /* KTRACE */
int
netbsd32_utrace(l, v, retval)
@ -2137,7 +2134,6 @@ netbsd32_getsid(l, v, retval)
return (sys_getsid(l, &ua, retval));
}
#ifdef KTRACE
int
netbsd32_fktrace(l, v, retval)
struct lwp *l;
@ -2168,7 +2164,6 @@ netbsd32_fktrace(l, v, retval)
NETBSD32TO64_UAP(pid);
return (sys_fktrace(l, &ua, retval));
}
#endif /* KTRACE */
int netbsd32___sigpending14(l, v, retval)
struct lwp *l;

View File

@ -1,4 +1,4 @@
/* $NetBSD: netbsd32_socket.c,v 1.26 2007/06/01 22:53:52 dsl Exp $ */
/* $NetBSD: netbsd32_socket.c,v 1.27 2007/08/15 12:07:31 ad Exp $ */
/*
* Copyright (c) 1998, 2001 Matthew R. Green
@ -29,11 +29,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: netbsd32_socket.c,v 1.26 2007/06/01 22:53:52 dsl Exp $");
#if defined(_KERNEL_OPT)
#include "opt_ktrace.h"
#endif
__KERNEL_RCSID(0, "$NetBSD: netbsd32_socket.c,v 1.27 2007/08/15 12:07:31 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -113,14 +109,11 @@ recvit32(l, s, mp, iov, namelenp, retsize)
{
struct file *fp;
struct uio auio;
int i;
int len, error;
int i, len, error, iovlen;
struct mbuf *from = 0, *control = 0;
struct socket *so;
struct proc *p;
#ifdef KTRACE
struct iovec *ktriov = NULL;
#endif
p = l->l_proc;
/* getsock() will use the descriptor for us */
@ -151,14 +144,13 @@ recvit32(l, s, mp, iov, namelenp, retsize)
goto out1;
}
}
#ifdef KTRACE
if (KTRPOINT(p, KTR_GENIO)) {
int iovlen = auio.uio_iovcnt * sizeof(struct iovec);
if (ktrpoint(KTR_GENIO)) {
iovlen = auio.uio_iovcnt * sizeof(struct iovec);
ktriov = (struct iovec *)malloc(iovlen, M_TEMP, M_WAITOK);
memcpy((void *)ktriov, (void *)auio.uio_iov, iovlen);
}
#endif
len = auio.uio_resid;
so = (struct socket *)fp->f_data;
error = (*so->so_receive)(so, &from, &auio, NULL,
@ -169,14 +161,12 @@ recvit32(l, s, mp, iov, namelenp, retsize)
error == EINTR || error == EWOULDBLOCK))
error = 0;
}
#ifdef KTRACE
if (ktriov != NULL) {
if (error == 0)
ktrgenio(l, s, UIO_READ, ktriov,
len - auio.uio_resid, error);
ktrgeniov(s, UIO_READ, ktriov, len - auio.uio_resid, error);
FREE(ktriov, M_TEMP);
}
#endif
if (error)
goto out;
*retsize = len - auio.uio_resid;

View File

@ -1,4 +1,4 @@
/* $NetBSD: netbsd32_sysctl.c,v 1.24 2007/03/18 21:38:34 dsl Exp $ */
/* $NetBSD: netbsd32_sysctl.c,v 1.25 2007/08/15 12:07:31 ad Exp $ */
/*
* Copyright (c) 2003 The NetBSD Foundation, Inc.
@ -32,11 +32,10 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: netbsd32_sysctl.c,v 1.24 2007/03/18 21:38:34 dsl Exp $");
__KERNEL_RCSID(0, "$NetBSD: netbsd32_sysctl.c,v 1.25 2007/08/15 12:07:31 ad Exp $");
#if defined(_KERNEL_OPT)
#include "opt_ddb.h"
#include "opt_ktrace.h"
#endif
#include <sys/param.h>
@ -51,9 +50,7 @@ __KERNEL_RCSID(0, "$NetBSD: netbsd32_sysctl.c,v 1.24 2007/03/18 21:38:34 dsl Exp
#include <sys/proc.h>
#include <sys/sysctl.h>
#include <sys/dirent.h>
#ifdef KTRACE
#include <sys/ktrace.h>
#endif
#include <uvm/uvm_extern.h>
@ -201,10 +198,7 @@ netbsd32___sysctl(l, v, retval)
if (error)
return (error);
#ifdef KTRACE
if (KTRPOINT(l->l_proc, KTR_MIB))
ktrmib(l, name, SCARG(uap, namelen));
#endif
ktrmib(name, SCARG(uap, namelen));
/*
* wire old so that copyout() is less likely to fail?

View File

@ -1,4 +1,4 @@
$NetBSD: syscalls.master,v 1.60 2007/08/07 19:00:42 ad Exp $
$NetBSD: syscalls.master,v 1.61 2007/08/15 12:07:31 ad Exp $
; from: NetBSD: syscalls.master,v 1.81 1998/07/05 08:49:50 jonathan Exp
; @(#)syscalls.master 8.2 (Berkeley) 1/13/94
@ -36,7 +36,6 @@
; #include's are copied to the syscall names and switch definition files only.
#if defined(_KERNEL_OPT)
#include "opt_ktrace.h"
#include "opt_nfsserver.h"
#include "opt_compat_netbsd.h"
#include "opt_ntp.h"
@ -110,11 +109,7 @@
42 NOARGS { int sys_pipe(void); }
43 NOARGS MPSAFE { gid_t sys_getegid(void); }
44 STD { int netbsd32_profil(netbsd32_caddr_t samples, netbsd32_size_t size, netbsd32_u_long offset, u_int scale); }
#if defined(KTRACE) || !defined(_KERNEL)
45 STD { int netbsd32_ktrace(const netbsd32_charp fname, int ops, int facs, int pid); }
#else
45 EXCL netbsd32_ktrace
#endif
46 STD { int netbsd32_sigaction(int signum, const netbsd32_sigactionp_t nsa, netbsd32_sigactionp_t osa); }
47 NOARGS MPSAFE { gid_t sys_getgid(void); }
48 COMPAT_13 { int netbsd32_sigprocmask(int how, \
@ -450,11 +445,7 @@
285 STD { int netbsd32___posix_lchown(const netbsd32_charp path, uid_t uid, gid_t gid); }
286 STD { pid_t netbsd32_getsid(pid_t pid); }
287 STD { int netbsd32___clone(int flags, netbsd32_voidp stack); }
#if defined(KTRACE) || !defined(_KERNEL)
288 STD { int netbsd32_fktrace(const int fd, int ops, int facs, int pid); }
#else
288 EXCL netbsd32_fktrace
#endif
289 STD { netbsd32_ssize_t netbsd32_preadv(int fd, const netbsd32_iovecp_t iovp, int iovcnt, int pad, off_t offset); }
290 STD { netbsd32_ssize_t netbsd32_pwritev(int fd, const netbsd32_iovecp_t iovp, int iovcnt, int pad, off_t offset); }
291 STD { int netbsd32___sigaction14(int signum, \

View File

@ -1,4 +1,4 @@
# $NetBSD: files,v 1.859 2007/08/15 03:53:09 kiyohara Exp $
# $NetBSD: files,v 1.860 2007/08/15 12:07:32 ad Exp $
# @(#)files.newconf 7.5 (Berkeley) 5/10/93
@ -1324,7 +1324,7 @@ file kern/kern_exit.c
file kern/kern_fork.c
file kern/kern_idle.c
file kern/kern_kthread.c
file kern/kern_ktrace.c
file kern/kern_ktrace.c ktrace
file kern/kern_ksyms.c ksyms | ddb | lkm needs-flag
file kern/kern_lkm.c lkm
file kern/kern_lock.c
@ -1383,7 +1383,6 @@ file kern/subr_time.c
file kern/subr_userconf.c userconf
file kern/subr_vmem.c
file kern/subr_workqueue.c
file kern/subr_xxx.c
file kern/sys_aio.c
file kern/sys_generic.c
file kern/sys_lwp.c

View File

@ -1,4 +1,4 @@
/* $NetBSD: init_sysctl.c,v 1.104 2007/08/06 11:51:46 yamt Exp $ */
/* $NetBSD: init_sysctl.c,v 1.105 2007/08/15 12:07:32 ad Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
@ -37,13 +37,12 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: init_sysctl.c,v 1.104 2007/08/06 11:51:46 yamt Exp $");
__KERNEL_RCSID(0, "$NetBSD: init_sysctl.c,v 1.105 2007/08/15 12:07:32 ad Exp $");
#include "opt_sysv.h"
#include "opt_multiprocessor.h"
#include "opt_posix.h"
#include "opt_compat_netbsd32.h"
#include "opt_ktrace.h"
#include "pty.h"
#include "rnd.h"
@ -74,9 +73,7 @@ __KERNEL_RCSID(0, "$NetBSD: init_sysctl.c,v 1.104 2007/08/06 11:51:46 yamt Exp $
#include <sys/device.h>
#include <sys/stat.h>
#include <sys/kauth.h>
#ifdef KTRACE
#include <sys/ktrace.h>
#endif
#ifdef COMPAT_NETBSD32
#include <compat/netbsd32/netbsd32.h>
@ -152,10 +149,9 @@ static const u_int sysctl_lwpprflagmap[] = {
#define KERN_PROCSLOP (5 * sizeof(struct kinfo_proc))
#define KERN_LWPSLOP (5 * sizeof(struct kinfo_lwp))
#ifdef KTRACE
int dcopyout(struct lwp *, const void *, void *, size_t);
static int dcopyout(struct lwp *, const void *, void *, size_t);
int
static int
dcopyout(l, kaddr, uaddr, len)
struct lwp *l;
const void *kaddr;
@ -165,18 +161,10 @@ dcopyout(l, kaddr, uaddr, len)
int error;
error = copyout(kaddr, uaddr, len);
if (!error && KTRPOINT(l->l_proc, KTR_MIB)) {
struct iovec iov;
ktrmibio(-1, UIO_READ, uaddr, len, error);
iov.iov_base = uaddr;
iov.iov_len = len;
ktrgenio(l, -1, UIO_READ, &iov, len, 0);
}
return error;
}
#else /* !KTRACE */
#define dcopyout(l, kaddr, uaddr, len) copyout(kaddr, uaddr, len)
#endif /* KTRACE */
#ifdef DIAGNOSTIC
static int sysctl_kern_trigger_panic(SYSCTLFN_PROTO);

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_exec.c,v 1.246 2007/07/22 19:16:05 pooka Exp $ */
/* $NetBSD: kern_exec.c,v 1.247 2007/08/15 12:07:32 ad Exp $ */
/*-
* Copyright (C) 1993, 1994, 1996 Christopher G. Demetriou
@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kern_exec.c,v 1.246 2007/07/22 19:16:05 pooka Exp $");
__KERNEL_RCSID(0, "$NetBSD: kern_exec.c,v 1.247 2007/08/15 12:07:32 ad Exp $");
#include "opt_ktrace.h"
#include "opt_syscall_debug.h"
@ -549,10 +549,7 @@ execve1(struct lwp *l, const char *path, char * const *args,
error = E2BIG;
goto bad;
}
#ifdef KTRACE
if (KTRPOINT(p, KTR_EXEC_ARG))
ktrkmem(l, KTR_EXEC_ARG, dp, len - 1);
#endif
ktrexecarg(dp, len - 1);
dp += len;
i++;
argc++;
@ -573,10 +570,7 @@ execve1(struct lwp *l, const char *path, char * const *args,
error = E2BIG;
goto bad;
}
#ifdef KTRACE
if (KTRPOINT(p, KTR_EXEC_ENV))
ktrkmem(l, KTR_EXEC_ENV, dp, len - 1);
#endif
ktrexecenv(dp, len - 1);
dp += len;
i++;
envc++;
@ -831,10 +825,10 @@ execve1(struct lwp *l, const char *path, char * const *args,
* root set it.
*/
if (p->p_tracep) {
mutex_enter(&ktrace_mutex);
mutex_enter(&ktrace_lock);
if (!(p->p_traceflag & KTRFAC_ROOT))
ktrderef(p);
mutex_exit(&ktrace_mutex);
mutex_exit(&ktrace_lock);
}
#endif
if (attr.va_mode & S_ISUID)
@ -943,10 +937,7 @@ execve1(struct lwp *l, const char *path, char * const *args,
#ifdef __HAVE_SYSCALL_INTERN
(*p->p_emul->e_syscall_intern)(p);
#endif
#ifdef KTRACE
if (KTRPOINT(p, KTR_EMUL))
ktremul(l);
#endif
ktremul();
#ifdef LKM
rw_exit(&exec_lock);

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_exit.c,v 1.184 2007/08/07 12:45:54 ad Exp $ */
/* $NetBSD: kern_exit.c,v 1.185 2007/08/15 12:07:32 ad Exp $ */
/*-
* Copyright (c) 1998, 1999, 2006, 2007 The NetBSD Foundation, Inc.
@ -74,7 +74,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kern_exit.c,v 1.184 2007/08/07 12:45:54 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: kern_exit.c,v 1.185 2007/08/15 12:07:32 ad Exp $");
#include "opt_ktrace.h"
#include "opt_perfctrs.h"
@ -291,9 +291,9 @@ exit1(struct lwp *l, int rv)
* Release trace file.
*/
if (p->p_tracep != NULL) {
mutex_enter(&ktrace_mutex);
mutex_enter(&ktrace_lock);
ktrderef(p);
mutex_exit(&ktrace_mutex);
mutex_exit(&ktrace_lock);
}
#endif
#ifdef SYSTRACE

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_fork.c,v 1.141 2007/07/09 21:10:52 ad Exp $ */
/* $NetBSD: kern_fork.c,v 1.142 2007/08/15 12:07:33 ad Exp $ */
/*-
* Copyright (c) 1999, 2001, 2004 The NetBSD Foundation, Inc.
@ -76,7 +76,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kern_fork.c,v 1.141 2007/07/09 21:10:52 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: kern_fork.c,v 1.142 2007/08/15 12:07:33 ad Exp $");
#include "opt_ktrace.h"
#include "opt_systrace.h"
@ -383,11 +383,11 @@ fork1(struct lwp *l1, int flags, int exitsig, void *stack, size_t stacksize,
* If not inherited, these were zeroed above.
*/
if (p1->p_traceflag & KTRFAC_INHERIT) {
mutex_enter(&ktrace_mutex);
mutex_enter(&ktrace_lock);
p2->p_traceflag = p1->p_traceflag;
if ((p2->p_tracep = p1->p_tracep) != NULL)
ktradref(p2);
mutex_exit(&ktrace_mutex);
mutex_exit(&ktrace_lock);
}
#endif
@ -490,10 +490,8 @@ fork1(struct lwp *l1, int flags, int exitsig, void *stack, size_t stacksize,
if (rnewprocp != NULL)
*rnewprocp = p2;
#ifdef KTRACE
if (KTRPOINT(p2, KTR_EMUL))
if (ktrpoint(KTR_EMUL))
p2->p_traceflag |= KTRFAC_TRC_EMUL;
#endif
/*
* Make child runnable, set start time, and add to run queue except

View File

@ -1,4 +1,40 @@
/* $NetBSD: kern_ktrace.c,v 1.124 2007/07/09 21:10:52 ad Exp $ */
/* $NetBSD: kern_ktrace.c,v 1.125 2007/08/15 12:07:33 ad Exp $ */
/*-
* Copyright (c) 2006, 2007 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Andrew Doran.
*
* 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. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
*/
/*
* Copyright (c) 1989, 1993
@ -32,10 +68,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kern_ktrace.c,v 1.124 2007/07/09 21:10:52 ad Exp $");
#include "opt_ktrace.h"
#include "opt_compat_mach.h"
__KERNEL_RCSID(0, "$NetBSD: kern_ktrace.c,v 1.125 2007/08/15 12:07:33 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -56,8 +89,6 @@ __KERNEL_RCSID(0, "$NetBSD: kern_ktrace.c,v 1.124 2007/07/09 21:10:52 ad Exp $")
#include <sys/mount.h>
#include <sys/syscallargs.h>
#ifdef KTRACE
/*
* TODO:
* - need better error reporting?
@ -97,29 +128,31 @@ struct ktr_desc {
int ktd_intrwakdl; /* ditto, but when interactive */
struct file *ktd_fp; /* trace output file */
struct lwp *ktd_lwp; /* our kernel thread */
lwp_t *ktd_lwp; /* our kernel thread */
TAILQ_HEAD(, ktrace_entry) ktd_queue;
callout_t ktd_wakch; /* delayed wakeup */
kcondvar_t ktd_sync_cv;
kcondvar_t ktd_cv;
};
static int ktealloc(struct ktrace_entry **, void **, struct lwp *, int,
static int ktealloc(struct ktrace_entry **, void **, lwp_t *, int,
size_t);
static void ktrwrite(struct ktr_desc *, struct ktrace_entry *);
static int ktrace_common(struct lwp *, int, int, int, struct file *);
static int ktrops(struct lwp *, struct proc *, int, int,
static int ktrace_common(lwp_t *, int, int, int, struct file *);
static int ktrops(lwp_t *, struct proc *, int, int,
struct ktr_desc *);
static int ktrsetchildren(struct lwp *, struct proc *, int, int,
static int ktrsetchildren(lwp_t *, struct proc *, int, int,
struct ktr_desc *);
static int ktrcanset(struct lwp *, struct proc *);
static int ktrcanset(lwp_t *, struct proc *);
static int ktrsamefile(struct file *, struct file *);
static void ktr_kmem(lwp_t *, int, const void *, size_t);
static void ktr_io(lwp_t *, int, enum uio_rw, struct iovec *, size_t);
static struct ktr_desc *
ktd_lookup(struct file *);
static void ktdrel(struct ktr_desc *);
static void ktdref(struct ktr_desc *);
static void ktraddentry(struct lwp *, struct ktrace_entry *, int);
static void ktraddentry(lwp_t *, struct ktrace_entry *, int);
/* Flags for ktraddentry (3rd arg) */
#define KTA_NOWAIT 0x0000
#define KTA_WAITOK 0x0001
@ -147,7 +180,8 @@ int ktd_delayqcnt = KTD_DELAYQCNT; /* # of entry allowed to delay */
int ktd_wakedelay = KTD_WAKEDELAY; /* delay of wakeup in *ms* */
int ktd_intrwakdl = KTD_INTRWAKDL; /* ditto, but when interactive */
kmutex_t ktrace_mutex;
kmutex_t ktrace_lock;
int ktrace_on;
static TAILQ_HEAD(, ktr_desc) ktdq = TAILQ_HEAD_INITIALIZER(ktdq);
MALLOC_DEFINE(M_KTRACE, "ktrace", "ktrace data buffer");
@ -167,7 +201,7 @@ ktd_callout(void *arg)
{
/*
* XXXSMP Should be acquiring ktrace_mutex, but that
* XXXSMP Should be acquiring ktrace_lock, but that
* is not yet possible from a callout. For now, we'll
* rely on the callout & ktrace thread both holding the
* kernel_lock.
@ -189,7 +223,7 @@ ktd_logerr(struct proc *p, int error)
{
struct ktr_desc *ktd;
KASSERT(mutex_owned(&ktrace_mutex));
KASSERT(mutex_owned(&ktrace_lock));
ktd = p->p_tracep;
if (ktd == NULL)
@ -200,7 +234,7 @@ ktd_logerr(struct proc *p, int error)
#endif
static inline int
ktrenter(struct lwp *l)
ktrenter(lwp_t *l)
{
if ((l->l_pflag & LP_KTRACTIVE) != 0)
@ -210,7 +244,7 @@ ktrenter(struct lwp *l)
}
static inline void
ktrexit(struct lwp *l)
ktrexit(lwp_t *l)
{
l->l_pflag &= ~LP_KTRACTIVE;
@ -223,20 +257,22 @@ void
ktrinit(void)
{
mutex_init(&ktrace_mutex, MUTEX_DEFAULT, IPL_NONE);
mutex_init(&ktrace_lock, MUTEX_DEFAULT, IPL_NONE);
}
/*
* Release a reference. Called with ktrace_mutex held.
* Release a reference. Called with ktrace_lock held.
*/
void
ktdrel(struct ktr_desc *ktd)
{
KASSERT(mutex_owned(&ktrace_mutex));
KASSERT(mutex_owned(&ktrace_lock));
KDASSERT(ktd->ktd_ref != 0);
KASSERT(ktd->ktd_ref > 0);
KASSERT(ktrace_on > 0);
ktrace_on--;
if (--ktd->ktd_ref <= 0) {
ktd->ktd_flags |= KTDF_DONE;
cv_signal(&ktd->ktd_cv);
@ -247,9 +283,10 @@ void
ktdref(struct ktr_desc *ktd)
{
KASSERT(mutex_owned(&ktrace_mutex));
KASSERT(mutex_owned(&ktrace_lock));
ktd->ktd_ref++;
ktrace_on++;
}
struct ktr_desc *
@ -257,12 +294,12 @@ ktd_lookup(struct file *fp)
{
struct ktr_desc *ktd;
KASSERT(mutex_owned(&ktrace_mutex));
KASSERT(mutex_owned(&ktrace_lock));
for (ktd = TAILQ_FIRST(&ktdq); ktd != NULL;
ktd = TAILQ_NEXT(ktd, ktd_list)) {
if (ktrsamefile(ktd->ktd_fp, fp)) {
ktd->ktd_ref++;
ktdref(ktd);
break;
}
}
@ -271,7 +308,7 @@ ktd_lookup(struct file *fp)
}
void
ktraddentry(struct lwp *l, struct ktrace_entry *kte, int flags)
ktraddentry(lwp_t *l, struct ktrace_entry *kte, int flags)
{
struct proc *p = l->l_proc;
struct ktr_desc *ktd;
@ -279,22 +316,19 @@ ktraddentry(struct lwp *l, struct ktrace_entry *kte, int flags)
struct timeval t1, t2;
#endif
mutex_enter(&ktrace_mutex);
mutex_enter(&ktrace_lock);
if (p->p_traceflag & KTRFAC_TRC_EMUL) {
/* Add emulation trace before first entry for this process */
p->p_traceflag &= ~KTRFAC_TRC_EMUL;
mutex_exit(&ktrace_mutex);
mutex_exit(&ktrace_lock);
ktrexit(l);
ktremul(l);
ktremul();
(void)ktrenter(l);
mutex_enter(&ktrace_mutex);
mutex_enter(&ktrace_lock);
}
/*
* Tracing may be canceled while we were sleeping waiting for
* memory.
*/
/* Tracing may have been cancelled. */
ktd = p->p_tracep;
if (ktd == NULL)
goto freekte;
@ -331,7 +365,7 @@ ktraddentry(struct lwp *l, struct ktrace_entry *kte, int flags)
#ifdef DEBUG
getmicrouptime(&t1);
#endif
if (cv_timedwait(&ktd->ktd_sync_cv, &ktrace_mutex,
if (cv_timedwait(&ktd->ktd_sync_cv, &ktrace_lock,
ktd_timeout * hz) != 0) {
ktd->ktd_flags |= KTDF_BLOCKING;
/*
@ -365,7 +399,7 @@ ktraddentry(struct lwp *l, struct ktrace_entry *kte, int flags)
skip_sync:
ktdrel(ktd);
mutex_exit(&ktrace_mutex);
mutex_exit(&ktrace_lock);
ktrexit(l);
return;
@ -373,7 +407,7 @@ relktd:
ktdrel(ktd);
freekte:
mutex_exit(&ktrace_mutex);
mutex_exit(&ktrace_lock);
ktefree(kte);
ktrexit(l);
}
@ -410,7 +444,7 @@ ktrderef(struct proc *p)
{
struct ktr_desc *ktd = p->p_tracep;
KASSERT(mutex_owned(&ktrace_mutex));
KASSERT(mutex_owned(&ktrace_lock));
p->p_traceflag = 0;
if (ktd == NULL)
@ -426,7 +460,7 @@ ktradref(struct proc *p)
{
struct ktr_desc *ktd = p->p_tracep;
KASSERT(mutex_owned(&ktrace_mutex));
KASSERT(mutex_owned(&ktrace_lock));
ktdref(ktd);
}
@ -434,7 +468,7 @@ ktradref(struct proc *p)
int
ktrderefall(struct ktr_desc *ktd, int auth)
{
struct lwp *curl = curlwp;
lwp_t *curl = curlwp;
struct proc *p;
int error = 0;
@ -443,14 +477,14 @@ ktrderefall(struct ktr_desc *ktd, int auth)
if (p->p_tracep != ktd)
continue;
mutex_enter(&p->p_mutex);
mutex_enter(&ktrace_mutex);
mutex_enter(&ktrace_lock);
if (p->p_tracep == ktd) {
if (!auth || ktrcanset(curl, p))
ktrderef(p);
else
error = EPERM;
}
mutex_exit(&ktrace_mutex);
mutex_exit(&ktrace_lock);
mutex_exit(&p->p_mutex);
}
mutex_exit(&proclist_lock);
@ -459,7 +493,7 @@ ktrderefall(struct ktr_desc *ktd, int auth)
}
int
ktealloc(struct ktrace_entry **ktep, void **bufp, struct lwp *l, int type,
ktealloc(struct ktrace_entry **ktep, void **bufp, lwp_t *l, int type,
size_t sz)
{
struct proc *p = l->l_proc;
@ -514,9 +548,10 @@ ktealloc(struct ktrace_entry **ktep, void **bufp, struct lwp *l, int type,
}
void
ktrsyscall(struct lwp *l, register_t code, register_t realcode,
const struct sysent *callp, register_t args[])
ktr_syscall(register_t code, register_t realcode,
const struct sysent *callp, register_t args[])
{
lwp_t *l = curlwp;
struct proc *p = l->l_proc;
struct ktrace_entry *kte;
struct ktr_syscall *ktp;
@ -525,6 +560,9 @@ ktrsyscall(struct lwp *l, register_t code, register_t realcode,
size_t len;
u_int i;
if (!KTRPOINT(p, KTR_SYSCALL))
return;
if (callp == NULL)
callp = p->p_emul->e_sysent;
@ -548,11 +586,15 @@ ktrsyscall(struct lwp *l, register_t code, register_t realcode,
}
void
ktrsysret(struct lwp *l, register_t code, int error, register_t *retval)
ktr_sysret(register_t code, int error, register_t *retval)
{
lwp_t *l = curlwp;
struct ktrace_entry *kte;
struct ktr_sysret *ktp;
if (!KTRPOINT(l->l_proc, KTR_SYSRET))
return;
if (ktealloc(&kte, (void *)&ktp, l, KTR_SYSRET,
sizeof(struct ktr_sysret)))
return;
@ -567,18 +609,27 @@ ktrsysret(struct lwp *l, register_t code, int error, register_t *retval)
}
void
ktrnamei(struct lwp *l, const char *path, size_t pathlen)
ktr_namei(const char *path, size_t pathlen)
{
ktrkmem(l, KTR_NAMEI, path, pathlen);
lwp_t *l = curlwp;
if (!KTRPOINT(l->l_proc, KTR_NAMEI))
return;
ktr_kmem(l, KTR_NAMEI, path, pathlen);
}
void
ktrnamei2(struct lwp *l, const char *eroot, size_t erootlen,
const char *path, size_t pathlen)
ktr_namei2(const char *eroot, size_t erootlen,
const char *path, size_t pathlen)
{
lwp_t *l = curlwp;
struct ktrace_entry *kte;
void *buf;
if (!KTRPOINT(l->l_proc, KTR_NAMEI))
return;
if (ktealloc(&kte, &buf, l, KTR_NAMEI, erootlen + pathlen))
return;
memcpy(buf, eroot, erootlen);
@ -588,15 +639,41 @@ ktrnamei2(struct lwp *l, const char *eroot, size_t erootlen,
}
void
ktremul(struct lwp *l)
ktr_emul(void)
{
lwp_t *l = curlwp;
const char *emul = l->l_proc->p_emul->e_name;
ktrkmem(l, KTR_EMUL, emul, strlen(emul));
if (!KTRPOINT(l->l_proc, KTR_EMUL))
return;
ktr_kmem(l, KTR_EMUL, emul, strlen(emul));
}
void
ktrkmem(struct lwp *l, int type, const void *bf, size_t len)
ktr_execarg(const void *bf, size_t len)
{
lwp_t *l = curlwp;
if (!KTRPOINT(l->l_proc, KTR_EXEC_ARG))
return;
ktr_kmem(l, KTR_EXEC_ARG, bf, len);
}
void
ktr_execenv(const void *bf, size_t len)
{
lwp_t *l = curlwp;
if (!KTRPOINT(l->l_proc, KTR_EXEC_ENV))
return;
ktr_kmem(l, KTR_EXEC_ENV, bf, len);
}
static void
ktr_kmem(lwp_t *l, int type, const void *bf, size_t len)
{
struct ktrace_entry *kte;
void *buf;
@ -607,18 +684,13 @@ ktrkmem(struct lwp *l, int type, const void *bf, size_t len)
ktraddentry(l, kte, KTA_WAITOK);
}
void
ktrgenio(struct lwp *l, int fd, enum uio_rw rw, struct iovec *iov,
int len, int error)
static void
ktr_io(lwp_t *l, int fd, enum uio_rw rw, struct iovec *iov, size_t len)
{
struct ktrace_entry *kte;
struct ktr_genio *ktp;
int resid = len, cnt;
size_t resid = len, cnt, buflen;
void *cp;
int buflen;
if (error)
return;
next:
buflen = min(PAGE_SIZE, resid + sizeof(struct ktr_genio));
@ -670,15 +742,55 @@ out:
}
void
ktrpsig(struct lwp *l, int sig, sig_t action, const sigset_t *mask,
const ksiginfo_t *ksi)
ktr_genio(int fd, enum uio_rw rw, const void *addr, size_t len, int error)
{
lwp_t *l = curlwp;
struct iovec iov;
if (!KTRPOINT(l->l_proc, KTR_GENIO) || error != 0)
return;
iov.iov_base = __UNCONST(addr);
iov.iov_len = len;
ktr_io(l, fd, rw, &iov, len);
}
void
ktr_geniov(int fd, enum uio_rw rw, struct iovec *iov, size_t len, int error)
{
lwp_t *l = curlwp;
if (!KTRPOINT(l->l_proc, KTR_GENIO) || error != 0)
return;
ktr_io(l, fd, rw, iov, len);
}
void
ktr_mibio(int fd, enum uio_rw rw, const void *addr, size_t len, int error)
{
lwp_t *l = curlwp;
struct iovec iov;
if (!KTRPOINT(l->l_proc, KTR_MIB) || error != 0)
return;
iov.iov_base = __UNCONST(addr);
iov.iov_len = len;
ktr_io(l, fd, rw, &iov, len);
}
void
ktr_psig(int sig, sig_t action, const sigset_t *mask,
const ksiginfo_t *ksi)
{
struct ktrace_entry *kte;
lwp_t *l = curlwp;
struct {
struct ktr_psig kp;
siginfo_t si;
} *kbuf;
if (!KTRPOINT(l->l_proc, KTR_PSIG))
return;
if (ktealloc(&kte, (void *)&kbuf, l, KTR_PSIG, sizeof(*kbuf)))
return;
@ -700,12 +812,16 @@ ktrpsig(struct lwp *l, int sig, sig_t action, const sigset_t *mask,
}
void
ktrcsw(struct lwp *l, int out, int user)
ktr_csw(int out, int user)
{
lwp_t *l = curlwp;
struct proc *p = l->l_proc;
struct ktrace_entry *kte;
struct ktr_csw *kc;
if (!KTRPOINT(p, KTR_CSW))
return;
/*
* Don't record context switches resulting from blocking on
* locks; it's too easy to get duff results.
@ -788,14 +904,27 @@ ktrcsw(struct lwp *l, int out, int user)
ktraddentry(l, kte, KTA_WAITOK);
}
bool
ktrpoint(int fac)
{
if (__predict_false(ktrace_on))
return false;
return KTRPOINT(curlwp->l_proc, fac);
}
int
ktruser(struct lwp *l, const char *id, void *addr, size_t len, int ustr)
ktruser(const char *id, void *addr, size_t len, int ustr)
{
struct ktrace_entry *kte;
struct ktr_user *ktp;
lwp_t *l = curlwp;
void *user_dta;
int error;
if (!KTRPOINT(l->l_proc, KTR_USER))
return 0;
if (len > KTR_USER_MAXLEN)
return ENOSPC;
@ -819,12 +948,16 @@ ktruser(struct lwp *l, const char *id, void *addr, size_t len, int ustr)
}
void
ktrkuser(struct lwp *l, const char *id, void *addr, size_t len)
ktr_kuser(const char *id, void *addr, size_t len)
{
struct ktrace_entry *kte;
struct ktr_user *ktp;
lwp_t *l = curlwp;
int error;
if (!KTRPOINT(l->l_proc, KTR_USER))
return;
if (len > KTR_USER_MAXLEN)
return;
@ -840,17 +973,26 @@ ktrkuser(struct lwp *l, const char *id, void *addr, size_t len)
}
void
ktrmmsg(struct lwp *l, const void *msgh, size_t size)
ktr_mmsg(const void *msgh, size_t size)
{
ktrkmem(l, KTR_MMSG, msgh, size);
lwp_t *l = curlwp;
if (!KTRPOINT(l->l_proc, KTR_MMSG))
return;
ktr_kmem(l, KTR_MMSG, msgh, size);
}
void
ktrmool(struct lwp *l, const void *kaddr, size_t size, const void *uaddr)
ktr_mool(const void *kaddr, size_t size, const void *uaddr)
{
struct ktrace_entry *kte;
struct ktr_mool *kp;
struct ktr_mool *bf;
lwp_t *l = curlwp;
if (!KTRPOINT(l->l_proc, KTR_MOOL))
return;
if (ktealloc(&kte, (void *)&kp, l, KTR_MOOL, size + sizeof(*kp)))
return;
@ -864,11 +1006,15 @@ ktrmool(struct lwp *l, const void *kaddr, size_t size, const void *uaddr)
}
void
ktrmib(struct lwp *l, const int *name, u_int namelen)
ktr_mib(const int *name, u_int namelen)
{
struct ktrace_entry *kte;
int *namep;
size_t size;
lwp_t *l = curlwp;
if (!KTRPOINT(l->l_proc, KTR_MIB))
return;
size = namelen * sizeof(*name);
@ -883,7 +1029,7 @@ ktrmib(struct lwp *l, const int *name, u_int namelen)
/* Interface and common routines */
int
ktrace_common(struct lwp *curl, int ops, int facs, int pid, struct file *fp)
ktrace_common(lwp_t *curl, int ops, int facs, int pid, struct file *fp)
{
struct proc *curp;
struct proc *p;
@ -905,30 +1051,36 @@ ktrace_common(struct lwp *curl, int ops, int facs, int pid, struct file *fp)
/*
* Clear all uses of the tracefile
*/
mutex_enter(&ktrace_mutex);
mutex_enter(&ktrace_lock);
ktd = ktd_lookup(fp);
mutex_exit(&ktrace_mutex);
mutex_exit(&ktrace_lock);
if (ktd == NULL)
goto done;
error = ktrderefall(ktd, 1);
goto done;
case KTROP_SET:
mutex_enter(&ktrace_mutex);
mutex_enter(&ktrace_lock);
ktd = ktd_lookup(fp);
mutex_exit(&ktrace_mutex);
mutex_exit(&ktrace_lock);
if (ktd == NULL) {
ktd = kmem_alloc(sizeof(*ktd), KM_SLEEP);
TAILQ_INIT(&ktd->ktd_queue);
callout_init(&ktd->ktd_wakch, 0);
cv_init(&ktd->ktd_cv, "ktrwait");
cv_init(&ktd->ktd_sync_cv, "ktrsync");
ktd->ktd_flags = ktd->ktd_qcount =
ktd->ktd_error = ktd->ktd_errcnt = 0;
ktd->ktd_ref = 1;
ktd->ktd_flags = 0;
ktd->ktd_qcount = 0;
ktd->ktd_error = 0;
ktd->ktd_errcnt = 0;
ktd->ktd_delayqcnt = ktd_delayqcnt;
ktd->ktd_wakedelay = mstohz(ktd_wakedelay);
ktd->ktd_intrwakdl = mstohz(ktd_intrwakdl);
ktd->ktd_ref = 0;
mutex_enter(&ktrace_lock);
ktdref(ktd);
mutex_exit(&ktrace_lock);
/*
* XXX: not correct. needs an way to detect
* whether ktruss or ktrace.
@ -948,15 +1100,15 @@ ktrace_common(struct lwp *curl, int ops, int facs, int pid, struct file *fp)
simple_unlock(&fp->f_slock);
ktd->ktd_fp = fp;
mutex_enter(&ktrace_mutex);
mutex_enter(&ktrace_lock);
if (ktd_lookup(fp) != NULL) {
ktdrel(ktd);
ktd = NULL;
} else
TAILQ_INSERT_TAIL(&ktdq, ktd, ktd_list);
if (ktd == NULL)
cv_wait(&lbolt, &ktrace_mutex);
mutex_exit(&ktrace_mutex);
cv_wait(&lbolt, &ktrace_lock);
mutex_exit(&ktrace_lock);
if (ktd == NULL)
goto done;
}
@ -1013,7 +1165,7 @@ ktrace_common(struct lwp *curl, int ops, int facs, int pid, struct file *fp)
error = EPERM;
done:
if (ktd != NULL) {
mutex_enter(&ktrace_mutex);
mutex_enter(&ktrace_lock);
if (error != 0) {
/*
* Wakeup the thread so that it can be die if we
@ -1023,7 +1175,7 @@ done:
}
if (KTROP(ops) == KTROP_SET || KTROP(ops) == KTROP_CLEARFILE)
ktdrel(ktd);
mutex_exit(&ktrace_mutex);
mutex_exit(&ktrace_lock);
}
ktrexit(curl);
return (error);
@ -1034,7 +1186,7 @@ done:
*/
/* ARGSUSED */
int
sys_fktrace(struct lwp *l, void *v, register_t *retval)
sys_fktrace(lwp_t *l, void *v, register_t *retval)
{
struct sys_fktrace_args /* {
syscallarg(int) fd;
@ -1068,7 +1220,7 @@ sys_fktrace(struct lwp *l, void *v, register_t *retval)
*/
/* ARGSUSED */
int
sys_ktrace(struct lwp *l, void *v, register_t *retval)
sys_ktrace(lwp_t *l, void *v, register_t *retval)
{
struct sys_ktrace_args /* {
syscallarg(const char *) fname;
@ -1136,14 +1288,14 @@ done:
}
int
ktrops(struct lwp *curl, struct proc *p, int ops, int facs,
ktrops(lwp_t *curl, struct proc *p, int ops, int facs,
struct ktr_desc *ktd)
{
int vers = ops & KTRFAC_VER_MASK;
int error = 0;
mutex_enter(&p->p_mutex);
mutex_enter(&ktrace_mutex);
mutex_enter(&ktrace_lock);
if (!ktrcanset(curl, p))
goto out;
@ -1191,14 +1343,14 @@ ktrops(struct lwp *curl, struct proc *p, int ops, int facs,
#endif
out:
mutex_exit(&ktrace_mutex);
mutex_exit(&ktrace_lock);
mutex_exit(&p->p_mutex);
return (1);
}
int
ktrsetchildren(struct lwp *curl, struct proc *top, int ops, int facs,
ktrsetchildren(lwp_t *curl, struct proc *top, int ops, int facs,
struct ktr_desc *ktd)
{
struct proc *p;
@ -1318,7 +1470,7 @@ ktrace_thread(void *arg)
struct ktrace_entry *kte;
int ktrerr, errcnt;
mutex_enter(&ktrace_mutex);
mutex_enter(&ktrace_lock);
for (;;) {
kte = TAILQ_FIRST(&ktd->ktd_queue);
if (kte == NULL) {
@ -1328,7 +1480,7 @@ ktrace_thread(void *arg)
}
if (ktd->ktd_ref == 0)
break;
cv_wait(&ktd->ktd_cv, &ktrace_mutex);
cv_wait(&ktd->ktd_cv, &ktrace_lock);
continue;
}
TAILQ_INIT(&ktd->ktd_queue);
@ -1336,7 +1488,7 @@ ktrace_thread(void *arg)
ktrerr = ktd->ktd_error;
errcnt = ktd->ktd_errcnt;
ktd->ktd_error = ktd->ktd_errcnt = 0;
mutex_exit(&ktrace_mutex);
mutex_exit(&ktrace_lock);
if (ktrerr) {
log(LOG_NOTICE,
@ -1344,11 +1496,11 @@ ktrace_thread(void *arg)
fp, ktrerr, errcnt);
}
ktrwrite(ktd, kte);
mutex_enter(&ktrace_mutex);
mutex_enter(&ktrace_lock);
}
TAILQ_REMOVE(&ktdq, ktd, ktd_list);
mutex_exit(&ktrace_mutex);
mutex_exit(&ktrace_lock);
simple_lock(&fp->f_slock);
FILE_USE(fp);
@ -1378,10 +1530,10 @@ ktrace_thread(void *arg)
* TODO: check groups. use caller effective gid.
*/
int
ktrcanset(struct lwp *calll, struct proc *targetp)
ktrcanset(lwp_t *calll, struct proc *targetp)
{
KASSERT(mutex_owned(&targetp->p_mutex));
KASSERT(mutex_owned(&ktrace_mutex));
KASSERT(mutex_owned(&ktrace_lock));
if (kauth_authorize_process(calll->l_cred, KAUTH_PROCESS_CANKTRACE,
targetp, NULL, NULL, NULL) == 0)
@ -1389,28 +1541,19 @@ ktrcanset(struct lwp *calll, struct proc *targetp)
return (0);
}
#endif /* KTRACE */
/*
* Put user defined entry to ktrace records.
*/
int
sys_utrace(struct lwp *l, void *v, register_t *retval)
sys_utrace(lwp_t *l, void *v, register_t *retval)
{
#ifdef KTRACE
struct sys_utrace_args /* {
syscallarg(const char *) label;
syscallarg(void *) addr;
syscallarg(size_t) len;
} */ *uap = v;
struct proc *p = l->l_proc;
if (!KTRPOINT(p, KTR_USER))
return (0);
return ktruser(l, SCARG(uap, label), SCARG(uap, addr),
return ktruser(SCARG(uap, label), SCARG(uap, addr),
SCARG(uap, len), 1);
#else /* !KTRACE */
return ENOSYS;
#endif /* KTRACE */
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_ras.c,v 1.19 2007/03/13 04:44:06 thorpej Exp $ */
/* $NetBSD: kern_ras.c,v 1.20 2007/08/15 12:07:33 ad Exp $ */
/*-
* Copyright (c) 2002, 2006 The NetBSD Foundation, Inc.
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kern_ras.c,v 1.19 2007/03/13 04:44:06 thorpej Exp $");
__KERNEL_RCSID(0, "$NetBSD: kern_ras.c,v 1.20 2007/08/15 12:07:33 ad Exp $");
#include <sys/param.h>
#include <sys/lock.h>
@ -90,9 +90,7 @@ ras_lookup(struct proc *p, void *addr)
if (addr > rp->ras_startaddr && addr < rp->ras_endaddr) {
rp->ras_hits++;
startaddr = rp->ras_startaddr;
#ifdef DIAGNOSTIC
DPRINTF(("RAS hit: p=%p %p\n", p, addr));
#endif
break;
}
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_sig.c,v 1.254 2007/07/09 21:10:53 ad Exp $ */
/* $NetBSD: kern_sig.c,v 1.255 2007/08/15 12:07:33 ad Exp $ */
/*-
* Copyright (c) 2006, 2007 The NetBSD Foundation, Inc.
@ -73,9 +73,8 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v 1.254 2007/07/09 21:10:53 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v 1.255 2007/08/15 12:07:33 ad Exp $");
#include "opt_ktrace.h"
#include "opt_ptrace.h"
#include "opt_multiprocessor.h"
#include "opt_compat_sunos.h"
@ -923,11 +922,8 @@ trapsignal(struct lwp *l, ksiginfo_t *ksi)
p->p_stats->p_ru.ru_nsignals++;
kpsendsig(l, ksi, &l->l_sigmask);
mutex_exit(&p->p_smutex);
#ifdef KTRACE
if (KTRPOINT(p, KTR_PSIG))
ktrpsig(l, signo, SIGACTION_PS(ps, signo).sa_handler,
&l->l_sigmask, ksi);
#endif
ktrpsig(signo, SIGACTION_PS(ps, signo).sa_handler,
&l->l_sigmask, ksi);
} else {
/* XXX for core dump/debugger */
p->p_sigctx.ps_lwp = l->l_lid;
@ -1819,13 +1815,11 @@ postsig(int signo)
p->p_stats->p_ru.ru_nsignals++;
sigget(l->l_sigpendset, &ksi, signo, NULL);
#ifdef KTRACE
if (KTRPOINT(p, KTR_PSIG)) {
if (ktrpoint(KTR_PSIG)) {
mutex_exit(&p->p_smutex);
ktrpsig(l, signo, action, returnmask, NULL);
ktrpsig(signo, action, returnmask, NULL);
mutex_enter(&p->p_smutex);
}
#endif
if (action == SIG_DFL) {
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_sleepq.c,v 1.11 2007/08/01 23:30:54 ad Exp $ */
/* $NetBSD: kern_sleepq.c,v 1.12 2007/08/15 12:07:33 ad Exp $ */
/*-
* Copyright (c) 2006, 2007 The NetBSD Foundation, Inc.
@ -42,9 +42,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kern_sleepq.c,v 1.11 2007/08/01 23:30:54 ad Exp $");
#include "opt_ktrace.h"
__KERNEL_RCSID(0, "$NetBSD: kern_sleepq.c,v 1.12 2007/08/15 12:07:33 ad Exp $");
#include <sys/param.h>
#include <sys/lock.h>
@ -56,9 +54,7 @@ __KERNEL_RCSID(0, "$NetBSD: kern_sleepq.c,v 1.11 2007/08/01 23:30:54 ad Exp $");
#include <sys/sched.h>
#include <sys/systm.h>
#include <sys/sleepq.h>
#ifdef KTRACE
#include <sys/ktrace.h>
#endif
#include <uvm/uvm_extern.h>
@ -242,10 +238,7 @@ sleepq_block(int timo, bool catch)
lwp_t *l = curlwp;
bool early = false;
#ifdef KTRACE
if (KTRPOINT(l->l_proc, KTR_CSW))
ktrcsw(l, 1, 0);
#endif
ktrcsw(1, 0);
/*
* If sleeping interruptably, check for pending signals, exits or
@ -296,10 +289,7 @@ sleepq_block(int timo, bool catch)
}
}
#ifdef KTRACE
if (KTRPOINT(l->l_proc, KTR_CSW))
ktrcsw(l, 0, 0);
#endif
ktrcsw(0, 0);
KERNEL_LOCK(l->l_biglocks, l);
return error;

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_stub.c,v 1.2 2007/03/03 10:08:19 itohy Exp $ */
/* $NetBSD: kern_stub.c,v 1.3 2007/08/15 12:07:34 ad Exp $ */
/*-
* Copyright (c) 2007 The NetBSD Foundation, Inc.
@ -33,20 +33,53 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
/*
* Copyright (c) 1982, 1986, 1991, 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.
*
* @(#)subr_xxx.c 8.3 (Berkeley) 3/29/95
*/
/*
* Stubs for system calls and facilities not included in the system.
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kern_stub.c,v 1.2 2007/03/03 10:08:19 itohy Exp $");
__KERNEL_RCSID(0, "$NetBSD: kern_stub.c,v 1.3 2007/08/15 12:07:34 ad Exp $");
#include "opt_ptrace.h"
#include "opt_ktrace.h"
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/proc.h>
#include <sys/signalvar.h>
#include <sys/syscallargs.h>
#include <sys/ktrace.h>
/*
* Nonexistent system call-- signal process (may want to handle it). Flag
@ -54,7 +87,38 @@ __KERNEL_RCSID(0, "$NetBSD: kern_stub.c,v 1.2 2007/03/03 10:08:19 itohy Exp $");
*/
#ifndef PTRACE
__weak_alias(sys_ptrace,sys_nosys);
#endif
#endif /* PTRACE */
/*
* ktrace stubs. ktruser() goes to enosys as we want to fail the syscall,
* but not kill the process: utrace() is a debugging feature.
*/
#ifndef KTRACE
__weak_alias(ktr_csw,nullop); /* Probes */
__weak_alias(ktr_emul,nullop);
__weak_alias(ktr_geniov,nullop);
__weak_alias(ktr_genio,nullop);
__weak_alias(ktr_mibio,nullop);
__weak_alias(ktr_namei,nullop);
__weak_alias(ktr_namei2,nullop);
__weak_alias(ktr_psig,nullop);
__weak_alias(ktr_syscall,nullop);
__weak_alias(ktr_sysret,nullop);
__weak_alias(ktr_kuser,nullop);
__weak_alias(ktr_mmsg,nullop);
__weak_alias(ktr_mib,nullop);
__weak_alias(ktr_mool,nullop);
__weak_alias(ktr_execarg,nullop);
__weak_alias(ktr_execenv,nullop);
__weak_alias(sys_fktrace,sys_nosys); /* Syscalls */
__weak_alias(sys_ktrace,sys_nosys);
__weak_alias(sys_utrace,sys_nosys);
int ktrace_on; /* Misc */
__weak_alias(ktruser,enosys);
__weak_alias(ktrpoint,nullop);
#endif /* KTRACE */
/*
* Scheduler activations system calls. These need to remain until libc's
@ -78,3 +142,67 @@ sys_nosys(struct lwp *l, void *v, register_t *retval)
mutex_exit(&proclist_mutex);
return ENOSYS;
}
/*
* Unsupported device function (e.g. writing to read-only device).
*/
int
enodev(void)
{
return (ENODEV);
}
/*
* Unconfigured device function; driver not configured.
*/
int
enxio(void)
{
return (ENXIO);
}
/*
* Unsupported ioctl function.
*/
int
enoioctl(void)
{
return (ENOTTY);
}
/*
* Unsupported system function.
* This is used for an otherwise-reasonable operation
* that is not supported by the current system binary.
*/
int
enosys(void)
{
return (ENOSYS);
}
/*
* Return error for operation not supported
* on a specific object or file type.
*/
int
eopnotsupp(void)
{
return (EOPNOTSUPP);
}
/*
* Generic null operation, always returns success.
*/
/*ARGSUSED*/
int
nullop(void *v)
{
return (0);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_subr.c,v 1.163 2007/08/01 19:50:24 degroote Exp $ */
/* $NetBSD: kern_subr.c,v 1.164 2007/08/15 12:07:34 ad Exp $ */
/*-
* Copyright (c) 1997, 1998, 1999, 2002 The NetBSD Foundation, Inc.
@ -86,7 +86,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kern_subr.c,v 1.163 2007/08/01 19:50:24 degroote Exp $");
__KERNEL_RCSID(0, "$NetBSD: kern_subr.c,v 1.164 2007/08/15 12:07:34 ad Exp $");
#include "opt_ddb.h"
#include "opt_md.h"
@ -1362,10 +1362,7 @@ trace_enter(struct lwp *l, register_t code,
scdebug_call(l, code, args);
#endif /* SYSCALL_DEBUG */
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSCALL))
ktrsyscall(l, code, realcode, callp, args);
#endif /* KTRACE */
ktrsyscall(code, realcode, callp, args);
#ifdef PTRACE
if ((p->p_slflag & (PSL_SYSCALL|PSL_TRACED)) ==
@ -1404,10 +1401,7 @@ trace_exit(struct lwp *l, register_t code, void *args, register_t rval[],
scdebug_ret(l, code, error, rval);
#endif /* SYSCALL_DEBUG */
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSRET))
ktrsysret(l, code, error, rval);
#endif /* KTRACE */
ktrsysret(code, error, rval);
#ifdef PTRACE
if ((p->p_slflag & (PSL_SYSCALL|PSL_TRACED)) ==

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_sysctl.c,v 1.209 2007/03/04 06:03:06 christos Exp $ */
/* $NetBSD: kern_sysctl.c,v 1.210 2007/08/15 12:07:34 ad Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
@ -75,10 +75,9 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kern_sysctl.c,v 1.209 2007/03/04 06:03:06 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: kern_sysctl.c,v 1.210 2007/08/15 12:07:34 ad Exp $");
#include "opt_defcorename.h"
#include "opt_ktrace.h"
#include "ksyms.h"
#include <sys/param.h>
@ -91,9 +90,7 @@ __KERNEL_RCSID(0, "$NetBSD: kern_sysctl.c,v 1.209 2007/03/04 06:03:06 christos E
#include <sys/mount.h>
#include <sys/syscallargs.h>
#include <sys/kauth.h>
#ifdef KTRACE
#include <sys/ktrace.h>
#endif
#include <machine/stdarg.h>
#define MAXDESCLEN 1024
@ -187,16 +184,7 @@ sysctl_copyin(struct lwp *l, const void *uaddr, void *kaddr, size_t len)
if (l != NULL) {
error = copyin(uaddr, kaddr, len);
#ifdef KTRACE
if (!error && KTRPOINT(l->l_proc, KTR_MIB)) {
struct iovec iov;
iov.iov_base = (void *)(vaddr_t)uaddr;
iov.iov_len = len;
ktrgenio(l, -1, UIO_WRITE, &iov, len, error);
}
#endif
ktrmibio(-1, UIO_WRITE, uaddr, len, error);
} else {
error = kcopy(uaddr, kaddr, len);
}
@ -211,15 +199,7 @@ sysctl_copyout(struct lwp *l, const void *kaddr, void *uaddr, size_t len)
if (l != NULL) {
error = copyout(kaddr, uaddr, len);
#ifdef KTRACE
if (!error && KTRPOINT(l->l_proc, KTR_MIB)) {
struct iovec iov;
iov.iov_base = (void *)(vaddr_t)uaddr;
iov.iov_len = len;
ktrgenio(l, -1, UIO_READ, &iov, len, error);
}
#endif
ktrmibio(-1, UIO_READ, uaddr, len, error);
} else {
error = kcopy(kaddr, uaddr, len);
}
@ -235,15 +215,7 @@ sysctl_copyinstr(struct lwp *l, const void *uaddr, void *kaddr,
if (l != NULL) {
error = copyinstr(uaddr, kaddr, len, done);
#ifdef KTRACE
if (!error && KTRPOINT(l->l_proc, KTR_MIB)) {
struct iovec iov;
iov.iov_base = (void *)(vaddr_t)uaddr;
iov.iov_len = len;
ktrgenio(l, -1, UIO_WRITE, &iov, len, error);
}
#endif
ktrmibio(-1, UIO_WRITE, uaddr, len, error);
} else {
error = copystr(uaddr, kaddr, len, done);
}
@ -327,10 +299,8 @@ sys___sysctl(struct lwp *l, void *v, register_t *retval)
if (error)
return (error);
#ifdef KTRACE
if (KTRPOINT(l->l_proc, KTR_MIB))
ktrmib(l, name, SCARG(uap, namelen));
#endif
ktrmib(name, SCARG(uap, namelen));
/*
* wire old so that copyout() is less likely to fail?
*/

View File

@ -1,109 +0,0 @@
/* $NetBSD: subr_xxx.c,v 1.17 2006/11/01 10:17:59 yamt Exp $ */
/*
* Copyright (c) 1982, 1986, 1991, 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.
*
* @(#)subr_xxx.c 8.3 (Berkeley) 3/29/95
*/
/*
* Miscellaneous trivial functions, including many
* that are often inline-expanded or done in assembler.
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: subr_xxx.c,v 1.17 2006/11/01 10:17:59 yamt Exp $");
#include <sys/param.h>
#include <sys/systm.h>
#include <machine/cpu.h>
/*
* Unsupported device function (e.g. writing to read-only device).
*/
int
enodev(void)
{
return (ENODEV);
}
/*
* Unconfigured device function; driver not configured.
*/
int
enxio(void)
{
return (ENXIO);
}
/*
* Unsupported ioctl function.
*/
int
enoioctl(void)
{
return (ENOTTY);
}
/*
* Unsupported system function.
* This is used for an otherwise-reasonable operation
* that is not supported by the current system binary.
*/
int
enosys(void)
{
return (ENOSYS);
}
/*
* Return error for operation not supported
* on a specific object or file type.
*/
int
eopnotsupp(void)
{
return (EOPNOTSUPP);
}
/*
* Generic null operation, always returns success.
*/
/*ARGSUSED*/
int
nullop(void *v)
{
return (0);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: sys_generic.c,v 1.103 2007/07/09 21:10:56 ad Exp $ */
/* $NetBSD: sys_generic.c,v 1.104 2007/08/15 12:07:34 ad Exp $ */
/*-
* Copyright (c) 2007 The NetBSD Foundation, Inc.
@ -77,9 +77,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: sys_generic.c,v 1.103 2007/07/09 21:10:56 ad Exp $");
#include "opt_ktrace.h"
__KERNEL_RCSID(0, "$NetBSD: sys_generic.c,v 1.104 2007/08/15 12:07:34 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -97,9 +95,7 @@ __KERNEL_RCSID(0, "$NetBSD: sys_generic.c,v 1.103 2007/07/09 21:10:56 ad Exp $")
#include <sys/vnode.h>
#include <sys/mount.h>
#include <sys/syscallargs.h>
#ifdef KTRACE
#include <sys/ktrace.h>
#endif
#include <uvm/uvm_extern.h>
@ -163,9 +159,6 @@ dofileread(lwp_t *l, int fd, struct file *fp, void *buf, size_t nbyte,
struct vmspace *vm;
size_t cnt;
int error;
#ifdef KTRACE
struct iovec ktriov;
#endif
p = l->l_proc;
error = proc_vmspace_getref(p, &vm);
@ -191,10 +184,6 @@ dofileread(lwp_t *l, int fd, struct file *fp, void *buf, size_t nbyte,
goto out;
}
#ifdef KTRACE
/* In case we are tracing, save a copy of iovec */
ktriov = aiov;
#endif
cnt = auio.uio_resid;
error = (*fp->f_ops->fo_read)(fp, offset, &auio, fp->f_cred, flags);
if (error)
@ -202,10 +191,7 @@ dofileread(lwp_t *l, int fd, struct file *fp, void *buf, size_t nbyte,
error == EINTR || error == EWOULDBLOCK))
error = 0;
cnt -= auio.uio_resid;
#ifdef KTRACE
if (KTRPOINT(p, KTR_GENIO) && error == 0)
ktrgenio(l, fd, UIO_READ, &ktriov, cnt, error);
#endif
ktrgenio(fd, UIO_READ, buf, nbyte, error);
*retval = cnt;
out:
FILE_UNUSE(fp, l);
@ -242,9 +228,7 @@ do_filereadv(struct lwp *l, int fd, const struct iovec *iovp, int iovcnt,
u_int iovlen;
struct file *fp;
struct filedesc *fdp;
#ifdef KTRACE
struct iovec *ktriov = NULL;
#endif
if (iovcnt == 0)
return EINVAL;
@ -325,16 +309,14 @@ do_filereadv(struct lwp *l, int fd, const struct iovec *iovp, int iovcnt,
}
}
#ifdef KTRACE
/*
* if tracing, save a copy of iovec
*/
if (KTRPOINT(p, KTR_GENIO)) {
if (ktrpoint(KTR_GENIO)) {
ktriov = kmem_alloc(iovlen, KM_SLEEP);
if (ktriov != NULL)
memcpy(ktriov, auio.uio_iov, iovlen);
}
#endif
cnt = auio.uio_resid;
error = (*fp->f_ops->fo_read)(fp, offset, &auio, fp->f_cred, flags);
@ -345,13 +327,10 @@ do_filereadv(struct lwp *l, int fd, const struct iovec *iovp, int iovcnt,
cnt -= auio.uio_resid;
*retval = cnt;
#ifdef KTRACE
if (ktriov != NULL) {
if (KTRPOINT(p, KTR_GENIO) && (error == 0))
ktrgenio(l, fd, UIO_READ, ktriov, cnt, error);
ktrgeniov(fd, UIO_READ, ktriov, cnt, error);
kmem_free(ktriov, iovlen);
}
#endif
done:
if (needfree)
@ -407,9 +386,6 @@ dofilewrite(lwp_t *l, int fd, struct file *fp, const void *buf,
struct vmspace *vm;
size_t cnt;
int error;
#ifdef KTRACE
struct iovec ktriov;
#endif
p = l->l_proc;
error = proc_vmspace_getref(p, &vm);
@ -434,10 +410,6 @@ dofilewrite(lwp_t *l, int fd, struct file *fp, const void *buf,
goto out;
}
#ifdef KTRACE
/* In case we are tracing, save a copy of iovec */
ktriov = aiov;
#endif
cnt = auio.uio_resid;
error = (*fp->f_ops->fo_write)(fp, offset, &auio, fp->f_cred, flags);
if (error) {
@ -451,10 +423,7 @@ dofilewrite(lwp_t *l, int fd, struct file *fp, const void *buf,
}
}
cnt -= auio.uio_resid;
#ifdef KTRACE
if (KTRPOINT(p, KTR_GENIO) && error == 0)
ktrgenio(l, fd, UIO_WRITE, &ktriov, cnt, error);
#endif
ktrgenio(fd, UIO_WRITE, buf, nbyte, error);
*retval = cnt;
out:
FILE_UNUSE(fp, l);
@ -491,9 +460,7 @@ do_filewritev(struct lwp *l, int fd, const struct iovec *iovp, int iovcnt,
u_int iovlen;
struct file *fp;
struct filedesc *fdp;
#ifdef KTRACE
struct iovec *ktriov = NULL;
#endif
if (iovcnt == 0)
return EINVAL;
@ -574,16 +541,15 @@ do_filewritev(struct lwp *l, int fd, const struct iovec *iovp, int iovcnt,
}
}
#ifdef KTRACE
/*
* if tracing, save a copy of iovec
*/
if (KTRPOINT(p, KTR_GENIO)) {
if (ktrpoint(KTR_GENIO)) {
ktriov = kmem_alloc(iovlen, KM_SLEEP);
if (ktriov != NULL)
memcpy(ktriov, auio.uio_iov, iovlen);
}
#endif
cnt = auio.uio_resid;
error = (*fp->f_ops->fo_write)(fp, offset, &auio, fp->f_cred, flags);
if (error) {
@ -599,13 +565,10 @@ do_filewritev(struct lwp *l, int fd, const struct iovec *iovp, int iovcnt,
cnt -= auio.uio_resid;
*retval = cnt;
#ifdef KTRACE
if (ktriov != NULL) {
if (KTRPOINT(p, KTR_GENIO) && (error == 0))
ktrgenio(l, fd, UIO_WRITE, ktriov, cnt, error);
ktrgeniov(fd, UIO_WRITE, ktriov, cnt, error);
kmem_free(ktriov, iovlen);
}
#endif
done:
if (needfree)
@ -686,15 +649,8 @@ sys_ioctl(struct lwp *l, void *v, register_t *retval)
kmem_free(memp, size);
goto out;
}
#ifdef KTRACE
if (KTRPOINT(p, KTR_GENIO)) {
struct iovec iov;
iov.iov_base = SCARG(uap, data);
iov.iov_len = size;
ktrgenio(l, SCARG(uap, fd), UIO_WRITE, &iov,
size, 0);
}
#endif
ktrgenio(SCARG(uap, fd), UIO_WRITE, SCARG(uap, data),
size, 0);
} else
*(void **)data = SCARG(uap, data);
} else if ((com&IOC_OUT) && size)
@ -732,15 +688,8 @@ sys_ioctl(struct lwp *l, void *v, register_t *retval)
*/
if (error == 0 && (com&IOC_OUT) && size) {
error = copyout(data, SCARG(uap, data), size);
#ifdef KTRACE
if (KTRPOINT(p, KTR_GENIO)) {
struct iovec iov;
iov.iov_base = SCARG(uap, data);
iov.iov_len = size;
ktrgenio(l, SCARG(uap, fd), UIO_READ, &iov,
size, error);
}
#endif
ktrgenio(SCARG(uap, fd), UIO_READ, SCARG(uap, data),
size, error);
}
break;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: uipc_syscalls.c,v 1.115 2007/07/15 08:33:38 dsl Exp $ */
/* $NetBSD: uipc_syscalls.c,v 1.116 2007/08/15 12:07:34 ad Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1990, 1993
@ -32,9 +32,8 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: uipc_syscalls.c,v 1.115 2007/07/15 08:33:38 dsl Exp $");
__KERNEL_RCSID(0, "$NetBSD: uipc_syscalls.c,v 1.116 2007/08/15 12:07:34 ad Exp $");
#include "opt_ktrace.h"
#include "opt_pipe.h"
#include <sys/param.h>
@ -50,9 +49,7 @@ __KERNEL_RCSID(0, "$NetBSD: uipc_syscalls.c,v 1.115 2007/07/15 08:33:38 dsl Exp
#include <sys/socketvar.h>
#include <sys/signalvar.h>
#include <sys/un.h>
#ifdef KTRACE
#include <sys/ktrace.h>
#endif
#include <sys/event.h>
#include <sys/mount.h>
@ -457,14 +454,12 @@ do_sys_sendmsg(struct lwp *l, int s, struct msghdr *mp, int flags,
{
struct file *fp;
struct uio auio;
int i, len, error;
int i, len, error, iovlen;
struct mbuf *to, *control;
struct socket *so;
struct iovec *tiov;
struct iovec aiov[UIO_SMALLIOV], *iov = aiov;
#ifdef KTRACE
struct iovec *ktriov;
#endif
/* If the caller passed us stuff in mbufs, we must free them */
if (mp->msg_flags & MSG_NAMEMBUF)
@ -495,10 +490,6 @@ do_sys_sendmsg(struct lwp *l, int s, struct msghdr *mp, int flags,
mp->msg_iov = iov;
}
#ifdef KTRACE
ktriov = NULL;
#endif
auio.uio_iov = mp->msg_iov;
auio.uio_iovcnt = mp->msg_iovlen;
auio.uio_rw = UIO_WRITE;
@ -547,14 +538,12 @@ do_sys_sendmsg(struct lwp *l, int s, struct msghdr *mp, int flags,
}
}
#ifdef KTRACE
if (KTRPOINT(l->l_proc, KTR_GENIO)) {
int iovlen = auio.uio_iovcnt * sizeof(struct iovec);
ktriov = NULL;
if (ktrpoint(KTR_GENIO)) {
iovlen = auio.uio_iovcnt * sizeof(struct iovec);
ktriov = malloc(iovlen, M_TEMP, M_WAITOK);
memcpy(ktriov, auio.uio_iov, iovlen);
}
#endif
/* getsock() will use the descriptor for us */
if ((error = getsock(l->l_proc->p_fd, s, &fp)) != 0)
@ -586,13 +575,10 @@ do_sys_sendmsg(struct lwp *l, int s, struct msghdr *mp, int flags,
if (error == 0)
*retsize = len - auio.uio_resid;
#ifdef KTRACE
if (ktriov != NULL) {
if (error == 0)
ktrgenio(l, s, UIO_WRITE, ktriov, *retsize, error);
ktrgeniov(s, UIO_WRITE, ktriov, *retsize, error);
free(ktriov, M_TEMP);
}
#endif
bad:
if (iov != aiov)
@ -775,18 +761,13 @@ do_sys_recvmsg(struct lwp *l, int s, struct msghdr *mp, struct mbuf **from,
struct uio auio;
struct iovec aiov[UIO_SMALLIOV], *iov = aiov;
struct iovec *tiov;
int i, len, error;
int i, len, error, iovlen;
struct socket *so;
#ifdef KTRACE
struct iovec *ktriov;
#endif
*from = NULL;
if (control != NULL)
*control = NULL;
#ifdef KTRACE
ktriov = NULL;
#endif
/* getsock() will use the descriptor for us */
if ((error = getsock(l->l_proc->p_fd, s, &fp)) != 0)
@ -838,14 +819,13 @@ do_sys_recvmsg(struct lwp *l, int s, struct msghdr *mp, struct mbuf **from,
goto out;
}
}
#ifdef KTRACE
if (KTRPOINT(l->l_proc, KTR_GENIO)) {
int iovlen = auio.uio_iovcnt * sizeof(struct iovec);
ktriov = NULL;
if (ktrpoint(KTR_GENIO)) {
iovlen = auio.uio_iovcnt * sizeof(struct iovec);
ktriov = malloc(iovlen, M_TEMP, M_WAITOK);
memcpy(ktriov, auio.uio_iov, iovlen);
}
#endif
len = auio.uio_resid;
mp->msg_flags &= MSG_USERFLAGS;
@ -857,13 +837,12 @@ do_sys_recvmsg(struct lwp *l, int s, struct msghdr *mp, struct mbuf **from,
&& (error == ERESTART || error == EINTR || error == EWOULDBLOCK))
/* Some data transferred */
error = 0;
#ifdef KTRACE
if (ktriov != NULL) {
if (error == 0)
ktrgenio(l, s, UIO_READ, ktriov, len, 0);
ktrgeniov(s, UIO_READ, ktriov, len, error);
free(ktriov, M_TEMP);
}
#endif
if (error != 0) {
m_freem(*from);
*from = NULL;

View File

@ -1,4 +1,4 @@
/* $NetBSD: vfs_lookup.c,v 1.96 2007/08/12 23:40:40 pooka Exp $ */
/* $NetBSD: vfs_lookup.c,v 1.97 2007/08/15 12:07:34 ad Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1993
@ -37,9 +37,8 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: vfs_lookup.c,v 1.96 2007/08/12 23:40:40 pooka Exp $");
__KERNEL_RCSID(0, "$NetBSD: vfs_lookup.c,v 1.97 2007/08/15 12:07:34 ad Exp $");
#include "opt_ktrace.h"
#include "opt_systrace.h"
#include "opt_magiclinks.h"
@ -58,10 +57,8 @@ __KERNEL_RCSID(0, "$NetBSD: vfs_lookup.c,v 1.96 2007/08/12 23:40:40 pooka Exp $"
#include <sys/proc.h>
#include <sys/syslog.h>
#include <sys/kauth.h>
#ifdef KTRACE
#include <sys/ktrace.h>
#endif
#ifdef SYSTRACE
#include <sys/systrace.h>
#endif
@ -301,8 +298,7 @@ namei(struct nameidata *ndp)
VREF(dp);
rw_exit(&cwdi->cwdi_lock);
#ifdef KTRACE
if (KTRPOINT(cnp->cn_lwp->l_proc, KTR_NAMEI)) {
if (ktrpoint(KTR_NAMEI)) {
if (ndp->ni_erootdir != NULL) {
/*
* To make any sense, the trace entry need to have the
@ -317,12 +313,12 @@ namei(struct nameidata *ndp)
emul_path = ndp->ni_next;
else
emul_path = cnp->cn_lwp->l_proc->p_emul->e_path;
ktrnamei2(cnp->cn_lwp, emul_path, strlen(emul_path),
ktrnamei2(emul_path, strlen(emul_path),
cnp->cn_pnbuf, ndp->ni_pathlen);
} else
ktrnamei(cnp->cn_lwp, cnp->cn_pnbuf, ndp->ni_pathlen);
ktrnamei(cnp->cn_pnbuf, ndp->ni_pathlen);
}
#endif
#ifdef SYSTRACE
if (ISSET(cnp->cn_lwp->l_proc->p_flag, PK_SYSTRACE))
systrace_namei(ndp);

View File

@ -1,4 +1,4 @@
/* $NetBSD: vfs_syscalls.c,v 1.324 2007/07/31 21:14:21 pooka Exp $ */
/* $NetBSD: vfs_syscalls.c,v 1.325 2007/08/15 12:07:35 ad Exp $ */
/*
* Copyright (c) 1989, 1993
@ -37,12 +37,11 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls.c,v 1.324 2007/07/31 21:14:21 pooka Exp $");
__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls.c,v 1.325 2007/08/15 12:07:35 ad Exp $");
#include "opt_compat_netbsd.h"
#include "opt_compat_43.h"
#include "opt_fileassoc.h"
#include "opt_ktrace.h"
#include "fss.h"
#include "veriexec.h"
@ -63,9 +62,7 @@ __KERNEL_RCSID(0, "$NetBSD: vfs_syscalls.c,v 1.324 2007/07/31 21:14:21 pooka Exp
#include <sys/sysctl.h>
#include <sys/syscallargs.h>
#include <sys/vfs_syscalls.h>
#ifdef KTRACE
#include <sys/ktrace.h>
#endif
#ifdef FILEASSOC
#include <sys/fileassoc.h>
#endif /* FILEASSOC */
@ -3450,14 +3447,7 @@ sys___getdents30(struct lwp *l, void *v, register_t *retval)
}
error = vn_readdir(fp, SCARG(uap, buf), UIO_USERSPACE,
SCARG(uap, count), &done, l, 0, 0);
#ifdef KTRACE
if (!error && KTRPOINT(p, KTR_GENIO)) {
struct iovec iov;
iov.iov_base = SCARG(uap, buf);
iov.iov_len = done;
ktrgenio(l, SCARG(uap, fd), UIO_READ, &iov, done, 0);
}
#endif
ktrgenio(SCARG(uap, fd), UIO_READ, SCARG(uap, buf), done, error);
*retval = done;
out:
FILE_UNUSE(fp, l);

View File

@ -1,4 +1,4 @@
/* $NetBSD: ktrace.h,v 1.48 2007/06/01 20:24:21 dsl Exp $ */
/* $NetBSD: ktrace.h,v 1.49 2007/08/15 12:07:35 ad Exp $ */
/*
* Copyright (c) 1988, 1993
@ -279,26 +279,144 @@ __END_DECLS
#else
void ktrinit(void);
void ktrcsw(struct lwp *, int, int);
void ktremul(struct lwp *);
void ktrgenio(struct lwp *, int, enum uio_rw, struct iovec *, int, int);
void ktrnamei(struct lwp *, const char *, size_t);
void ktrnamei2(struct lwp *, const char *, size_t, const char *, size_t);
void ktrpsig(struct lwp *, int, sig_t, const sigset_t *, const ksiginfo_t *);
void ktrsyscall(struct lwp *, register_t, register_t,
const struct sysent *, register_t []);
void ktrsysret(struct lwp *, register_t, int, register_t *);
int ktruser(struct lwp *, const char *, void *, size_t, int);
void ktrkuser(struct lwp *, const char *, void *, size_t);
void ktrmmsg(struct lwp *, const void *, size_t);
void ktrkmem(struct lwp *, int, const void *, size_t);
void ktrmib(struct lwp *, const int *, u_int);
void ktrmool(struct lwp *, const void *, size_t, const void *);
void ktrderef(struct proc *);
void ktradref(struct proc *);
extern kmutex_t ktrace_mutex;
extern kmutex_t ktrace_lock;
extern int ktrace_on;
int ktruser(const char *, void *, size_t, int);
bool ktrpoint(int);
void ktr_csw(int, int);
void ktr_emul(void);
void ktr_geniov(int, enum uio_rw, struct iovec *, size_t, int);
void ktr_genio(int, enum uio_rw, const void *, size_t, int);
void ktr_mibio(int, enum uio_rw, const void *, size_t, int);
void ktr_namei(const char *, size_t);
void ktr_namei2(const char *, size_t, const char *, size_t);
void ktr_psig(int, sig_t, const sigset_t *, const ksiginfo_t *);
void ktr_syscall(register_t, register_t, const struct sysent *,
register_t []);
void ktr_sysret(register_t, int, register_t *);
void ktr_kuser(const char *, void *, size_t);
void ktr_mmsg(const void *, size_t);
void ktr_mib(const int *a , u_int b);
void ktr_mool(const void *, size_t, const void *);
void ktr_execarg(const void *, size_t);
void ktr_execenv(const void *, size_t);
static inline void
ktrcsw(int a, int b)
{
if (__predict_false(ktrace_on))
ktr_csw(a, b);
}
static inline void
ktremul(void)
{
if (__predict_false(ktrace_on))
ktr_emul();
}
static inline void
ktrgenio(int a, enum uio_rw b, const void *c, size_t d, int e)
{
if (__predict_false(ktrace_on))
ktr_genio(a, b, c, d, e);
}
static inline void
ktrgeniov(int a, enum uio_rw b, struct iovec *c, int d, int e)
{
if (__predict_false(ktrace_on))
ktr_genio(a, b, c, d, e);
}
static inline void
ktrmibio(int a, enum uio_rw b, const void *c, size_t d, int e)
{
if (__predict_false(ktrace_on))
ktr_mibio(a, b, c, d, e);
}
static inline void
ktrnamei(const char *a, size_t b)
{
if (__predict_false(ktrace_on))
ktr_namei(a, b);
}
static inline void
ktrnamei2(const char *a, size_t b, const char *c, size_t d)
{
if (__predict_false(ktrace_on))
ktr_namei2(a, b, c, d);
}
static inline void
ktrpsig(int a, sig_t b, const sigset_t *c, const ksiginfo_t * d)
{
if (__predict_false(ktrace_on))
ktr_psig(a, b, c, d);
}
static inline void
ktrsyscall(register_t a, register_t b, const struct sysent *c, register_t d[])
{
if (__predict_false(ktrace_on))
ktr_syscall(a, b, c, d);
}
static inline void
ktrsysret(register_t a, int b, register_t *c)
{
if (__predict_false(ktrace_on))
ktr_sysret(a, b, c);
}
static inline void
ktrkuser(const char *a, void *b, size_t c)
{
if (__predict_false(ktrace_on))
ktr_kuser(a, b, c);
}
static inline void
ktrmmsg(const void *a, size_t b)
{
if (__predict_false(ktrace_on))
ktr_mmsg(a, b);
}
static inline void
ktrmib(const int *a , u_int b)
{
if (__predict_false(ktrace_on))
ktr_mib(a, b);
}
static inline void
ktrmool(const void *a, size_t b, const void *c)
{
if (__predict_false(ktrace_on))
ktr_mool(a, b, c);
}
static inline void
ktrexecarg(const void *a, size_t b)
{
if (__predict_false(ktrace_on))
ktr_execarg(a, b);
}
static inline void
ktrexecenv(const void *a, size_t b)
{
if (__predict_false(ktrace_on))
ktr_execenv(a, b);
}
#endif /* !_KERNEL */