Skip to main content

ArchVmAspace

Struct ArchVmAspace 

Source
pub struct ArchVmAspace { /* private fields */ }

Implementations§

Source§

impl ArchVmAspace

Source

pub fn init(&self) -> Result<(), Status>

This is used to create a regular address space with no special features. In architectures that do not support unified address spaces, it is also used to create shared and restricted address spaces. However, when unified address spaces are supported, the shared and restricted address spaces should be created with init_shared and init_restricted.

Source

pub fn init_shared(&self) -> Result<(), Status>

This is used to create a shared address space, whose contents can be accessed from multiple unified address spaces. These address spaces have a statically initialized top level page.

Source

pub fn init_restricted(&self) -> Result<(), Status>

This is used to create a restricted address space, whose contents can be accessed from a single unified address space.

Source

pub fn init_unified( &self, shared: &ArchVmAspace, restricted: &ArchVmAspace, ) -> Result<(), Status>

init_unified: This is used to create a unified address space. This type of address space owns no mappings of its own; rather, it is composed of a shared address space and a restricted address space. As a result, it expects init_shared to have been called on the shared address space, and expects init_restricted to have been called on the restricted address space.

Source

pub fn disable_updates(&self)

This method puts the instance into read-only mode and asserts that it contains no mappings.

Note, this method may be a no-op on some architectures. See https://fxbug.dev/42159319.

It is an error to call this method on an instance that contains mappings. Once called, subsequent operations that modify the page table will trigger a panic.

The purpose of this method is to help enforce lifecycle and state transitions of VmAspace and ArchVmAspaceInterface.

Source

pub fn destroy(&self) -> Result<(), Status>

Destroy expects the aspace to be fully unmapped, as any mapped regions indicate incomplete cleanup at the higher layers. Note that this does not apply to unified aspaces, which may still contain some mappings when destroy() is called.

It is safe to call destroy even if init, init_shared, init_restricted, or init_unified failed. Once destroy has been called it is a user error to call any of the other methods on the aspace, unless specifically stated otherwise, and doing so may cause a panic.

Source

pub unsafe fn map_contiguous( &self, vaddr: usize, paddr: PAddr, count: usize, mmu_flags: ArchMmuFlags, ) -> Result<(), Status>

Map a physically contiguous region into the virtual address space. This is allowed to use any page size the architecture allows given the input parameters.

§Safety

The caller must ensure the virtual and physical range are valid to map.

Source

pub unsafe fn map( &self, vaddr: usize, phys: *mut PAddr, count: usize, mmu_flags: ArchMmuFlags, existing_action: ExistingEntryAction, ) -> Result<(), Status>

§Safety

The caller must ensure phys points to an array of at least count physical addresses and that the virtual and physical ranges are valid to map.

Source

pub unsafe fn unmap( &self, vaddr: usize, count: usize, enlarge: ArchUnmapOptions, ) -> Result<(), Status>

Unmaps the given virtual address range.

§Safety

The caller must ensure the specified virtual range is no longer in use.

Source

pub fn unmap_only_enlarge_on_oom(&self) -> bool

Returns whether or not an unmap might need to enlarge an operation for reasons other than being out of memory. If this returns true, then unmapping a partial large page will fail always require an enlarged operation.

Source

pub unsafe fn protect( &self, vaddr: usize, count: usize, mmu_flags: ArchMmuFlags, enlarge: ArchUnmapOptions, ) -> Result<(), Status>

Change the page protections on the given virtual address range

May return ZX_ERR_NO_MEMORY if the operation requires splitting a large page and the next level page table allocation fails. In this case, mappings in the input range may be a mix of the old and new flags. ArchUnmapOptions controls whether a larger range than requested is permitted to experience a temporary permissions change. A temporary change may be required if a break-before-make style unmap -> remap of the large page is required.

§Safety

The caller must ensure the permissions for the given virtual address range are valid.

Source

pub fn query(&self, vaddr: usize) -> Result<(PAddr, ArchMmuFlags), Status>

Queries the translation for vaddr.

Source

pub fn pick_spot( &self, base: usize, end: usize, align: usize, size: usize, mmu_flags: ArchMmuFlags, ) -> usize

Picks a spot in the virtual address space.

Source

pub fn harvest_accessed( &self, vaddr: usize, count: usize, non_terminal_action: NonTerminalAction, terminal_action: TerminalAction, ) -> Result<(), Status>

Walks the given range of pages and for any pages that are mapped and have their access bit set:

  • Tells the page queues it has been accessed via PageQueues::MarkAccessed
  • Potentially removes the accessed flag.
  • Potentially frees unaccessed page tables.
Source

pub fn mark_accessed(&self, vaddr: usize, count: usize) -> Result<(), Status>

Marks any pages in the given virtual address range as being accessed.

Source

pub fn accessed_since_last_check(&self, clear: bool) -> bool

Returns whether or not this aspace might have additional accessed information since the last time this method was called with clear=true. If this returns false then, modulo races, harvest_accessed is defined to not find any set bits and not call PageQueues::MarkAccessed.

This is intended for use by the harvester to avoid scanning for any accessed or dirty bits if the aspace has not been accessed at all.

Note that restricted and shared ArchVmAspace’s will report that they have been accessed if an associated unified ArchVmAspace has been accessed. However, the reverse is not true; the unified ArchVmAspace will not return true if the associated shared/restricted aspaces have been accessed.

The clear flag controls whether the aspace having been accessed should be cleared or not. Not clearing makes this function const and not modify any state. If clear is true then this method is only thread-compatible and must be externally synchronized.

Source

pub fn arch_table_phys(&self) -> PAddr

Physical address of the backing data structure used for translation.

This should be treated as an opaque value outside of architecture-specific components.

Auto Trait Implementations§

§

impl Freeze for ArchVmAspace

§

impl RefUnwindSafe for ArchVmAspace

§

impl Send for ArchVmAspace

§

impl Sync for ArchVmAspace

§

impl !Unpin for ArchVmAspace

§

impl UnsafeUnpin for ArchVmAspace

§

impl UnwindSafe for ArchVmAspace

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Init<T> for T

§

unsafe fn __init(self, slot: *mut T) -> Result<(), Infallible>

Initializes slot. Read more
§

fn chain<F>(self, f: F) -> ChainInit<Self, F, T, E>
where F: FnOnce(&mut T) -> Result<(), E>,

First initializes the value using self then calls the function f with the initialized value. Read more
§

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

§

fn into(self) -> U

Calls U::from(self).

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

§

impl<T> PinInit<T> for T

§

unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), Infallible>

Initializes slot. Read more
§

fn pin_chain<F>(self, f: F) -> ChainPinInit<Self, F, T, E>
where F: FnOnce(Pin<&mut T>) -> Result<(), E>,

First initializes the value using self then calls the function f with the initialized value. Read more
§

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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

§

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

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

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

Performs the conversion.