The Pedigree Project 0.1
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
MemoryMapManager Class Reference

#include <MemoryMappedFile.h>

+ Inheritance diagram for MemoryMapManager:
+ Collaboration diagram for MemoryMapManager:

Classes

class  LockPlan
 
class  OperationGuard
 
class  PreparedFileResize
 
struct  RemapRequest
 

Public Types

enum class  Placement { Hint , FixedReplace , FixedNoReplace }
 
enum class  MapStatus {
  Success , NoMemory , AddressInUse , PolicyDenied ,
  TextBusy , LockLimit
}
 
enum class  VmStatus {
  Success , InvalidRange , Unmapped , Unsupported ,
  NoMemory , LockLimit
}
 
enum class  FileRemapStatus {
  Success , InvalidRange , Unsupported , NoMemory ,
  PolicyDenied , LockLimit , PermissionDenied
}
 
enum class  UserPageCopyStatus {
  Success , Inaccessible , NoMemory , IoError ,
  Unsupported
}
 
enum class  ProtectStatus {
  Success , Unmapped , AccessDenied , InvalidRange ,
  Unsupported , NoMemory , TextBusy
}
 
enum class  FaultResolution { Unhandled , Resolved , BackingFault }
 
enum class  ResizeStatus { Ready , NoMemory , Unsupported , Invalid }
 

Public Member Functions

FileRemapStatus remapFilePages (uintptr_t base, size_t length, size_t byteOffset, bool nonblock)
 
VmStatus remap (const RemapRequest &request, uintptr_t &result)
 
VmStatus residency (uintptr_t base, size_t length, unsigned char *kernelVector, FileResidencyAccess access, void *credentials)
 
VmStatus discard (uintptr_t base, size_t length)
 
UserPageCopyStatus copyUserPage (VirtualAddressSpace &space, uintptr_t userAddress, void *kernelBuffer, size_t bytes, bool write)
 
PopulationStatus populateMemory (VirtualAddressSpace &space, uintptr_t base, size_t length)
 
void bindMemoryLockPolicy (VirtualAddressSpace &space)
 
MemoryLockStatus lockMemory (VirtualAddressSpace &space, uintptr_t base, size_t length, MemoryLockMode mode, bool privileged)
 
MemoryLockStatus lockAllMemory (VirtualAddressSpace &space, bool current, MemoryLockMode currentMode, MemoryLockMode futureMode, bool privileged)
 
bool hasLockedMemory (VirtualAddressSpace &space, uintptr_t base, size_t length)
 
MemoryMappedObject * mapFile (File *pFile, uintptr_t &address, size_t length, MemoryMappedObject::Permissions perms, size_t offset=0, bool bCopyOnWrite=true)
 
bool hasSharedWriteCapability (File *backing)
 
MemoryMappedObject * mapFile (File *pFile, uintptr_t &address, size_t length, MemoryMappedObject::Permissions perms, size_t offset, bool bCopyOnWrite, Placement placement, MapStatus *status, MemoryMappedObject::Permissions maximumPerms=MemoryMappedObject::Read|MemoryMappedObject::Write|MemoryMappedObject::Exec, const SharedPointer< MappingAttachment > &attachment=SharedPointer< MappingAttachment >(), MemoryLockMode requestedLock=MemoryLockMode::None, const FileMappingOrigin &origin={})
 
MemoryMappedObject * mapAnon (uintptr_t &address, size_t length, MemoryMappedObject::Permissions perms)
 
MemoryMappedObject * mapAnon (uintptr_t &address, size_t length, MemoryMappedObject::Permissions perms, Placement placement, MapStatus *status, MemoryLockMode requestedLock=MemoryLockMode::None)
 
bool clone (Process *pTarget)
 
SwapStatus pageOutRange (uintptr_t base, size_t length)
 
SwapStatus activateSwap (uint32_t endpoint)
 
SwapStatus deactivateSwap (uint32_t endpoint)
 
SwapSnapshot swapSnapshot ()
 
bool operationOwnedByCurrentExecution ()
 
size_t remove (uintptr_t base, size_t length)
 
size_t removeAndRelease (uintptr_t base, size_t length, VmStatus *status=nullptr)
 
SharedPointer< MappingAttachment > findAttachment (uintptr_t base)
 
size_t removeAttachment (const SharedPointer< MappingAttachment > &attachment)
 
size_t setPermissions (uintptr_t base, size_t length, MemoryMappedObject::Permissions perms, ProtectStatus *status=nullptr)
 
