Skip to content

[rv_dm] Fix dmcontrol read to return 0 for haltreq and resumereq - #31209

Closed
devtyagi3909 wants to merge 1 commit into
lowRISC:masterfrom
devtyagi3909:fix-rvdm-dmcontrol-read
Closed

devtyagi3909 wants to merge 1 commit into
lowRISC:masterfrom
devtyagi3909:fix-rvdm-dmcontrol-read

Conversation

@devtyagi3909

Copy link
Copy Markdown

Fixes #23204.

According to the RISC-V Debug Specification (v0.13.2, Section 3.12.2), the dmcontrol.haltreq and dmcontrol.resumereq fields are defined as write-only, and should always return 0 when read. However, the current implementation returns the latched dmcontrol_q directly, allowing a debugger to read these bits back as 1.

This PR introduces a dmcontrol_read intermediary that explicitly zeroes out these write-only fields before returning the register data to the DMI response queue. This brings the RTL into compliance with the spec.

This is technically an upstream change for pulp-platform/riscv-dbg but they actually already implemented this exact fix in their master branch. This PR ports the same fix logic back to the vendored OpenTitan copy.

Fixes lowRISC#23204.

According to the RISC-V Debug Specification (v0.13.2), the
dmcontrol.haltreq and dmcontrol.resumereq fields are defined
as write-only, and should always return 0 when read.

This PR introduces a dmcontrol_read intermediary that
explicitly zeroes out these write-only fields before returning
the register data to the debugger via the DMI response queue.
@devtyagi3909

Copy link
Copy Markdown
Author

Closing this PR since the OpenTitan CI strictly blocks direct modifications to the vendored hw/vendor/pulp_riscv_dbg directory. I have submitted this exact fix upstream to ETH Zurich, and it was successfully merged today into pulp-platform/riscv-dbg:master (see pulp-platform/riscv-dbg#204). OpenTitan will automatically inherit this fix during the next vendor sync!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[rv_dm] dmcontrol.haltreq should always read as 0

1 participant