class VmAspace

Defined at line 37 of file ../../zircon/kernel/vm/include/vm/vm_aspace.h

Public Members

static const uint VMM_FLAG_VALLOC_SPECIFIC
static const uint VMM_FLAG_COMMIT

Public Methods

vaddr_t base ()

simple accessors

Defined at line 101 of file ../../zircon/kernel/vm/include/vm/vm_aspace.h

size_t size ()

Defined at line 102 of file ../../zircon/kernel/vm/include/vm/vm_aspace.h

const char * name ()

Defined at line 103 of file ../../zircon/kernel/vm/include/vm/vm_aspace.h

ArchVmAspace & arch_aspace ()

Defined at line 104 of file ../../zircon/kernel/vm/include/vm/vm_aspace.h

bool is_user ()

Defined at line 105 of file ../../zircon/kernel/vm/include/vm/vm_aspace.h

bool is_aslr_enabled ()

Defined at line 106 of file ../../zircon/kernel/vm/include/vm/vm_aspace.h

VmAspace * kernel_aspace ()

accessor for singleton kernel address space

Defined at line 116 of file ../../zircon/kernel/vm/include/vm/vm_aspace.h

fbl::RefPtr<VmAspace> Create (Type type, const char * name)

Create 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 null on failure (e.g. due to resource starvation).

Defined at line 235 of file ../../zircon/kernel/vm/vm_aspace.cc

fbl::RefPtr<VmAspace> Create (vaddr_t base, size_t size, Type type, const char * name, ShareOpt share_opt)

Defined at line 203 of file ../../zircon/kernel/vm/vm_aspace.cc

fbl::RefPtr<VmAspace> CreateUnified (VmAspace * shared, VmAspace * restricted, const char * name)

Create 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 Destroy()'d before the shared and restricted VmAspaces; Destroy()'ing the

constituent VmAspaces before Destroy()'ing this one will trigger asserts.

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

Defined at line 173 of file ../../zircon/kernel/vm/vm_aspace.cc

zx_status_t Destroy ()

Destroy this address space.

Destroy does not free this object, but rather allows it to be freed when the last retaining

RefPtr is destroyed.

Defined at line 302 of file ../../zircon/kernel/vm/vm_aspace.cc

void Rename (const char * name)

Defined at line 262 of file ../../zircon/kernel/vm/vm_aspace.cc

fbl::RefPtr<VmAddressRegion> RootVmar ()

Get the root VMAR (briefly acquires the aspace lock)

May return nullptr if the aspace has been destroyed or is not yet initialized.

Defined at line 295 of file ../../zircon/kernel/vm/vm_aspace.cc

bool is_destroyed ()

Returns true if the address space has been destroyed.

Defined at line 335 of file ../../zircon/kernel/vm/vm_aspace.cc

void AttachToThread (Thread * t)

set the per thread aspace pointer to this

Defined at line 559 of file ../../zircon/kernel/vm/vm_aspace.cc

void Dump (bool verbose)

Defined at line 711 of file ../../zircon/kernel/vm/vm_aspace.cc

void DumpLocked (bool verbose)

Defined at line 717 of file ../../zircon/kernel/vm/vm_aspace.cc

void DropAllUserPageTables ()

Defined at line 776 of file ../../zircon/kernel/vm/vm_aspace.cc

void DropUserPageTables ()

Defined at line 784 of file ../../zircon/kernel/vm/vm_aspace.cc

void DumpAllAspaces (bool verbose)

Defined at line 730 of file ../../zircon/kernel/vm/vm_aspace.cc

void HarvestAllUserAccessedBits (NonTerminalAction non_terminal_action, TerminalAction terminal_action)

Defined at line 817 of file ../../zircon/kernel/vm/vm_aspace.cc

zx_status_t GetMemoryUsage (vm_usage_t * usage)

Counts memory usage under the VmAspace.

Defined at line 1026 of file ../../zircon/kernel/object/diagnostics.cc

zx_status_t SoftFault (vaddr_t va, uint flags)

Generates a soft fault against this aspace. This is similar to a PageFault except:

* This aspace 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 PageFault from occurring.

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

Defined at line 674 of file ../../zircon/kernel/vm/vm_aspace.cc

zx_status_t SoftFaultInRange (vaddr_t va, uint flags, size_t len)

Similar to SoftFault, 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 aspace 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.

Defined at line 679 of file ../../zircon/kernel/vm/vm_aspace.cc

zx_status_t AccessedFault (vaddr_t va)

Generates an accessed flag fault against this aspace. This is a specialized version of

SoftFault that will only resolve a potential missing access flag and nothing else.