bool contains (uintptr_t base, size_t length)
 
bool allows (uintptr_t base, size_t length, MemoryMappedObject::Permissions permissions)
 
bool sharedBacking (Process *process, uintptr_t address, uintptr_t &identity, size_t &offset)
 
bool faultIn (uintptr_t address, bool write)
 
bool faultInRange (uintptr_t address, size_t length, bool write)
 
bool writableAnonymousRange (uintptr_t address, size_t length)
 
FaultResolution resolveUserFault (uintptr_t address, bool write, bool wasPresent, bool execute)
 
ResizeStatus prepareFileResize (File *file, size_t oldSize, size_t newSize, UniquePointer< PreparedFileResize > &result)
 
bool sync (uintptr_t base, size_t length, bool async, int *error=nullptr)
 
void invalidate (uintptr_t base, size_t length)
 
void unmap (MemoryMappedObject *pObj)
 
void unmapAll ()
 
virtual bool trap (InterruptState &state, uintptr_t address, bool bIsWrite, bool bWasPresent)
 
virtual bool compact ()
 
virtual const char * getMemoryPressureDescription ()
 

Static Public Member Functions

static MemoryMapManager & instance ()
 

Protected Member Functions

void unmapAllUnlocked ()
 
void acquireLock ()
 
void releaseLock ()
 

Private Types

enum  Ops { Sync , Invalidate }
 
typedef MappingList< MemoryMappedObject > MmObjectList
 

Private Member Functions

 MemoryMapManager ()
 
MemoryLockStatus prepareManagedLocks (VirtualAddressSpace &space, uintptr_t base, size_t length, MemoryLockMode mode, bool all, UniquePointer< PreparedMemoryLock > &result)
 
MemoryMappedObject * publishMapping (File *file, uintptr_t &address, size_t length, MemoryMappedObject::Permissions perms, size_t offset, bool copyOnWrite, Placement placement, MapStatus *status, MemoryMappedObject::Permissions maximumPerms, const SharedPointer< MappingAttachment > &attachment, MemoryLockMode requestedLock, const FileMappingOrigin &origin={})
 
void retireLockedPages (VirtualAddressSpace &space, size_t pages)
 
void enterOperation ()
 
bool tryEnterOperation ()
 
void leaveOperation ()
 
size_t removeInternal (uintptr_t base, size_t length, bool releaseReservations, VmStatus *status=nullptr)
 
void releaseReservation (Process *process, VirtualAddressSpace &addressSpace, uintptr_t base, size_t length)
 
bool faultInUnlocked (uintptr_t address, bool write, MemoryMappedObject *&selected, bool residentAnonymousOnly=false)
 
bool accessRange (uintptr_t address, size_t length, bool write, bool residentAnonymousOnly)
 
bool handleTrapUnlocked (uintptr_t address, bool bIsWrite, bool bWasPresent, bool execute, MemoryMappedObject *selected)
 
bool handleTrap (uintptr_t address, bool bIsWrite, bool bWasPresent, bool execute=false, MemoryMappedObject *selected=nullptr)
 
bool op (Ops what, uintptr_t base, size_t length, bool async)
 

Private Attributes

Tree< VirtualAddressSpace *, MmObjectList * > m_MmObjectLists
 
Spinlock m_Lock
 
Mutex m_LifecycleLock
 
Spinlock m_LifecycleStateLock
 
void * m_pLifecycleOwner
 
size_t m_LifecycleDepth
 

Static Private Attributes

static MemoryMapManager m_Instance
 

Friends

class PosixSubsystem
 
class VfsUserMemoryPolicy
 

Detailed Description

This class is a multiplexing trap handler, to handle traps for MemoryMappedObjects, dispatching them to the right place.

Definition at line 559 of file MemoryMappedFile.h.

Member Typedef Documentation

◆ MmObjectList

Definition at line 888 of file MemoryMappedFile.h.

Member Enumeration Documentation

◆ FaultResolution

enum class MemoryMapManager::FaultResolution
strong

Definition at line 737 of file MemoryMappedFile.h.

◆ FileRemapStatus

enum class MemoryMapManager::FileRemapStatus
strong

Definition at line 580 of file MemoryMappedFile.h.

◆ MapStatus

enum class MemoryMapManager::MapStatus
strong

Definition at line 570 of file MemoryMappedFile.h.

◆ Ops

