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

#include <VirtualAddressSpace.h>

+ Inheritance diagram for VirtualAddressSpace:
+ Collaboration diagram for VirtualAddressSpace:

Classes

struct  DetachedPage
 
struct  PageRemapRequest
 
class  PreparedPageRemap
 
struct  RemapRange
 
class  Stack
 

Public Types

enum class  ResidentCopyStatus { Success , Inaccessible , Unsupported }
 
enum class  RemapStatus {
  Success , InvalidRange , Unsupported , NoMemory ,
  Retry
}
 
using RemapAdmission = bool(*)(void *context)
 

Public Member Functions

RawUserMemory & rawUserMemory ()
 
virtual size_t runtimeMappingPages (uintptr_t, size_t)
 
MemoryLockAccount * memoryLockAccount () const
 
void setMemoryLockAccount (MemoryLockAccount *account)
 
UserMemoryPolicy * userMemoryPolicy () const
 
void setUserMemoryPolicy (UserMemoryPolicy *policy)
 
virtual void * expandHeap (ssize_t incr, size_t flags)
 
virtual bool isAddressValid (void *virtualAddress)=0
 
virtual bool isMapped (void *virtualAddress)=0
 
virtual bool map (physical_uintptr_t physicalAddress, void *virtualAddress, size_t flags)=0
 
virtual bool tryMapUserPage (physical_uintptr_t physical, void *address, size_t flags, size_t *committedTablePages=nullptr)
 
virtual bool tryDetachUserPage (void *address, physical_uintptr_t expected)
 
virtual bool mapHuge (physical_uintptr_t physAddress, void *virtualAddress, size_t count, size_t flags)
 
virtual bool getMapping (void *virtualAddress, physical_uintptr_t &physicalAddress, size_t &flags)=0
 
virtual bool handleCopyOnWriteFault (void *virtualAddress, bool userMode)=0
 
virtual ResidentCopyStatus copyResidentUserPage (uintptr_t userAddress, void *kernelBuffer, size_t bytes, bool write)
 
virtual bool tryWriteUser32 (uintptr_t address, uint32_t value)
 
virtual bool tryReadUser32 (uintptr_t address, uint32_t &value)
 
virtual bool tryReadUserPointer (uintptr_t address, uintptr_t &value)
 
virtual bool tryCompareExchangeUser32 (uintptr_t address, uint32_t &expected, uint32_t desired, bool &exchanged)
 
virtual void setFlags (void *virtualAddress, size_t newFlags)=0
 
virtual MUST_USE_RESULT bool trySetFlags (void *virtualAddress, size_t newFlags)
 
virtual void unmap (void *virtualAddress)=0
 
virtual bool detachMapping (void *virtualAddress, physical_uintptr_t &physical, size_t &flags, size_t requiredFlags=0)
 
virtual RemapStatus prepareRemap (const PageRemapRequest &request, UniquePointer< PreparedPageRemap > &plan)
 
virtual void setRemapPreparationFailureForTest (ssize_t allocations)
 
virtual Stack * allocateStack ()=0
 
virtual Stack * allocateStack (size_t stackSz)
 
virtual void freeStack (Stack *pStack)=0
 
virtual VirtualAddressSpace * clone (bool copyOnWrite=true)=0
 
virtual void revertToKernelAddressSpace ()=0
 
virtual ~VirtualAddressSpace ()
 
void setHeap (void *heap, void *heapEnd)
 
virtual bool memIsInKernelHeap (void *pMem)=0
 
virtual bool memIsInHeap (void *pMem)=0
 
virtual void * getEndOfHeap ()=0
 
virtual uintptr_t getKernelStart () const =0
 
virtual uintptr_t getUserStart () const =0
 
virtual uintptr_t getUserReservedStart () const =0
 
virtual uintptr_t getDynamicLinkerAddress () const =0
 
virtual uintptr_t getKernelHeapStart () const =0
 
virtual uintptr_t getKernelHeapEnd () const =0
 
virtual uintptr_t getKernelCacheStart () const =0
 
virtual uintptr_t getKernelCacheEnd () const =0
 
virtual uintptr_t getKernelEventBlockStart () const =0
 
virtual uintptr_t getKernelModulesStart () const =0
 
virtual uintptr_t getKernelModulesEnd () const =0
 
virtual uintptr_t getKernelVirtualPagestack () const
 
virtual uintptr_t getKernelVirtualPagestackAdd1 () const
 
virtual uintptr_t getKernelVirtualPagestackAdd2 () const
 
virtual uintptr_t getDynamicStart () const
 
virtual uintptr_t getDynamicEnd () const
 
virtual uintptr_t getGlobalInfoBlock () const
 

Static Public Member Functions

static EXPORTED_PUBLIC VirtualAddressSpace & getKernelAddressSpace ()
 
static VirtualAddressSpace * create ()
 

