From owner-svn-src-head@FreeBSD.ORG Sat Mar 24 05:17:39 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 47D13106566B; Sat, 24 Mar 2012 05:17:39 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 32DF38FC1A; Sat, 24 Mar 2012 05:17:39 +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 q2O5HdCm013972; Sat, 24 Mar 2012 05:17:39 GMT (envelope-from gonzo@svn.freebsd.org) Received: (from gonzo@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q2O5HcKa013968; Sat, 24 Mar 2012 05:17:38 GMT (envelope-from gonzo@svn.freebsd.org) Message-Id: <201203240517.q2O5HcKa013968@svn.freebsd.org> From: Oleksandr Tymoshenko Date: Sat, 24 Mar 2012 05:17:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r233412 - head/sys/mips/mips X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 24 Mar 2012 05:17:39 -0000 Author: gonzo Date: Sat Mar 24 05:17:38 2012 New Revision: 233412 URL: http://svn.freebsd.org/changeset/base/233412 Log: Add DTrace-related part to machine-dependent code: - DTrace trap handler - invop-related variables (unused on MIPS but still referenced from dtrace) Modified: head/sys/mips/mips/exception.S head/sys/mips/mips/trap.c Modified: head/sys/mips/mips/exception.S ============================================================================== --- head/sys/mips/mips/exception.S Sat Mar 24 05:16:26 2012 (r233411) +++ head/sys/mips/mips/exception.S Sat Mar 24 05:17:38 2012 (r233412) @@ -55,6 +55,7 @@ */ #include "opt_ddb.h" +#include "opt_kdtrace.h" #include #include #include @@ -65,6 +66,26 @@ .set noreorder # Noreorder is default style! +#ifdef KDTRACE_HOOKS + .data + .globl dtrace_invop_jump_addr + .align 4 + .type dtrace_invop_jump_addr, @object + .size dtrace_invop_jump_addr, 8 +dtrace_invop_jump_addr: + .word 0 + .word 0 + .globl dtrace_invop_calltrap_addr + .align 4 + .type dtrace_invop_calltrap_addr, @object + .size dtrace_invop_calltrap_addr, 8 +dtrace_invop_calltrap_addr: + .word 0 + .word 0 + + .text +#endif + /* * Reasonable limit */ Modified: head/sys/mips/mips/trap.c ============================================================================== --- head/sys/mips/mips/trap.c Sat Mar 24 05:16:26 2012 (r233411) +++ head/sys/mips/mips/trap.c Sat Mar 24 05:17:38 2012 (r233412) @@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$"); #include "opt_ddb.h" #include "opt_global.h" #include "opt_ktrace.h" +#include "opt_kdtrace.h" #define NO_REG_DEFS 1 /* Prevent asm.h from including regdef.h */ #include @@ -93,6 +94,33 @@ __FBSDID("$FreeBSD$"); #include #endif +#ifdef KDTRACE_HOOKS +#include + +/* + * This is a hook which is initialised by the dtrace module + * to handle traps which might occur during DTrace probe + * execution. + */ +dtrace_trap_func_t dtrace_trap_func; + +dtrace_doubletrap_func_t dtrace_doubletrap_func; + +/* + * This is a hook which is initialised by the systrace module + * when it is loaded. This keeps the DTrace syscall provider + * 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 + #ifdef TRAP_DEBUG int trap_debug = 0; SYSCTL_INT(_machdep, OID_AUTO, trap_debug, CTLFLAG_RW, @@ -529,6 +557,29 @@ trap(struct trapframe *trapframe) } } #endif + +#ifdef KDTRACE_HOOKS + /* + * A trap can occur while DTrace executes a probe. Before + * executing the probe, DTrace blocks re-scheduling and sets + * a flag in it's per-cpu flags to indicate that it doesn't + * want to fault. On returning from the probe, the no-fault + * flag is cleared and finally re-scheduling is enabled. + * + * If the DTrace kernel module has registered a trap handler, + * call it and if it returns non-zero, assume that it has + * handled the trap and modified the trap frame so that this + * function can return normally. + */ + /* + * XXXDTRACE: add fasttrap and pid probes handlers here (if ever) + */ + if (!usermode) { + if (dtrace_trap_func != NULL && (*dtrace_trap_func)(trapframe, type)) + return (trapframe->pc); + } +#endif + switch (type) { case T_MCHECK: #ifdef DDB @@ -633,6 +684,9 @@ dofault: PROC_LOCK(p); --p->p_lock; PROC_UNLOCK(p); + /* + * XXXDTRACE: add dtrace_doubletrap_func here? + */ #ifdef VMFAULT_TRACE printf("vm_fault(%p (pmap %p), %p (%p), %x, %d) -> %x at pc %p\n", map, &vm->vm_pmap, (void *)va, (void *)(intptr_t)trapframe->badvaddr,