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

Add missing PTE checks #387

Closed
wants to merge 1 commit into from
Closed

Conversation

ved-rivos
Copy link
Contributor

The PTE checking in the sail model is missing part of the following rule that requires raising a page fault if reserved bits are set:

If pte.v = 0, or if pte.r = 0 and pte.w = 1, or if any bits or encodings that are reserved for future standard use are set within pte, stop and raise a page-fault exception corresponding to the original access type

  • The bits 63:54 are reserved for future standard extensions. The bit 63 is defined by Svnapot and bits 62:61 by Svpbmt - but both these extensions are not in the model presently.
  • For non-leaf PTEs, the D, A, and U bits are reserved for future standard use.

All tests pass.

Copy link
Collaborator

@jrtc27 jrtc27 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC these checks didn't used to be in the spec, so it's not that they're missing, it's that you want to make the model conform to a newer version of the priv spec?

a.V() == 0b0 | (a.W() == 0b1 & a.R() == 0b0)
a.V() == 0b0 |
(a.W() == 0b1 & a.R() == 0b0) |
(ext != 0b0000000000) |
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This breaks extensions (e.g. CHERI) that do assign meaning to these bits and exist as users of the Sail model

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the base priv spec says we need to raise a page fault when these bits are non-zero, I'm not sure we can ignore it. Maybe we need to add some kind of mechanism so CHERI can override the behaviour of isInvalidPTE and similar functions with its own implementations?

Copy link
Contributor Author

@ved-rivos ved-rivos Jan 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The privileged specification reserves these bits for future standard use. There are two extensions - Svpbmt and Svnapot - that use some of the bits that are not present in our golden reference model. The use of bits by extensions needs to be enabled by the governing xenvcfg register. Not having these checks makes it a problem to use it as a golden reference as these mismatches need to be waived. I hope to provide the models for the other missing pieces in the virtual memory system architecture - Svnapot, Svpbmt, and Sv57 - and this bug fix is needed to build those. When CHERI becomes a standard extension I think it would follow the architecture and add the environment controls to enable the use of a subset of those bits that get allocated for CHERI use.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I sent PR #393 with the Svnapot and Svpbmt extensions. Sorry, i had to duplicate contents of this PR in #393. Was trying to make updates incrementally but since this did not get merged, had to do the duplication. Please let me know if I should just close this PR since #393 is the superset.

@allenjbaum
Copy link
Collaborator

allenjbaum commented Jan 12, 2024 via email

@ved-rivos ved-rivos closed this Jan 22, 2024
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.

4 participants