enum MemoryMapManager::Ops
private

Definition at line 878 of file MemoryMappedFile.h.

◆ Placement

enum class MemoryMapManager::Placement
strong

Definition at line 564 of file MemoryMappedFile.h.

◆ ProtectStatus

Adjusts permissions across the given range, crossing object boundaries if necessary.

Returns
number of objects affected by this call.

Definition at line 702 of file MemoryMappedFile.h.

◆ ResizeStatus

enum class MemoryMapManager::ResizeStatus
strong

Definition at line 740 of file MemoryMappedFile.h.

◆ UserPageCopyStatus

enum class MemoryMapManager::UserPageCopyStatus
strong

Definition at line 600 of file MemoryMappedFile.h.

◆ VmStatus

enum class MemoryMapManager::VmStatus
strong

Definition at line 579 of file MemoryMappedFile.h.

Constructor & Destructor Documentation

◆ MemoryMapManager()

MemoryMapManager::MemoryMapManager ( )
private

Default and only constructor. Registers with PageFaultHandler.

Definition at line 803 of file MemoryMappedFile.cc.

References PageFaultHandler::instance(), PageFaultHandler::registerHandler(), and MemoryPressureManager::registerHandler().

◆ ~MemoryMapManager()

MemoryMapManager::~MemoryMapManager ( )
private

Definition at line 891 of file MemoryMappedFile.cc.

Member Function Documentation

◆ accessRange()

bool MemoryMapManager::accessRange ( uintptr_t  address,
size_t  length,
bool  write,
bool  residentAnonymousOnly 
)
private

Definition at line 1442 of file MemoryMappedFile.cc.

◆ acquireLock()

void MemoryMapManager::acquireLock ( )
protected

Acquire the manager's operation gate.

Take this before becoming unscheduleable when a caller needs to invoke unmapAllUnlocked. Contention sleeps through the operation barrier rather than spinning until the gate becomes available.

Definition at line 1789 of file MemoryMappedFile.cc.

Referenced by PosixSubsystem::~PosixSubsystem().

+ Here is the caller graph for this function:

◆ activateSwap()

SwapStatus MemoryMapManager::activateSwap ( uint32_t  endpoint)

Definition at line 8 of file MemoryMappedFile-swap.cc.

◆ allows()

bool MemoryMapManager::allows ( uintptr_t  base,
size_t  length,
MemoryMappedObject::Permissions  permissions 
)

Returns true if memory-map objects cover the full range with all of the requested permissions.

Definition at line 1207 of file MemoryMappedFile.cc.

References MemoryMappedObject::address(), PhysicalMemoryManager::getPageSize(), Process::getParent(), ProcessorBase::information(), MemoryMappedObject::length(), m_MmObjectLists, and MemoryMappedObject::permissions().

Referenced by sync().

+ Here is the caller graph for this function:

◆ bindMemoryLockPolicy()

void MemoryMapManager::bindMemoryLockPolicy ( VirtualAddressSpace &  space)

Definition at line 69 of file MemoryMappedFile-lock.cc.

◆ clone()

bool MemoryMapManager::clone ( Process *  pTarget)

Registers the current address space's mappings with the target process.

Parameters
pTargetThe process to clone into.

Definition at line 897 of file MemoryMappedFile.cc.

References MemoryMappedObject::address(), MemoryMappedObject::clone(), SharedPointer< T >::get(), Process::getAddressSpace(), ProcessorBase::information(), Tree< K, E >::insert(), Tree< K, E >::lookup(), m_MmObjectLists, and MappingList< Object >::reserveBack().

◆ compact()

bool MemoryMapManager::compact ( )
virtual

Trigger a compact in all address spaces.

This may switch in and out of several address spaces.

Implements MemoryPressureHandler.

Definition at line 1722 of file MemoryMappedFile.cc.

References ProcessorBase::information(), m_MmObjectLists, and ProcessorBase::switchAddressSpace().

◆ contains()

bool MemoryMapManager::contains ( uintptr_t  base,
size_t  length 
)

Returns true if at least one memory mapped object is in the range given, false otherwise.

Definition at line 1183 of file MemoryMappedFile.cc.

References PhysicalMemoryManager::getPageSize(), ProcessorBase::information(), m_MmObjectLists, and MemoryMappedObject::matches().

◆ copyUserPage()

