RootTable

Struct RootTable 

Source
pub struct RootTable<T: Translation> { /* private fields */ }
Expand description

A complete hierarchy of page tables including all levels.

Implementations§

Source§

impl<T: Translation> RootTable<T>

Source

pub fn new( translation: T, level: usize, translation_regime: TranslationRegime, va_range: VaRange, ) -> Self

Creates a new page table starting at the given root level.

The level must be between 0 and 3; level -1 (for 52-bit addresses with LPA2) is not currently supported by this library. The value of TCR_EL1.T0SZ must be set appropriately to match.

Source

pub fn size(&self) -> usize

Returns the size in bytes of the virtual address space which can be mapped in this page table.

This is a function of the chosen root level.

Source

pub fn map_range( &mut self, range: &MemoryRegion, pa: PhysicalAddress, flags: Attributes, constraints: Constraints, ) -> Result<(), MapError>

Recursively maps a range into the pagetable hierarchy starting at the root level, mapping the pages to the corresponding physical address range starting at pa. Block and page entries will be written to, but will only be mapped if flags contains Attributes::VALID.

Returns an error if the virtual address range is out of the range covered by the pagetable, or if the flags argument has unsupported attributes set.

Source

pub fn to_physical(&self) -> PhysicalAddress

Returns the physical address of the root table in memory.

Source

pub fn va_range(&self) -> VaRange

Returns the virtual address range for which this table is intended.

This affects which TTBR register is used.

Source

pub fn translation_regime(&self) -> TranslationRegime

Returns the translation regime for which this table is intended.

Source

pub fn translation(&self) -> &T

Returns a reference to the translation used for this page table.

Source

pub fn modify_range<F>( &mut self, range: &MemoryRegion, f: &F, ) -> Result<(), MapError>
where F: Fn(&MemoryRegion, &mut Descriptor, usize) -> Result<(), ()> + ?Sized,

Applies the provided updater function to the page table descriptors covering a given memory range.

This may involve splitting block entries if the provided range is not currently mapped down to its precise boundaries. For visiting all the descriptors covering a memory range without potential splitting (and no descriptor updates), use walk_range instead.

The updater function receives the following arguments:

  • The virtual address range mapped by each page table descriptor. A new descriptor will have been allocated before the invocation of the updater function if a page table split was needed.
  • A mutable reference to the page table descriptor that permits modifications.
  • The level of a translation table the descriptor belongs to.

The updater function should return:

  • Ok to continue updating the remaining entries.
  • Err to signal an error and stop updating the remaining entries.

This should generally only be called while the page table is not active. In particular, any change that may require break-before-make per the architecture must be made while the page table is inactive. Mapping a previously unmapped memory range may be done while the page table is active.

§Errors

Returns MapError::PteUpdateFault if the updater function returns an error.

Returns MapError::RegionBackwards if the range is backwards.

Returns MapError::AddressRange if the largest address in the range is greater than the largest virtual address covered by the page table given its root level.

Returns [`MapError::BreakBeforeMakeViolation’] if the range intersects with live mappings, and modifying those would violate architectural break-before-make (BBM) requirements.

Source

pub fn walk_range<F>( &self, range: &MemoryRegion, f: &mut F, ) -> Result<(), MapError>

Applies the provided callback function to the page table descriptors covering a given memory range.

The callback function receives the following arguments:

  • The range covered by the current step in the walk. This is always a subrange of range even when the descriptor covers a region that exceeds it.
  • The page table descriptor itself.
  • The level of a translation table the descriptor belongs to.

The callback function should return:

  • Ok to continue visiting the remaining entries.
  • Err to signal an error and stop visiting the remaining entries.
§Errors

Returns MapError::PteUpdateFault if the callback function returns an error.

Returns MapError::RegionBackwards if the range is backwards.

Returns MapError::AddressRange if the largest address in the range is greater than the largest virtual address covered by the page table given its root level.

Trait Implementations§

Source§

impl<T: Translation> Debug for RootTable<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<T: Translation> Drop for RootTable<T>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<T> Freeze for RootTable<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for RootTable<T>
where T: RefUnwindSafe,

§

impl<T> Send for RootTable<T>
where T: Send,

§

impl<T> Sync for RootTable<T>
where T: Sync,

§

impl<T> Unpin for RootTable<T>
where T: Unpin,

§

impl<T> UnwindSafe for RootTable<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.