fix: guest-page-fault reporting for non-leaf VS-stage PTEs - #3407
Open
Maanvi212006 wants to merge 3 commits into
Open
fix: guest-page-fault reporting for non-leaf VS-stage PTEs#3407Maanvi212006 wants to merge 3 commits into
Maanvi212006 wants to merge 3 commits into
Conversation
Signed-off-by: Maanvi212006 <maanvichetwani21@gmail.com>
Signed-off-by: Maanvi212006 <maanvichetwani21@gmail.com>
This was referenced Aug 2, 2026
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 is this PR needed?
During two-stage address translation, a VS-stage page table entry (PTE) produces a guest physical address (GPA), which is then translated by the G-stage. According to the RISC-V Privileged Specification, for Sv39x4, if the generated GPA has non-zero bits in the range 63:41, the processor must raise a guest-page-fault.
The current implementation correctly handles this case for leaf VS-stage PTEs by setting
ptw_stage_dtoG_FINAL_STAGE. However, the non-leaf VS-stage PTE path leavesptw_stage_dunchanged (S_STAGE), causing the exception to be reported as a normal page fault instead of a guest-page-fault.This PR updates the non-leaf PTE path to use
G_FINAL_STAGE, making its behavior consistent with the leaf PTE path and compliant with the RISC-V Privileged Specification.Related Issue
Fixes #3401
Changes
core/cva6_mmu/cva6_ptw.sv.ptw_stage_d = ptw_stage_q;