Date: Mon, 7 Jan 2008 07:22:27 GMT From: John Birrell <jb@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 132678 for review Message-ID: <200801070722.m077MRtB021840@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=132678 Change 132678 by jb@jb_freebsd1 on 2008/01/07 07:21:49 Add the hook to allow the dtrace module to process breakpoint interrupts if it is loaded. The Function Boundary Trace (fbt) and Statically Defined Trace (sdt) providers trigger probes on amd64 by replacing the "pushl %ebp" and 'ret' opcodes with int3 (#BP, 0xcc) and then checking the trap address against the list of installed probes. If the address has a probe associated with it, the dtrace module calls it's probes and the function that was broken by the breakpoint, then repairs the trap frame and returns via 'doreti'. In the case that the trap address isn't from a DTrace probe, the return path takes execution back to the calltrap code and the trap is handled in the usual way. No doubt there is a simpler way to do this pointer ping pong. Affected files ... .. //depot/projects/dtrace/src/sys/amd64/amd64/exception.S#7 edit Differences ... ==== //depot/projects/dtrace/src/sys/amd64/amd64/exception.S#7 (text+ko) ==== @@ -37,6 +37,7 @@ #include "opt_atpic.h" #include "opt_compat.h" #include "opt_hwpmc_hooks.h" +#include "opt_kdtrace.h" #include <machine/asmacros.h> #include <machine/psl.h> @@ -44,6 +45,27 @@ #include "assym.s" +#ifdef KDTRACE_HOOKS + .bss + .globl dtrace_invop_jump_addr + .align 8 + .type dtrace_invop_jump_addr, @object + .size dtrace_invop_jump_addr, 8 +dtrace_invop_jump_addr: + .zero 8 + .globl dtrace_invop_calltrap_addr + .align 8 + .type dtrace_invop_calltrap_addr, @object + .size dtrace_invop_calltrap_addr, 8 +dtrace_invop_calltrap_addr: + .zero 8 + .globl dtrace_invop_return_addr + .align 8 + .type dtrace_invop_return_addr, @object + .size dtrace_invop_return_addr, 8 +dtrace_invop_return_addr: + .zero 8 +#endif .text #ifdef HWPMC_HOOKS ENTRY(start_exceptions) @@ -170,6 +192,28 @@ movq %r14,TF_R14(%rsp) movq %r15,TF_R15(%rsp) FAKE_MCOUNT(TF_RIP(%rsp)) +#ifdef KDTRACE_HOOKS + /* + * DTrace Function Boundary Trace (fbt) and Statically Defined + * Trace (sdt) probes are triggered by int3 (0xcc) which causes + * the #BP (T_BPTFLT) breakpoint interrupt. For all other trap + * types, just handle them in the usual way. + */ + cmpq $T_BPTFLT,TF_TRAPNO(%rsp) + jne calltrap + + /* Check if there is no DTrace hook registered. */ + cmpq $0,dtrace_invop_jump_addr + je calltrap + + /* Set our alternate jump addresses for the jump back. */ + movq $calltrap, dtrace_invop_calltrap_addr(%rip) + movq $doreti, dtrace_invop_return_addr(%rip) + + /* Jump to the code hooked in by DTrace. */ + movq dtrace_invop_jump_addr, %rax + jmpq *dtrace_invop_jump_addr +#endif .globl calltrap .type calltrap,@function calltrap:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200801070722.m077MRtB021840>