From: Nam Cao <namcao@linutronix.de>
To: Xiaofeng Yuan <xiaofengmian@163.com>, pjw@kernel.org
Cc: palmer@dabbelt.com, aou@eecs.berkeley.edu,
linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org,
Xiaofeng Yuan <xiaofengmian@163.com>
Subject: Re: [PATCH v3] riscv: probes: simulate c.jal instruction
Date: Fri, 26 Jun 2026 09:41:54 +0200 [thread overview]
Message-ID: <87echtiw8t.fsf@yellow.woof> (raw)
In-Reply-To: <20260626062228.54873-1-xiaofengmian@163.com>
Xiaofeng Yuan <xiaofengmian@163.com> writes:
> diff --git a/arch/riscv/kernel/probes/decode-insn.c b/arch/riscv/kernel/probes/decode-insn.c
> index 65d9590bf..8506470e9 100644
> --- a/arch/riscv/kernel/probes/decode-insn.c
> +++ b/arch/riscv/kernel/probes/decode-insn.c
> @@ -29,7 +29,7 @@ riscv_probe_decode_insn(probe_opcode_t *addr, struct arch_probe_insn *api)
> * TODO: the REJECTED ones below need to be implemented
> */
> #ifdef CONFIG_RISCV_ISA_C
> - RISCV_INSN_REJECTED(c_jal, insn);
> + RISCV_INSN_SET_SIMULATE(c_jal, insn);
> RISCV_INSN_REJECTED(c_ebreak, insn);
Nit: move this RISCV_INSN_SET_SIMULATE down to be with the others.
> RISCV_INSN_SET_SIMULATE(c_j, insn);
> diff --git a/arch/riscv/kernel/probes/simulate-insn.c b/arch/riscv/kernel/probes/simulate-insn.c
> index fa581590c..6d7a5f949 100644
> --- a/arch/riscv/kernel/probes/simulate-insn.c
> +++ b/arch/riscv/kernel/probes/simulate-insn.c
> @@ -163,6 +163,14 @@ bool __kprobes simulate_c_j(u32 opcode, unsigned long addr, struct pt_regs *regs
> return true;
> }
>
> +bool __kprobes simulate_c_jal(u32 opcode, unsigned long addr, struct pt_regs *regs)
> +{
> + if (!rv_insn_reg_set_val(regs, 1, addr + 2))
> + return false;
rv_insn_reg_set_val() is a helper to change a register by index. But
it's always RA in this case, so I think it's much clearer to simply:
regs->ra = addr + 2;
(with the two above suggested changes, the patch would look identical to
a patch I have but I forgot to send, and I would be able to give my
Tested-by tag without additional effort from me :D)
Nam
prev parent reply other threads:[~2026-06-26 7:41 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-26 6:22 [PATCH v3] riscv: probes: simulate c.jal instruction Xiaofeng Yuan
2026-06-26 7:41 ` Nam Cao [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87echtiw8t.fsf@yellow.woof \
--to=namcao@linutronix.de \
--cc=aou@eecs.berkeley.edu \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=palmer@dabbelt.com \
--cc=pjw@kernel.org \
--cc=xiaofengmian@163.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox