Skip to content

Svvptc: do not cache invalid PTEs in the TLB - #1974

Open
davidharrishmc wants to merge 3 commits into
openhwfoundation:rva23from
davidharrishmc:dh/svvptc
Open

davidharrishmc wants to merge 3 commits into
openhwfoundation:rva23from
davidharrishmc:dh/svvptc

Conversation

@davidharrishmc

@davidharrishmc davidharrishmc commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Implements Svvptc, an RVA23 option. Wally's walker wrote the entry for an invalid PTE (V=0, at any level) into the I-TLB/D-TLB, so the replayed access kept faulting until SFENCE.VMA or eviction; Svvptc requires stores that set V from 0 to 1 to become visible to later implicit accesses in bounded time (norm:Svvptc_explicit_stores_update_valid_bit).

  • hptw.sv: InvalidPTEFaultM sends LEAF to FAULT, blocks the TLB write, and raises the page fault through the existing walk-fault path (which already handles fetch spills, misaligned spills and pending walks).
  • tlbcontrol.sv: ~PTE_V drops out of the hit-path page fault (the TLB can no longer hold V=0); the ITLB ADUE coverage-exclusion row moves accordingly.
  • V=1 PTEs that fault for other reasons (permissions, U/SUM, A/D under Svade, reserved bits, PBMT/NAPOT, misaligned superpages) are still cached; Svvptc covers only V 0→1.
  • Declares Svvptc in the rv32gc/rv64gc ACT UDB yamls (sail.json already did).

Found by FORCE-RISCV in ImperasDV lockstep. The FORCE reproducers and directed load/store/fetch, leaf/non-leaf, fetch-spill and misaligned-spill tests pass (also on Sail); the new ACT Svvptc suite (riscv/riscv-arch-test#2776) fails on rva23 and passes with this change; lockstep over all rv64gc/rv32gc Sv priv suites, Misalign and coverage tests shows only the existing Svnapot waivers; Verilator regression and lint-wally are unchanged.

🤖 Generated with Claude Code

davidharrishmc and others added 2 commits October 11, 2026 15:22
The HPTW wrote a walk that ended at an invalid (V=0) leaf or non-leaf PTE into
the ITLB/DTLB, and later hits raised the page fault from the cached entry until
an SFENCE.VMA.  A handler that sets V=1 and retries without SFENCE.VMA (legal
with Svvptc, an RVA23 option) then faults forever.

The walker now raises the page fault itself from LEAF through the existing
FAULT path, as it does for reserved non-leaf PTE bits, and writes nothing into
the TLB.  The next access re-walks and sees the updated PTE.  Since the TLB
never holds an invalid PTE, tlbcontrol no longer checks PTE.V; the ITLB
ENVCFG_ADUE_1 coverage exclusion moves from row 18 to row 16 accordingly.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The HPTW no longer caches invalid PTEs, so these configurations implement
Svvptc, as their sail.json files already claim.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
riscv-arch-test#2770 turned Svvptc off in the ACT copies of the rv32gc
and rv64gc Sail configurations because the walker cached invalid PTEs,
and cvw#1985 brings that to main. This branch fixes the walker, so
Svvptc stays supported here. The comment touches the same lines, so the
next merge of main into rva23 conflicts instead of silently turning
Svvptc off.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Signed-off-by: David Harris <David_Harris@hmc.edu>
@rosethompson

Copy link
Copy Markdown
Contributor

This is an interesting change. Originally the hptw did not write invalid entries into the TLB. We switched it because an ITLB fault would occur multiple times for each instruction in the pipeline until the faulting instruction made it to the Memory stage wasting many cycles. With this change we should also prevent the subsequent instruction fetches from making requests until the ITLB fault makes it to the Memory stage.

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.

2 participants