Public Attributes

void * m_Heap
 
void * m_HeapEnd
 

Static Public Attributes

static const size_t KernelMode = 0x01
 
static const size_t Write = 0x02
 
static const size_t Execute = 0x04
 
static const size_t WriteThrough = 0x08
 
static const size_t CacheDisable = 0x10
 
static const size_t CopyOnWrite = 0x20
 
static const size_t Swapped = 0x40
 
static const size_t Shared = 0x200
 
static const size_t WriteCombine = 0x400
 
static const size_t Accessed = 0x800
 
static const size_t Dirty = 0x1000
 
static const size_t ClearDirty = 0x2000
 
static const size_t NoAccess = 0x4000
 
static const size_t WriteProtected = 0x8000
 
static const size_t Borrowed = 0x10000
 
static const size_t RuntimeMapping = 0x20000
 
static constexpr size_t MaximumRemapPages = 65536
 
static physical_uintptr_t m_ZeroPage = 0
 

Protected Member Functions

bool admitRawMemoryChange (const PreparedMemoryLock &plan, bool privileged, MemoryLockCharge &charge) const
 
void commitRawMemoryChange (PreparedMemoryLock &plan, MemoryLockCharge charge)
 
bool prepareZeroPage ()
 
 VirtualAddressSpace (void *Heap)
 

Protected Attributes

uint64_t m_HeapRegionId = 0
 

Private Member Functions

 VirtualAddressSpace ()
 
 VirtualAddressSpace (const VirtualAddressSpace &)
 
VirtualAddressSpace & operator= (const VirtualAddressSpace &)
 
void rollbackHeapExpansion (void *virtualAddress, size_t pageCount)
 

Private Attributes

RawUserMemory m_RawUserMemory
 
MemoryLockAccount * m_MemoryLockAccount = nullptr
 
UserMemoryPolicy * m_UserMemoryPolicy = nullptr
 

Friends

class Debugger
 

Detailed Description

The VirtualAddressSpace encapsulates all the functionality of a virtual memory- management. This includes management of the mapping between physical and virtual memory, management of allocated physical memory pages and management of free/allocated virtual memory.

Definition at line 38 of file include/pedigree/kernel/processor/VirtualAddressSpace.h.

Member Typedef Documentation

◆ RemapAdmission

using VirtualAddressSpace::RemapAdmission = bool (*)(void* context)

Member Enumeration Documentation

◆ RemapStatus

enum class VirtualAddressSpace::RemapStatus
strong

◆ ResidentCopyStatus

enum class VirtualAddressSpace::ResidentCopyStatus
strong

Constructor & Destructor Documentation

◆ ~VirtualAddressSpace()

virtual VirtualAddressSpace::~VirtualAddressSpace ( )
inlinevirtual

The destructor does nothing

Definition at line 324 of file include/pedigree/kernel/processor/VirtualAddressSpace.h.

◆ VirtualAddressSpace() [1/3]

VirtualAddressSpace::VirtualAddressSpace ( void *  Heap)
inlineprotected

The constructor does nothing

Definition at line 461 of file include/pedigree/kernel/processor/VirtualAddressSpace.h.

◆ VirtualAddressSpace() [2/3]

VirtualAddressSpace::VirtualAddressSpace ( )
private

The default constructor

◆ VirtualAddressSpace() [3/3]

VirtualAddressSpace::VirtualAddressSpace ( const VirtualAddressSpace &  )
private

The copy-constructor

Note
NOT implemented

Member Function Documentation

◆ admitRawMemoryChange()

bool VirtualAddressSpace::admitRawMemoryChange ( const PreparedMemoryLock &  plan,
bool  privileged,
MemoryLockCharge &  charge 
) const
protected

Definition at line 44 of file VirtualAddressSpace.cc.

◆ allocateStack() [1/2]

virtual Stack * VirtualAddressSpace::allocateStack ( )
pure virtual

Allocates a single stack for a thread. Will use the default kernel thread size.

Implemented in HostedVirtualAddressSpace, X64VirtualAddressSpace, Arm64VirtualAddressSpace, and Armv7VirtualAddressSpace.

Referenced by allocateStack(), Thread::allocateStackAtLevel(), and PerProcessorScheduler::checkEventState().

+ Here is the caller graph for this function:

◆ allocateStack() [2/2]

virtual Stack * VirtualAddressSpace::allocateStack ( size_t  stackSz)
inlinevirtual

Allocates a single stack of the given size for a thread.

Reimplemented in Arm64VirtualAddressSpace, Armv7VirtualAddressSpace, HostedVirtualAddressSpace, and X64VirtualAddressSpace.

Definition at line 299 of file include/pedigree/kernel/processor/VirtualAddressSpace.h.

References allocateStack().

◆ clone()

virtual VirtualAddressSpace * VirtualAddressSpace::clone ( bool  copyOnWrite = true)
pure virtual

