git: facd3a41d9d1 - stable/13 - dtrace: use dtrace_instr_size() in the riscv dtrace_subr.c

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Sun, 07 May 2023 17:59:54 UTC
The branch stable/13 has been updated by markj:

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

commit facd3a41d9d1d27a2cd96ba855fc73b702caa3db
Author:     Christos Margiolis <christos@FreeBSD.org>
AuthorDate: 2023-04-20 16:24:03 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2023-05-07 17:54:08 +0000

    dtrace: use dtrace_instr_size() in the riscv dtrace_subr.c
    
    No functional change intended.
    
    Reviewed by:    mhorne, markj
    MFC after:      1 week
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D39652
    
    (cherry picked from commit 75081b9ed8e67c8443551828f1b5ccf3d449b41b)
---
 sys/cddl/dev/dtrace/riscv/dtrace_subr.c | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/sys/cddl/dev/dtrace/riscv/dtrace_subr.c b/sys/cddl/dev/dtrace/riscv/dtrace_subr.c
index f32bb3a2343e..3d43adb8a92f 100644
--- a/sys/cddl/dev/dtrace/riscv/dtrace_subr.c
+++ b/sys/cddl/dev/dtrace/riscv/dtrace_subr.c
@@ -190,8 +190,6 @@ dtrace_gethrestime(void)
 int
 dtrace_trap(struct trapframe *frame, u_int type)
 {
-	uint16_t insn;
-
 	/*
 	 * A trap can occur while DTrace executes a probe. Before
 	 * executing the probe, DTrace blocks re-scheduling and sets
@@ -219,15 +217,10 @@ dtrace_trap(struct trapframe *frame, u_int type)
 
 			/*
 			 * Offset the instruction pointer to the instruction
-			 * following the one causing the fault. Check if the
-			 * instruction is compressed or not. Standard
-			 * instructions always have bits [1:0] == 11.
+			 * following the one causing the fault.
 			 */
-			insn = *(uint16_t *)frame->tf_sepc;
-			if (match_opcode(insn, 0x3, 0x3))
-				frame->tf_sepc += INSN_SIZE;
-			else
-				frame->tf_sepc += INSN_C_SIZE;
+			frame->tf_sepc +=
+			    dtrace_instr_size((uint8_t *)frame->tf_sepc);
 
 			return (1);
 		default: