diff --git a/sys/cddl/dev/systrace/systrace.c b/sys/cddl/dev/systrace/systrace.c index 3e992e3a553a..7762b399dd60 100644 --- a/sys/cddl/dev/systrace/systrace.c +++ b/sys/cddl/dev/systrace/systrace.c @@ -59,17 +59,38 @@ #include #ifdef LINUX_SYSTRACE -#include -#include -#include -#include -#include +#if defined(__amd64__) +#include +#include +#include +#include +#elif defined(__i386__) +#include +#include +#include +#include +#else +#error Only i386 and amd64 are supported. +#endif extern struct sysent linux_sysent[]; -#define DEVNAME "dtrace/linsystrace" -#define PROVNAME "linsyscall" +#define MODNAME "linux32" #define MAXSYSCALL LINUX_SYS_MAXSYSCALL #define SYSCALLNAMES linux_syscallnames #define SYSENT linux_sysent +#elif defined(FREEBSD32_SYSTRACE) +/* + * The syscall arguments are processed into a DTrace argument array + * using a generated function. See sys/kern/makesyscalls.sh. + */ +#include +#include +#include +#include +extern const char *freebsd32_syscallnames[]; +#define MODNAME "freebsd32" +#define MAXSYSCALL FREEBSD32_SYS_MAXSYSCALL +#define SYSCALLNAMES freebsd32_syscallnames +#define SYSENT freebsd32_sysent #else /* * The syscall arguments are processed into a DTrace argument array @@ -77,13 +98,15 @@ extern struct sysent linux_sysent[]; */ #include #include -#define DEVNAME "dtrace/systrace" -#define PROVNAME "syscall" +#define MODNAME "freebsd" #define MAXSYSCALL SYS_MAXSYSCALL #define SYSCALLNAMES syscallnames #define SYSENT sysent #endif +#define PROVNAME "syscall" +#define DEVNAME "dtrace/systrace/" MODNAME + #define SYSTRACE_ARTIFICIAL_FRAMES 1 #define SYSTRACE_SHIFT 16 @@ -214,14 +237,14 @@ systrace_provide(void *arg, dtrace_probedesc_t *desc) return; for (i = 0; i < MAXSYSCALL; i++) { - if (dtrace_probe_lookup(systrace_id, NULL, + if (dtrace_probe_lookup(systrace_id, MODNAME, uglyhack.pp_syscallnames[i], "entry") != 0) continue; - (void) dtrace_probe_create(systrace_id, NULL, uglyhack.pp_syscallnames[i], + (void) dtrace_probe_create(systrace_id, MODNAME, uglyhack.pp_syscallnames[i], "entry", SYSTRACE_ARTIFICIAL_FRAMES, (void *)((uintptr_t)SYSTRACE_ENTRY(i))); - (void) dtrace_probe_create(systrace_id, NULL, uglyhack.pp_syscallnames[i], + (void) dtrace_probe_create(systrace_id, MODNAME, uglyhack.pp_syscallnames[i], "return", SYSTRACE_ARTIFICIAL_FRAMES, (void *)((uintptr_t)SYSTRACE_RETURN(i))); } @@ -335,12 +358,16 @@ SYSINIT(systrace_load, SI_SUB_DTRACE_PROVIDER, SI_ORDER_ANY, systrace_load, NULL SYSUNINIT(systrace_unload, SI_SUB_DTRACE_PROVIDER, SI_ORDER_ANY, systrace_unload, NULL); #ifdef LINUX_SYSTRACE -DEV_MODULE(linsystrace, systrace_modevent, NULL); -MODULE_VERSION(linsystrace, 1); -MODULE_DEPEND(linsystrace, linux, 1, 1, 1); -MODULE_DEPEND(linsystrace, systrace, 1, 1, 1); -MODULE_DEPEND(linsystrace, dtrace, 1, 1, 1); -MODULE_DEPEND(linsystrace, opensolaris, 1, 1, 1); +DEV_MODULE(systrace_linux32, systrace_modevent, NULL); +MODULE_VERSION(systrace_linux32, 1); +MODULE_DEPEND(systrace_linux32, linux, 1, 1, 1); +MODULE_DEPEND(systrace_linux32, dtrace, 1, 1, 1); +MODULE_DEPEND(systrace_linux32, opensolaris, 1, 1, 1); +#elif defined(FREEBSD32_SYSTRACE) +DEV_MODULE(systrace_freebsd32, systrace_modevent, NULL); +MODULE_VERSION(systrace_freebsd32, 1); +MODULE_DEPEND(systrace_freebsd32, dtrace, 1, 1, 1); +MODULE_DEPEND(systrace_freebsd32, opensolaris, 1, 1, 1); #else DEV_MODULE(systrace, systrace_modevent, NULL); MODULE_VERSION(systrace, 1); diff --git a/sys/modules/dtrace/Makefile b/sys/modules/dtrace/Makefile index 02c476697c6f..09fe55e29cd1 100644 --- a/sys/modules/dtrace/Makefile +++ b/sys/modules/dtrace/Makefile @@ -15,7 +15,10 @@ SUBDIR= dtmalloc \ systrace .if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386" -SUBDIR+= fasttrap fbt +SUBDIR+= fasttrap fbt systrace_linux32 +.endif +.if ${MACHINE_CPUARCH} == "amd64" +SUBDIR+= systrace_freebsd32 .endif .include diff --git a/sys/modules/dtrace/dtraceall/Makefile b/sys/modules/dtrace/dtraceall/Makefile index 6f098024611c..5174548bb4d9 100644 --- a/sys/modules/dtrace/dtraceall/Makefile +++ b/sys/modules/dtrace/dtraceall/Makefile @@ -1,8 +1,15 @@ # $FreeBSD$ KMOD= dtraceall -SRCS= dtraceall.c +SRCS= dtraceall.c opt_compat.h CFLAGS+= -I${.CURDIR}/../../.. +.if !defined(KERNBUILDDIR) +opt_compat.h: +.if ${MACHINE_ARCH} == "amd64" + echo "#define COMPAT_FREEBSD32 1" >> ${.TARGET} +.endif +.endif + .include diff --git a/sys/modules/dtrace/dtraceall/dtraceall.c b/sys/modules/dtrace/dtraceall/dtraceall.c index ecb5e344b034..76172b7aa50a 100644 --- a/sys/modules/dtrace/dtraceall/dtraceall.c +++ b/sys/modules/dtrace/dtraceall/dtraceall.c @@ -32,6 +32,7 @@ #include #include #include +#include "opt_compat.h" static int dtraceall_modevent(module_t mod __unused, int type, void *data __unused) @@ -73,4 +74,7 @@ MODULE_DEPEND(dtraceall, fasttrap, 1, 1, 1); MODULE_DEPEND(dtraceall, lockstat, 1, 1, 1); MODULE_DEPEND(dtraceall, sdt, 1, 1, 1); MODULE_DEPEND(dtraceall, systrace, 1, 1, 1); +#if defined(COMPAT_FREEBSD32) +MODULE_DEPEND(dtraceall, systrace_freebsd32, 1, 1, 1); +#endif MODULE_DEPEND(dtraceall, profile, 1, 1, 1); diff --git a/sys/modules/dtrace/systrace_freebsd32/Makefile b/sys/modules/dtrace/systrace_freebsd32/Makefile new file mode 100644 index 000000000000..284d99f54683 --- /dev/null +++ b/sys/modules/dtrace/systrace_freebsd32/Makefile @@ -0,0 +1,13 @@ +# $FreeBSD$ + +.PATH: ${.CURDIR}/../../../cddl/dev/systrace + +KMOD= systrace_freebsd32 +SRCS= systrace.c +SRCS+= vnode_if.h + +CFLAGS+= -I${.CURDIR}/../../../cddl/compat/opensolaris \ + -I${.CURDIR}/../../../cddl/contrib/opensolaris/uts/common \ + -I${.CURDIR}/../../.. -DFREEBSD32_SYSTRACE + +.include diff --git a/sys/modules/dtrace/systrace_linux32/Makefile b/sys/modules/dtrace/systrace_linux32/Makefile new file mode 100644 index 000000000000..c55987d2643f --- /dev/null +++ b/sys/modules/dtrace/systrace_linux32/Makefile @@ -0,0 +1,13 @@ +# $FreeBSD$ + +.PATH: ${.CURDIR}/../../../cddl/dev/systrace + +KMOD= systrace_linux32 +SRCS= systrace.c +SRCS+= vnode_if.h + +CFLAGS+= -I${.CURDIR}/../../../cddl/compat/opensolaris \ + -I${.CURDIR}/../../../cddl/contrib/opensolaris/uts/common \ + -I${.CURDIR}/../../.. -DLINUX_SYSTRACE + +.include