Clone this VirtualAddressSpace. That means that we copy-on-write-map the application * image. *

Parameters
[in]copyOnWritewhether the new address space copies pages on write, or shares them with the parent address space.
Returns
pointer to the new VirtualAddressSpace

Implemented in HostedVirtualAddressSpace, X64VirtualAddressSpace, Arm64VirtualAddressSpace, and Armv7VirtualAddressSpace.

◆ commitRawMemoryChange()

void VirtualAddressSpace::commitRawMemoryChange ( PreparedMemoryLock &  plan,
MemoryLockCharge  charge 
)
protected

Definition at line 64 of file VirtualAddressSpace.cc.

◆ copyResidentUserPage()

virtual ResidentCopyStatus VirtualAddressSpace::copyResidentUserPage ( uintptr_t  userAddress,
void *  kernelBuffer,
size_t  bytes,
bool  write 
)
inlinevirtual

One-page, no-fault copy with a resident nonpageable kernel buffer.

Reimplemented in X64VirtualAddressSpace.

Definition at line 177 of file include/pedigree/kernel/processor/VirtualAddressSpace.h.

◆ create()

VirtualAddressSpace * VirtualAddressSpace::create ( )
static

Create a new VirtualAddressSpace. Only the kernel is mapped into that virtual address space

Returns
pointer to the new VirtualAddressSpace, 0 otherwise

Definition at line 43 of file arm64/VirtualAddressSpace.cc.

Referenced by HostedVirtualAddressSpace::clone(), and X64VirtualAddressSpace::clone().

+ Here is the caller graph for this function:

◆ detachMapping()

virtual bool VirtualAddressSpace::detachMapping ( void *  virtualAddress,
physical_uintptr_t &  physical,
size_t &  flags,
size_t  requiredFlags = 0 
)
inlinevirtual

Atomically snapshot and detach a resident mapping. A flags mismatch leaves the mapping intact, but still returns its physical address and flags.

Reimplemented in Arm64VirtualAddressSpace, Armv7VirtualAddressSpace, HostedVirtualAddressSpace, and X64VirtualAddressSpace.

Definition at line 247 of file include/pedigree/kernel/processor/VirtualAddressSpace.h.

Referenced by MemoryMappedFile::compact(), HostedVirtualAddressSpace::detachMapping(), and rollbackHeapExpansion().

+ Here is the caller graph for this function:

◆ expandHeap()

void * VirtualAddressSpace::expandHeap ( ssize_t  incr,
size_t  flags 
)
virtual

Expand the heap

Parameters
[in]pageCountthe number of pages that should be allocated and mapped to the heap end
[in]flagsflags that describe which accesses should be allowed on the page
Returns
pointer to the beginning of the newly allocated/mapped heap, 0 otherwise

Definition at line 91 of file VirtualAddressSpace.cc.

References CopyOnWrite, PhysicalMemoryManager::freePage(), getDynamicStart(), getKernelStart(), PhysicalMemoryManager::getPageSize(), PhysicalMemoryManager::instance(), m_Heap, m_HeapEnd, m_ZeroPage, map(), PhysicalMemoryManager::pin(), rollbackHeapExpansion(), and Write.

◆ freeStack()

virtual void VirtualAddressSpace::freeStack ( Stack *  pStack)
pure virtual

Frees a stack allocated with allocateStack.

Implemented in HostedVirtualAddressSpace, X64VirtualAddressSpace, Arm64VirtualAddressSpace, and Armv7VirtualAddressSpace.

Referenced by Thread::cleanStateLevel(), and Thread::notifySubsystemExit().

+ Here is the caller graph for this function:

◆ getDynamicEnd()

virtual uintptr_t VirtualAddressSpace::getDynamicEnd ( ) const
inlinevirtual

Gets address of the end of the dynamic memory mapping area.

Reimplemented in HostedVirtualAddressSpace, X64VirtualAddressSpace, Arm64VirtualAddressSpace, and Armv7VirtualAddressSpace.

Definition at line 402 of file include/pedigree/kernel/processor/VirtualAddressSpace.h.

◆ getDynamicLinkerAddress()

virtual uintptr_t VirtualAddressSpace::getDynamicLinkerAddress ( ) const
pure virtual

Gets address of the dynamic linker in the address space.

Implemented in HostedVirtualAddressSpace, X64VirtualAddressSpace, Arm64VirtualAddressSpace, and Armv7VirtualAddressSpace.

◆ getDynamicStart()

virtual uintptr_t VirtualAddressSpace::getDynamicStart ( ) const
inlinevirtual

Gets address of the start of the dynamic memory mapping area. This is an area in which memory mappings can be created for userspace applications. Systems that do not have room in the address space for this may return zero.

