Skip to content

fix: guest-page-fault reporting for non-leaf VS-stage PTEs - #3407

Open
Maanvi212006 wants to merge 3 commits into
openhwgroup:masterfrom
Maanvi212006:fix-vs-stage-gpf
Open

fix: guest-page-fault reporting for non-leaf VS-stage PTEs#3407
Maanvi212006 wants to merge 3 commits into
openhwgroup:masterfrom
Maanvi212006:fix-vs-stage-gpf

Conversation

@Maanvi212006

Copy link
Copy Markdown
  • I have searched for similar pull requests
  • I am a human engaging in an interpersonal interaction. During this interaction, my words are my own and are not generated. If relevant, I provide links to my sources.

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_d to G_FINAL_STAGE. However, the non-leaf VS-stage PTE path leaves ptw_stage_d unchanged (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

  • Update the non-leaf VS-stage PTE error path in core/cva6_mmu/cva6_ptw.sv.
  • Replace:
    ptw_stage_d = ptw_stage_q;
    

Signed-off-by: Maanvi212006 <maanvichetwani21@gmail.com>
Maanvi212006 and others added 2 commits July 25, 2026 19:49
Signed-off-by: Maanvi212006 <maanvichetwani21@gmail.com>
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.

[BUG] a non-leaf VS-stage PTE with out-of-range guest physical address raises a page-fault instead of a guest-page-fault

2 participants