The branch main has been updated by markj:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=d6f0e671d0797b56011880f84d12ce5fb20bf099

commit d6f0e671d0797b56011880f84d12ce5fb20bf099
Author:     Mark Johnston <[email protected]>
AuthorDate: 2026-05-20 14:49:28 +0000
Commit:     Mark Johnston <[email protected]>
CommitDate: 2026-05-20 14:49:28 +0000

    kinst/arm64: Fix return values from kinst_invop()
    
    After commit 853cd8723494 it became invalid for kinst_invop() to return
    0: dtrace_invop_start() would convert this to a sentinel value
    indicating that it did not consume the breakpoint, and so we'd just
    call kdb_trap() to handle it.
    
    Change kinst_invop() to return NOP_INSTR after handling a matching
    breakpoint.  NOP_INSTR is handled by advancing the ELR, so we have to
    compensate by subtracting INSTR_SIZE before returning.
    
    Reviewed by:    christos
    MFC after:      1 week
    Fixes:          853cd8723494 ("arm64: Clean up usage of the dtrace invop 
handler")
    Differential Revision:  https://reviews.freebsd.org/D56987
---
 sys/cddl/dev/kinst/aarch64/kinst_isa.c | 38 ++++++++++++++++++----------------
 1 file changed, 20 insertions(+), 18 deletions(-)

diff --git a/sys/cddl/dev/kinst/aarch64/kinst_isa.c 
b/sys/cddl/dev/kinst/aarch64/kinst_isa.c
index 20ca26219a55..1ccfe20b8dcb 100644
--- a/sys/cddl/dev/kinst/aarch64/kinst_isa.c
+++ b/sys/cddl/dev/kinst/aarch64/kinst_isa.c
@@ -18,7 +18,7 @@
 
 DPCPU_DEFINE_STATIC(struct kinst_cpu_state, kinst_state);
 
-static int
+static void
 kinst_emulate(struct trapframe *frame, const struct kinst_probe *kp)
 {
        kinst_patchval_t instr = kp->kp_savedval;
@@ -132,17 +132,13 @@ kinst_emulate(struct trapframe *frame, const struct 
kinst_probe *kp)
                else
                        frame->tf_elr += INSN_SIZE;
        }
-
-       return (0);
 }
 
 static int
 kinst_jump_next_instr(struct trapframe *frame, const struct kinst_probe *kp)
 {
-       frame->tf_elr = (register_t)((const uint8_t *)kp->kp_patchpoint +
-           INSN_SIZE);
-
-       return (0);
+       frame->tf_elr = (register_t)(uintptr_t)kp->kp_patchpoint;
+       return (NOP_INSTR);
 }
 
 static void
@@ -215,21 +211,27 @@ kinst_invop(uintptr_t addr, struct trapframe *frame, 
uintptr_t scratch)
        dtrace_probe(kp->kp_id, 0, 0, 0, 0, 0);
        cpu->cpu_dtrace_caller = 0;
 
-       if (kp->kp_md.emulate)
-               return (kinst_emulate(frame, kp));
+       if (kp->kp_md.emulate) {
+               kinst_emulate(frame, kp);
+       } else {
+               ks->state = KINST_PROBE_FIRED;
+               ks->kp = kp;
 
-       ks->state = KINST_PROBE_FIRED;
-       ks->kp = kp;
+               /*
+                * Cache the current SPSR and clear interrupts for the duration
+                * of the double breakpoint.
+                */
+               ks->status = frame->tf_spsr;
+               frame->tf_spsr |= PSR_I;
+               frame->tf_elr = (register_t)kp->kp_tramp;
+       }
 
        /*
-        * Cache the current SPSR and clear interrupts for the duration
-        * of the double breakpoint.
+        * NOP_INSTR is handled in dtrace_invop_start() by advancing the ELR, so
+        * compensate by subtracting INSTR_SIZE before returning.
         */
-       ks->status = frame->tf_spsr;
-       frame->tf_spsr |= PSR_I;
-       frame->tf_elr = (register_t)kp->kp_tramp;
-
-       return (0);
+       frame->tf_elr -= INSN_SIZE;
+       return (NOP_INSTR);
 }
 
 void

Reply via email to