Skip to content

riscv: add initial support for hardware breakpoints

Jesse Taube linux-kselftest linux-mm linux-perf-users linux-riscv lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest8 patches 3 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/8riscv: Add insn.c, consolidate instruction decodingarch/riscv/include/asm/bug.h arch/riscv/include/asm/insn.h arch/riscv/kernel/Makefile +5 more+309 -1870 replies
2/8riscv: Add SBI debug trigger extension and function idsarch/riscv/include/asm/sbi.h+29 -00 replies
3/8riscv: insn: Add get_insn_nofaultarch/riscv/include/asm/insn.h arch/riscv/kernel/insn.c+15 -00 replies
4/8riscv: Introduce support for hardware break/watchpointsarch/riscv/Kconfig arch/riscv/include/asm/hw_breakpoint.h arch/riscv/include/asm/kdebug.h +4 more+687 -20 replies
5/8riscv: hw_breakpoint: Use icount for single steppingarch/riscv/Kconfig arch/riscv/kernel/hw_breakpoint.c+172 -181 reply
6/8riscv: ptrace: Add hw breakpoint supportarch/riscv/include/asm/processor.h arch/riscv/include/uapi/asm/ptrace.h arch/riscv/kernel/hw_breakpoint.c +2 more+140 -10 replies
7/8riscv: ptrace: Add hw breakpoint regsetarch/riscv/kernel/ptrace.c include/uapi/linux/elf.h tools/include/uapi/linux/elf.h+62 -00 replies
8/8selftests: riscv: Add test for hardware breakpointstools/perf/tests/tests.h tools/testing/selftests/riscv/Makefile tools/testing/selftests/riscv/breakpoints/.gitignore +2 more+262 -22 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/8] riscv: add initial support for hardware breakpoints

This patchset adds initial support for hardware breakpoints and watchpoints to the RISC-V architecture. The framework is built on top of perf subsystem and SBI debug trigger extension.

Currently following features are not supported and are in works:
- icount for single stepping
- Virtualization of debug triggers
- kernel space debug triggers

The SBI debug trigger extension can be found at:
https://github.com/riscv-non-isa/riscv-sbi-doc/blob/master/src/ext-debug-triggers.adoc

The Sdtrig ISA is part of RISC-V debug specification which can be found at:
https://github.com/riscv/riscv-debug-spec

based off the original RFC by Himanshu Chauhan here:
https://lore.kernel.org/lkml/[email protected]/

Second RFC by Jesse Taube here:
https://lore.kernel.org/lkml/[email protected]/

Himanshu Chauhan (2):
riscv: Add SBI debug trigger extension and function ids
riscv: Introduce support for hardware break/watchpoints

Jesse Taube (6):
riscv: Add insn.c, consolidate instruction decoding
riscv: insn: Add get_insn_nofault
riscv: hw_breakpoint: Use icount for single stepping
riscv: ptrace: Add hw breakpoint support
riscv: ptrace: Add hw breakpoint regset
selftests: riscv: Add test for hardware breakpoints

 arch/riscv/Kconfig                            |  13 +
 arch/riscv/include/asm/bug.h                  |  12 -
 arch/riscv/include/asm/hw_breakpoint.h        |  59 ++
 arch/riscv/include/asm/insn.h                 | 132 ++-
 arch/riscv/include/asm/kdebug.h               |   3 +-
 arch/riscv/include/asm/processor.h            |   4 +
 arch/riscv/include/asm/sbi.h                  |  33 +-
 arch/riscv/include/uapi/asm/ptrace.h          |   9 +
 arch/riscv/kernel/Makefile                    |   2 +
 arch/riscv/kernel/hw_breakpoint.c             | 769 ++++++++++++++++++
 arch/riscv/kernel/insn.c                      | 165 ++++
 arch/riscv/kernel/kgdb.c                      | 102 +--
 arch/riscv/kernel/probes/kprobes.c            |   1 +
 arch/riscv/kernel/process.c                   |   4 +
 arch/riscv/kernel/ptrace.c                    | 169 ++++
 arch/riscv/kernel/traps.c                     |  11 +-
 arch/riscv/kernel/traps_misaligned.c          |  93 +--
 include/uapi/linux/elf.h                      |   2 +
 tools/include/uapi/linux/elf.h                |   1 +
 tools/perf/tests/tests.h                      |   3 +-
 tools/testing/selftests/riscv/Makefile        |   2 +-
 .../selftests/riscv/breakpoints/.gitignore    |   1 +
 .../selftests/riscv/breakpoints/Makefile      |  12 +
 .../riscv/breakpoints/breakpoint_test.c       | 246 ++++++
 24 files changed, 1657 insertions(+), 191 deletions(-)
 create mode 100644 arch/riscv/include/asm/hw_breakpoint.h
 create mode 100644 arch/riscv/kernel/hw_breakpoint.c
 create mode 100644 arch/riscv/kernel/insn.c
 create mode 100644 tools/testing/selftests/riscv/breakpoints/.gitignore
 create mode 100644 tools/testing/selftests/riscv/breakpoints/Makefile
 create mode 100644 tools/testing/selftests/riscv/breakpoints/breakpoint_test.c
Signature · 1 line
2.43.0