[PATCH 04/16] riscv: kprobes: Use generated instruction headers

Nam Cao namcao at linutronix.de
Wed Jun 10 23:14:27 PDT 2026


Charlie Jenkins via B4 Relay
<devnull+thecharlesjenkins.gmail.com at kernel.org> writes:
>  bool __kprobes simulate_c_jr(u32 opcode, unsigned long addr, struct pt_regs *regs)
>  {
> -	return simulate_c_jr_jalr(opcode, addr, regs, false);
> +	unsigned long next_addr;
> +	unsigned long *regs_ptr = (unsigned long *)regs;
> +
> +	next_addr = regs_ptr[riscv_insn_c_jr_extract_xs1(opcode)];
> +	instruction_pointer_set(regs, next_addr);
> +
> +	regs->ra = addr + 2;

c.jr does not change ra.

> +	return true;
>  }

We have CONFIG_RISCV_KPROBES_KUNIT now, please try that.

Nam



More information about the linux-riscv mailing list