v8 2026-11-07

RISC-V 硬件断点观察点 · v8

基于 perf/ptrace 和 SBI Sdtrig 扩展为 RISC-V 增加硬件断点/观察点,单步优先使用 icount,不可用时回退到软件单步。

原始补丁链接

子 Patch(8)

1/8
riscv: Introduce support for hardware break/watchpoints
[riscv: Introduce support for hardware break/watchpoints] [patchwork series v8] submitter=Himanshu Chauhan patches (8): [v8,1/8] riscv: Introduce support for hardware break/watchpoints [v8,2/8] ri
2/8
riscv: Add breakpoint and watchpoint test for riscv
Add self test for riscv architecture. It uses ptrace to ptrace framework to set/unset break/watchpoint and uses signals to check triggers. Also add $(KHDR_INCLUDES) to CFLAGS for the riscv test build
3/8
riscv: add ptrace requests for hardware breakpoints
Add support for the RISC-V PTRACE_GETHBPREGS and PTRACE_SETHBPREGS requests. A tracer can use these requests to read or program one hardware breakpoint or watchpoint slot at a time. Store the ptrace-
4/8
riscv: add regset access for hardware breakpoints
Add NT_RISCV_HW_BREAK and NT_RISCV_HW_WATCH. A tracer can use PTRACE_GETREGSET and PTRACE_SETREGSET to read or program the RISC-V hardware breakpoint and watchpoint slots. The regset layout uses fixe
5/8
selftests/breakpoints: extend riscv test for ptrace hw break/watchpoints
Cover the new ptrace-based hardware breakpoint/watchpoint support added for riscv: exercise the PTRACE_GETREGSET/SETREGSET regset path as well as the raw PTRACE_GETHBPREGS/SETHBPREGS interface, alongs
6/8
riscv: Add shared instruction fetch and decode helpers
Move get_insn() and __read_insn() out of traps_misaligned.c so breakpoint single-step code can share the instruction fetch logic. Add helpers to read GPR values and compute the next RISC-V PC for con
7/8
riscv: Add software supported single stepping with mc/mc6 triggers
With mc/mc6 triggers, after handling breakpoint at current pc, there is no way to tell trigger to skip same breakpoint after the handler returns. This can cause loop of breakpoints at the same address
8/8
perf tests: keep bp_signal memory accesses visible
In the breakpoint signal handler test, a breakpoint is set on __test_function. Keep that helper as a real call target so the breakpoint has a stable address. The test also relies on the watched varia