pub struct ArchVmAspace { /* private fields */ }Implementations§
Source§impl ArchVmAspace
impl ArchVmAspace
Sourcepub fn init(&self) -> Result<(), Status>
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.
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.
Sourcepub fn init_restricted(&self) -> Result<(), Status>
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.
Sourcepub fn init_unified(
&self,
shared: &ArchVmAspace,
restricted: &ArchVmAspace,
) -> Result<(), Status>
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.
Sourcepub fn disable_updates(&self)
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.
Sourcepub fn destroy(&self) -> Result<(), Status>
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.
Sourcepub unsafe fn map_contiguous(
&self,
vaddr: usize,
paddr: PAddr,
count: usize,
mmu_flags: ArchMmuFlags,
) -> Result<(), Status>
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.
Sourcepub unsafe fn map(
&self,
vaddr: usize,
phys: *mut PAddr,
count: usize,
mmu_flags: ArchMmuFlags,
existing_action: ExistingEntryAction,
) -> Result<(), Status>
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.
Sourcepub unsafe fn unmap(
&self,
vaddr: usize,
count: usize,
enlarge: ArchUnmapOptions,
) -> Result<(), Status>
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.
Sourcepub fn unmap_only_enlarge_on_oom(&self) -> bool
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.
Sourcepub unsafe fn protect(
&self,
vaddr: usize,
count: usize,
mmu_flags: ArchMmuFlags,
enlarge: ArchUnmapOptions,
) -> Result<(), Status>
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.
Sourcepub fn query(&self, vaddr: usize) -> Result<(PAddr, ArchMmuFlags), Status>
pub fn query(&self, vaddr: usize) -> Result<(PAddr, ArchMmuFlags), Status>
Queries the translation for vaddr.
Sourcepub fn pick_spot(
&self,
base: usize,
end: usize,
align: usize,
size: usize,
mmu_flags: ArchMmuFlags,
) -> usize
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.
Sourcepub fn harvest_accessed(
&self,
vaddr: usize,
count: usize,
non_terminal_action: NonTerminalAction,
terminal_action: TerminalAction,
) -> Result<(), Status>
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.
Sourcepub fn mark_accessed(&self, vaddr: usize, count: usize) -> Result<(), Status>
pub fn mark_accessed(&self, vaddr: usize, count: usize) -> Result<(), Status>
Marks any pages in the given virtual address range as being accessed.
Sourcepub fn accessed_since_last_check(&self, clear: bool) -> bool
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.
Sourcepub fn arch_table_phys(&self) -> PAddr
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 Twhere
T: 'static + ?Sized,
impl<T> Any for Twhere
T: 'static + ?Sized,
§impl<T> Borrow<T> for Twhere
T: ?Sized,
impl<T> Borrow<T> for Twhere
T: ?Sized,
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Init<T> for T
impl<T> Init<T> for T
§impl<T, U> Into<U> for Twhere
U: From<T>,
impl<T, U> Into<U> for Twhere
U: From<T>,
§impl<T> PinInit<T> for T
impl<T> PinInit<T> for T
§unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), Infallible>
unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), Infallible>
slot. Read more