MemoryMapManager::UserPageCopyStatus MemoryMapManager::copyUserPage ( VirtualAddressSpace &  space,
uintptr_t  userAddress,
void *  kernelBuffer,
size_t  bytes,
bool  write 
)

Definition at line 10 of file MemoryMappedFile-usercopy.cc.

◆ deactivateSwap()

SwapStatus MemoryMapManager::deactivateSwap ( uint32_t  endpoint)

Definition at line 12 of file MemoryMappedFile-swap.cc.

◆ discard()

MemoryMapManager::VmStatus MemoryMapManager::discard ( uintptr_t  base,
size_t  length 
)

Definition at line 118 of file MemoryMappedFile-advice.cc.

◆ enterOperation()

void MemoryMapManager::enterOperation ( )
private

Definition at line 815 of file MemoryMappedFile.cc.

◆ faultIn()

bool MemoryMapManager::faultIn ( uintptr_t  address,
bool  write 
)

Definition at line 1428 of file MemoryMappedFile.cc.

◆ faultInRange()

bool MemoryMapManager::faultInRange ( uintptr_t  address,
size_t  length,
bool  write 
)

Fault in and validate every page touched by a byte range.

Definition at line 1434 of file MemoryMappedFile.cc.

◆ faultInUnlocked()

bool MemoryMapManager::faultInUnlocked ( uintptr_t  address,
bool  write,
MemoryMappedObject *&  selected,
bool  residentAnonymousOnly = false 
)
private

Definition at line 1350 of file MemoryMappedFile.cc.

◆ findAttachment()

SharedPointer< MappingAttachment > MemoryMapManager::findAttachment ( uintptr_t  base)

Find a logical attachment even when its first fragment was unmapped.

Definition at line 995 of file MemoryMappedFile.cc.

References MemoryMappedObject::address(), ProcessorBase::information(), and m_MmObjectLists.

◆ getMemoryPressureDescription()

virtual const char * MemoryMapManager::getMemoryPressureDescription ( )
inlinevirtual

Returns static storage so describing a recovery action cannot itself allocate memory.

Implements MemoryPressureHandler.

Definition at line 793 of file MemoryMappedFile.h.

◆ handleTrap()

bool MemoryMapManager::handleTrap ( uintptr_t  address,
bool  bIsWrite,
bool  bWasPresent,
bool  execute = false,
MemoryMappedObject *  selected = nullptr 
)
private

Definition at line 1616 of file MemoryMappedFile.cc.

◆ handleTrapUnlocked()

bool MemoryMapManager::handleTrapUnlocked ( uintptr_t  address,
bool  bIsWrite,
bool  bWasPresent,
bool  execute,
MemoryMappedObject *  selected 
)
private

Definition at line 1626 of file MemoryMappedFile.cc.

◆ hasLockedMemory()

bool MemoryMapManager::hasLockedMemory ( VirtualAddressSpace &  space,
uintptr_t  base,
size_t  length 
)

Definition at line 316 of file MemoryMappedFile-lock.cc.

◆ hasSharedWriteCapability()

bool MemoryMapManager::hasSharedWriteCapability ( File *  backing)

Retain an outer OperationGuard when using this query before publication.

Definition at line 1707 of file MemoryMappedFile.cc.

References File::futexIdentity(), MemoryMappedObject::m_bCopyOnWrite, and m_MmObjectLists.

◆ instance()

static MemoryMapManager & MemoryMapManager::instance ( )
inlinestatic

◆ invalidate()

void MemoryMapManager::invalidate ( uintptr_t  base,
size_t  length 
)

Invalidates backing-cache state where required by the mapping.

Definition at line 1564 of file MemoryMappedFile.cc.

◆ leaveOperation()

void MemoryMapManager::leaveOperation ( )
private

Definition at line 874 of file MemoryMappedFile.cc.

◆ lockAllMemory()

MemoryLockStatus MemoryMapManager::lockAllMemory ( VirtualAddressSpace &  space,
bool  current,
MemoryLockMode  currentMode,
MemoryLockMode  futureMode,
bool  privileged 
)

Definition at line 276 of file MemoryMappedFile-lock.cc.

◆ lockMemory()

MemoryLockStatus MemoryMapManager::lockMemory ( VirtualAddressSpace &  space,
uintptr_t  base,
size_t  length,
MemoryLockMode  mode,
bool  privileged 
)

Definition at line 234 of file MemoryMappedFile-lock.cc.

◆ mapAnon() [1/2]

