Commit 05ede658 authored by Nam Cao's avatar Nam Cao Committed by Paul Walmsley
Browse files

riscv: kprobes: Remove duplication of RVC_EXTRACT_JTYPE_IMM



Use RVC_EXTRACT_JTYPE_IMM, instead of reimplementing it in simulate_c_j().

Signed-off-by: default avatarNam Cao <namcao@linutronix.de>
Reviewed-by: default avatarAlexandre Ghiti <alexghiti@rivosinc.com>
Link: https://lore.kernel.org/linux-riscv/24497deaab06d6b12cb84923606ec26f67e25424.1747215274.git.namcao@linutronix.de/


[pjw@kernel.org: fixed subject line typo]
Signed-off-by: default avatarPaul Walmsley <pjw@kernel.org>
parent 76494817
Loading
Loading
Loading
Loading
+2 −17
Original line number Diff line number Diff line
@@ -170,24 +170,9 @@ bool __kprobes simulate_branch(u32 opcode, unsigned long addr, struct pt_regs *r

bool __kprobes simulate_c_j(u32 opcode, unsigned long addr, struct pt_regs *regs)
{
	/*
	 *  15    13 12                            2 1      0
	 * | funct3 | offset[11|4|9:8|10|6|7|3:1|5] | opcode |
	 *     3                   11                    2
	 */

	s32 offset;
	s32 offset = RVC_EXTRACT_JTYPE_IMM(opcode);

	offset  = ((opcode >> 3)  & 0x7) << 1;
	offset |= ((opcode >> 11) & 0x1) << 4;
	offset |= ((opcode >> 2)  & 0x1) << 5;
	offset |= ((opcode >> 7)  & 0x1) << 6;
	offset |= ((opcode >> 6)  & 0x1) << 7;
	offset |= ((opcode >> 9)  & 0x3) << 8;
	offset |= ((opcode >> 8)  & 0x1) << 10;
	offset |= ((opcode >> 12) & 0x1) << 11;

	instruction_pointer_set(regs, addr + sign_extend32(offset, 11));
	instruction_pointer_set(regs, addr + offset);

	return true;
}