Repository navigation
fix(fetch): report the faulting instruction halfword in TVAL - #10
Merged
RossComputerGuy merged 1 commit intoOct 6, 2026
Merged
Conversation
Latch the accepted fetch fault address independently of the instruction PC. Preserve EPC while reporting PC+2 for a failed second halfword, for both instruction access and page faults in the in-order executors.
murdoa
force-pushed
the
fix/straddling-instruction-tval
branch
from
October 6, 2026 20:01
874227b to
0512d02
Compare
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.
Stacked on #9.
Bug
With compressed instructions enabled, a 32-bit instruction can start two bytes before a page boundary. Its first halfword may be readable while fetching the second halfword faults.
For example, an instruction beginning at
0x0ffewhose second halfword faults at0x1000should report:0x0ffe0x0ffe0x0ffe0x1000EPC identifies the instruction to restart. When reporting a nonzero TVAL for an instruction access/page fault, RISC-V requires the address of the portion that faulted. Reporting the instruction start instead points a page-fault handler at the already-mapped page rather than the missing next page.
The fetch unit retains the instruction-start PC, but does not retain a separate fault address. Both in-order executors consequently use the instruction start for both EPC and TVAL.
Fix
PC + 2for the straddle's second read.This covers cached and uncached in-order cores. OoO and the separate pipelined fetch interface are unchanged.
Validation
52 new core cases cover RV32/RV64 access faults, Sv39 page faults, ERR-only/ACK+ERR, and both executors/cache modes. They check EPC/TVAL and architectural trap CSRs, destination preservation, and handler recovery. First-half failures and successful straddles are controls against incorrectly adding two to every fetch address.
All 20 second-halfword cases reproduce the wrong TVAL on the baseline and pass with the patch. The other 32 new cases and 170 existing targeted cases pass on both: 202 pass / 20 fail → 222 pass / 0 fail.