Reimplemented in HostedVirtualAddressSpace, X64VirtualAddressSpace, Arm64VirtualAddressSpace, and Armv7VirtualAddressSpace.

Definition at line 398 of file include/pedigree/kernel/processor/VirtualAddressSpace.h.

Referenced by expandHeap(), Thread::getTlsBase(), and Thread::~Thread().

+ Here is the caller graph for this function:

◆ getEndOfHeap()

virtual void * VirtualAddressSpace::getEndOfHeap ( )
pure virtual

Gets a pointer to the byte after the end of the heap.

Implemented in HostedVirtualAddressSpace, X64VirtualAddressSpace, Arm64VirtualAddressSpace, and Armv7VirtualAddressSpace.

◆ getGlobalInfoBlock()

virtual uintptr_t VirtualAddressSpace::getGlobalInfoBlock ( ) const
inlinevirtual

Gets address of the global info block location.

Reimplemented in X64VirtualAddressSpace, Arm64VirtualAddressSpace, and Armv7VirtualAddressSpace.

Definition at line 407 of file include/pedigree/kernel/processor/VirtualAddressSpace.h.

◆ getKernelAddressSpace()

VirtualAddressSpace & VirtualAddressSpace::getKernelAddressSpace ( )
static

◆ getKernelCacheEnd()

virtual uintptr_t VirtualAddressSpace::getKernelCacheEnd ( ) const
pure virtual

Gets address of the end of the kernel's cache region.

Implemented in HostedVirtualAddressSpace, X64VirtualAddressSpace, Arm64VirtualAddressSpace, and Armv7VirtualAddressSpace.

◆ getKernelCacheStart()

virtual uintptr_t VirtualAddressSpace::getKernelCacheStart ( ) const
pure virtual

Gets address of the start of the kernel's cache region.

Implemented in HostedVirtualAddressSpace, X64VirtualAddressSpace, Arm64VirtualAddressSpace, and Armv7VirtualAddressSpace.

◆ getKernelEventBlockStart()

virtual uintptr_t VirtualAddressSpace::getKernelEventBlockStart ( ) const
pure virtual

Gets address of the start of the kernel's event handling block.

Implemented in HostedVirtualAddressSpace, X64VirtualAddressSpace, Arm64VirtualAddressSpace, and Armv7VirtualAddressSpace.

Referenced by Event::getTrampoline().

+ Here is the caller graph for this function:

◆ getKernelHeapEnd()

virtual uintptr_t VirtualAddressSpace::getKernelHeapEnd ( ) const
pure virtual

Gets address of the end of the kernel's heap region.

Implemented in HostedVirtualAddressSpace, X64VirtualAddressSpace, Arm64VirtualAddressSpace, and Armv7VirtualAddressSpace.

◆ getKernelHeapStart()

virtual uintptr_t VirtualAddressSpace::getKernelHeapStart ( ) const
pure virtual

Gets address of the start of the kernel's heap region.

Implemented in HostedVirtualAddressSpace, X64VirtualAddressSpace, Arm64VirtualAddressSpace, and Armv7VirtualAddressSpace.

◆ getKernelModulesEnd()

virtual uintptr_t VirtualAddressSpace::getKernelModulesEnd ( ) const
pure virtual

Gets address of the end of the kernel's module region.

Implemented in HostedVirtualAddressSpace, X64VirtualAddressSpace, Arm64VirtualAddressSpace, and Armv7VirtualAddressSpace.

Referenced by KernelElf::loadModule().

+ Here is the caller graph for this function:

◆ getKernelModulesStart()

virtual uintptr_t VirtualAddressSpace::getKernelModulesStart ( ) const
pure virtual

Gets address of the start of the kernel's module region.

Implemented in HostedVirtualAddressSpace, X64VirtualAddressSpace, Arm64VirtualAddressSpace, and Armv7VirtualAddressSpace.

Referenced by KernelElf::loadModule().

+ Here is the caller graph for this function:

◆ getKernelStart()

virtual uintptr_t VirtualAddressSpace::getKernelStart ( ) const
pure virtual

Gets start address of the kernel in the address space.

Implemented in HostedVirtualAddressSpace, X64VirtualAddressSpace, Arm64VirtualAddressSpace, and Armv7VirtualAddressSpace.

Referenced by PerProcessorScheduler::checkEventState(), and expandHeap().

+ Here is the caller graph for this function:

◆ getKernelVirtualPagestack()

virtual uintptr_t VirtualAddressSpace::getKernelVirtualPagestack ( ) const
inlinevirtual

Gets address of the physical page stack, if one exists.

Reimplemented in HostedVirtualAddressSpace, and X64VirtualAddressSpace.

Definition at line 377 of file include/pedigree/kernel/processor/VirtualAddressSpace.h.

Referenced by X86CommonPhysicalMemoryManager::PageStack::initialise().

+ Here is the caller graph for this function:

◆ getKernelVirtualPagestackAdd1()