MemoryMappedObject * MemoryMapManager::mapAnon ( uintptr_t &  address,
size_t  length,
MemoryMappedObject::Permissions  perms 
)

Create a new anonymous memory mapping.

Definition at line 193 of file MemoryMappedFile-map.cc.

References mapAnon().

Referenced by PosixSubsystem::invoke(), and mapAnon().

+ Here is the caller graph for this function:

◆ mapAnon() [2/2]

MemoryMappedObject * MemoryMapManager::mapAnon ( uintptr_t &  address,
size_t  length,
MemoryMappedObject::Permissions  perms,
Placement  placement,
MapStatus *  status,
MemoryLockMode  requestedLock = MemoryLockMode::None 
)

Definition at line 197 of file MemoryMappedFile-map.cc.

◆ mapFile() [1/2]

MemoryMappedObject * MemoryMapManager::mapFile ( File *  pFile,
uintptr_t &  address,
size_t  length,
MemoryMappedObject::Permissions  perms,
size_t  offset,
bool  bCopyOnWrite,
Placement  placement,
MapStatus *  status,
MemoryMappedObject::Permissions  maximumPerms = MemoryMappedObject::Read | MemoryMappedObject::Write | MemoryMappedObject::Exec,
const SharedPointer< MappingAttachment > &  attachment = SharedPointer<MappingAttachment>(),
MemoryLockMode  requestedLock = MemoryLockMode::None,
const FileMappingOrigin &  origin = {} 
)

Definition at line 173 of file MemoryMappedFile-map.cc.

◆ mapFile() [2/2]

MemoryMappedObject * MemoryMapManager::mapFile ( File *  pFile,
uintptr_t &  address,
size_t  length,
MemoryMappedObject::Permissions  perms,
size_t  offset = 0,
bool  bCopyOnWrite = true 
)

Map in the given File.

Definition at line 167 of file MemoryMappedFile-map.cc.

References mapFile().

Referenced by DynamicLinker::loadObject(), DynamicLinker::loadProgram(), and mapFile().

+ Here is the caller graph for this function:

◆ op()

bool MemoryMapManager::op ( MemoryMapManager::Ops  what,
uintptr_t  base,
size_t  length,
bool  async 
)
private

Definition at line 1270 of file MemoryMappedFile.cc.

◆ operationOwnedByCurrentExecution()

bool MemoryMapManager::operationOwnedByCurrentExecution ( )

Definition at line 869 of file MemoryMappedFile.cc.

◆ pageOutRange()

SwapStatus MemoryMapManager::pageOutRange ( uintptr_t  base,
size_t  length 
)

Definition at line 37 of file MemoryMappedFile-swap.cc.

◆ populateMemory()

PopulationStatus MemoryMapManager::populateMemory ( VirtualAddressSpace &  space,
uintptr_t  base,
size_t  length 
)

Definition at line 341 of file MemoryMappedFile-lock.cc.

◆ prepareFileResize()

MemoryMapManager::ResizeStatus MemoryMapManager::prepareFileResize ( File *  file,
size_t  oldSize,
size_t  newSize,
UniquePointer< PreparedFileResize > &  result 
)

Caller retains writer, operation and backing-data locks through planning, backend/cache preparation and commit. Preparation does not alter PTEs.

Definition at line 56 of file MemoryMappedFile-resize.cc.

References UniquePointer< T >::adopt(), Tree< K, E >::begin(), Tree< K, E >::count(), Tree< K, E >::end(), File::futexIdentity(), TargetInfo::getPageSize(), Tree< K, E >::lookup(), m_MmObjectLists, and Tree< K, E >::tryInsert().

Referenced by File::resize().

+ Here is the caller graph for this function:

◆ prepareManagedLocks()

MemoryLockStatus MemoryMapManager::prepareManagedLocks ( VirtualAddressSpace &  space,
uintptr_t  base,
size_t  length,
MemoryLockMode  mode,
bool  all,
UniquePointer< PreparedMemoryLock > &  result 
)
private

Definition at line 181 of file MemoryMappedFile-lock.cc.

◆ publishMapping()

MemoryMappedObject * MemoryMapManager::publishMapping ( File *  file,
uintptr_t &  address,
size_t  length,
MemoryMappedObject::Permissions  perms,
size_t  offset,
bool  copyOnWrite,
Placement  placement,
MapStatus *  status,
MemoryMappedObject::Permissions  maximumPerms,
const SharedPointer< MappingAttachment > &  attachment,
MemoryLockMode  requestedLock,
const FileMappingOrigin &  origin = {} 
)
private

