svn commit: r212057 - in user/nwhitehorn/ps3: amd64/amd64
amd64/include boot/common cddl/compat/opensolaris/kern
cddl/compat/opensolaris/sys
cddl/contrib/opensolaris/uts/common cddl/contrib/opensol...
Nathan Whitehorn
nwhitehorn at FreeBSD.org
Tue Aug 31 15:58:16 UTC 2010
Author: nwhitehorn
Date: Tue Aug 31 15:58:15 2010
New Revision: 212057
URL: http://svn.freebsd.org/changeset/base/212057
Log:
IFC @ r212055
Added:
user/nwhitehorn/ps3/mips/rmi/dev/nlge/
- copied from r212055, head/sys/mips/rmi/dev/nlge/
user/nwhitehorn/ps3/mips/rmi/dev/xlr/debug.h
- copied unchanged from r212055, head/sys/mips/rmi/dev/xlr/debug.h
user/nwhitehorn/ps3/mips/rmi/fmn.c
- copied unchanged from r212055, head/sys/mips/rmi/fmn.c
user/nwhitehorn/ps3/mips/rmi/rmi_boot_info.h
- copied unchanged from r212055, head/sys/mips/rmi/rmi_boot_info.h
user/nwhitehorn/ps3/mips/rmi/xlr_pcmcia.c
- copied unchanged from r212055, head/sys/mips/rmi/xlr_pcmcia.c
user/nwhitehorn/ps3/powerpc/powermac/platform_powermac.c
- copied unchanged from r212055, head/sys/powerpc/powermac/platform_powermac.c
user/nwhitehorn/ps3/x86/pci/
- copied from r212055, head/sys/x86/pci/
Deleted:
user/nwhitehorn/ps3/mips/rmi/clock.c
user/nwhitehorn/ps3/mips/rmi/clock.h
user/nwhitehorn/ps3/mips/rmi/debug.h
user/nwhitehorn/ps3/mips/rmi/on_chip.c
user/nwhitehorn/ps3/mips/rmi/shared_structs.h
user/nwhitehorn/ps3/mips/rmi/shared_structs_func.h
user/nwhitehorn/ps3/mips/rmi/shared_structs_offsets.h
user/nwhitehorn/ps3/mips/rmi/xlrconfig.h
user/nwhitehorn/ps3/powerpc/aim/platform_chrp.c
user/nwhitehorn/ps3/powerpc/aim/trap_subr.S
Modified:
user/nwhitehorn/ps3/amd64/amd64/cpu_switch.S
user/nwhitehorn/ps3/amd64/amd64/exception.S
user/nwhitehorn/ps3/amd64/amd64/machdep.c
user/nwhitehorn/ps3/amd64/amd64/trap.c
user/nwhitehorn/ps3/amd64/include/segments.h
user/nwhitehorn/ps3/amd64/include/trap.h
user/nwhitehorn/ps3/boot/common/Makefile.inc
user/nwhitehorn/ps3/boot/common/ufsread.c
user/nwhitehorn/ps3/cddl/compat/opensolaris/kern/opensolaris_policy.c
user/nwhitehorn/ps3/cddl/compat/opensolaris/sys/policy.h
user/nwhitehorn/ps3/cddl/contrib/opensolaris/uts/common/Makefile.files
user/nwhitehorn/ps3/cddl/contrib/opensolaris/uts/common/dtrace/fasttrap.c
user/nwhitehorn/ps3/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c
user/nwhitehorn/ps3/cddl/contrib/opensolaris/uts/common/fs/zfs/metaslab.c
user/nwhitehorn/ps3/cddl/contrib/opensolaris/uts/common/fs/zfs/rrwlock.c
user/nwhitehorn/ps3/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c
user/nwhitehorn/ps3/cddl/contrib/opensolaris/uts/common/fs/zfs/space_map.c
user/nwhitehorn/ps3/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/metaslab.h
user/nwhitehorn/ps3/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/metaslab_impl.h
user/nwhitehorn/ps3/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/spa_impl.h
user/nwhitehorn/ps3/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/space_map.h
user/nwhitehorn/ps3/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_acl.h
user/nwhitehorn/ps3/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_znode.h
user/nwhitehorn/ps3/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zio.h
user/nwhitehorn/ps3/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c
user/nwhitehorn/ps3/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_queue.c
user/nwhitehorn/ps3/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_acl.c
user/nwhitehorn/ps3/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c
user/nwhitehorn/ps3/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c
user/nwhitehorn/ps3/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c
user/nwhitehorn/ps3/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_znode.c
user/nwhitehorn/ps3/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c
user/nwhitehorn/ps3/cddl/contrib/opensolaris/uts/common/sys/vnode.h
user/nwhitehorn/ps3/cddl/contrib/opensolaris/uts/intel/dtrace/fasttrap_isa.c
user/nwhitehorn/ps3/compat/x86bios/x86bios.c
user/nwhitehorn/ps3/compat/x86bios/x86bios.h
user/nwhitehorn/ps3/conf/files.amd64
user/nwhitehorn/ps3/conf/files.i386
user/nwhitehorn/ps3/conf/files.powerpc
user/nwhitehorn/ps3/dev/age/if_age.c
user/nwhitehorn/ps3/dev/ahci/ahci.c
user/nwhitehorn/ps3/dev/ata/ata-pci.h
user/nwhitehorn/ps3/dev/ata/chipsets/ata-intel.c
user/nwhitehorn/ps3/dev/e1000/if_em.c
user/nwhitehorn/ps3/dev/e1000/if_em.h
user/nwhitehorn/ps3/dev/e1000/if_igb.c
user/nwhitehorn/ps3/dev/e1000/if_igb.h
user/nwhitehorn/ps3/dev/e1000/if_lem.c
user/nwhitehorn/ps3/dev/e1000/if_lem.h
user/nwhitehorn/ps3/dev/ed/if_ed_isa.c
user/nwhitehorn/ps3/dev/ed/if_ed_novell.c
user/nwhitehorn/ps3/dev/ed/if_ed_pci.c
user/nwhitehorn/ps3/dev/fb/vesa.c
user/nwhitehorn/ps3/dev/ichsmb/ichsmb_pci.c
user/nwhitehorn/ps3/dev/ichwd/ichwd.c
user/nwhitehorn/ps3/dev/ichwd/ichwd.h
user/nwhitehorn/ps3/dev/ixgb/if_ixgb.c
user/nwhitehorn/ps3/dev/ixgb/if_ixgb.h
user/nwhitehorn/ps3/dev/ixgbe/ixgbe.c
user/nwhitehorn/ps3/dev/ixgbe/ixgbe.h
user/nwhitehorn/ps3/dev/sound/pci/hda/hdac.c
user/nwhitehorn/ps3/dev/twa/tw_cl.h
user/nwhitehorn/ps3/dev/twa/tw_cl_externs.h
user/nwhitehorn/ps3/dev/twa/tw_cl_fwif.h
user/nwhitehorn/ps3/dev/twa/tw_cl_init.c
user/nwhitehorn/ps3/dev/twa/tw_cl_intr.c
user/nwhitehorn/ps3/dev/twa/tw_cl_io.c
user/nwhitehorn/ps3/dev/twa/tw_cl_misc.c
user/nwhitehorn/ps3/dev/twa/tw_cl_share.h
user/nwhitehorn/ps3/dev/twa/tw_osl.h
user/nwhitehorn/ps3/dev/twa/tw_osl_cam.c
user/nwhitehorn/ps3/dev/twa/tw_osl_freebsd.c
user/nwhitehorn/ps3/dev/twa/tw_osl_share.h
user/nwhitehorn/ps3/dev/vr/if_vr.c
user/nwhitehorn/ps3/fs/devfs/devfs_vnops.c
user/nwhitehorn/ps3/fs/nfs/nfs_commonsubs.c
user/nwhitehorn/ps3/fs/nfs/nfs_var.h
user/nwhitehorn/ps3/fs/nfsserver/nfs_nfsdsocket.c
user/nwhitehorn/ps3/fs/nfsserver/nfs_nfsdstate.c
user/nwhitehorn/ps3/fs/nullfs/null_vnops.c
user/nwhitehorn/ps3/fs/unionfs/union_subr.c
user/nwhitehorn/ps3/geom/eli/g_eli.c
user/nwhitehorn/ps3/geom/eli/g_eli.h
user/nwhitehorn/ps3/i386/i386/exception.s
user/nwhitehorn/ps3/i386/i386/machdep.c
user/nwhitehorn/ps3/i386/i386/trap.c
user/nwhitehorn/ps3/i386/include/segments.h
user/nwhitehorn/ps3/i386/include/trap.h
user/nwhitehorn/ps3/i386/include/vm86.h
user/nwhitehorn/ps3/kern/init_sysent.c
user/nwhitehorn/ps3/kern/kern_exec.c
user/nwhitehorn/ps3/kern/kern_sig.c
user/nwhitehorn/ps3/kern/kern_thr.c
user/nwhitehorn/ps3/kern/kern_umtx.c
user/nwhitehorn/ps3/kern/subr_acl_nfs4.c
user/nwhitehorn/ps3/kern/subr_acl_posix1e.c
user/nwhitehorn/ps3/kern/subr_taskqueue.c
user/nwhitehorn/ps3/kern/sys_generic.c
user/nwhitehorn/ps3/kern/syscalls.c
user/nwhitehorn/ps3/kern/syscalls.master
user/nwhitehorn/ps3/kern/systrace_args.c
user/nwhitehorn/ps3/kern/vfs_default.c
user/nwhitehorn/ps3/kern/vfs_mount.c
user/nwhitehorn/ps3/kern/vfs_subr.c
user/nwhitehorn/ps3/mips/include/atomic.h
user/nwhitehorn/ps3/mips/include/locore.h
user/nwhitehorn/ps3/mips/include/memdev.h
user/nwhitehorn/ps3/mips/include/pcb.h
user/nwhitehorn/ps3/mips/include/pmap.h
user/nwhitehorn/ps3/mips/include/pte.h
user/nwhitehorn/ps3/mips/include/regnum.h
user/nwhitehorn/ps3/mips/include/ucontext.h
user/nwhitehorn/ps3/mips/mips/pmap.c
user/nwhitehorn/ps3/mips/rmi/board.c
user/nwhitehorn/ps3/mips/rmi/board.h
user/nwhitehorn/ps3/mips/rmi/dev/xlr/rge.c
user/nwhitehorn/ps3/mips/rmi/files.xlr
user/nwhitehorn/ps3/mips/rmi/interrupt.h
user/nwhitehorn/ps3/mips/rmi/intr_machdep.c
user/nwhitehorn/ps3/mips/rmi/iodi.c
user/nwhitehorn/ps3/mips/rmi/iomap.h
user/nwhitehorn/ps3/mips/rmi/msgring.h
user/nwhitehorn/ps3/mips/rmi/pic.h
user/nwhitehorn/ps3/mips/rmi/rmi_mips_exts.h
user/nwhitehorn/ps3/mips/rmi/tick.c
user/nwhitehorn/ps3/mips/rmi/xlr_machdep.c
user/nwhitehorn/ps3/mips/rmi/xlr_pci.c
user/nwhitehorn/ps3/modules/dtrace/Makefile
user/nwhitehorn/ps3/modules/dtrace/dtrace/Makefile
user/nwhitehorn/ps3/modules/dtrace/dtraceall/dtraceall.c
user/nwhitehorn/ps3/modules/dtrace/fasttrap/Makefile
user/nwhitehorn/ps3/net/if_epair.c
user/nwhitehorn/ps3/netinet/ipfw/ip_fw_log.c
user/nwhitehorn/ps3/netinet/sctp.h
user/nwhitehorn/ps3/netinet/sctp_cc_functions.c
user/nwhitehorn/ps3/netinet/sctp_crc32.c
user/nwhitehorn/ps3/netinet/sctp_crc32.h
user/nwhitehorn/ps3/netinet/sctp_indata.c
user/nwhitehorn/ps3/netinet/sctp_input.c
user/nwhitehorn/ps3/netinet/sctp_os_bsd.h
user/nwhitehorn/ps3/netinet/sctp_output.c
user/nwhitehorn/ps3/netinet/sctp_pcb.c
user/nwhitehorn/ps3/netinet/sctp_pcb.h
user/nwhitehorn/ps3/netinet/sctp_peeloff.c
user/nwhitehorn/ps3/netinet/sctp_sysctl.c
user/nwhitehorn/ps3/netinet/sctp_sysctl.h
user/nwhitehorn/ps3/netinet/sctp_timer.c
user/nwhitehorn/ps3/netinet/sctp_usrreq.c
user/nwhitehorn/ps3/netinet/sctputil.c
user/nwhitehorn/ps3/netinet/tcp_input.c
user/nwhitehorn/ps3/netinet/tcp_subr.c
user/nwhitehorn/ps3/netinet6/sctp6_usrreq.c
user/nwhitehorn/ps3/nfsserver/nfs_serv.c
user/nwhitehorn/ps3/pci/if_rl.c
user/nwhitehorn/ps3/powerpc/aim/machdep.c
user/nwhitehorn/ps3/powerpc/aim/mmu_oea.c
user/nwhitehorn/ps3/powerpc/aim/mmu_oea64.c
user/nwhitehorn/ps3/powerpc/aim/ofw_machdep.c
user/nwhitehorn/ps3/powerpc/aim/vm_machdep.c
user/nwhitehorn/ps3/powerpc/booke/platform_bare.c
user/nwhitehorn/ps3/powerpc/include/ofw_machdep.h
user/nwhitehorn/ps3/powerpc/mpc85xx/mpc85xx.c
user/nwhitehorn/ps3/powerpc/powermac/cuda.c
user/nwhitehorn/ps3/powerpc/powermac/pmu.c
user/nwhitehorn/ps3/powerpc/powermac/smu.c
user/nwhitehorn/ps3/powerpc/powerpc/platform.c
user/nwhitehorn/ps3/powerpc/powerpc/platform_if.m
user/nwhitehorn/ps3/powerpc/ps3/platform_ps3.c
user/nwhitehorn/ps3/rpc/replay.c
user/nwhitehorn/ps3/sys/cdefs.h
user/nwhitehorn/ps3/sys/dtrace_bsd.h
user/nwhitehorn/ps3/sys/mman.h
user/nwhitehorn/ps3/sys/mount.h
user/nwhitehorn/ps3/sys/param.h
user/nwhitehorn/ps3/sys/signal.h
user/nwhitehorn/ps3/sys/syscall.h
user/nwhitehorn/ps3/sys/syscall.mk
user/nwhitehorn/ps3/sys/sysproto.h
user/nwhitehorn/ps3/vm/vm_mmap.c
user/nwhitehorn/ps3/x86/x86/local_apic.c
Directory Properties:
user/nwhitehorn/ps3/ (props changed)
user/nwhitehorn/ps3/amd64/include/xen/ (props changed)
user/nwhitehorn/ps3/boot/powerpc/ps3/ (props changed)
user/nwhitehorn/ps3/cddl/contrib/opensolaris/ (props changed)
user/nwhitehorn/ps3/contrib/dev/acpica/ (props changed)
user/nwhitehorn/ps3/contrib/pf/ (props changed)
user/nwhitehorn/ps3/contrib/x86emu/ (props changed)
user/nwhitehorn/ps3/dev/xen/xenpci/ (props changed)
user/nwhitehorn/ps3/powerpc/ps3/ (props changed)
Modified: user/nwhitehorn/ps3/amd64/amd64/cpu_switch.S
==============================================================================
--- user/nwhitehorn/ps3/amd64/amd64/cpu_switch.S Tue Aug 31 15:52:12 2010 (r212056)
+++ user/nwhitehorn/ps3/amd64/amd64/cpu_switch.S Tue Aug 31 15:58:15 2010 (r212057)
@@ -338,19 +338,16 @@ ENTRY(savectx)
movl $MSR_FSBASE,%ecx
rdmsr
- shlq $32,%rdx
- leaq (%rax,%rdx),%rax
- movq %rax,PCB_FSBASE(%rdi)
+ movl %eax,PCB_FSBASE(%rdi)
+ movl %edx,PCB_FSBASE+4(%rdi)
movl $MSR_GSBASE,%ecx
rdmsr
- shlq $32,%rdx
- leaq (%rax,%rdx),%rax
- movq %rax,PCB_GSBASE(%rdi)
+ movl %eax,PCB_GSBASE(%rdi)
+ movl %edx,PCB_GSBASE+4(%rdi)
movl $MSR_KGSBASE,%ecx
rdmsr
- shlq $32,%rdx
- leaq (%rax,%rdx),%rax
- movq %rax,PCB_KGSBASE(%rdi)
+ movl %eax,PCB_KGSBASE(%rdi)
+ movl %edx,PCB_KGSBASE+4(%rdi)
sgdt PCB_GDT(%rdi)
sidt PCB_IDT(%rdi)
Modified: user/nwhitehorn/ps3/amd64/amd64/exception.S
==============================================================================
--- user/nwhitehorn/ps3/amd64/amd64/exception.S Tue Aug 31 15:52:12 2010 (r212056)
+++ user/nwhitehorn/ps3/amd64/amd64/exception.S Tue Aug 31 15:58:15 2010 (r212057)
@@ -108,6 +108,10 @@ IDTVEC(dbg)
TRAP_NOEN(T_TRCTRAP)
IDTVEC(bpt)
TRAP_NOEN(T_BPTFLT)
+#ifdef KDTRACE_HOOKS
+IDTVEC(dtrace_ret)
+ TRAP_NOEN(T_DTRACE_RET)
+#endif
/* Regular traps; The cpu does not supply tf_err for these. */
#define TRAP(a) \
Modified: user/nwhitehorn/ps3/amd64/amd64/machdep.c
==============================================================================
--- user/nwhitehorn/ps3/amd64/amd64/machdep.c Tue Aug 31 15:52:12 2010 (r212056)
+++ user/nwhitehorn/ps3/amd64/amd64/machdep.c Tue Aug 31 15:58:15 2010 (r212057)
@@ -54,6 +54,7 @@ __FBSDID("$FreeBSD$");
#include "opt_msgbuf.h"
#include "opt_perfmon.h"
#include "opt_sched.h"
+#include "opt_kdtrace.h"
#include <sys/param.h>
#include <sys/proc.h>
@@ -1089,6 +1090,9 @@ extern inthand_t
IDTVEC(tss), IDTVEC(missing), IDTVEC(stk), IDTVEC(prot),
IDTVEC(page), IDTVEC(mchk), IDTVEC(rsvd), IDTVEC(fpu), IDTVEC(align),
IDTVEC(xmm), IDTVEC(dblfault),
+#ifdef KDTRACE_HOOKS
+ IDTVEC(dtrace_ret),
+#endif
IDTVEC(fast_syscall), IDTVEC(fast_syscall32);
#ifdef DDB
@@ -1617,6 +1621,9 @@ hammer_time(u_int64_t modulep, u_int64_t
setidt(IDT_AC, &IDTVEC(align), SDT_SYSIGT, SEL_KPL, 0);
setidt(IDT_MC, &IDTVEC(mchk), SDT_SYSIGT, SEL_KPL, 0);
setidt(IDT_XF, &IDTVEC(xmm), SDT_SYSIGT, SEL_KPL, 0);
+#ifdef KDTRACE_HOOKS
+ setidt(IDT_DTRACE_RET, &IDTVEC(dtrace_ret), SDT_SYSIGT, SEL_UPL, 0);
+#endif
r_idt.rd_limit = sizeof(idt0) - 1;
r_idt.rd_base = (long) idt;
Modified: user/nwhitehorn/ps3/amd64/amd64/trap.c
==============================================================================
--- user/nwhitehorn/ps3/amd64/amd64/trap.c Tue Aug 31 15:52:12 2010 (r212056)
+++ user/nwhitehorn/ps3/amd64/amd64/trap.c Tue Aug 31 15:58:15 2010 (r212057)
@@ -109,6 +109,13 @@ dtrace_doubletrap_func_t dtrace_doubletr
* implementation opaque.
*/
systrace_probe_func_t systrace_probe_func;
+
+/*
+ * These hooks are necessary for the pid, usdt and fasttrap providers.
+ */
+dtrace_fasttrap_probe_ptr_t dtrace_fasttrap_probe_ptr;
+dtrace_pid_probe_ptr_t dtrace_pid_probe_ptr;
+dtrace_return_probe_ptr_t dtrace_return_probe_ptr;
#endif
extern void trap(struct trapframe *frame);
@@ -239,6 +246,55 @@ trap(struct trapframe *frame)
if (dtrace_trap_func != NULL)
if ((*dtrace_trap_func)(frame, type))
goto out;
+ if (type == T_DTRACE_PROBE || type == T_DTRACE_RET ||
+ type == T_BPTFLT) {
+ struct reg regs;
+
+ regs.r_r15 = frame->tf_r15;
+ regs.r_r14 = frame->tf_r14;
+ regs.r_r13 = frame->tf_r13;
+ regs.r_r12 = frame->tf_r12;
+ regs.r_r11 = frame->tf_r11;
+ regs.r_r10 = frame->tf_r10;
+ regs.r_r9 = frame->tf_r9;
+ regs.r_r8 = frame->tf_r8;
+ regs.r_rdi = frame->tf_rdi;
+ regs.r_rsi = frame->tf_rsi;
+ regs.r_rbp = frame->tf_rbp;
+ regs.r_rbx = frame->tf_rbx;
+ regs.r_rdx = frame->tf_rdx;
+ regs.r_rcx = frame->tf_rcx;
+ regs.r_rax = frame->tf_rax;
+ regs.r_rip = frame->tf_rip;
+ regs.r_cs = frame->tf_cs;
+ regs.r_rflags = frame->tf_rflags;
+ regs.r_rsp = frame->tf_rsp;
+ regs.r_ss = frame->tf_ss;
+ if (frame->tf_flags & TF_HASSEGS) {
+ regs.r_ds = frame->tf_ds;
+ regs.r_es = frame->tf_es;
+ regs.r_fs = frame->tf_fs;
+ regs.r_gs = frame->tf_gs;
+ } else {
+ regs.r_ds = 0;
+ regs.r_es = 0;
+ regs.r_fs = 0;
+ regs.r_gs = 0;
+ }
+ if (type == T_DTRACE_PROBE &&
+ dtrace_fasttrap_probe_ptr != NULL &&
+ dtrace_fasttrap_probe_ptr(®s) == 0)
+ goto out;
+ if (type == T_BPTFLT &&
+ dtrace_pid_probe_ptr != NULL &&
+ dtrace_pid_probe_ptr(®s) == 0)
+ goto out;
+ if (type == T_DTRACE_RET &&
+ dtrace_return_probe_ptr != NULL &&
+ dtrace_return_probe_ptr(®s) == 0)
+ goto out;
+
+ }
#endif
if ((frame->tf_rflags & PSL_I) == 0) {
Modified: user/nwhitehorn/ps3/amd64/include/segments.h
==============================================================================
--- user/nwhitehorn/ps3/amd64/include/segments.h Tue Aug 31 15:52:12 2010 (r212056)
+++ user/nwhitehorn/ps3/amd64/include/segments.h Tue Aug 31 15:58:15 2010 (r212057)
@@ -214,6 +214,7 @@ struct region_descriptor {
#define IDT_XF 19 /* #XF: SIMD Floating-Point Exception */
#define IDT_IO_INTS NRSVIDT /* Base of IDT entries for I/O interrupts. */
#define IDT_SYSCALL 0x80 /* System Call Interrupt Vector */
+#define IDT_DTRACE_RET 0x92 /* DTrace pid provider Interrupt Vector */
/*
* Entries in the Global Descriptor Table (GDT)
Modified: user/nwhitehorn/ps3/amd64/include/trap.h
==============================================================================
--- user/nwhitehorn/ps3/amd64/include/trap.h Tue Aug 31 15:52:12 2010 (r212056)
+++ user/nwhitehorn/ps3/amd64/include/trap.h Tue Aug 31 15:58:15 2010 (r212057)
@@ -62,6 +62,8 @@
#define T_MCHK 28 /* machine check trap */
#define T_XMMFLT 29 /* SIMD floating-point exception */
#define T_RESERVED 30 /* reserved (unknown) */
+#define T_DTRACE_RET 31 /* DTrace pid return */
+#define T_DTRACE_PROBE 32 /* DTrace fasttrap probe */
/* XXX most of the following codes aren't used, but could be. */
Modified: user/nwhitehorn/ps3/boot/common/Makefile.inc
==============================================================================
--- user/nwhitehorn/ps3/boot/common/Makefile.inc Tue Aug 31 15:52:12 2010 (r212056)
+++ user/nwhitehorn/ps3/boot/common/Makefile.inc Tue Aug 31 15:58:15 2010 (r212057)
@@ -9,7 +9,7 @@ SRCS+= load_elf32.c load_elf32_obj.c rel
SRCS+= load_elf64.c load_elf64_obj.c reloc_elf64.c
.elif ${MACHINE} == "pc98"
SRCS+= load_elf32.c load_elf32_obj.c reloc_elf32.c
-.elif ${MACHINE_ARCH} == "powerpc" || ${MACHINE_CPUARCH} == "arm"
+.elif ${MACHINE_CPUARCH} == "arm"
SRCS+= load_elf32.c reloc_elf32.c
.elif ${MACHINE_CPUARCH} == "powerpc"
SRCS+= load_elf32.c reloc_elf32.c
Modified: user/nwhitehorn/ps3/boot/common/ufsread.c
==============================================================================
--- user/nwhitehorn/ps3/boot/common/ufsread.c Tue Aug 31 15:52:12 2010 (r212056)
+++ user/nwhitehorn/ps3/boot/common/ufsread.c Tue Aug 31 15:58:15 2010 (r212057)
@@ -223,14 +223,19 @@ fsread(ino_t inode, void *buf, size_t nb
return -1;
n = INO_TO_VBO(n, inode);
#if defined(UFS1_ONLY)
- dp1 = ((struct ufs1_dinode *)blkbuf)[n];
+ memcpy(&dp1, (struct ufs1_dinode *)blkbuf + n,
+ sizeof(struct ufs1_dinode));
#elif defined(UFS2_ONLY)
- dp2 = ((struct ufs2_dinode *)blkbuf)[n];
+ memcpy(&dp2, (struct ufs2_dinode *)blkbuf + n,
+ sizeof(struct ufs2_dinode));
#else
if (fs->fs_magic == FS_UFS1_MAGIC)
- dp1 = ((struct ufs1_dinode *)blkbuf)[n];
+ memcpy(&dp1, (struct ufs1_dinode *)blkbuf + n,
+ sizeof(struct ufs1_dinode));
else
- dp2 = ((struct ufs2_dinode *)blkbuf)[n];
+ memcpy(&dp2, (struct ufs2_dinode *)blkbuf + n,
+ sizeof(struct ufs2_dinode));
+
#endif
inomap = inode;
fs_off = 0;
Modified: user/nwhitehorn/ps3/cddl/compat/opensolaris/kern/opensolaris_policy.c
==============================================================================
--- user/nwhitehorn/ps3/cddl/compat/opensolaris/kern/opensolaris_policy.c Tue Aug 31 15:52:12 2010 (r212056)
+++ user/nwhitehorn/ps3/cddl/compat/opensolaris/kern/opensolaris_policy.c Tue Aug 31 15:58:15 2010 (r212057)
@@ -332,7 +332,7 @@ secpolicy_vnode_owner(struct vnode *vp,
}
int
-secpolicy_vnode_chown(struct vnode *vp, cred_t *cred, boolean_t check_self)
+secpolicy_vnode_chown(struct vnode *vp, cred_t *cred, uid_t owner)
{
if (secpolicy_fs_owner(vp->v_mount, cred) == 0)
Modified: user/nwhitehorn/ps3/cddl/compat/opensolaris/sys/policy.h
==============================================================================
--- user/nwhitehorn/ps3/cddl/compat/opensolaris/sys/policy.h Tue Aug 31 15:52:12 2010 (r212056)
+++ user/nwhitehorn/ps3/cddl/compat/opensolaris/sys/policy.h Tue Aug 31 15:58:15 2010 (r212057)
@@ -47,8 +47,7 @@ int secpolicy_zinject(struct ucred *cred
int secpolicy_fs_unmount(struct ucred *cred, struct mount *vfsp);
int secpolicy_basic_link(struct vnode *vp, struct ucred *cred);
int secpolicy_vnode_owner(struct vnode *vp, cred_t *cred, uid_t owner);
-int secpolicy_vnode_chown(struct vnode *vp, cred_t *cred,
- boolean_t check_self);
+int secpolicy_vnode_chown(struct vnode *vp, cred_t *cred, uid_t owner);
int secpolicy_vnode_stky_modify(struct ucred *cred);
int secpolicy_vnode_remove(struct vnode *vp, struct ucred *cred);
int secpolicy_vnode_access(struct ucred *cred, struct vnode *vp,
Modified: user/nwhitehorn/ps3/cddl/contrib/opensolaris/uts/common/Makefile.files
==============================================================================
--- user/nwhitehorn/ps3/cddl/contrib/opensolaris/uts/common/Makefile.files Tue Aug 31 15:52:12 2010 (r212056)
+++ user/nwhitehorn/ps3/cddl/contrib/opensolaris/uts/common/Makefile.files Tue Aug 31 15:58:15 2010 (r212057)
@@ -106,3 +106,6 @@ ZFS_OBJS += \
zfs_vfsops.o \
zfs_vnops.o \
zvol.o
+
+ZUT_OBJS += \
+ zut.o
Modified: user/nwhitehorn/ps3/cddl/contrib/opensolaris/uts/common/dtrace/fasttrap.c
==============================================================================
--- user/nwhitehorn/ps3/cddl/contrib/opensolaris/uts/common/dtrace/fasttrap.c Tue Aug 31 15:52:12 2010 (r212056)
+++ user/nwhitehorn/ps3/cddl/contrib/opensolaris/uts/common/dtrace/fasttrap.c Tue Aug 31 15:58:15 2010 (r212057)
@@ -17,6 +17,10 @@
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
+ *
+ * Portions Copyright 2010 The FreeBSD Foundation
+ *
+ * $FreeBSD$
*/
/*
@@ -24,7 +28,9 @@
* Use is subject to license terms.
*/
+#if defined(sun)
#pragma ident "%Z%%M% %I% %E% SMI"
+#endif
#include <sys/atomic.h>
#include <sys/errno.h>
@@ -32,11 +38,15 @@
#include <sys/modctl.h>
#include <sys/conf.h>
#include <sys/systm.h>
+#if defined(sun)
#include <sys/ddi.h>
+#endif
#include <sys/sunddi.h>
#include <sys/cpuvar.h>
#include <sys/kmem.h>
+#if defined(sun)
#include <sys/strsubr.h>
+#endif
#include <sys/fasttrap.h>
#include <sys/fasttrap_impl.h>
#include <sys/fasttrap_isa.h>
@@ -44,9 +54,17 @@
#include <sys/dtrace_impl.h>
#include <sys/sysmacros.h>
#include <sys/proc.h>
-#include <sys/priv.h>
#include <sys/policy.h>
+#if defined(sun)
#include <util/qsort.h>
+#endif
+#include <sys/mutex.h>
+#include <sys/kernel.h>
+#if !defined(sun)
+#include <sys/user.h>
+#include <sys/dtrace_bsd.h>
+#include <cddl/dev/dtrace/dtrace_cddl.h>
+#endif
/*
* User-Land Trap-Based Tracing
@@ -125,11 +143,20 @@
* never hold the provider lock and creation lock simultaneously
*/
-static dev_info_t *fasttrap_devi;
+static d_open_t fasttrap_open;
+static d_ioctl_t fasttrap_ioctl;
+
+static struct cdevsw fasttrap_cdevsw = {
+ .d_version = D_VERSION,
+ .d_open = fasttrap_open,
+ .d_ioctl = fasttrap_ioctl,
+ .d_name = "fasttrap",
+};
+static struct cdev *fasttrap_cdev;
static dtrace_meta_provider_id_t fasttrap_meta_id;
-static timeout_id_t fasttrap_timeout;
-static kmutex_t fasttrap_cleanup_mtx;
+static struct callout fasttrap_timeout;
+static struct mtx fasttrap_cleanup_mtx;
static uint_t fasttrap_cleanup_work;
/*
@@ -181,6 +208,10 @@ static void fasttrap_proc_release(fasttr
#define FASTTRAP_PROCS_INDEX(pid) ((pid) & fasttrap_procs.fth_mask)
+#if !defined(sun)
+static kmutex_t fasttrap_cpuc_pid_lock[MAXCPU];
+#endif
+
static int
fasttrap_highbit(ulong_t i)
{
@@ -229,6 +260,7 @@ fasttrap_hash_str(const char *p)
void
fasttrap_sigtrap(proc_t *p, kthread_t *t, uintptr_t pc)
{
+#if defined(sun)
sigqueue_t *sqp = kmem_zalloc(sizeof (sigqueue_t), KM_SLEEP);
sqp->sq_info.si_signo = SIGTRAP;
@@ -241,6 +273,17 @@ fasttrap_sigtrap(proc_t *p, kthread_t *t
if (t != NULL)
aston(t);
+#else
+ ksiginfo_t *ksi = kmem_zalloc(sizeof (ksiginfo_t), KM_SLEEP);
+
+ ksiginfo_init(ksi);
+ ksi->ksi_signo = SIGTRAP;
+ ksi->ksi_code = TRAP_DTRACE;
+ ksi->ksi_addr = (caddr_t)pc;
+ PROC_LOCK(p);
+ (void) tdksignal(t, SIGTRAP, ksi);
+ PROC_UNLOCK(p);
+#endif
}
/*
@@ -257,9 +300,9 @@ fasttrap_mod_barrier(uint64_t gen)
fasttrap_mod_gen++;
- for (i = 0; i < NCPU; i++) {
- mutex_enter(&cpu_core[i].cpuc_pid_lock);
- mutex_exit(&cpu_core[i].cpuc_pid_lock);
+ CPU_FOREACH(i) {
+ mutex_enter(&fasttrap_cpuc_pid_lock[i]);
+ mutex_exit(&fasttrap_cpuc_pid_lock[i]);
}
}
@@ -274,16 +317,15 @@ fasttrap_pid_cleanup_cb(void *data)
fasttrap_provider_t **fpp, *fp;
fasttrap_bucket_t *bucket;
dtrace_provider_id_t provid;
- int i, later;
+ int i, later = 0;
static volatile int in = 0;
ASSERT(in == 0);
in = 1;
- mutex_enter(&fasttrap_cleanup_mtx);
while (fasttrap_cleanup_work) {
fasttrap_cleanup_work = 0;
- mutex_exit(&fasttrap_cleanup_mtx);
+ mtx_unlock(&fasttrap_cleanup_mtx);
later = 0;
@@ -349,10 +391,12 @@ fasttrap_pid_cleanup_cb(void *data)
mutex_exit(&bucket->ftb_mtx);
}
- mutex_enter(&fasttrap_cleanup_mtx);
+ mtx_lock(&fasttrap_cleanup_mtx);
}
+#if 0
ASSERT(fasttrap_timeout != 0);
+#endif
/*
* If we were unable to remove a retired provider, try again after
@@ -364,14 +408,17 @@ fasttrap_pid_cleanup_cb(void *data)
* get a chance to do that work if and when the timeout is reenabled
* (if detach fails).
*/
- if (later > 0 && fasttrap_timeout != (timeout_id_t)1)
- fasttrap_timeout = timeout(&fasttrap_pid_cleanup_cb, NULL, hz);
+ if (later > 0 && callout_active(&fasttrap_timeout))
+ callout_reset(&fasttrap_timeout, hz, &fasttrap_pid_cleanup_cb,
+ NULL);
else if (later > 0)
fasttrap_cleanup_work = 1;
- else
- fasttrap_timeout = 0;
+ else {
+#if !defined(sun)
+ /* Nothing to be done for FreeBSD */
+#endif
+ }
- mutex_exit(&fasttrap_cleanup_mtx);
in = 0;
}
@@ -381,11 +428,11 @@ fasttrap_pid_cleanup_cb(void *data)
static void
fasttrap_pid_cleanup(void)
{
- mutex_enter(&fasttrap_cleanup_mtx);
+
+ mtx_lock(&fasttrap_cleanup_mtx);
fasttrap_cleanup_work = 1;
- if (fasttrap_timeout == 0)
- fasttrap_timeout = timeout(&fasttrap_pid_cleanup_cb, NULL, 1);
- mutex_exit(&fasttrap_cleanup_mtx);
+ callout_reset(&fasttrap_timeout, 1, &fasttrap_pid_cleanup_cb, NULL);
+ mtx_unlock(&fasttrap_cleanup_mtx);
}
/*
@@ -400,9 +447,23 @@ fasttrap_fork(proc_t *p, proc_t *cp)
pid_t ppid = p->p_pid;
int i;
+#if defined(sun)
ASSERT(curproc == p);
ASSERT(p->p_proc_flag & P_PR_LOCK);
+#else
+ PROC_LOCK_ASSERT(p, MA_OWNED);
+#endif
+#if defined(sun)
ASSERT(p->p_dtrace_count > 0);
+#else
+ /*
+ * This check is purposely here instead of in kern_fork.c because,
+ * for legal resons, we cannot include the dtrace_cddl.h header
+ * inside kern_fork.c and insert if-clause there.
+ */
+ if (p->p_dtrace_count == 0)
+ return;
+#endif
ASSERT(cp->p_dtrace_count == 0);
/*
@@ -419,9 +480,11 @@ fasttrap_fork(proc_t *p, proc_t *cp)
* We don't have to worry about the child process disappearing
* because we're in fork().
*/
- mutex_enter(&cp->p_lock);
+#if defined(sun)
+ mtx_lock_spin(&cp->p_slock);
sprlock_proc(cp);
- mutex_exit(&cp->p_lock);
+ mtx_unlock_spin(&cp->p_slock);
+#endif
/*
* Iterate over every tracepoint looking for ones that belong to the
@@ -451,8 +514,10 @@ fasttrap_fork(proc_t *p, proc_t *cp)
mutex_exit(&bucket->ftb_mtx);
}
+#if defined(sun)
mutex_enter(&cp->p_lock);
sprunlock(cp);
+#endif
}
/*
@@ -463,24 +528,24 @@ fasttrap_fork(proc_t *p, proc_t *cp)
static void
fasttrap_exec_exit(proc_t *p)
{
+#if defined(sun)
ASSERT(p == curproc);
- ASSERT(MUTEX_HELD(&p->p_lock));
-
- mutex_exit(&p->p_lock);
+#endif
+ PROC_LOCK_ASSERT(p, MA_OWNED);
+ PROC_UNLOCK(p);
/*
* We clean up the pid provider for this process here; user-land
* static probes are handled by the meta-provider remove entry point.
*/
fasttrap_provider_retire(p->p_pid, FASTTRAP_PID_NAME, 0);
-
- mutex_enter(&p->p_lock);
+ PROC_LOCK(p);
}
/*ARGSUSED*/
static void
-fasttrap_pid_provide(void *arg, const dtrace_probedesc_t *desc)
+fasttrap_pid_provide(void *arg, dtrace_probedesc_t *desc)
{
/*
* There are no "default" pid probes.
@@ -504,7 +569,9 @@ fasttrap_tracepoint_enable(proc_t *p, fa
ASSERT(probe->ftp_tps[index].fit_tp->ftt_pid == pid);
+#if defined(sun)
ASSERT(!(p->p_flag & SVFORK));
+#endif
/*
* Before we make any modifications, make sure we've imposed a barrier
@@ -610,7 +677,11 @@ again:
* Increment the count of the number of tracepoints active in
* the victim process.
*/
+#if defined(sun)
ASSERT(p->p_proc_flag & P_PR_LOCK);
+#else
+ PROC_LOCK_ASSERT(p, MA_OWNED);
+#endif
p->p_dtrace_count++;
return (rc);
@@ -666,7 +737,7 @@ fasttrap_tracepoint_disable(proc_t *p, f
fasttrap_bucket_t *bucket;
fasttrap_provider_t *provider = probe->ftp_prov;
fasttrap_tracepoint_t **pp, *tp;
- fasttrap_id_t *id, **idp;
+ fasttrap_id_t *id, **idp = NULL;
pid_t pid;
uintptr_t pc;
@@ -800,7 +871,11 @@ fasttrap_tracepoint_disable(proc_t *p, f
* Decrement the count of the number of tracepoints active
* in the victim process.
*/
+#if defined(sun)
ASSERT(p->p_proc_flag & P_PR_LOCK);
+#else
+ PROC_LOCK_ASSERT(p, MA_OWNED);
+#endif
p->p_dtrace_count--;
}
@@ -851,26 +926,31 @@ fasttrap_enable_callbacks(void)
static void
fasttrap_disable_callbacks(void)
{
+#if defined(sun)
ASSERT(MUTEX_HELD(&cpu_lock));
+#endif
+
mutex_enter(&fasttrap_count_mtx);
ASSERT(fasttrap_pid_count > 0);
fasttrap_pid_count--;
if (fasttrap_pid_count == 0) {
+#if defined(sun)
cpu_t *cur, *cpu = CPU;
for (cur = cpu->cpu_next_onln; cur != cpu;
cur = cur->cpu_next_onln) {
rw_enter(&cur->cpu_ft_lock, RW_WRITER);
}
-
+#endif
dtrace_pid_probe_ptr = NULL;
dtrace_return_probe_ptr = NULL;
-
+#if defined(sun)
for (cur = cpu->cpu_next_onln; cur != cpu;
cur = cur->cpu_next_onln) {
rw_exit(&cur->cpu_ft_lock);
}
+#endif
}
mutex_exit(&fasttrap_count_mtx);
}
@@ -880,13 +960,16 @@ static void
fasttrap_pid_enable(void *arg, dtrace_id_t id, void *parg)
{
fasttrap_probe_t *probe = parg;
- proc_t *p;
+ proc_t *p = NULL;
int i, rc;
+
ASSERT(probe != NULL);
ASSERT(!probe->ftp_enabled);
ASSERT(id == probe->ftp_id);
+#if defined(sun)
ASSERT(MUTEX_HELD(&cpu_lock));
+#endif
/*
* Increment the count of enabled probes on this probe's provider;
@@ -911,6 +994,7 @@ fasttrap_pid_enable(void *arg, dtrace_id
* a fork in which the traced process is being born and we're copying
* USDT probes. Otherwise, the process is gone so bail.
*/
+#if defined(sun)
if ((p = sprlock(probe->ftp_pid)) == NULL) {
if ((curproc->p_flag & SFORKING) == 0)
return;
@@ -934,13 +1018,19 @@ fasttrap_pid_enable(void *arg, dtrace_id
ASSERT(!(p->p_flag & SVFORK));
mutex_exit(&p->p_lock);
+#else
+ if ((p = pfind(probe->ftp_pid)) == NULL)
+ return;
+#endif
/*
* We have to enable the trap entry point before any user threads have
* the chance to execute the trap instruction we're about to place
* in their process's text.
*/
+ PROC_UNLOCK(p);
fasttrap_enable_callbacks();
+ PROC_LOCK(p);
/*
* Enable all the tracepoints and add this probe's id to each
@@ -967,8 +1057,12 @@ fasttrap_pid_enable(void *arg, dtrace_id
i--;
}
+#if defined(sun)
mutex_enter(&p->p_lock);
sprunlock(p);
+#else
+ PROC_UNLOCK(p);
+#endif
/*
* Since we're not actually enabling this probe,
@@ -978,9 +1072,12 @@ fasttrap_pid_enable(void *arg, dtrace_id
return;
}
}
-
+#if defined(sun)
mutex_enter(&p->p_lock);
sprunlock(p);
+#else
+ PROC_UNLOCK(p);
+#endif
probe->ftp_enabled = 1;
}
@@ -996,19 +1093,19 @@ fasttrap_pid_disable(void *arg, dtrace_i
ASSERT(id == probe->ftp_id);
+ mutex_enter(&provider->ftp_mtx);
+
/*
* We won't be able to acquire a /proc-esque lock on the process
* iff the process is dead and gone. In this case, we rely on the
* provider lock as a point of mutual exclusion to prevent other
* DTrace consumers from disabling this probe.
*/
- if ((p = sprlock(probe->ftp_pid)) != NULL) {
- ASSERT(!(p->p_flag & SVFORK));
- mutex_exit(&p->p_lock);
+ if ((p = pfind(probe->ftp_pid)) == NULL) {
+ mutex_exit(&provider->ftp_mtx);
+ return;
}
- mutex_enter(&provider->ftp_mtx);
-
/*
* Disable all the associated tracepoints (for fully enabled probes).
*/
@@ -1030,9 +1127,6 @@ fasttrap_pid_disable(void *arg, dtrace_i
if (provider->ftp_retired && !provider->ftp_marked)
whack = provider->ftp_marked = 1;
mutex_exit(&provider->ftp_mtx);
-
- mutex_enter(&p->p_lock);
- sprunlock(p);
} else {
/*
* If the process is dead, we're just waiting for the
@@ -1042,6 +1136,9 @@ fasttrap_pid_disable(void *arg, dtrace_i
whack = provider->ftp_marked = 1;
mutex_exit(&provider->ftp_mtx);
}
+#if !defined(sun)
+ PROC_UNLOCK(p);
+#endif
if (whack)
fasttrap_pid_cleanup();
@@ -1051,7 +1148,9 @@ fasttrap_pid_disable(void *arg, dtrace_i
probe->ftp_enabled = 0;
+#if defined(sun)
ASSERT(MUTEX_HELD(&cpu_lock));
+#endif
fasttrap_disable_callbacks();
}
@@ -1163,6 +1262,7 @@ fasttrap_proc_lookup(pid_t pid)
fasttrap_bucket_t *bucket;
fasttrap_proc_t *fprc, *new_fprc;
+
bucket = &fasttrap_procs.fth_table[FASTTRAP_PROCS_INDEX(pid)];
mutex_enter(&bucket->ftb_mtx);
@@ -1189,6 +1289,10 @@ fasttrap_proc_lookup(pid_t pid)
new_fprc->ftpc_pid = pid;
new_fprc->ftpc_rcount = 1;
new_fprc->ftpc_acount = 1;
+#if !defined(sun)
+ mutex_init(&new_fprc->ftpc_mtx, "fasttrap proc mtx", MUTEX_DEFAULT,
+ NULL);
+#endif
mutex_enter(&bucket->ftb_mtx);
@@ -1311,17 +1415,8 @@ fasttrap_provider_lookup(pid_t pid, cons
* Make sure the process exists, isn't a child created as the result
* of a vfork(2), and isn't a zombie (but may be in fork).
*/
- mutex_enter(&pidlock);
- if ((p = prfind(pid)) == NULL) {
- mutex_exit(&pidlock);
+ if ((p = pfind(pid)) == NULL)
return (NULL);
- }
- mutex_enter(&p->p_lock);
- mutex_exit(&pidlock);
- if (p->p_flag & (SVFORK | SEXITING)) {
- mutex_exit(&p->p_lock);
- return (NULL);
- }
/*
* Increment p_dtrace_probes so that the process knows to inform us
@@ -1334,15 +1429,18 @@ fasttrap_provider_lookup(pid_t pid, cons
* Grab the credentials for this process so we have
* something to pass to dtrace_register().
*/
- mutex_enter(&p->p_crlock);
- crhold(p->p_cred);
- cred = p->p_cred;
- mutex_exit(&p->p_crlock);
- mutex_exit(&p->p_lock);
+ PROC_LOCK_ASSERT(p, MA_OWNED);
+ crhold(p->p_ucred);
+ cred = p->p_ucred;
+ PROC_UNLOCK(p);
new_fp = kmem_zalloc(sizeof (fasttrap_provider_t), KM_SLEEP);
new_fp->ftp_pid = pid;
new_fp->ftp_proc = fasttrap_proc_lookup(pid);
+#if !defined(sun)
+ mutex_init(&new_fp->ftp_mtx, "provider mtx", MUTEX_DEFAULT, NULL);
+ mutex_init(&new_fp->ftp_cmtx, "lock on creating", MUTEX_DEFAULT, NULL);
+#endif
ASSERT(new_fp->ftp_proc != NULL);
@@ -1420,6 +1518,10 @@ fasttrap_provider_free(fasttrap_provider
fasttrap_proc_release(provider->ftp_proc);
+#if !defined(sun)
+ mutex_destroy(&provider->ftp_mtx);
+ mutex_destroy(&provider->ftp_cmtx);
+#endif
kmem_free(provider, sizeof (fasttrap_provider_t));
/*
@@ -1429,17 +1531,14 @@ fasttrap_provider_free(fasttrap_provider
* corresponds to this process's hash chain in the provider hash
* table. Don't sweat it if we can't find the process.
*/
- mutex_enter(&pidlock);
- if ((p = prfind(pid)) == NULL) {
- mutex_exit(&pidlock);
+ if ((p = pfind(pid)) == NULL) {
return;
}
- mutex_enter(&p->p_lock);
- mutex_exit(&pidlock);
-
p->p_dtrace_probes--;
- mutex_exit(&p->p_lock);
+#if !defined(sun)
+ PROC_UNLOCK(p);
+#endif
}
static void
@@ -1527,7 +1626,7 @@ fasttrap_add_probe(fasttrap_probe_spec_t
fasttrap_probe_t *pp;
fasttrap_tracepoint_t *tp;
char *name;
- int i, aframes, whack;
+ int i, aframes = 0, whack;
/*
* There needs to be at least one desired trace point.
@@ -1715,7 +1814,7 @@ fasttrap_meta_provide(void *arg, dtrace_
*/
if (strlen(dhpv->dthpv_provname) + 10 >=
sizeof (provider->ftp_name)) {
- cmn_err(CE_WARN, "failed to instantiate provider %s: "
+ printf("failed to instantiate provider %s: "
"name too long to accomodate pid", dhpv->dthpv_provname);
return (NULL);
}
@@ -1724,7 +1823,7 @@ fasttrap_meta_provide(void *arg, dtrace_
* Don't let folks spoof the true pid provider.
*/
if (strcmp(dhpv->dthpv_provname, FASTTRAP_PID_NAME) == 0) {
- cmn_err(CE_WARN, "failed to instantiate provider %s: "
+ printf("failed to instantiate provider %s: "
"%s is an invalid name", dhpv->dthpv_provname,
FASTTRAP_PID_NAME);
return (NULL);
@@ -1747,7 +1846,7 @@ fasttrap_meta_provide(void *arg, dtrace_
if ((provider = fasttrap_provider_lookup(pid, dhpv->dthpv_provname,
&dhpv->dthpv_pattr)) == NULL) {
- cmn_err(CE_WARN, "failed to instantiate provider %s for "
+ printf("failed to instantiate provider %s for "
"process %u", dhpv->dthpv_provname, (uint_t)pid);
return (NULL);
}
@@ -1908,15 +2007,21 @@ static dtrace_mops_t fasttrap_mops = {
/*ARGSUSED*/
static int
-fasttrap_open(dev_t *devp, int flag, int otyp, cred_t *cred_p)
+fasttrap_open(struct cdev *dev __unused, int oflags __unused,
+ int devtype __unused, struct thread *td __unused)
{
return (0);
}
/*ARGSUSED*/
static int
-fasttrap_ioctl(dev_t dev, int cmd, intptr_t arg, int md, cred_t *cr, int *rv)
+fasttrap_ioctl(struct cdev *dev, u_long cmd, caddr_t arg, int fflag,
+ struct thread *td)
{
+#ifdef notyet
+ struct kinfo_proc kp;
+ const cred_t *cr = td->td_ucred;
+#endif
if (!dtrace_attached())
return (EAGAIN);
@@ -1928,9 +2033,13 @@ fasttrap_ioctl(dev_t dev, int cmd, intpt
int ret;
char *c;
+#if defined(sun)
if (copyin(&uprobe->ftps_noffs, &noffs,
sizeof (uprobe->ftps_noffs)))
return (EFAULT);
+#else
+ noffs = uprobe->ftps_noffs;
+#endif
/*
* Probes must have at least one tracepoint.
@@ -1946,10 +2055,19 @@ fasttrap_ioctl(dev_t dev, int cmd, intpt
probe = kmem_alloc(size, KM_SLEEP);
+#if defined(sun)
if (copyin(uprobe, probe, size) != 0) {
kmem_free(probe, size);
return (EFAULT);
}
+#else
+ memcpy(probe, uprobe, sizeof(*probe));
+ if (noffs > 1 && copyin(uprobe + 1, probe + 1, size) != 0) {
+ kmem_free(probe, size);
+ return (EFAULT);
+ }
+#endif
+
/*
* Verify that the function and module strings contain no
@@ -1969,30 +2087,52 @@ fasttrap_ioctl(dev_t dev, int cmd, intpt
}
}
+#ifdef notyet
if (!PRIV_POLICY_CHOICE(cr, PRIV_ALL, B_FALSE)) {
proc_t *p;
pid_t pid = probe->ftps_pid;
+#if defined(sun)
mutex_enter(&pidlock);
+#endif
/*
* Report an error if the process doesn't exist
* or is actively being birthed.
*/
- if ((p = prfind(pid)) == NULL || p->p_stat == SIDL) {
+ p = pfind(pid);
+ if (p)
+ fill_kinfo_proc(p, &kp);
+ if (p == NULL || kp.ki_stat == SIDL) {
+#if defined(sun)
mutex_exit(&pidlock);
+#endif
return (ESRCH);
}
+#if defined(sun)
mutex_enter(&p->p_lock);
mutex_exit(&pidlock);
+#else
+ PROC_LOCK_ASSERT(p, MA_OWNED);
+#endif
+#ifdef notyet
if ((ret = priv_proc_cred_perm(cr, p, NULL,
VREAD | VWRITE)) != 0) {
+#if defined(sun)
mutex_exit(&p->p_lock);
+#else
+ PROC_UNLOCK(p);
+#endif
return (ret);
}
-
+#endif /* notyet */
+#if defined(sun)
mutex_exit(&p->p_lock);
+#else
+ PROC_UNLOCK(p);
+#endif
}
+#endif /* notyet */
ret = fasttrap_add_probe(probe);
err:
@@ -2004,35 +2144,62 @@ err:
fasttrap_instr_query_t instr;
fasttrap_tracepoint_t *tp;
uint_t index;
+#if defined(sun)
int ret;
+#endif
+#if defined(sun)
if (copyin((void *)arg, &instr, sizeof (instr)) != 0)
return (EFAULT);
+#endif
+#ifdef notyet
if (!PRIV_POLICY_CHOICE(cr, PRIV_ALL, B_FALSE)) {
proc_t *p;
pid_t pid = instr.ftiq_pid;
+#if defined(sun)
mutex_enter(&pidlock);
+#endif
/*
* Report an error if the process doesn't exist
* or is actively being birthed.
*/
- if ((p = prfind(pid)) == NULL || p->p_stat == SIDL) {
+ p = pfind(pid);
+ if (p)
+ fill_kinfo_proc(p, &kp);
+ if (p == NULL || kp.ki_stat == SIDL) {
+#if defined(sun)
mutex_exit(&pidlock);
+#endif
return (ESRCH);
*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
More information about the svn-src-user
mailing list