anjiahao1 opened a new pull request, #22307:
URL: https://github.com/apache/nuttx/pull/22307
## Summary
Fix the RISC-V trigger driver so it follows the RISC-V Debug
Specification 1.0:
- Enumerate trigger slots as the specification describes instead of
writing 0xffffffff to tselect and expecting out-of-range writes to be
clamped.
- Identify the firing trigger by matching EPC/TVAL and clearing the hit
bit. tselect is only a selector; hardware does not update it when a
trigger fires.
- Initialize the union used to build tdata1 so chain, size, timing and
select are not stack garbage.
- Verify tdata1 writes, since tdata is WARL; fail when a slot rejects
the requested trigger type or match mode.
- Writing 0 to tdata1 must disable a trigger, but some implementations
(including QEMU) dispatch tdata1 writes by the type carried in the
written value and drop a write of 0. Verify the disable and clear the
enable bits when the write was dropped.
- Program triggers in the specified order: disabled tdata1, tdata2,
final tdata1. Route the tdata2 write to the target type first so it
is not dropped on implementations that dispatch by the current type.
- Support mcontrol6 slots (type 2 is deprecated in 1.0), validate the
requested NAPOT size against maskmax, and keep all trigger state per
CPU because the trigger CSRs are per hart.
- tcontrol is optional in the specification; gate the MTE/MPTE setup
with a new internal ARCH_RISCV_NO_TCONTROL symbol, selected by the
QEMU RV chip.
## Impact
* Is new feature added? NO
* Impact on user: YES - hardware breakpoints and watchpoints work on
RISC-V cores implementing Debug Spec 1.0.
* Impact on build: YES - adds the internal ARCH_RISCV_NO_TCONTROL
Kconfig symbol, selected by ARCH_CHIP_QEMU_RV.
* Impact on hardware: YES - only the RISC-V trigger driver changes.
* Impact on documentation: NO
* Impact on security: NO
* Impact on compatibility: NO
## Testing
Build host: Linux x86_64, NuttX CI Docker image
(ghcr.io/apache/nuttx/apache-nuttx-ci-linux, riscv-none-elf-gcc)
Target: rv-virt:nsh (RV32)
```
tools/configure.sh -a <apps> rv-virt:nsh
make -j10
```
The image builds without warnings. It boots under QEMU:
```
qemu-system-riscv32 -semihosting -M virt,aclint=on -smp 1 \
-bios none -kernel ./nuttx -nographic
```
and reaches the NSH prompt.
The original downstream commit was validated on QEMU rv-virt, UP and
SMP: the debugpoint self-test passes for breakpoints and read/write
watchpoints, and the kernel serial gdbstub stops on hardware
breakpoints, single step and watchpoints.
## PR verification
* [x] This PR introduces only one functional change.
* [x] I have updated all required description fields above.
* [x] My PR adheres to Contributing Guidelines and Documentation.
* [ ] My PR is still work in progress (not ready for review).
* [x] My PR is ready for review and can be safely merged into a codebase.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]