-
Notifications
You must be signed in to change notification settings - Fork 16
feat: introduce generic multi-architecture paging/address-space model #710
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
Open
DID-Lab-SZU
wants to merge
12
commits into
asterinas:main
Choose a base branch
from
DID-Lab-SZU:feat/arch-paging-model
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
f158f4b
Integrate architecture paging model and fix verification
Je5s1e 0a0ee37
Merge branch 'asterinas:main' into feat/arch-paging-model
DID-Lab-SZU d3131c3
Merge branch 'asterinas:main' into feat/arch-paging-model
DID-Lab-SZU cd6490d
Merge official main into feat/arch-paging-model
Je5s1e ab07013
Clean up page table owner proof imports
Je5s1e f276dc5
Merge branch 'asterinas:main' into feat/arch-paging-model
DID-Lab-SZU 143f581
resolve confilct
Je5s1e 48c5aef
Merge branch 'asterinas:main' into feat/arch-paging-model
DID-Lab-SZU 26aee5c
Merge upstream main and resolve confict
Je5s1e 64f9d49
resolve conflicts
Je5s1e 02f2f35
address architecture paging review feedback
Je5s1e 87bb628
Merge official main and resolve conflicts
Je5s1e File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| pub mod model; | ||
| pub use model::*; | ||
|
|
||
| // Compatibility re-exports for proof modules that still use `specs::arch`. | ||
| // The authoritative values live in the executable memory/architecture modules. | ||
| pub use crate::{ | ||
| arch::mm::{NR_ENTRIES, NR_LEVELS, PAGE_SIZE}, | ||
| mm::{MAX_NR_PAGES, MAX_PADDR}, | ||
| }; | ||
|
|
||
| mod x86; | ||
| pub use x86::*; |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| use vstd::prelude::*; | ||
|
|
||
| use crate::mm::{Paddr, PagingConstsTrait, Vaddr}; | ||
|
|
||
| verus! { | ||
|
|
||
| /// The paging-related part of an architecture contract. | ||
| /// | ||
| /// The associated paging constants are still supplied by the existing | ||
| /// `PagingConstsTrait`; this trait only adds the architecture-wide physical | ||
| /// address bound and the proof that the two contracts are compatible. | ||
| pub trait ArchPagingModel { | ||
| type C: PagingConstsTrait; | ||
|
|
||
| /// The exclusive upper bound for physical frame addresses. | ||
| spec fn max_paddr_spec() -> Paddr; | ||
|
|
||
| proof fn lemma_paging_model_requirements() | ||
| ensures | ||
| 0 < Self::max_paddr_spec(), | ||
| Self::C::BASE_PAGE_SIZE() <= Self::max_paddr_spec(), | ||
| Self::max_paddr_spec() % Self::C::BASE_PAGE_SIZE() == 0, | ||
| ; | ||
| } | ||
|
|
||
| /// A physical address that can identify a base-page frame for architecture `A`. | ||
| pub open spec fn valid_frame_paddr_for<A: ArchPagingModel>(pa: Paddr) -> bool { | ||
| pa % A::C::BASE_PAGE_SIZE() == 0 && pa < A::max_paddr_spec() | ||
| } | ||
|
|
||
| /// The address-space part of an architecture contract. | ||
| pub trait ArchAddressSpaceModel: ArchPagingModel { | ||
| /// The base of the kernel's physical-to-virtual linear mapping. | ||
| spec fn linear_mapping_base_vaddr_spec() -> Vaddr; | ||
|
|
||
| /// The first virtual address reserved for vmalloc mappings. | ||
| spec fn vmalloc_base_vaddr_spec() -> Vaddr; | ||
|
|
||
| proof fn lemma_address_space_model_requirements() | ||
| ensures | ||
| Self::linear_mapping_base_vaddr_spec() % Self::C::BASE_PAGE_SIZE() == 0, | ||
| Self::linear_mapping_base_vaddr_spec() < Self::vmalloc_base_vaddr_spec(), | ||
| Self::max_paddr_spec() < Self::vmalloc_base_vaddr_spec() | ||
| - Self::linear_mapping_base_vaddr_spec(), | ||
| Self::max_paddr_spec() + Self::linear_mapping_base_vaddr_spec() < usize::MAX, | ||
| ; | ||
| } | ||
|
|
||
| /// Convert a physical address through architecture `A`'s linear mapping. | ||
| pub open spec fn paddr_to_vaddr_for<A: ArchAddressSpaceModel>(pa: Paddr) -> Vaddr { | ||
| (pa + A::linear_mapping_base_vaddr_spec()) as usize | ||
| } | ||
|
|
||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Like above, shall we replace all the original |
||
| /// Convert a linear-mapped virtual address back to a physical address. | ||
| pub open spec fn vaddr_to_paddr_for<A: ArchAddressSpaceModel>(va: Vaddr) -> Paddr { | ||
| (va - A::linear_mapping_base_vaddr_spec()) as usize | ||
| } | ||
|
|
||
| } // verus! | ||
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
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
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Marsman1996 Shall we replace all the original
valid_frame_paddrwith this new definition?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should, since the original
valid_frame_paddris only for x86 arch 🤔There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems they update the
valid_frame_paddrto call thisvalid_frame_paddr_fornow.