pub trait PagingConstsTrait:
Clone
+ Debug
+ Send
+ Sync
+ 'static {
const BASE_PAGE_SIZE: usize;
const NR_LEVELS: PagingLevel;
const HIGHEST_TRANSLATION_LEVEL: PagingLevel;
const PTE_SIZE: usize;
const ADDRESS_WIDTH: usize;
const VA_SIGN_EXT: bool;
// Required method
proof fn lemma_paging_consts_requirements();
// Provided method
proof fn lemma_paging_consts_properties() { ... }
}Expand description
A minimal set of constants that determines the paging system. This provides an abstraction over most paging modes in common architectures.
Verification requires 4 KiB pages, 8-byte PTEs, 1..=MAX_NR_LEVELS levels,
and 12 + 9 * NR_LEVELS <= ADDRESS_WIDTH < usize::BITS.
Required Associated Constants§
Sourceconst BASE_PAGE_SIZE: usize
const BASE_PAGE_SIZE: usize
The smallest page size. This is also the page size at level 1 page tables.
Sourceconst NR_LEVELS: PagingLevel
const NR_LEVELS: PagingLevel
The number of levels in the page table. The numbering of levels goes from deepest node to the root node. For example, the level 1 to 5 on AMD64 corresponds to Page Tables, Page Directory Tables, Page Directory Pointer Tables, Page-Map Level-4 Table, and Page-Map Level-5 Table, respectively.
Sourceconst HIGHEST_TRANSLATION_LEVEL: PagingLevel
const HIGHEST_TRANSLATION_LEVEL: PagingLevel
The highest level that a PTE can be directly used to translate a VA. This affects the the largest page size supported by the page table.
Sourceconst ADDRESS_WIDTH: usize
const ADDRESS_WIDTH: usize
The address width may be BASE_PAGE_SIZE.ilog2() + NR_LEVELS * IN_FRAME_INDEX_BITS. If it is shorter than that, the higher bits in the highest level are ignored.
Sourceconst VA_SIGN_EXT: bool
const VA_SIGN_EXT: bool
Whether virtual addresses are sign-extended.
The sign bit of a Vaddr is the bit at index PagingConstsTrait::ADDRESS_WIDTH - 1.
If this constant is true, bits in Vaddr that are higher than the sign bit must be
equal to the sign bit. If an address violates this rule, both the hardware and OSTD
should reject it.
Otherwise, if this constant is false, higher bits must be zero.
Regardless of sign extension, Vaddr is always not signed upon calculation.
That means, 0xffff_ffff_ffff_0000 < 0xffff_ffff_ffff_0001 is true.
Required Methods§
Sourceproof fn lemma_paging_consts_requirements()
proof fn lemma_paging_consts_requirements()
Self::BASE_PAGE_SIZE == 4096,1 <= Self::NR_LEVELS <= MAX_NR_LEVELS,0 < Self::BASE_PAGE_SIZE,is_pow2(Self::BASE_PAGE_SIZE as int),0 < Self::HIGHEST_TRANSLATION_LEVEL <= Self::NR_LEVELS < PagingLevel::MAX,is_pow2(Self::PTE_SIZE as int),0 < Self::PTE_SIZE <= Self::BASE_PAGE_SIZE,0 < Self::ADDRESS_WIDTH < usize::BITS,Self::BASE_PAGE_SIZE.ilog2()
+ (Self::BASE_PAGE_SIZE / Self::PTE_SIZE).ilog2() * Self::NR_LEVELS
<= Self::ADDRESS_WIDTH,Self::PTE_SIZE == core::mem::size_of::<usize>(),The requirements of the paging constants so that the memory management system can work correctly.
NOTE: The postcondition is designed to be minimal, to actually be used in proofs, call lemma_paging_consts_properties
instead to get all the properties that are derived from the requirements.
Provided Methods§
Sourceproof fn lemma_paging_consts_properties()
proof fn lemma_paging_consts_properties()
Self::PTE_SIZE == 8,Self::BASE_PAGE_SIZE.ilog2()
+ (Self::BASE_PAGE_SIZE / Self::PTE_SIZE).ilog2() * (Self::NR_LEVELS - 1)
<= Self::ADDRESS_WIDTH,0 < Self::BASE_PAGE_SIZE / Self::PTE_SIZE <= Self::BASE_PAGE_SIZE,is_pow2((Self::BASE_PAGE_SIZE / Self::PTE_SIZE) as int),Self::BASE_PAGE_SIZE / Self::PTE_SIZE == NR_ENTRIES,Self::BASE_PAGE_SIZE == 4096,1 <= Self::NR_LEVELS <= MAX_NR_LEVELS,0 < Self::BASE_PAGE_SIZE,is_pow2(Self::BASE_PAGE_SIZE as int),0 < Self::HIGHEST_TRANSLATION_LEVEL <= Self::NR_LEVELS < PagingLevel::MAX,is_pow2(Self::PTE_SIZE as int),0 < Self::PTE_SIZE <= Self::BASE_PAGE_SIZE,0 < Self::ADDRESS_WIDTH < usize::BITS,Self::BASE_PAGE_SIZE.ilog2()
+ (Self::BASE_PAGE_SIZE / Self::PTE_SIZE).ilog2() * Self::NR_LEVELS
<= Self::ADDRESS_WIDTH,Self::PTE_SIZE == core::mem::size_of::<usize>(),The derived properties of the paging constants.
NOTE: Implementations of PagingConstsTrait do not need to implement this lemma, the proof is automatically inherited from the default implementation.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".