Defined at line 703 of file ../../zircon/kernel/vm/vm_aspace.cc

zx_status_t PageFault (vaddr_t va, uint flags)

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

Defined at line 576 of file ../../zircon/kernel/vm/vm_aspace.cc

fbl::RefPtr<VmAddressRegionOrMapping> FindRegion (vaddr_t va)

Convenience method for traversing the tree of VMARs to find the deepest

VMAR in the tree that includes *va*.

Returns nullptr if the aspace has been destroyed or is not yet initialized.

Defined at line 540 of file ../../zircon/kernel/vm/vm_aspace.cc

zx_status_t AllocPhysical (const char * name, size_t size, void ** ptr, uint8_t align_pow2, paddr_t paddr, uint vmm_flags, arch_mmu_flags_t arch_mmu_flags)

legacy functions to assist in the transition to VMARs

These all assume a flat VMAR structure in which all VMOs are mapped

as children of the root. They will all assert if used on user aspaces

TODO(teisenbe): remove uses of these in favor of new VMAR interfaces

Defined at line 421 of file ../../zircon/kernel/vm/vm_aspace.cc

zx_status_t AllocContiguous (const char * name, size_t size, void ** ptr, uint8_t align_pow2, uint vmm_flags, arch_mmu_flags_t arch_mmu_flags)

Defined at line 462 of file ../../zircon/kernel/vm/vm_aspace.cc

zx_status_t Alloc (const char * name, size_t size, void ** ptr, uint8_t align_pow2, uint vmm_flags, arch_mmu_flags_t arch_mmu_flags)

Defined at line 490 of file ../../zircon/kernel/vm/vm_aspace.cc

zx_status_t FreeRegion (vaddr_t va)

Defined at line 514 of file ../../zircon/kernel/vm/vm_aspace.cc

zx_status_t MapObjectInternal (fbl::RefPtr<VmObject> vmo, const char * name, uint64_t offset, size_t size, void ** ptr, uint8_t align_pow2, uint vmm_flags, arch_mmu_flags_t arch_mmu_flags)

Internal use function for mapping VMOs. Do not use. This is exposed in

the public API purely for tests.

Defined at line 340 of file ../../zircon/kernel/vm/vm_aspace.cc

uintptr_t vdso_base_address ()

Defined at line 759 of file ../../zircon/kernel/vm/vm_aspace.cc

uintptr_t vdso_code_address ()

Defined at line 768 of file ../../zircon/kernel/vm/vm_aspace.cc

bool IntersectsVdsoCodeLocked (vaddr_t base, size_t size)

Helper function to test for collision with vdso_code_mapping_.

Defined at line 791 of file ../../zircon/kernel/vm/vm_aspace.cc

bool IsHighMemoryPriority ()

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

Defined at line 799 of file ../../zircon/kernel/vm/vm_aspace.cc

Protected Methods

Lock<CriticalMutex> * lock ()

Defined at line 236 of file ../../zircon/kernel/vm/include/vm/vm_aspace.h

Lock<CriticalMutex> & lock_ref ()

Defined at line 237 of file ../../zircon/kernel/vm/include/vm/vm_aspace.h

Lock<CriticalMutex> * region_lock ()

Defined at line 238 of file ../../zircon/kernel/vm/include/vm/vm_aspace.h

Lock<CriticalMutex> & region_lock_ref ()

Defined at line 239 of file ../../zircon/kernel/vm/include/vm/vm_aspace.h

crypto::Prng & AslrPrng ()

Expose the PRNG for ASLR to VmAddressRegion

Defined at line 242 of file ../../zircon/kernel/vm/include/vm/vm_aspace.h

uint8_t AslrEntropyBits (bool compact)

Defined at line 247 of file ../../zircon/kernel/vm/include/vm/vm_aspace.h

Enumerations

enum class Type : uint8_t
Name Value Comments
User 0 --
Kernel 1 --
LowKernel 2

You probably do not want to use LOW_KERNEL. It is primarily used for SMP bootstrap or mexec
to allow mappings of very low memory using the standard VMM subsystem.

GuestPhysical 3

Used to construct an address space representing hypervisor guest memory.

Defined at line 39 of file ../../zircon/kernel/vm/include/vm/vm_aspace.h

enum class ShareOpt
Name Value
None 0
Restricted 1
Shared 2

Create 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 `InitShared` 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 `InitRestricted` method.

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

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

Defined at line 70 of file ../../zircon/kernel/vm/include/vm/vm_aspace.h

Records

Friends

void VmAspace ()
class RefPtr
class Access
class GuestPhysicalAspace
class VmMapping
class VmAddressRegion
class VmAddressRegionOrMapping