class VmMapping
Defined at line 1005 of file ../../zircon/kernel/vm/include/vm/vm_address_region.h
A representation of the mapping of a VMO into the address space
Public Members
static const uint64_t kPageFaultMaxOptimisticPages
Public Methods
fbl::RefPtr<VmObject> vmo ()
Defined at line 141 of file ../../zircon/kernel/vm/vm_mapping.cc
zx_status_t DecommitRange (size_t offset, size_t len)
Convenience wrapper for vmo()->DecommitRange() with the necessary
offset modification and locking.
Defined at line 855 of file ../../zircon/kernel/vm/vm_mapping.cc
zx_status_t MapRange (size_t offset, size_t len, bool commit, bool ignore_existing)
Map in pages from the underlying vm object, optionally committing pages as it goes.
|ignore_existing| controls whether existing hardware mappings in the specified range should be
ignored or treated as an error. |ignore_existing| should only be set to true for user mappings
where populating mappings may already be racy with multiple threads, and where we are already
tolerant of mappings being arbitrarily created and destroyed.
Defined at line 693 of file ../../zircon/kernel/vm/vm_mapping.cc
AttributionCounts GetAttributedMemory ()
Defined at line 164 of file ../../zircon/kernel/vm/vm_mapping.cc
void DumpLocked (uint depth, bool verbose)
Defined at line 171 of file ../../zircon/kernel/vm/vm_mapping.cc
void AspaceUnmapLockedObject (uint64_t offset, uint64_t len, UnmapOptions options)
Unmap any pages that map the passed in vmo range from the arch aspace.
May not intersect with this range.
If |only_has_zero_pages| is true then the caller is asserting that it knows that any mappings
in the region will only be for the shared zero page.
Defined at line 420 of file ../../zircon/kernel/vm/vm_mapping.cc
void AspaceRemoveWriteLockedObject (uint64_t offset, uint64_t len)
Removes any writeable mappings for the passed in vmo range from the arch aspace.
May fall back to unmapping pages from the arch aspace if necessary.
Defined at line 472 of file ../../zircon/kernel/vm/vm_mapping.cc
void AspaceDebugUnpinLockedObject (uint64_t offset, uint64_t len)
Checks if this is a kernel mapping within the given VMO range, which would be an error to be
unpinning.
Defined at line 533 of file ../../zircon/kernel/vm/vm_mapping.cc
uint arch_mmu_flags_locked (vaddr_t offset)
Accessors for VMO-mapping state
These can be read under either lock (both locks being held for writing), so we provide two
different accessors, one for each lock.
Defined at line 1010 of file ../../zircon/kernel/vm/include/vm/vm_address_region.h
uint arch_mmu_flags_locked_object (vaddr_t offset)
Defined at line 1013 of file ../../zircon/kernel/vm/include/vm/vm_address_region.h
MappingProtectionRanges::FlagsRange arch_mmu_flags_range_locked (vaddr_t offset)
Defined at line 1017 of file ../../zircon/kernel/vm/include/vm/vm_address_region.h
uint64_t object_offset ()
Defined at line 1021 of file ../../zircon/kernel/vm/include/vm/vm_address_region.h
uint64_t mapping_subtree_max_offset ()
Defined at line 1022 of file ../../zircon/kernel/vm/include/vm/vm_address_region.h
Lock<CriticalMutex> * object_lock ()
Defined at line 1026 of file ../../zircon/kernel/vm/include/vm/vm_address_region.h
Lock<CriticalMutex> & object_lock_ref ()
Defined at line 1029 of file ../../zircon/kernel/vm/include/vm/vm_address_region.h
fbl::RefPtr<VmObject> vmo_locked ()
Intended to be used from VmEnumerator callbacks where the aspace_->lock() will be held.
Defined at line 1034 of file ../../zircon/kernel/vm/include/vm/vm_address_region.h
zx_status_t DebugUnmap (vaddr_t base, size_t size)
Unlocked convenience wrapper of UnmapLocked for testing.
Defined at line 1053 of file ../../zircon/kernel/vm/include/vm/vm_address_region.h
zx_status_t DebugProtect (vaddr_t base, size_t size, uint new_arch_mmu_flags)
Unlocked convenience wrapper of ProtectLocked for testing.
Defined at line 1060 of file ../../zircon/kernel/vm/include/vm/vm_address_region.h
void assert_object_lock ()
|assert_object_lock| exists to satisfy clang capability analysis since there are circumstances
when the object_->lock() is actually being held, but it was not acquired by dereferencing
object_. In this scenario we need to explain to the analysis that the lock held is actually the
same as object_->lock(), and even though we otherwise have no intention of using object_, the
only way to do this is to notionally dereferencing object_ to compare the lock.
Since this is asserting that the lock is held, and not just returning a reference to the lock,
this method is logically correct since object_ itself is only modified if object_->lock() is
held.
Defined at line 1105 of file ../../zircon/kernel/vm/include/vm/vm_address_region.h
ktl::pair<zx_status_t, uint32_t> PageFault (vaddr_t va, uint pf_flags, size_t additional_pages, VmObject * object, MultiPageRequest * page_request)
Page fault in an address within the mapping. The requested address must be paged aligned. If
|additional_pages| is non-zero, then up to that many additional pages may be resolved using the
same |pf_flags|. It is not an error for the |additional_pages| to span beyond the mapping or
underlying VMO, although the range will get truncated internally. As such only the page
containing va is required to be resolved, and this method may return ZX_OK if any number,
including zero, of the additional pages are resolved.
|object| is required to be the value of object_ with the requirement that if the aspace lock()
is not held over the call to this function, then the caller is required to ensure that |object|
will remain alive for the duration of the call.
As the |additional_pages| are resolved with the same |pf_flags| they may trigger copy-on-write
or other allocations in the underlying VMO.
If this returns ZX_ERR_SHOULD_WAIT, then the caller should wait on |page_request|
and try again. In addition to a status this returns how many pages got mapped in.
This may return ZX_ERR_UNAVAILABLE if the aspace lock() is not held and means that the mapping
was destroyed before the page fault could be handled.
If ZX_OK is returned then the number of pages mapped in is guaranteed to be >0.
If |additional_pages| was non-zero, then the maximum number of pages that will be mapped is
|additional_pages + 1|. Otherwise the maximum number of pages that will be mapped is
kPageFaultMaxOptimisticPages.
Defined at line 1137 of file ../../zircon/kernel/vm/vm_mapping.cc
template <typename F>
zx_status_t EnumerateProtectionRangesLocked (vaddr_t base, size_t size, F func)
Enumerates any different protection ranges that exist inside this mapping. The virtual range
specified by range_base and range_size must be within this mappings base_ and size_. The
provided callback is called in virtual address order for each protection type. ZX_ERR_NEXT
and ZX_ERR_STOP can be used to control iteration, with any other status becoming the return
value of this method.
Defined at line 1144 of file ../../zircon/kernel/vm/include/vm/vm_address_region.h
VmObject::MappingTreeTraits::Key GetKey ()
WAVL tree key function
For use in WAVL tree code only.
Defined at line 1160 of file ../../zircon/kernel/vm/include/vm/vm_address_region.h
ktl::pair<zx_status_t, uint32_t> PageFaultLocked (vaddr_t va, uint pf_flags, size_t additional_pages, MultiPageRequest * page_request)
Convenience wrapper around PageFault that can be called with the aspace lock held and will
never return ZX_ERR_UNAVAILABLE.
Defined at line 1174 of file ../../zircon/kernel/vm/vm_mapping.cc
void MarkMergeable (fbl::RefPtr<VmMapping> mapping)
Marks this mapping as being a candidate for merging, and will immediately attempt to merge with
any neighboring mappings. Making a mapping mergeable essentially indicates that you will no
longer use this specific VmMapping instance to refer to the referenced region, and will access
the region via the parent vmar in the future, and so the region merely needs to remain valid
through some VmMapping.
For this the function requires you to hand in your last remaining refptr to the mapping.
Defined at line 1369 of file ../../zircon/kernel/vm/vm_mapping.cc
zx::result<fbl::RefPtr<VmMapping>> ForceWritable ()
TODO(https://fxbug.dev/42106188): Informs the mapping that a write is going to be performed to
the backing VMO, even if the VMO is not writable. This gives the mapping an opportunity to
create a private clone of the VMO if necessary and use that to back a new mapping instead,
providing a way to 'safely' perform the write. On success a RefPtr is returned either to the
current mapping, or to a new mapping if one was created. If a new mapping was created then this
mapping is no longer valid.
Defined at line 1471 of file ../../zircon/kernel/vm/vm_mapping.cc
Protected Methods
void ~VmMapping ()
Defined at line 136 of file ../../zircon/kernel/vm/vm_mapping.cc
Enumerations
enum UnmapOptions
| Name | Value |
|---|---|
| kNone | 0u |
| OnlyHasZeroPages | (1u << 0) |
| Harvest | (1u << 1) |
Defined at line 1109 of file ../../zircon/kernel/vm/include/vm/vm_address_region.h
Friends
class VmMappingSubtreeState
class MappingTreeTraits
class VmAddressRegion
class RefPtr