Repository navigation
CSR: preserve trap values when interrupts win - #298
Open
good-circle wants to merge 1 commit into
Open
good-circle wants to merge 1 commit into
good-circle wants to merge 1 commit into
Conversation
An interrupt can win trap selection while a pending page fault or misaligned access still writes its trap-value CSR. When the interrupt targets M-mode and the exception is delegated to S-mode, this corrupts stval even though no S-mode trap is taken. Gate those exception writes with !raiseIntr so they follow the same priority as cause, delegation and trap-target selection.
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.
If an interrupt and a page fault or misaligned access are pending together, trap cause, delegation, and target selection already prioritize the interrupt. The independent exception paths can still write a trap-value CSR, however. For example, an interrupt targeting M-mode can leave stval overwritten by a page fault that would have been delegated to S-mode, even though no S-mode trap was taken.
Gate page-fault and misaligned-access trap-value writes with !raiseIntr so they follow the existing trap-selection priority.
Validation: 30 directed CSR RTL cases passed after the fix; the original RTL failed 10. The corrected S2C bit also passed a 12-billion-instruction mcf prefix with FORK DiffTest at 50 MHz and 16 GiB RAM.