diff options
author | Mark Johnston <markj@FreeBSD.org> | 2014-07-14 04:38:17 +0000 |
---|---|---|
committer | Mark Johnston <markj@FreeBSD.org> | 2014-07-14 04:38:17 +0000 |
commit | 291624fdf61dc70790e695364293821ee89063b9 (patch) | |
tree | f6f00a8ecef69c372df2dbabbd94de9a70811897 /sys/amd64 | |
parent | 1dd381bf67d451a93b36683fad35473976327170 (diff) | |
download | src-291624fdf61dc70790e695364293821ee89063b9.tar.gz src-291624fdf61dc70790e695364293821ee89063b9.zip |
Invoke the DTrace trap handler before calling trap() on amd64. This matches
the upstream implementation and helps ensure that a trap induced by tracing
fbt::trap:entry is handled without recursively generating another trap.
This makes it possible to run most (but not all) of the DTrace tests under
common/safety/ without triggering a kernel panic.
Submitted by: Anton Rang <anton.rang@isilon.com> (original version)
Phabric: D95
Notes
Notes:
svn path=/head/; revision=268600
Diffstat (limited to 'sys/amd64')
-rw-r--r-- | sys/amd64/amd64/exception.S | 17 | ||||
-rw-r--r-- | sys/amd64/amd64/trap.c | 12 |
2 files changed, 17 insertions, 12 deletions
diff --git a/sys/amd64/amd64/exception.S b/sys/amd64/amd64/exception.S index d51078dd1808..bb5fd5669e74 100644 --- a/sys/amd64/amd64/exception.S +++ b/sys/amd64/amd64/exception.S @@ -228,7 +228,24 @@ alltraps_pushregs_no_rdi: .type calltrap,@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 MEXITCOUNT jmp doreti /* Handle any pending ASTs */ diff --git a/sys/amd64/amd64/trap.c b/sys/amd64/amd64/trap.c index c56b99e434b1..d9203bc5e7c8 100644 --- a/sys/amd64/amd64/trap.c +++ b/sys/amd64/amd64/trap.c @@ -218,18 +218,6 @@ trap(struct trapframe *frame) goto out; } -#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 its 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 (dtrace_trap_func != NULL && (*dtrace_trap_func)(frame, type)) - goto out; -#endif - if ((frame->tf_rflags & PSL_I) == 0) { /* * Buggy application or kernel code has disabled |