From owner-svn-src-all@FreeBSD.ORG Thu Nov 24 18:44:09 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7C912106566B; Thu, 24 Nov 2011 18:44:09 +0000 (UTC) (envelope-from rstone@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 69B098FC15; Thu, 24 Nov 2011 18:44:09 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id pAOIi9JF007940; Thu, 24 Nov 2011 18:44:09 GMT (envelope-from rstone@svn.freebsd.org) Received: (from rstone@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id pAOIi9GI007932; Thu, 24 Nov 2011 18:44:09 GMT (envelope-from rstone@svn.freebsd.org) Message-Id: <201111241844.pAOIi9GI007932@svn.freebsd.org> From: Ryan Stone Date: Thu, 24 Nov 2011 18:44:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r227945 - in stable/9/sys: amd64/amd64 amd64/include cddl/contrib/opensolaris/uts/intel/dtrace i386/i386 i386/include X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Nov 2011 18:44:09 -0000 Author: rstone Date: Thu Nov 24 18:44:09 2011 New Revision: 227945 URL: http://svn.freebsd.org/changeset/base/227945 Log: MFC r227290 and r227291: r227290: Fix the DTrace pid return trap interrupt vector. Previously we were using 31, but that vector is reserved. Without this fix, running dtrace -p would either cause the target process to crash or the kernel to page fault r227291: Replace fasttrap_copyout() with uwrite(). FreeBSD copyout() is not able to write to the .text section of a process. Approved by: re (kib) Modified: stable/9/sys/amd64/amd64/trap.c stable/9/sys/amd64/include/segments.h stable/9/sys/amd64/include/trap.h stable/9/sys/cddl/contrib/opensolaris/uts/intel/dtrace/fasttrap_isa.c stable/9/sys/i386/i386/trap.c stable/9/sys/i386/include/segments.h stable/9/sys/i386/include/trap.h Directory Properties: stable/9/sys/ (props changed) stable/9/sys/amd64/include/xen/ (props changed) stable/9/sys/boot/ (props changed) stable/9/sys/boot/i386/efi/ (props changed) stable/9/sys/boot/ia64/efi/ (props changed) stable/9/sys/boot/ia64/ski/ (props changed) stable/9/sys/boot/powerpc/boot1.chrp/ (props changed) stable/9/sys/boot/powerpc/ofw/ (props changed) stable/9/sys/cddl/contrib/opensolaris/ (props changed) stable/9/sys/conf/ (props changed) stable/9/sys/contrib/dev/acpica/ (props changed) stable/9/sys/contrib/octeon-sdk/ (props changed) stable/9/sys/contrib/pf/ (props changed) stable/9/sys/contrib/x86emu/ (props changed) Modified: stable/9/sys/amd64/amd64/trap.c ============================================================================== --- stable/9/sys/amd64/amd64/trap.c Thu Nov 24 18:37:16 2011 (r227944) +++ stable/9/sys/amd64/amd64/trap.c Thu Nov 24 18:44:09 2011 (r227945) @@ -125,7 +125,7 @@ void dblfault_handler(struct trapframe * static int trap_pfault(struct trapframe *, int); static void trap_fatal(struct trapframe *, vm_offset_t); -#define MAX_TRAP_MSG 30 +#define MAX_TRAP_MSG 33 static char *trap_msg[] = { "", /* 0 unused */ "privileged instruction fault", /* 1 T_PRIVINFLT */ @@ -158,6 +158,9 @@ static char *trap_msg[] = { "machine check trap", /* 28 T_MCHK */ "SIMD floating-point exception", /* 29 T_XMMFLT */ "reserved (unknown) fault", /* 30 T_RESERVED */ + "", /* 31 unused (reserved) */ + "DTrace pid return trap", /* 32 T_DTRACE_RET */ + "DTrace fasttrap probe trap", /* 33 T_DTRACE_PROBE */ }; #ifdef KDB @@ -245,28 +248,26 @@ trap(struct trapframe *frame) * handled the trap and modified the trap frame so that this * function can return normally. */ - 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; - + fill_frame_regs(frame, ®s); if (type == T_DTRACE_PROBE && dtrace_fasttrap_probe_ptr != NULL && dtrace_fasttrap_probe_ptr(®s) == 0) - goto out; - if (type == T_BPTFLT && + goto out; + else if (type == T_BPTFLT && dtrace_pid_probe_ptr != NULL && dtrace_pid_probe_ptr(®s) == 0) - goto out; - if (type == T_DTRACE_RET && + goto out; + else if (type == T_DTRACE_RET && dtrace_return_probe_ptr != NULL && dtrace_return_probe_ptr(®s) == 0) goto out; - } + if (dtrace_trap_func != NULL && (*dtrace_trap_func)(frame, type)) + goto out; #endif if ((frame->tf_rflags & PSL_I) == 0) { Modified: stable/9/sys/amd64/include/segments.h ============================================================================== --- stable/9/sys/amd64/include/segments.h Thu Nov 24 18:37:16 2011 (r227944) +++ stable/9/sys/amd64/include/segments.h Thu Nov 24 18:44:09 2011 (r227945) @@ -214,7 +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 */ +#define IDT_DTRACE_RET 0x20 /* DTrace pid provider Interrupt Vector */ /* * Entries in the Global Descriptor Table (GDT) Modified: stable/9/sys/amd64/include/trap.h ============================================================================== --- stable/9/sys/amd64/include/trap.h Thu Nov 24 18:37:16 2011 (r227944) +++ stable/9/sys/amd64/include/trap.h Thu Nov 24 18:44:09 2011 (r227945) @@ -62,8 +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 */ +#define T_DTRACE_RET 32 /* DTrace pid return */ +#define T_DTRACE_PROBE 33 /* DTrace fasttrap probe */ /* XXX most of the following codes aren't used, but could be. */ Modified: stable/9/sys/cddl/contrib/opensolaris/uts/intel/dtrace/fasttrap_isa.c ============================================================================== --- stable/9/sys/cddl/contrib/opensolaris/uts/intel/dtrace/fasttrap_isa.c Thu Nov 24 18:37:16 2011 (r227944) +++ stable/9/sys/cddl/contrib/opensolaris/uts/intel/dtrace/fasttrap_isa.c Thu Nov 24 18:44:09 2011 (r227945) @@ -97,7 +97,7 @@ uwrite(proc_t *p, void *kaddr, size_t le return (proc_ops(UIO_WRITE, p, kaddr, uaddr, len)); } -#endif +#endif /* sun */ #ifdef __i386__ #define r_rax r_eax #define r_rbx r_ebx @@ -1380,6 +1380,7 @@ fasttrap_pid_probe(struct reg *rp) { int ret = 0; uintptr_t addr = 0; + #ifdef __amd64 if (p->p_model == DATAMODEL_NATIVE) { addr = rp->r_rsp - sizeof (uintptr_t); @@ -1558,7 +1559,7 @@ fasttrap_pid_probe(struct reg *rp) * ------------------------ ----- * a: <= 15 * jmp ftt_size> 5 - * b: <= 15 + * b: <= 15 * int T_DTRACE_RET 2 * ----- * <= 37 @@ -1731,12 +1732,16 @@ fasttrap_pid_probe(struct reg *rp) ASSERT(i <= sizeof (scratch)); + +#if defined(sun) if (fasttrap_copyout(scratch, (char *)addr, i)) { +#else + if (uwrite(curproc, scratch, i, addr)) { +#endif fasttrap_sigtrap(p, curthread, pc); new_pc = pc; break; } - if (tp->ftt_retids != NULL) { curthread->t_dtrace_step = 1; curthread->t_dtrace_ret = 1; Modified: stable/9/sys/i386/i386/trap.c ============================================================================== --- stable/9/sys/i386/i386/trap.c Thu Nov 24 18:37:16 2011 (r227944) +++ stable/9/sys/i386/i386/trap.c Thu Nov 24 18:44:09 2011 (r227945) @@ -136,7 +136,7 @@ void dblfault_handler(void); extern inthand_t IDTVEC(lcall_syscall); -#define MAX_TRAP_MSG 30 +#define MAX_TRAP_MSG 33 static char *trap_msg[] = { "", /* 0 unused */ "privileged instruction fault", /* 1 T_PRIVINFLT */ @@ -169,6 +169,10 @@ static char *trap_msg[] = { "machine check trap", /* 28 T_MCHK */ "SIMD floating-point exception", /* 29 T_XMMFLT */ "reserved (unknown) fault", /* 30 T_RESERVED */ + "", /* 31 unused (reserved) */ + "DTrace pid return trap", /* 32 T_DTRACE_RET */ + "DTrace fasttrap probe trap", /* 33 T_DTRACE_PROBE */ + }; #if defined(I586_CPU) && !defined(NO_F00F_HACK) @@ -265,10 +269,6 @@ trap(struct trapframe *frame) * handled the trap and modified the trap frame so that this * function can return normally. */ - if ((type == T_PROTFLT || type == T_PAGEFLT) && - 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; @@ -287,6 +287,9 @@ trap(struct trapframe *frame) dtrace_return_probe_ptr(®s) == 0) goto out; } + if ((type == T_PROTFLT || type == T_PAGEFLT) && + dtrace_trap_func != NULL && (*dtrace_trap_func)(frame, type)) + goto out; #endif if ((frame->tf_eflags & PSL_I) == 0) { Modified: stable/9/sys/i386/include/segments.h ============================================================================== --- stable/9/sys/i386/include/segments.h Thu Nov 24 18:37:16 2011 (r227944) +++ stable/9/sys/i386/include/segments.h Thu Nov 24 18:44:09 2011 (r227945) @@ -207,7 +207,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 */ +#define IDT_DTRACE_RET 0x20 /* DTrace pid provider Interrupt Vector */ /* * Entries in the Global Descriptor Table (GDT) Modified: stable/9/sys/i386/include/trap.h ============================================================================== --- stable/9/sys/i386/include/trap.h Thu Nov 24 18:37:16 2011 (r227944) +++ stable/9/sys/i386/include/trap.h Thu Nov 24 18:44:09 2011 (r227945) @@ -62,8 +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 */ +#define T_DTRACE_RET 32 /* DTrace pid return */ +#define T_DTRACE_PROBE 33 /* DTrace fasttrap probe */ /* XXX most of the following codes aren't used, but could be. */