aboutsummaryrefslogtreecommitdiffstats
path: root/arch/riscv/kernel
diff options
context:
space:
mode:
authorNam Cao <namcao@linutronix.de>2025-05-11 23:17:53 +0200
committerPaul Walmsley <pjw@kernel.org>2025-09-16 18:46:43 -0600
commit5fe59140276d94f1390d062f5643f852270f8d95 (patch)
treece20c5fa69144f2460da96e88b73420d0239bac6 /arch/riscv/kernel
parentraid6: riscv: replace one load with a move to speed up the caculation (diff)
downloadlinux-5fe59140276d94f1390d062f5643f852270f8d95.tar.gz
linux-5fe59140276d94f1390d062f5643f852270f8d95.zip
riscv: kprobes: Move branch_rs2_idx to insn.h
Similar to other instruction-processing macros/functions, branch_rs2_idx should be in insn.h. Move it into insn.h as RV_EXTRACT_RS2_REG. This new name matches the style in insn.h. Signed-off-by: Nam Cao <namcao@linutronix.de> Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com> Link: https://lore.kernel.org/linux-riscv/107d4a6c1818bf169be2407b273a0483e6d55bbb.1747215274.git.namcao@linutronix.de/ [pjw@kernel.org: updated to use RV_X_MASK and to apply] Signed-off-by: Paul Walmsley <pjw@kernel.org>
Diffstat (limited to 'arch/riscv/kernel')
-rw-r--r--arch/riscv/kernel/probes/simulate-insn.c5
1 files changed, 1 insertions, 4 deletions
diff --git a/arch/riscv/kernel/probes/simulate-insn.c b/arch/riscv/kernel/probes/simulate-insn.c
index 6c166029079c..77be381bb8b4 100644
--- a/arch/riscv/kernel/probes/simulate-insn.c
+++ b/arch/riscv/kernel/probes/simulate-insn.c
@@ -121,9 +121,6 @@ bool __kprobes simulate_auipc(u32 opcode, unsigned long addr, struct pt_regs *re
#define branch_rs1_idx(opcode) \
(((opcode) >> 15) & 0x1f)
-#define branch_rs2_idx(opcode) \
- (((opcode) >> 20) & 0x1f)
-
#define branch_funct3(opcode) \
(((opcode) >> 12) & 0x7)
@@ -157,7 +154,7 @@ bool __kprobes simulate_branch(u32 opcode, unsigned long addr, struct pt_regs *r
unsigned long rs2_val;
if (!rv_insn_reg_get_val(regs, branch_rs1_idx(opcode), &rs1_val) ||
- !rv_insn_reg_get_val(regs, branch_rs2_idx(opcode), &rs2_val))
+ !rv_insn_reg_get_val(regs, RV_EXTRACT_RS2_REG(opcode), &rs2_val))
return false;
offset_tmp = branch_offset(opcode);