summaryrefslogtreecommitdiffstats
path: root/sys/mips
diff options
context:
space:
mode:
authorgonzo <gonzo@FreeBSD.org>2012-03-24 05:17:38 +0000
committergonzo <gonzo@FreeBSD.org>2012-03-24 05:17:38 +0000
commit45fa45a9ccc39ab51aa7429912b55d8c7556bcf5 (patch)
treeca02bb891618fd7adf4321b26b9c363832c46fb9 /sys/mips
parentf3d75b9c280fcf4333f6d096a64f223d0ee98841 (diff)
downloadFreeBSD-src-45fa45a9ccc39ab51aa7429912b55d8c7556bcf5.zip
FreeBSD-src-45fa45a9ccc39ab51aa7429912b55d8c7556bcf5.tar.gz
Add DTrace-related part to machine-dependent code:
- DTrace trap handler - invop-related variables (unused on MIPS but still referenced from dtrace)
Diffstat (limited to 'sys/mips')
-rw-r--r--sys/mips/mips/exception.S21
-rw-r--r--sys/mips/mips/trap.c54
2 files changed, 75 insertions, 0 deletions
diff --git a/sys/mips/mips/exception.S b/sys/mips/mips/exception.S
index 34cf564..50da30b 100644
--- a/sys/mips/mips/exception.S
+++ b/sys/mips/mips/exception.S
@@ -55,6 +55,7 @@
*/
#include "opt_ddb.h"
+#include "opt_kdtrace.h"
#include <machine/asm.h>
#include <machine/cpu.h>
#include <machine/regnum.h>
@@ -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
*/
diff --git a/sys/mips/mips/trap.c b/sys/mips/mips/trap.c
index bfffd8b..f2b343a 100644
--- a/sys/mips/mips/trap.c
+++ b/sys/mips/mips/trap.c
@@ -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 <sys/param.h>
@@ -93,6 +94,33 @@ __FBSDID("$FreeBSD$");
#include <sys/kdb.h>
#endif
+#ifdef KDTRACE_HOOKS
+#include <sys/dtrace_bsd.h>
+
+/*
+ * 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,
OpenPOWER on IntegriCloud