Definition at line 208 of file MemoryMappedFile-map.cc.

◆ releaseLock()

void MemoryMapManager::releaseLock ( )
protected

Release the manager's operation gate.

Definition at line 1793 of file MemoryMappedFile.cc.

Referenced by PosixSubsystem::~PosixSubsystem().

+ Here is the caller graph for this function:

◆ releaseReservation()

void MemoryMapManager::releaseReservation ( Process *  process,
VirtualAddressSpace &  addressSpace,
uintptr_t  base,
size_t  length 
)
private

Definition at line 1042 of file MemoryMappedFile.cc.

◆ remap()

MemoryMapManager::VmStatus MemoryMapManager::remap ( const RemapRequest &  request,
uintptr_t &  result 
)

Definition at line 117 of file MemoryMappedFile-remap.cc.

◆ remapFilePages()

MemoryMapManager::FileRemapStatus MemoryMapManager::remapFilePages ( uintptr_t  base,
size_t  length,
size_t  byteOffset,
bool  nonblock 
)

Definition at line 11 of file MemoryMappedFile-rebias.cc.

◆ remove()

size_t MemoryMapManager::remove ( uintptr_t  base,
size_t  length 
)

Removes the given range from whatever objects might own them, and will cross object boundaries if necessary.

If this will result in a MemoryMappedObject being completely unmapped, it will be removed.

Returns
number of objects affected by this call.

Definition at line 941 of file MemoryMappedFile.cc.

◆ removeAndRelease()

size_t MemoryMapManager::removeAndRelease ( uintptr_t  base,
size_t  length,
VmStatus *  status = nullptr 
)

Removes mappings and returns their virtual-address reservations to the current process. Unmapped holes in the requested range are left alone.

This is the munmap path. MAP_FIXED replacement uses remove() so that the replacement inherits the reservations of the mappings it displaces.

Definition at line 945 of file MemoryMappedFile.cc.

References PhysicalMemoryManager::getPageSize(), Process::getParent(), ProcessorBase::information(), and RawUserMemory::prepareReplacement().

◆ removeAttachment()

size_t MemoryMapManager::removeAttachment ( const SharedPointer< MappingAttachment > &  attachment)

Remove only this attachment's fragments, preserving replacement mappings.

Definition at line 1013 of file MemoryMappedFile.cc.

References MemoryMappedObject::address(), PhysicalMemoryManager::getPageSize(), Process::getParent(), ProcessorBase::information(), and m_MmObjectLists.

◆ removeInternal()

size_t MemoryMapManager::removeInternal ( uintptr_t  base,
size_t  length,
bool  releaseReservations,
VmStatus *  status = nullptr 
)
private

Definition at line 421 of file MemoryMappedFile-map.cc.

◆ residency()

MemoryMapManager::VmStatus MemoryMapManager::residency ( uintptr_t  base,
size_t  length,
unsigned char *  kernelVector,
FileResidencyAccess  access,
void *  credentials 
)

Definition at line 88 of file MemoryMappedFile-advice.cc.

◆ resolveUserFault()

MemoryMapManager::FaultResolution MemoryMapManager::resolveUserFault ( uintptr_t  address,
bool  write,
bool  wasPresent,
bool  execute 
)

Definition at line 1477 of file MemoryMappedFile.cc.

◆ retireLockedPages()

void MemoryMapManager::retireLockedPages ( VirtualAddressSpace &  space,
size_t  pages 
)
private

Definition at line 331 of file MemoryMappedFile-lock.cc.

◆ setPermissions()

size_t MemoryMapManager::setPermissions ( uintptr_t  base,
size_t  length,
MemoryMappedObject::Permissions  perms,
ProtectStatus *  status = nullptr 
)

Definition at line 1064 of file MemoryMappedFile.cc.

◆ sharedBacking()

bool MemoryMapManager::sharedBacking ( Process *  process,
uintptr_t  address,
uintptr_t &  identity,
size_t &  offset 
)

Definition at line 1336 of file MemoryMappedFile.cc.

◆ swapSnapshot()

SwapSnapshot MemoryMapManager::swapSnapshot ( )

Definition at line 32 of file MemoryMappedFile-swap.cc.

◆ sync()

bool MemoryMapManager::sync ( uintptr_t  base,
size_t  length,
bool  async,
int *  error = nullptr 
)

