All of lore.kernel.org
 help / color / mirror / Atom feed
From: Xiaofeng Yuan <yuanxiaofeng@eswincomputing.com>
To: Paul Walmsley <pjw@kernel.org>, Palmer Dabbelt <palmer@dabbelt.com>
Cc: Albert Ou <aou@eecs.berkeley.edu>, Nam Cao <namcaov@gmail.com>,
	linux-riscv@lists.infradead.org, yuanxiaofeng@eswincomputing.com
Subject: [PATCH 0/2] riscv: kprobes: simulate nop and c.nop instructions
Date: Wed, 19 Aug 2026 18:14:17 +0800	[thread overview]
Message-ID: <20260819101419.1367-1-yuanxiaofeng@eswincomputing.com> (raw)

nop and c.nop have no architectural effect, so handling them through
an out-of-line instruction slot and single-stepping is pure overhead.
This series simulates them directly in the breakpoint handler by
advancing the program counter, following the approach already used on
arm64, and extends the RISC-V kprobes KUnit test to cover both paths.

Patch 1 adds the simulation. Patch 2 extends the KUnit test with
test_kprobes_nop and test_kprobes_c_nop.

Verified by cross-compiling for RISC-V and running the kprobes KUnit
test in QEMU (ok 1 kprobes_riscv).

Xiaofeng Yuan (2):
  riscv: kprobes: simulate nop and c.nop instructions
  riscv: kprobes: add nop and c.nop to the KUnit test

 arch/riscv/include/asm/insn.h                 | 11 ++++++++
 arch/riscv/kernel/probes/decode-insn.c        |  6 +++++
 arch/riscv/kernel/probes/simulate-insn.c      | 14 ++++++++++
 arch/riscv/kernel/probes/simulate-insn.h      |  2 ++
 .../kernel/tests/kprobes/test-kprobes-asm.S   | 27 +++++++++++++++++++
 5 files changed, 60 insertions(+)

-- 
2.43.0


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

             reply	other threads:[~2026-08-19 10:14 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-19 10:14 Xiaofeng Yuan [this message]
2026-08-19 10:14 ` [PATCH 1/2] riscv: kprobes: simulate nop and c.nop instructions Xiaofeng Yuan
2026-08-19 11:54   ` Nam Cao
2026-08-19 10:14 ` [PATCH 2/2] riscv: kprobes: add nop and c.nop to the KUnit test Xiaofeng Yuan
2026-08-19 11:58   ` Nam Cao
  -- strict thread matches above, loose matches on Subject: below --
2026-08-19 10:26 [PATCH 0/2] riscv: kprobes: simulate nop and c.nop instructions Xiaofeng Yuan

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=20260819101419.1367-1-yuanxiaofeng@eswincomputing.com \
    --to=yuanxiaofeng@eswincomputing.com \
    --cc=aou@eecs.berkeley.edu \
    --cc=linux-riscv@lists.infradead.org \
    --cc=namcaov@gmail.com \
    --cc=palmer@dabbelt.com \
    --cc=pjw@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.