virtual uintptr_t VirtualAddressSpace::getKernelVirtualPagestackAdd1 ( ) const
inlinevirtual

Gets address of the first additional page stack, if one exists.

Reimplemented in X64VirtualAddressSpace.

Definition at line 382 of file include/pedigree/kernel/processor/VirtualAddressSpace.h.

Referenced by X86CommonPhysicalMemoryManager::PageStack::initialise().

+ Here is the caller graph for this function:

◆ getKernelVirtualPagestackAdd2()

virtual uintptr_t VirtualAddressSpace::getKernelVirtualPagestackAdd2 ( ) const
inlinevirtual

Gets address of the second additional page stack, if one exists.

Reimplemented in X64VirtualAddressSpace.

Definition at line 387 of file include/pedigree/kernel/processor/VirtualAddressSpace.h.

Referenced by X86CommonPhysicalMemoryManager::PageStack::initialise().

+ Here is the caller graph for this function:

◆ getMapping()

virtual bool VirtualAddressSpace::getMapping ( void *  virtualAddress,
physical_uintptr_t &  physicalAddress,
size_t &  flags 
)
pure virtual

◆ getUserReservedStart()

virtual uintptr_t VirtualAddressSpace::getUserReservedStart ( ) const
pure virtual

Gets start address of reserved areas of the userpace address space.

Implemented in HostedVirtualAddressSpace, X64VirtualAddressSpace, Arm64VirtualAddressSpace, and Armv7VirtualAddressSpace.

Referenced by PosixSubsystem::prepareExecutable().

+ Here is the caller graph for this function:

◆ getUserStart()

virtual uintptr_t VirtualAddressSpace::getUserStart ( ) const
pure virtual

Gets start address of the region usable and cloneable for userspace.

Implemented in HostedVirtualAddressSpace, X64VirtualAddressSpace, Arm64VirtualAddressSpace, and Armv7VirtualAddressSpace.

Referenced by PerProcessorScheduler::checkEventState(), and PosixSubsystem::prepareExecutable().

+ Here is the caller graph for this function:

◆ handleCopyOnWriteFault()

virtual bool VirtualAddressSpace::handleCopyOnWriteFault ( void *  virtualAddress,
bool  userMode 
)
pure virtual

Resolve a write-protection fault on a copy-on-write mapping.

The replacement page is initialised before it becomes visible. Concurrent callers revalidate the mapping and treat an already-writable replacement as a successfully handled stale fault when the faulting privilege level may access it.

Parameters
[in]userModetrue when the faulting access came from user mode.

Implemented in Arm64VirtualAddressSpace, Armv7VirtualAddressSpace, HostedVirtualAddressSpace, and X64VirtualAddressSpace.

Referenced by HostedVirtualAddressSpace::handleCopyOnWriteFault(), and PageFaultHandler::interrupt().

+ Here is the caller graph for this function:

◆ isAddressValid()

virtual bool VirtualAddressSpace::isAddressValid ( void *  virtualAddress)
pure virtual

Is a particular virtual address valid?

Parameters
[in]virtualAddressthe virtual address to check
Returns
true, if the address is valid, false otherwise

Implemented in Arm64VirtualAddressSpace, Armv7VirtualAddressSpace, HostedVirtualAddressSpace, and X64VirtualAddressSpace.

Referenced by PerProcessorScheduler::checkEventState().

+ Here is the caller graph for this function:

◆ isMapped()

virtual bool VirtualAddressSpace::isMapped ( void *  virtualAddress)
pure virtual

◆ map()

virtual bool VirtualAddressSpace::map ( physical_uintptr_t  physicalAddress,
void *  virtualAddress,
size_t  flags 
)
pure virtual

Map a specific physical page (of size PhysicalMemoryManager::getPageSize()) at a specific location into the virtual address space.

Note
This function must also work on pages marked as swapped out.
Parameters
[in]physicalAddressthe address of the physical page that should be mapped into the virtual address space.
[in]virtualAddressthe virtual address at which the page apears within the virtual address space.
[in]flagsflags that describe which accesses should be allowed on the page.
Returns
true, if successfull, false otherwise

Implemented in HostedVirtualAddressSpace, X64VirtualAddressSpace, Arm64VirtualAddressSpace, and Armv7VirtualAddressSpace.

Referenced by HostedPhysicalMemoryManager::allocateRegion(), X86CommonPhysicalMemoryManager::allocateRegion(), Arm64PhysicalMemoryManager::allocateRegion(), Armv7PhysicalMemoryManager::allocateRegion(), PerProcessorScheduler::checkEventState(), expandHeap(), Thread::getTlsBase(), Elf::loadModule(), HostedVirtualAddressSpace::map(), mapHuge(), X86CommonPhysicalMemoryManager::PageStack::maybeMap(), AnonymousMemoryMap::trap(), and MemoryMappedFile::trap().

