Author: jhb
Date: Tue Apr 21 17:38:07 2020
New Revision: 360168
URL: https://svnweb.freebsd.org/changeset/base/360168

Log:
  Handle non-dtrace-triggered kernel breakpoint traps in mips.
  
  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 <nicomaz...@gmail.com>
  Reviewed by:  markj
  Obtained from:        CheriBSD
  Differential Revision:        https://reviews.freebsd.org/D24478

Modified:
  head/sys/cddl/dev/dtrace/mips/dtrace_subr.c
  head/sys/mips/mips/trap.c

Modified: head/sys/cddl/dev/dtrace/mips/dtrace_subr.c
==============================================================================
--- head/sys/cddl/dev/dtrace/mips/dtrace_subr.c Tue Apr 21 17:32:57 2020        
(r360167)
+++ head/sys/cddl/dev/dtrace/mips/dtrace_subr.c Tue Apr 21 17:38:07 2020        
(r360168)
@@ -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);
 

Modified: head/sys/mips/mips/trap.c
==============================================================================
--- head/sys/mips/mips/trap.c   Tue Apr 21 17:32:57 2020        (r360167)
+++ head/sys/mips/mips/trap.c   Tue Apr 21 17:38:07 2020        (r360168)
@@ -807,10 +807,9 @@ dofault:
 #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);
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to