Syncs memory mapped objects within the given range back to their backing store, if they have one.

Definition at line 1316 of file MemoryMappedFile.cc.

References allows(), and PhysicalMemoryManager::getPageSize().

◆ trap()

bool MemoryMapManager::trap ( InterruptState &  state,
uintptr_t  address,
bool  bIsWrite,
bool  bWasPresent 
)
virtual

Trap handler, called when a fault takes place.

Implements MemoryTrapHandler.

Definition at line 1601 of file MemoryMappedFile.cc.

◆ tryEnterOperation()

bool MemoryMapManager::tryEnterOperation ( )
private

Definition at line 847 of file MemoryMappedFile.cc.

◆ unmap()

void MemoryMapManager::unmap ( MemoryMappedObject *  pObj)

Removes the mappings for the given object from the address space.

Definition at line 1568 of file MemoryMappedFile.cc.

References PhysicalMemoryManager::getPageSize(), ProcessorBase::information(), MemoryMappedObject::length(), and m_MmObjectLists.

Referenced by DynamicLinker::loadObject(), and DynamicLinker::loadProgram().

+ Here is the caller graph for this function:

◆ unmapAll()

void MemoryMapManager::unmapAll ( )

Removes all mappings from this address space.

Definition at line 1595 of file MemoryMappedFile.cc.

References unmapAllUnlocked().

Referenced by PosixSubsystem::exit(), and PosixSubsystem::invoke().

+ Here is the caller graph for this function:

◆ unmapAllUnlocked()

void MemoryMapManager::unmapAllUnlocked ( )
protected

Removes all mappings from the address space, unlocked.

Requires callers to have acquired the lock by other means.

Definition at line 1760 of file MemoryMappedFile.cc.

References PhysicalMemoryManager::getPageSize(), ProcessorBase::information(), MemoryMappedObject::length(), and m_MmObjectLists.

Referenced by unmapAll(), and PosixSubsystem::~PosixSubsystem().

+ Here is the caller graph for this function:

◆ writableAnonymousRange()

bool MemoryMapManager::writableAnonymousRange ( uintptr_t  address,
size_t  length 
)

Nonfaulting check for resident, writable anonymous pages. Retain an OperationGuard while using the result; file-backed and unmanaged mappings are excluded so a destination cannot alias file cache storage.

Definition at line 1438 of file MemoryMappedFile.cc.

Referenced by PosixSubsystem::readCachedFile().

+ Here is the caller graph for this function:

Friends And Related Symbol Documentation

◆ PosixSubsystem

friend class PosixSubsystem
friend

Definition at line 560 of file MemoryMappedFile.h.

◆ VfsUserMemoryPolicy

friend class VfsUserMemoryPolicy
friend

Definition at line 561 of file MemoryMappedFile.h.

Member Data Documentation

◆ m_Instance

MemoryMapManager MemoryMapManager::m_Instance
staticprivate

Singleton instance.

Definition at line 886 of file MemoryMappedFile.h.

◆ m_LifecycleDepth

size_t MemoryMapManager::m_LifecycleDepth
private

Definition at line 906 of file MemoryMappedFile.h.

◆ m_LifecycleLock

Mutex MemoryMapManager::m_LifecycleLock
private

Keeps the object-list topology and object lifetimes stable while an operation is running without holding m_Lock across object callbacks.

Definition at line 900 of file MemoryMappedFile.h.

◆ m_LifecycleStateLock

Spinlock MemoryMapManager::m_LifecycleStateLock
private

Protects recursive lifecycle-gate ownership metadata.

Definition at line 903 of file MemoryMappedFile.h.

◆ m_Lock

Spinlock MemoryMapManager::m_Lock
private

Lock for the cache.

Definition at line 894 of file MemoryMappedFile.h.

◆ m_MmObjectLists

Tree<VirtualAddressSpace*, MmObjectList*> MemoryMapManager::m_MmObjectLists
private

Cache of virtual address spaces -> MmObjectLists.

Definition at line 891 of file MemoryMappedFile.h.

Referenced by allows(), clone(), compact(), contains(), findAttachment(), hasSharedWriteCapability(), prepareFileResize(), removeAttachment(), unmap(), and unmapAllUnlocked().

◆ m_pLifecycleOwner

void* MemoryMapManager::m_pLifecycleOwner
private

Definition at line 905 of file MemoryMappedFile.h.


The documentation for this class was generated from the following files: