hptw: tag the DTLB entry with the access's own VA on a chained walk (#1885) - #1887
Open
davidharrishmc wants to merge 1 commit into
Open
davidharrishmc wants to merge 1 commit into
davidharrishmc wants to merge 1 commit into
Conversation
The DTLB entry is tagged with the MMU's VAdr input, which is the LSU address muxed by SelHPTWAdr, so SelHPTWAdr has to drop during DTLBWriteM. openhwfoundation#1875 qualified that term with (DTLBWalkPending & ~ITLBWalkPending), which is false when a DTLB walk and an ITLB walk are both pending: on such a chained walk the mux stays on the walker and the entry is tagged with the walker's PTE address. The bogus entry carries the leaf PTE of the data page (U=1 in the Sv tests) and covers the trap handler's data region, so the next S-mode access that hits it with SUM=0 fails ImproperPrivilege and takes a spurious page fault (openhwfoundation#1885). Restores the openhwfoundation#1871 expression and leaves the rest of openhwfoundation#1875 in place. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
Fixes #1885 with one line, as an alternative to the full revert in #1886.
What was wrong
The DTLB entry is tagged with the MMU's
VAdrinput, which is the LSU address muxed bySelHPTWAdr, soSelHPTWAdrhas to drop duringDTLBWriteM. #1875 qualified that term with(DTLBWalkPending & ~ITLBWalkPending), which is false when a DTLB walk and an ITLB walk are bothpending — the chained walk #1871 introduced. On such a walk the mux stays on the walker and the
entry is tagged with the walker's PTE address.
MEMPIPE_PROBE, same ELF and cycle, before and after (Im=1is the pending ITLB walk,HPTW=10isLEAF,
DW=1the DTLB write):The mis-tagged entry carries PTE
0xdb(V, R, X, U=1, A, D) over the trap handler's dataregion, so the next S-mode access that hits it with
SUM=0failsImproperPrivilegeand takes aspurious page fault. Full analysis in #1885.
Verification
On top of
ff84ec108, Verilator 5.036 plus Questa + ImperasDV where noted:arch64vm_sv39,sv48,sv48_a,sv48_bSv, act4 HEAD and22c01e88b1, rv32gc 30 + rv64gc 97regression-wally(Those 6 are pre-existing in a fresh worktree: three configs where
testbench.sv:797dereferencescore.priv.privunconditionally, two suites whose vectors this machine never built, andwally64priv/WALLY-trap-01, which fails the same way on main.)Caveat
This does not address the other half of #1875 — the removal of
MemAccessInFlightM/MemAccessDoneM. The same trace shows a performed M-stage access being flushed and replayed(
[68520]D$ ADDRESS_SETUP, then[68530]HPTWFlushW), which is what those guards existed for.Harmless for a cached load, not for an uncached/IO access or an AMO (R4 in the #1871 notes). I have
no failing case for it, so it is an open risk, not a second bug — if you would rather be
conservative, take #1886 instead and re-land #1875 without the
SelHPTWAdrhunk.🤖 Generated with Claude Code