Skip to main content

VmAspace

Struct VmAspace 

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

Implementations§

Source§

impl VmAspace

Source

pub fn create(type_: Type, name: &CStr) -> Option<RefPtr<VmAspace>>

Creates an address space of the type specified in type_ with name name.

Although reference counted, the returned VmAspace must be explicitly destroyed via destroy.

Returns None on failure (e.g. due to resource starvation).

Source

pub fn create_with_opts( base: usize, size: usize, type_: Type, name: &CStr, share_opt: ShareOpt, ) -> Option<RefPtr<VmAspace>>

Creates an address space of the type specified in type_ with name name.

The returned aspace will start at base and span size.

If share_opt is ShareOpt::Shared, we’re creating a shared address space, and the underlying ArchVmAspace will be initialized using the init_shared method instead of the normal init method.

If share_opt is ShareOpt::Restricted, we’re creating a restricted address space, and the underlying ArchVmAspace will be initialized using the init_restricted method.

Although reference counted, the returned VmAspace must be explicitly destroyed via destroy.

Returns None on failure (e.g. due to resource starvation).

Source

pub unsafe fn create_unified( shared: *mut VmAspace, restricted: *mut VmAspace, name: &CStr, ) -> Option<RefPtr<VmAspace>>

Creates a unified address space that consists of the given constituent address spaces.

The passed in address spaces must meet the following criteria:

  1. They must manage non-overlapping regions.
  2. The shared VmAspace must have been created with the shared argument set to true.

Although reference counted, the returned VmAspace must be explicitly destroyed via destroy. Note that it must be destroyed before the shared and restricted VmAspaces; destroying the constituent VmAspaces before destroying this one will trigger asserts.

Returns None on failure (e.g. due to resource starvation).

§Safety

The caller must ensure that shared and restricted are valid pointers to address spaces initialized as shared and restricted respectively.

Source

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

Destroys this address space.

destroy does not free this object, but rather allows it to be freed when the last retaining RefPtr is destroyed.

Source

pub fn rename(&self, name: &CStr)

Renames this address space.

Source

pub fn base(&self) -> usize

Returns the base virtual address of this address space.

Source

pub fn size(&self) -> usize

Returns the size in bytes of this address space.

Source

pub fn name(&self) -> &CStr

Returns the name of this address space.

Source

pub fn arch_aspace(&self) -> &ArchVmAspace

Returns a reference to the architecturally specific part of the address space (ArchVmAspace). This is internally locked and does not need to be guarded by lock_.

Source

pub fn is_user(&self) -> bool

Returns true if this is a user address space (Type::User).

Source

pub fn is_aslr_enabled(&self) -> bool

Returns true if ASLR is enabled for this address space.

Source

pub fn is_destroyed(&self) -> bool

Returns true if this address space has been destroyed.

Source

pub fn kernel_aspace() -> Option<RefPtr<VmAspace>>

Returns the singleton kernel address space.

Source

pub fn root_vmar(&self) -> Option<RefPtr<VmAddressRegion>>

Returns the root address region (RootVmar) for this address space.

Source

pub fn attach_to_thread(&self, thread: ThreadPtr)

Sets the per-thread address space pointer to this address space.

Source

pub fn dump(&self, verbose: bool)

Dumps information about this address space to the debug log.

Source

pub fn drop_all_user_page_tables()

Drops all user page tables across all user address spaces.

Source

pub fn drop_user_page_tables(&self)

Drops all user page tables for this address space.

Source

pub fn dump_all_aspaces(verbose: bool)

Dumps all address spaces in the system.

Source

pub fn harvest_all_user_accessed_bits( non_terminal_action: NonTerminalAction, terminal_action: TerminalAction, )

Harvests all accessed information across all user mappings and updates any page age information for terminal mappings, and potentially harvests page tables depending on the passed in action.

This requires holding aspaces_list_lock_ over the entire duration and whilst not a commonly used lock this function should still only be called infrequently to avoid monopolizing the lock.

Source

pub fn soft_fault(&self, va: usize, flags: u32) -> Result<(), Status>

Generates a soft fault against this address space.

This is similar to page_fault except:

  • This address space may not currently be active and this does not have to be called from the hardware exception handler.
  • May be invoked spuriously in situations where the hardware mappings would have prevented a real page_fault from occurring.

May block on page requests and must be called without locks held.

Source

pub fn soft_fault_in_range( &self, va: usize, flags: u32, len: usize, ) -> Result<(), Status>

Similar to soft_fault, but additionally takes a length indicating that the range of [va, va+len) is expected to be accessed with flags after resolving this fault. The address space can take this range as a hint to attempt to preemptively avoid future faults.

There are no alignment restrictions on va or len, although it is assumed that len is greater than zero.

Source

pub fn accessed_fault(&self, va: usize) -> Result<(), Status>

Generates an accessed flag fault against this address space.

This is a specialized version of soft_fault that will only resolve a potential missing access flag and nothing else.

Source

pub fn page_fault(&self, va: usize, flags: u32) -> Result<(), Status>

Page fault routine.

Should only be called by the hypervisor or by Thread::Current::Fault.

Source

pub unsafe fn alloc_physical( &self, name: &CStr, size: usize, ptr: *mut *mut c_void, align_pow2: u8, paddr: PAddr, vmm_flags: u32, arch_mmu_flags: ArchMmuFlags, ) -> Result<(), Status>

Legacy function to assist in the transition to VMARs.

Assumes a flat VMAR structure in which all VMOs are mapped as children of the root. Will assert if used on user address spaces.

§Safety

The caller must ensure ptr points to a valid memory location that can hold the allocated address or specific starting address.

Source

pub unsafe fn alloc_contiguous( &self, name: &CStr, size: usize, ptr: *mut *mut c_void, align_pow2: u8, vmm_flags: u32, arch_mmu_flags: ArchMmuFlags, ) -> Result<(), Status>

Legacy function to assist in the transition to VMARs.

Assumes a flat VMAR structure in which all VMOs are mapped as children of the root. Will assert if used on user address spaces.

§Safety

The caller must ensure ptr points to a valid memory location that can hold the allocated address or specific starting address.

Source

pub unsafe fn free_region(&self, va: usize) -> Result<(), Status>

Legacy function to assist in the transition to VMARs.

Assumes a flat VMAR structure in which all VMOs are mapped as children of the root. Will assert if used on user address spaces.

§Safety

The caller must ensure that the virtual address range being freed is no longer in use.

Source

pub fn vdso_base_address(&self) -> usize

Returns the vDSO base address for this address space.

Source

pub fn vdso_code_address(&self) -> usize

Returns the vDSO code address for this address space.

Source

pub fn is_high_memory_priority(&self) -> bool

Returns whether this address space is currently set to be a high memory priority.

Trait Implementations§

Source§

impl HasRefCount for VmAspace

Source§

fn ref_count(&self) -> &RefCounted

Returns a reference to the contained RefCounted field.
Source§

impl Recyclable for VmAspace

Source§

unsafe fn recycle(ptr: NonNull<Self>)

Recycles the object. Read more
Source§

fn allocate(_value: Self) -> Result<NonNull<Self>, AllocError>

Allocates a new instance of Self.
Source§

unsafe fn recycle_ffi(ptr: *mut c_void)

Helper for FFI functions to call recycle. Read more

Auto Trait Implementations§

§

impl Freeze for VmAspace

§

impl RefUnwindSafe for VmAspace

§

impl Send for VmAspace

§

impl Sync for VmAspace

§

impl !Unpin for VmAspace

§

impl UnsafeUnpin for VmAspace

§

impl UnwindSafe for VmAspace

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.