Fix mtvec WARL readback and trap dispatch coherence - #3566
Open
124107157-KV wants to merge 1 commit into
Open
124107157-KV wants to merge 1 commit into
124107157-KV wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why this PR is needed
mtveccurrently allows software to write and read back address bits that are outside the implemented physical-address width.For the
cv64a6_imafdc_sv39configuration, machine-mode instruction fetch ultimately uses the implemented physical-address width (PLEN). However, theCSR_MTVECwrite path stores the trap-vector value at the architecturalXLENwidth, apart from the existing mode and alignment legalization.This means software can write an
mtvecvalue containing unsupported high address bits and read those bits back unchanged, while a subsequent machine-mode trap can ultimately fetch from the corresponding low physical-address alias.The CSR-visible
mtvecvalue can therefore differ from the trap-vector address that the implementation can actually consume.Since
mtvecis WARL, unsupported address bits can instead be legalized when the CSR is written. This keepsmtvecreadback coherent with the effective machine-mode trap target.Changes
mtvecto the implemented physical-address width after the existing mode and alignment handling.mtvec-warl-rv64regression test.verif/tests/testlist_issues.yaml.mtvecvalue containing a valid low trap-handler address together with an unsupported high address bit.The RTL change legalizes the final
mtvecvalue using:This is applied after the existing direct/vectored-mode and alignment handling.
Validation
Tested with the
cv64a6_imafdc_sv39configuration usingveri-testharness.Baseline RTL
The new
mtvec-warl-rv64directed regression was run with the RTL fix temporarily removed.mtvecwrite path retained the unsupported high address bit.make veri-testharnessinvocation failed with return code 2, as expected for the regression failure.Fixed RTL
The same regression was then run with the
mtvecWARL legalization applied.mtvecvalue.veri-testharnesscompleted successfully with...done.Additional checks:
git diff --checkis clean.CSR_MTVECwrite path.Scope / limitations
This change is intentionally scoped to the
mtvecreadback-versus-trap-target coherence problem reported in this issue.It does not change:
stvecvstvecThis keeps the change focused on the reported machine-mode
mtvecinconsistency.Fixes #3458