[PATCH 1/2] riscv: kprobes: simulate nop and c.nop instructions

Nam Cao namcao at linutronix.de
Wed Aug 19 04:54:30 PDT 2026


Xiaofeng Yuan <yuanxiaofeng at eswincomputing.com> writes:

> nop and c.nop have no architectural effect, so allocating an
> out-of-line instruction slot and single-stepping through them is
> pure overhead. Simulate them directly in the breakpoint handler
> by advancing the program counter, following the approach already
> used on arm64.
>
> This avoids slot allocation, text patching, IRQ flag save/restore
> and the single-step exception for these instructions.
>
> Compile tested on RISC-V, and verified with the RISC-V kprobes
> KUnit test which now covers nop and c.nop.

For RISC-V, how common is installing probes on nop instructions?

Looking at the commit adding nop simulation on Arm, I see it is useful
for probes on USDT. Is this also the case for RISC-V?

Additionally, it would be great if there is a benchmark to justify
adding this.

Nam



More information about the linux-riscv mailing list