+ Here is the caller graph for this function:

◆ mapHuge()

bool VirtualAddressSpace::mapHuge ( physical_uintptr_t  physAddress,
void *  virtualAddress,
size_t  count,
size_t  flags 
)
virtual

Map a region of memory using the largest possible frame size. Where possible the largest page size should be used, degrading into smaller page sizes as needed (e.g. 1 GB, 2 MB, 4K) to reduce the overhead of the mapping on the system. Default implementation calls map() in a loop.

Returns
true if successful, false otherwise.

Reimplemented in X64VirtualAddressSpace.

Definition at line 163 of file VirtualAddressSpace.cc.

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

Referenced by X86CommonPhysicalMemoryManager::initialise64(), and X64VirtualAddressSpace::mapHuge().

+ Here is the caller graph for this function:

◆ memIsInHeap()

virtual bool VirtualAddressSpace::memIsInHeap ( void *  pMem)
pure virtual

Determines if a given point is within the virtual address space region dedicated to the kernel heap.

Implemented in Arm64VirtualAddressSpace, Armv7VirtualAddressSpace, HostedVirtualAddressSpace, and X64VirtualAddressSpace.

◆ memIsInKernelHeap()

virtual bool VirtualAddressSpace::memIsInKernelHeap ( void *  pMem)
pure virtual

Determines whether a given address is within the kernel's heap region.

Implemented in Arm64VirtualAddressSpace, Armv7VirtualAddressSpace, HostedVirtualAddressSpace, and X64VirtualAddressSpace.

◆ memoryLockAccount()

MemoryLockAccount * VirtualAddressSpace::memoryLockAccount ( ) const
inline

◆ operator=()

VirtualAddressSpace & VirtualAddressSpace::operator= ( const VirtualAddressSpace &  )
private

The copy-constructor

Note
Not implemented

◆ prepareRemap()

virtual RemapStatus VirtualAddressSpace::prepareRemap ( const PageRemapRequest &  request,
UniquePointer< PreparedPageRemap > &  plan 
)
inlinevirtual

Preparation changes no live leaf or reservation; Retry changes neither.

Reimplemented in X64VirtualAddressSpace.

Definition at line 283 of file include/pedigree/kernel/processor/VirtualAddressSpace.h.

◆ prepareZeroPage()

bool VirtualAddressSpace::prepareZeroPage ( )
protected

Definition at line 70 of file VirtualAddressSpace.cc.

◆ rawUserMemory()

RawUserMemory & VirtualAddressSpace::rawUserMemory ( )
inline

◆ revertToKernelAddressSpace()

virtual void VirtualAddressSpace::revertToKernelAddressSpace ( )
pure virtual

Undo a clone() - this happens when an application is Exec()'d - we destroy all mappings not in the kernel address space so the space is 'clean'.

Implemented in HostedVirtualAddressSpace, X64VirtualAddressSpace, Arm64VirtualAddressSpace, and Armv7VirtualAddressSpace.

Referenced by PosixSubsystem::invoke(), and Process::~Process().

+ Here is the caller graph for this function:

◆ rollbackHeapExpansion()

void VirtualAddressSpace::rollbackHeapExpansion ( void *  virtualAddress,
size_t  pageCount 
)
private

Reverts the heap expansion, that was begun with expandHeap

Parameters
[in]virtualAddresscurrent heap address
[in]pageCountnumber of mapped pages to unmap and free

Definition at line 153 of file VirtualAddressSpace.cc.

References detachMapping(), PhysicalMemoryManager::freePage(), PhysicalMemoryManager::getPageSize(), and PhysicalMemoryManager::instance().

Referenced by expandHeap().

+ Here is the caller graph for this function:

◆ runtimeMappingPages()

virtual size_t VirtualAddressSpace::runtimeMappingPages ( uintptr_t  ,
size_t   
)
inlinevirtual

◆ setFlags()

virtual void VirtualAddressSpace::setFlags ( void *  virtualAddress,
size_t  newFlags 
)
pure virtual

Set the flags of the page at a specific virtual address.

Note
The page must have been mapped with VirtualAddressSpace::map() and the page must still be mapped or marked as swapped out.
Parameters
[in]virtualAddressthe virtual address
[in]newFlagsthe flags

Implemented in Arm64VirtualAddressSpace, Armv7VirtualAddressSpace, HostedVirtualAddressSpace, and X64VirtualAddressSpace.

Referenced by Elf::finaliseModule(), HostedVirtualAddressSpace::setFlags(), AnonymousMemoryMap::setPermissions(), and MemoryMappedFile::setPermissions().

+ Here is the caller graph for this function:

◆ setHeap()

void VirtualAddressSpace::setHeap ( void *  heap,
void *  heapEnd 
)
inline

Setter for the internal Heap and HeapEnd variables

