Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question about VA fault detection in system both support Sv32 and Sv39 #285

Closed
viktoryou opened this issue Mar 19, 2024 · 1 comment
Closed

Comments

@viktoryou
Copy link

viktoryou commented Mar 19, 2024

In such IOMMU implementation with capabilities.Sv32=1 & capabilities.Sv39=1 and 64-bit addresss width, as the IOMMU model suggests, when iosatp.MODE=Sv32 and DC.SXL=1, 63–32 should all equal to bit 31, or else a page-fault exception will occur.

While I think this is not exactly what the IOMMU spec requires:

When SXL is 1, the following rules apply:

  • If the first-stage is not Bare, then a page fault corresponding to the original access type occurs if
    the IOVA has bits beyond bit 31 set to 1.
  • If the second-stage is not Bare, then a guest page fault corresponding to the original access type
    occurs if the incoming GPA has bits beyond bit 33 set to 1.

I prefer this is a bug in the model (see code), since in a 32-bit system, there is no such canonical rule for Sv32 as Sv39/Sv48/Sv57 in 64-bit system. The check may only detect the [63:32] for IOVA and [63:34] for GPA not to one.

@viktoryou viktoryou changed the title Question about VA fault detection in system both support Sv32 and Sv48 Question about VA fault detection in system both support Sv32 and Sv39 Mar 19, 2024
@ved-rivos
Copy link
Collaborator

ved-rivos commented Mar 19, 2024

You are right that the code would produce a wrong result for 0xFFFFFFFF_???????? case for SXL=1. Fixing as follows in PR #286 :

if ( (masked_upper_bits != 0 && masked_upper_bits != mask && SXL == 0) ||
     (masked_upper_bits != 0 && SXL == 1) ) goto page_fault;

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

No branches or pull requests

2 participants