Skip to content

Commit

Permalink
Handle non-dtrace-triggered kernel breakpoint traps in mips.
Browse files Browse the repository at this point in the history
If DTRACE is enabled at compile time, all kernel breakpoint traps are
first given to dtrace to see if they are triggered by a FBT probe.
Previously if dtrace didn't recognize the trap, it was silently
ignored breaking the handling of other kernel breakpoint traps such as
the debug.kdb.enter sysctl.  This only returns early from the trap
handler if dtrace recognizes the trap and handles it.

Submitted by:	Nicolò Mazzucato <[email protected]>
Reviewed by:	markj
Obtained from:	CheriBSD
Differential Revision:	https://reviews.freebsd.org/D24478
  • Loading branch information
bsdjhb committed Apr 21, 2020
1 parent 0c01198 commit 5c4309b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 3 additions & 0 deletions sys/cddl/dev/dtrace/mips/dtrace_subr.c
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,9 @@ dtrace_invop_start(struct trapframe *frame)
int invop;

invop = dtrace_invop(frame->pc, frame, frame->pc);
if (invop == 0)
return (-1);

offs = (invop & LDSD_DATA_MASK);
sp = (register_t *)((uint8_t *)frame->sp + offs);

Expand Down
5 changes: 2 additions & 3 deletions sys/mips/mips/trap.c
Original file line number Diff line number Diff line change
Expand Up @@ -807,10 +807,9 @@ trap(struct trapframe *trapframe)
#if defined(KDTRACE_HOOKS) || defined(DDB)
case T_BREAK:
#ifdef KDTRACE_HOOKS
if (!usermode && dtrace_invop_jump_addr != 0) {
dtrace_invop_jump_addr(trapframe);
if (!usermode && dtrace_invop_jump_addr != NULL &&
dtrace_invop_jump_addr(trapframe) == 0)
return (trapframe->pc);
}
#endif
#ifdef DDB
kdb_trap(type, 0, trapframe);
Expand Down

0 comments on commit 5c4309b

Please sign in to comment.