Definition at line 327 of file include/pedigree/kernel/processor/VirtualAddressSpace.h.

References m_Heap, and m_HeapEnd.

◆ setMemoryLockAccount()

void VirtualAddressSpace::setMemoryLockAccount ( MemoryLockAccount *  account)
inline

◆ setRemapPreparationFailureForTest()

virtual void VirtualAddressSpace::setRemapPreparationFailureForTest ( ssize_t  allocations)
inlinevirtual

One-shot failure after the given number of successful preparation allocations.

Reimplemented in X64VirtualAddressSpace.

Definition at line 291 of file include/pedigree/kernel/processor/VirtualAddressSpace.h.

◆ setUserMemoryPolicy()

void VirtualAddressSpace::setUserMemoryPolicy ( UserMemoryPolicy *  policy)
inline

◆ tryCompareExchangeUser32()

virtual bool VirtualAddressSpace::tryCompareExchangeUser32 ( uintptr_t  address,
uint32_t &  expected,
uint32_t  desired,
bool &  exchanged 
)
inlinevirtual

A successful access may still report a failed comparison.

Reimplemented in HostedVirtualAddressSpace, and X64VirtualAddressSpace.

Definition at line 211 of file include/pedigree/kernel/processor/VirtualAddressSpace.h.

◆ tryDetachUserPage()

virtual bool VirtualAddressSpace::tryDetachUserPage ( void *  address,
physical_uintptr_t  expected 
)
inlinevirtual

◆ tryMapUserPage()

virtual bool VirtualAddressSpace::tryMapUserPage ( physical_uintptr_t  physical,
void *  address,
size_t  flags,
size_t *  committedTablePages = nullptr 
)
inlinevirtual

◆ tryReadUser32()

virtual bool VirtualAddressSpace::tryReadUser32 ( uintptr_t  address,
uint32_t &  value 
)
inlinevirtual

Atomic, no-fault accesses through a resident userspace mapping.

Reimplemented in HostedVirtualAddressSpace, and X64VirtualAddressSpace.

Definition at line 198 of file include/pedigree/kernel/processor/VirtualAddressSpace.h.

◆ tryReadUserPointer()

virtual bool VirtualAddressSpace::tryReadUserPointer ( uintptr_t  address,
uintptr_t &  value 
)
inlinevirtual

◆ trySetFlags()

virtual MUST_USE_RESULT bool VirtualAddressSpace::trySetFlags ( void *  virtualAddress,
size_t  newFlags 
)
inlinevirtual

Changes an existing mapping, returning false without publishing failed protection.

Reimplemented in Arm64VirtualAddressSpace, Armv7VirtualAddressSpace, HostedVirtualAddressSpace, and X64VirtualAddressSpace.

Definition at line 234 of file include/pedigree/kernel/processor/VirtualAddressSpace.h.

Referenced by HostedVirtualAddressSpace::trySetFlags().

+ Here is the caller graph for this function:

◆ tryWriteUser32()

virtual bool VirtualAddressSpace::tryWriteUser32 ( uintptr_t  address,
uint32_t  value 
)
inlinevirtual

Stores one 32-bit value through a resident userspace mapping without switching into this address space. Implementations reject mappings that could fault or change backing storage while the write is in progress.

Reimplemented in HostedVirtualAddressSpace, and X64VirtualAddressSpace.

Definition at line 191 of file include/pedigree/kernel/processor/VirtualAddressSpace.h.

◆ unmap()

virtual void VirtualAddressSpace::unmap ( void *  virtualAddress)
pure virtual

◆ userMemoryPolicy()

UserMemoryPolicy * VirtualAddressSpace::userMemoryPolicy ( ) const
inline

Friends And Related Symbol Documentation

◆ Debugger

friend class Debugger
friend

Debugger can access our private members for statistics reporting.

Definition at line 41 of file include/pedigree/kernel/processor/VirtualAddressSpace.h.

Member Data Documentation

◆ Accessed

const size_t VirtualAddressSpace::Accessed = 0x800
static

Whether the page has been accessed.

Definition at line 66 of file include/pedigree/kernel/processor/VirtualAddressSpace.h.

Referenced by X64VirtualAddressSpace::fromFlags(), and X64VirtualAddressSpace::toFlags().

◆ Borrowed

const size_t VirtualAddressSpace::Borrowed = 0x10000
static

◆ CacheDisable

const size_t VirtualAddressSpace::CacheDisable = 0x10
static

◆ ClearDirty

const size_t VirtualAddressSpace::ClearDirty = 0x2000
static

Clear the dirty flag set by the above.

Definition at line 70 of file include/pedigree/kernel/processor/VirtualAddressSpace.h.

Referenced by X64VirtualAddressSpace::toFlags().

◆ CopyOnWrite

const size_t VirtualAddressSpace::CopyOnWrite = 0x20
static

