Skip to content

Commit 7843b48

Browse files
covanamPaul Walmsley
authored andcommitted
riscv: kprobes: Remove duplication of RV_EXTRACT_UTYPE_IMM
Use RV_EXTRACT_UTYPE_IMM, instead of reimplementing it in simulate_auipc(). Signed-off-by: Nam Cao <namcao@linutronix.de> Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com> Link: https://lore.kernel.org/linux-riscv/8f0defce9f1f23f1b44bb9750ed083cfc124213c.1747215274.git.namcao@linutronix.de/ Signed-off-by: Paul Walmsley <pjw@kernel.org>
1 parent e333496 commit 7843b48

File tree

1 file changed

+1
-12
lines changed

1 file changed

+1
-12
lines changed

arch/riscv/kernel/probes/simulate-insn.c

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -81,17 +81,6 @@ bool __kprobes simulate_jalr(u32 opcode, unsigned long addr, struct pt_regs *reg
8181
return ret;
8282
}
8383

84-
#define auipc_imm(opcode) \
85-
((((opcode) >> 12) & 0xfffff) << 12)
86-
87-
#if __riscv_xlen == 64
88-
#define auipc_offset(opcode) sign_extend64(auipc_imm(opcode), 31)
89-
#elif __riscv_xlen == 32
90-
#define auipc_offset(opcode) auipc_imm(opcode)
91-
#else
92-
#error "Unexpected __riscv_xlen"
93-
#endif
94-
9584
bool __kprobes simulate_auipc(u32 opcode, unsigned long addr, struct pt_regs *regs)
9685
{
9786
/*
@@ -102,7 +91,7 @@ bool __kprobes simulate_auipc(u32 opcode, unsigned long addr, struct pt_regs *re
10291
*/
10392

10493
u32 rd_idx = RV_EXTRACT_RD_REG(opcode);
105-
unsigned long rd_val = addr + auipc_offset(opcode);
94+
unsigned long rd_val = addr + (s32)RV_EXTRACT_UTYPE_IMM(opcode);
10695

10796
if (!rv_insn_reg_set_val(regs, rd_idx, rd_val))
10897
return false;

0 commit comments

Comments
 (0)