svn commit: r268869 - in head/sys: amd64/amd64 cddl/dev/dtrace/amd64 cddl/dev/fbt
Mark Johnston
markj at FreeBSD.org
Sat Jul 19 02:27:33 UTC 2014
Author: markj
Date: Sat Jul 19 02:27:31 2014
New Revision: 268869
URL: http://svnweb.freebsd.org/changeset/base/268869
Log:
Use a C wrapper for trap() instead of checking and calling the DTrace trap
hook in assembly.
Suggested by: kib
Reviewed by: kib (original version)
X-MFC-With: r268600
Modified:
head/sys/amd64/amd64/exception.S
head/sys/amd64/amd64/trap.c
head/sys/cddl/dev/dtrace/amd64/dtrace_subr.c
head/sys/cddl/dev/fbt/fbt.c
Modified: head/sys/amd64/amd64/exception.S
==============================================================================
--- head/sys/amd64/amd64/exception.S Sat Jul 19 02:15:28 2014 (r268868)
+++ head/sys/amd64/amd64/exception.S Sat Jul 19 02:27:31 2014 (r268869)
@@ -228,24 +228,7 @@ alltraps_pushregs_no_rdi:
.type calltrap, at function
calltrap:
movq %rsp,%rdi
-#ifdef KDTRACE_HOOKS
- /*
- * Give DTrace a chance to vet this trap and skip the call to trap() if
- * it turns out that it was caused by a DTrace probe.
- */
- movq dtrace_trap_func,%rax
- testq %rax,%rax
- je skiphook
- call *%rax
- testq %rax,%rax
- jne skiptrap
- movq %rsp,%rdi
-skiphook:
-#endif
- call trap
-#ifdef KDTRACE_HOOKS
-skiptrap:
-#endif
+ call trap_check
MEXITCOUNT
jmp doreti /* Handle any pending ASTs */
Modified: head/sys/amd64/amd64/trap.c
==============================================================================
--- head/sys/amd64/amd64/trap.c Sat Jul 19 02:15:28 2014 (r268868)
+++ head/sys/amd64/amd64/trap.c Sat Jul 19 02:27:31 2014 (r268869)
@@ -97,7 +97,8 @@ PMC_SOFT_DEFINE( , , page_fault, write);
#include <sys/dtrace_bsd.h>
#endif
-extern void trap(struct trapframe *frame);
+extern void __noinline trap(struct trapframe *frame);
+extern void trap_check(struct trapframe *frame);
extern void syscall(struct trapframe *frame);
void dblfault_handler(struct trapframe *frame);
@@ -604,6 +605,19 @@ out:
return;
}
+/*
+ * Ensure that we ignore any DTrace-induced faults. This function cannot
+ * be instrumented, so it cannot generate such faults itself.
+ */
+void
+trap_check(struct trapframe *frame)
+{
+
+ if (dtrace_trap_func != NULL && (*dtrace_trap_func)(frame))
+ return;
+ trap(frame);
+}
+
static int
trap_pfault(frame, usermode)
struct trapframe *frame;
Modified: head/sys/cddl/dev/dtrace/amd64/dtrace_subr.c
==============================================================================
--- head/sys/cddl/dev/dtrace/amd64/dtrace_subr.c Sat Jul 19 02:15:28 2014 (r268868)
+++ head/sys/cddl/dev/dtrace/amd64/dtrace_subr.c Sat Jul 19 02:27:31 2014 (r268869)
@@ -462,9 +462,7 @@ dtrace_gethrestime(void)
return (current_time.tv_sec * 1000000000ULL + current_time.tv_nsec);
}
-/*
- * Function to handle DTrace traps during probes. See amd64/amd64/exception.S.
- */
+/* Function to handle DTrace traps during probes. See amd64/amd64/trap.c. */
int
dtrace_trap(struct trapframe *frame)
{
Modified: head/sys/cddl/dev/fbt/fbt.c
==============================================================================
--- head/sys/cddl/dev/fbt/fbt.c Sat Jul 19 02:15:28 2014 (r268868)
+++ head/sys/cddl/dev/fbt/fbt.c Sat Jul 19 02:27:31 2014 (r268869)
@@ -232,13 +232,18 @@ fbt_provide_module_function(linker_file_
int size;
u_int8_t *instr, *limit;
- if (strncmp(name, "dtrace_", 7) == 0 &&
- strncmp(name, "dtrace_safe_", 12) != 0) {
+ if ((strncmp(name, "dtrace_", 7) == 0 &&
+ strncmp(name, "dtrace_safe_", 12) != 0) ||
+ strcmp(name, "trap_check") == 0) {
/*
* Anything beginning with "dtrace_" may be called
* from probe context unless it explicitly indicates
* that it won't be called from probe context by
* using the prefix "dtrace_safe_".
+ *
+ * Additionally, we avoid instrumenting trap_check() to avoid
+ * the possibility of generating a fault in probe context before
+ * DTrace's fault handler is called.
*/
return (0);
}
More information about the svn-src-all
mailing list