◆ Dirty

const size_t VirtualAddressSpace::Dirty = 0x1000
static

Whether the page has been dirtied.

Definition at line 68 of file include/pedigree/kernel/processor/VirtualAddressSpace.h.

Referenced by X64VirtualAddressSpace::fromFlags(), and X64VirtualAddressSpace::toFlags().

◆ Execute

const size_t VirtualAddressSpace::Execute = 0x04
static

◆ KernelMode

const size_t VirtualAddressSpace::KernelMode = 0x01
static

The page is only accessible from kernel-mode. If this flag is not set the page is also accessible from user-mode.

Definition at line 47 of file include/pedigree/kernel/processor/VirtualAddressSpace.h.

Referenced by Arm64PhysicalMemoryManager::allocateRegion(), Armv7PhysicalMemoryManager::allocateRegion(), Arm64VirtualAddressSpace::allocateStack(), Armv7VirtualAddressSpace::allocateStack(), Archive::Archive(), PosixSubsystem::checkAddress(), PerProcessorScheduler::checkEventState(), HostedVirtualAddressSpace::clone(), HostedVirtualAddressSpace::doAllocateStack(), X64VirtualAddressSpace::doAllocateStack(), Elf::finaliseModule(), X64VirtualAddressSpace::fromFlags(), Armv7VirtualAddressSpace::getMapping(), Arm64VirtualAddressSpace::handleCopyOnWriteFault(), Armv7VirtualAddressSpace::handleCopyOnWriteFault(), HostedVirtualAddressSpace::handleCopyOnWriteFault(), HostedPhysicalMemoryManager::initialisationDone(), KernelElf::initialise(), MemoryPool::initialise(), X86CommonPhysicalMemoryManager::initialise64(), Event::isValidHandlerMapping(), Elf::loadModule(), HostedVirtualAddressSpace::map(), Arm64VirtualAddressSpace::map(), Armv7VirtualAddressSpace::map(), Device::Address::map(), Cache::map(), X86CommonPhysicalMemoryManager::PageStack::maybeMap(), KernelElf::prepareRuntimeModules(), HostedVirtualAddressSpace::setFlags(), AnonymousMemoryMap::supportsPageOut(), HostedVirtualAddressSpace::switchAddressSpace(), X64VirtualAddressSpace::toFlags(), and HostedVirtualAddressSpace::tryWriteUser32().

◆ m_Heap

void* VirtualAddressSpace::m_Heap

◆ m_HeapEnd

void* VirtualAddressSpace::m_HeapEnd

◆ m_HeapRegionId

uint64_t VirtualAddressSpace::m_HeapRegionId = 0
protected

◆ m_MemoryLockAccount

MemoryLockAccount* VirtualAddressSpace::m_MemoryLockAccount = nullptr
private

◆ m_RawUserMemory

RawUserMemory VirtualAddressSpace::m_RawUserMemory
private

◆ m_UserMemoryPolicy

UserMemoryPolicy* VirtualAddressSpace::m_UserMemoryPolicy = nullptr
private

◆ m_ZeroPage

physical_uintptr_t VirtualAddressSpace::m_ZeroPage = 0
static

Physical address of a zero page, always page-aligned.

Definition at line 416 of file include/pedigree/kernel/processor/VirtualAddressSpace.h.

Referenced by expandHeap().

◆ MaximumRemapPages

constexpr size_t VirtualAddressSpace::MaximumRemapPages = 65536
staticconstexpr

◆ NoAccess

const size_t VirtualAddressSpace::NoAccess = 0x4000
static

◆ RuntimeMapping

const size_t VirtualAddressSpace::RuntimeMapping = 0x20000
static

◆ Shared

const size_t VirtualAddressSpace::Shared = 0x200
static

◆ Swapped

const size_t VirtualAddressSpace::Swapped = 0x40
static

◆ Write

const size_t VirtualAddressSpace::Write = 0x02
static

◆ WriteCombine

const size_t VirtualAddressSpace::WriteCombine = 0x400
static

If this flag is set, the cache strategy is write-combine.

Definition at line 64 of file include/pedigree/kernel/processor/VirtualAddressSpace.h.

Referenced by X64VirtualAddressSpace::fromFlags(), Device::Address::map(), X64VirtualAddressSpace::toFlags(), and MemoryMappedFile::trap().

◆ WriteProtected

const size_t VirtualAddressSpace::WriteProtected = 0x8000
static

◆ WriteThrough

const size_t VirtualAddressSpace::WriteThrough = 0x08
static

If this flag is set, the cache strategy is write-through.

Definition at line 54 of file include/pedigree/kernel/processor/VirtualAddressSpace.h.

Referenced by X64VirtualAddressSpace::fromFlags(), Device::Address::map(), X64VirtualAddressSpace::toFlags(), and MemoryMappedFile::trap().


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