All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH v3 0/7] riscv: add initial sdext support
@ 2026-01-27 13:15 Chao Liu
  2026-01-27 13:15 ` [RFC PATCH v3 1/7] target/riscv: deprecate 'debug' CPU property Chao Liu
                   ` (6 more replies)
  0 siblings, 7 replies; 10+ messages in thread
From: Chao Liu @ 2026-01-27 13:15 UTC (permalink / raw)
  To: Alistair Francis, Daniel Henrique Barboza, Palmer Dabbelt,
	Weiwei Li, Liu Zhiwei
  Cc: qemu-devel, qemu-riscv, wangjingwei, hust-os-kernel-patches,
	Chao Liu

Hi,

Per Daniel's review feedback, this v3 series is based on Alistair's
riscv-to-apply.next branch [3]. It depends on Max Chou's patch
"target/riscv: Use the tb->cs_bqse as the extend tb flags."
(not included in this series; apply it first) [2].

It is based on RISC-V Debug Specification 1.0 [1].

It introduces the sdext/sdtrig config bits, DCSR/DPC/DSCRATCH state,
Debug Mode enter/leave helpers, DRET, EBREAK entry, single-step, and
trigger action=debug mode.

To reduce review load, this series focuses on the Sdext features first.
The Debug Module (DM) and related flows will follow in a later series.

Changes in v3:
- Rebase onto Alistair's riscv-to-apply.next branch.
- Depend on Max Chou's patch "target/riscv: Use the tb->cs_bqse as
  the extend tb flags." (not included; apply it first) [2].
- Patch 2: default sdext to false in riscv_cpu_extensions[].

Changes in v2:
- Drop the RHCT expected AML update from this series.
- Replace the split sdext/sdtrig config bits patch with deprecating the
  'debug' CPU property.
- Rebase and update patch subjects to target/riscv prefix.

Changes in v1:
- Debug Mode entry/exit updates DCSR/DPC and restores execution via DRET.
- EBREAK honors DCSR ebreak bits and enters Debug Mode when enabled.
- Single-step uses DCSR.STEP with a TB flag and a helper at TB exit.
  It references Max Chou's patch "target/riscv: Use the tb->cs_bqse as
  the extend tb flags." [2].
- Sdtrig supports action=debug mode for mcontrol/mcontrol6 and reports
  inst-count triggers in tinfo.

Differences vs Debug Spec (known gaps):
- No Debug Module (no DMI, dmcontrol/dmstatus, haltreq/resumereq).
- No debug ROM, program buffer, abstract commands, or SBA.
- Resume is modeled by leaving Debug Mode at cpu_exec_enter.
- Step/exception ordering is simplified: if the stepped instruction
  traps, the normal exception is taken and Debug Mode is not forced.
- Several DCSR fields are not fully modeled (stopcount/stoptime, etc).

Roadmap (next stage, DM focus):
1) Add a DM core with DMI access and hart state tracking.
2) Implement halt/resume handshake and move Debug Mode transitions
   under DM control.
3) Add debug ROM, program buffer, and abstract commands for GPR/CSR
   and memory access.
4) Add SBA if required by tooling.
5) Tighten ordering rules for step/exception/trigger priorities.


References:
[1] https://github.com/riscv/riscv-debug-spec/releases/tag/1.0
[2] https://lore.kernel.org/qemu-devel/20260108132631.9429-6-max.chou@sifive.com/
[3] https://github.com/alistair23/qemu/tree/riscv-to-apply.next


Thanks,
Chao


Chao Liu (6):
  target/riscv: add sdext debug CSRs state
  target/riscv: add sdext Debug Mode helpers
  target/riscv: add dret instruction
  target/riscv: add sdext enter Debug Mode on ebreak
  target/riscv: add sdext single-step support
  target/riscv: add sdtrig trigger action=debug mode

Daniel Henrique Barboza (1):
  target/riscv: deprecate 'debug' CPU property

 docs/about/deprecated.rst                     |   7 +
 include/exec/translation-block.h              |   4 +-
 target/riscv/cpu.c                            |  61 ++++++++-
 target/riscv/cpu.h                            |   9 ++
 target/riscv/cpu_bits.h                       |  33 +++++
 target/riscv/cpu_cfg_fields.h.inc             |   3 +-
 target/riscv/cpu_helper.c                     |  93 +++++++++++++
 target/riscv/csr.c                            | 128 +++++++++++++++++-
 target/riscv/debug.c                          |  58 +++++++-
 target/riscv/helper.h                         |   3 +
 target/riscv/insn32.decode                    |   1 +
 .../riscv/insn_trans/trans_privileged.c.inc   |  24 +++-
 target/riscv/machine.c                        |  44 ++++--
 target/riscv/op_helper.c                      |  72 ++++++++++
 target/riscv/tcg/tcg-cpu.c                    |  21 ++-
 target/riscv/translate.c                      |  15 +-
 16 files changed, 548 insertions(+), 28 deletions(-)

-- 
2.52.0



^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2026-01-30  6:14 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-27 13:15 [RFC PATCH v3 0/7] riscv: add initial sdext support Chao Liu
2026-01-27 13:15 ` [RFC PATCH v3 1/7] target/riscv: deprecate 'debug' CPU property Chao Liu
2026-01-27 13:15 ` [RFC PATCH v3 2/7] target/riscv: add sdext debug CSRs state Chao Liu
2026-01-28 19:42   ` Daniel Henrique Barboza
2026-01-30  6:14     ` Chao Liu
2026-01-27 13:15 ` [RFC PATCH v3 3/7] target/riscv: add sdext Debug Mode helpers Chao Liu
2026-01-27 13:15 ` [RFC PATCH v3 4/7] target/riscv: add dret instruction Chao Liu
2026-01-27 13:15 ` [RFC PATCH v3 5/7] target/riscv: add sdext enter Debug Mode on ebreak Chao Liu
2026-01-27 13:15 ` [RFC PATCH v3 6/7] target/riscv: add sdext single-step support Chao Liu
2026-01-27 13:15 ` [RFC PATCH v3 7/7] target/riscv: add sdtrig trigger action=debug mode Chao Liu

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.