The Pedigree Project 0.1
Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
Armv7VirtualAddressSpace Class Referencefinal
+ Inheritance diagram for Armv7VirtualAddressSpace:
+ Collaboration diagram for Armv7VirtualAddressSpace:

Public Member Functions

bool isAddressValid (void *address) override
 
bool isMapped (void *address) override
 
bool map (physical_uintptr_t physical, void *address, size_t flags) override
 
bool tryMapUserPage (physical_uintptr_t physical, void *address, size_t flags, size_t *committedTablePages=nullptr) override
 
bool tryDetachUserPage (void *address, physical_uintptr_t expected) override
 
bool getMapping (void *address, physical_uintptr_t &physical, size_t &flags) override
 
bool handleCopyOnWriteFault (void *address, bool userMode) override
 
void setFlags (void *address, size_t flags) override
 
bool trySetFlags (void *address, size_t flags) override
 
void unmap (void *address) override
 
bool detachMapping (void *address, physical_uintptr_t &physical, size_t &flags, size_t requiredFlags=0) override
 
Stack * allocateStack () override
 
Stack * allocateStack (size_t bytes) override
 
void freeStack (Stack *stack) override
 
VirtualAddressSpace * clone (bool copyOnWrite=true) override
 
void revertToKernelAddressSpace () override
 
bool memIsInKernelHeap (void *address) override
 
bool memIsInHeap (void *address) override
 
void * getEndOfHeap () override
 
uintptr_t getKernelStart () const override
 
uintptr_t getUserStart () const override
 
uintptr_t getUserReservedStart () const override
 
uintptr_t getDynamicLinkerAddress () const override
 
uintptr_t getKernelHeapStart () const override
 
uintptr_t getKernelHeapEnd () const override
 
uintptr_t getKernelCacheStart () const override
 
uintptr_t getKernelCacheEnd () const override
 
uintptr_t getKernelEventBlockStart () const override
 
uintptr_t getKernelModulesStart () const override
 
uintptr_t getKernelModulesEnd () const override
 
uintptr_t getGlobalInfoBlock () const override
 
uintptr_t getDynamicStart () const override
 
uintptr_t getDynamicEnd () const override
 
physical_uintptr_t root () const
 
- Public Member Functions inherited from VirtualAddressSpace
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 mapHuge (physical_uintptr_t physAddress, void *virtualAddress, size_t count, size_t flags)
 
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 RemapStatus prepareRemap (const PageRemapRequest &request, UniquePointer< PreparedPageRemap > &plan)
 
virtual void setRemapPreparationFailureForTest (ssize_t allocations)
 
virtual ~VirtualAddressSpace ()
 
void setHeap (void *heap, void *heapEnd)
 
virtual uintptr_t getKernelVirtualPagestack () const
 
virtual uintptr_t getKernelVirtualPagestackAdd1 () const
 
virtual uintptr_t getKernelVirtualPagestackAdd2 () const
 

Private Member Functions

 Armv7VirtualAddressSpace (bool kernel)
 
uint32_t * findEntry (uintptr_t address, bool create, size_t *newTables=nullptr)
 
uint32_t * findExistingEntry (uintptr_t address, bool *section=nullptr) const
 
bool cloneUserTables (Armv7VirtualAddressSpace &destination, bool copyOnWrite)
 
void freeUserTables ()
 

Static Private Member Functions

static uint32_t pageDescriptor (physical_uintptr_t physical, size_t flags)
 

Private Attributes

physical_uintptr_t m_Root
 
uintptr_t m_StackTop
 
Spinlock m_Lock
 

Static Private Attributes

static Armv7VirtualAddressSpace m_KernelSpace
 

Friends

class ProcessorBase
 
VirtualAddressSpace & VirtualAddressSpace::getKernelAddressSpace ()
 
VirtualAddressSpace * VirtualAddressSpace::create ()
 

Additional Inherited Members

- Public Types inherited from VirtualAddressSpace
enum class  ResidentCopyStatus { Success , Inaccessible , Unsupported }
 
enum class  RemapStatus {
  Success , InvalidRange , Unsupported , NoMemory ,
  Retry
}
 
using RemapAdmission = bool(*)(void *context)
 
- Static Public Member Functions inherited from VirtualAddressSpace
static EXPORTED_PUBLIC VirtualAddressSpace & getKernelAddressSpace ()
 
static VirtualAddressSpace * create ()
 
- Public Attributes inherited from VirtualAddressSpace
void * m_Heap
 
void * m_HeapEnd
 
- Static Public Attributes inherited from VirtualAddressSpace
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 inherited from VirtualAddressSpace
bool admitRawMemoryChange (const PreparedMemoryLock &plan, bool privileged, MemoryLockCharge &charge) const
 
void commitRawMemoryChange (PreparedMemoryLock &plan, MemoryLockCharge charge)
 
bool prepareZeroPage ()
 
 VirtualAddressSpace (void *Heap)
 
- Protected Attributes inherited from VirtualAddressSpace
uint64_t m_HeapRegionId = 0
 

Detailed Description

Definition at line 18 of file kernel/core/processor/armv7/VirtualAddressSpace.h.

Constructor & Destructor Documentation

◆ ~Armv7VirtualAddressSpace()

Armv7VirtualAddressSpace::~Armv7VirtualAddressSpace ( )
override

Definition at line 55 of file armv7/VirtualAddressSpace.cc.

◆ Armv7VirtualAddressSpace()

Armv7VirtualAddressSpace::Armv7VirtualAddressSpace ( bool  kernel)
explicitprivate

Definition at line 44 of file armv7/VirtualAddressSpace.cc.

Member Function Documentation

◆ allocateStack() [1/2]

VirtualAddressSpace::Stack * Armv7VirtualAddressSpace::allocateStack ( )
overridevirtual

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

Implements VirtualAddressSpace.

Definition at line 286 of file armv7/VirtualAddressSpace.cc.

References allocateStack().

Referenced by allocateStack(), and allocateStack().

+ Here is the caller graph for this function:

◆ allocateStack() [2/2]

VirtualAddressSpace::Stack * Armv7VirtualAddressSpace::allocateStack ( size_t  stackSz)
overridevirtual

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

Reimplemented from VirtualAddressSpace.

Definition at line 290 of file armv7/VirtualAddressSpace.cc.

References allocateStack(), detachMapping(), Armv7PhysicalMemoryManager::freePage(), VirtualAddressSpace::KernelMode, map(), and VirtualAddressSpace::Write.

◆ clone()

VirtualAddressSpace * Armv7VirtualAddressSpace::clone ( bool  copyOnWrite = true)
overridevirtual

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

Implements VirtualAddressSpace.

Definition at line 409 of file armv7/VirtualAddressSpace.cc.

References clone(), VirtualAddressSpace::m_Heap, and VirtualAddressSpace::m_HeapEnd.

Referenced by clone().

+ Here is the caller graph for this function:

◆ cloneUserTables()

bool Armv7VirtualAddressSpace::cloneUserTables ( Armv7VirtualAddressSpace &  destination,
bool  copyOnWrite 
)
private

Definition at line 344 of file armv7/VirtualAddressSpace.cc.

◆ detachMapping()

bool Armv7VirtualAddressSpace::detachMapping ( void *  virtualAddress,
physical_uintptr_t &  physical,
size_t &  flags,
size_t  requiredFlags = 0 
)
overridevirtual

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

Reimplemented from VirtualAddressSpace.

Definition at line 223 of file armv7/VirtualAddressSpace.cc.

References ProcessorBase::invalidate().

Referenced by allocateStack(), freeStack(), handleCopyOnWriteFault(), and unmap().

+ Here is the caller graph for this function:

◆ findEntry()

uint32_t * Armv7VirtualAddressSpace::findEntry ( uintptr_t  address,
bool  create,
size_t *  newTables = nullptr 
)
private

Definition at line 79 of file armv7/VirtualAddressSpace.cc.

◆ findExistingEntry()

uint32_t * Armv7VirtualAddressSpace::findExistingEntry ( uintptr_t  address,
bool *  section = nullptr 
) const
private

Definition at line 67 of file armv7/VirtualAddressSpace.cc.

◆ freeStack()

void Armv7VirtualAddressSpace::freeStack ( Stack *  pStack)
overridevirtual

Frees a stack allocated with allocateStack.

Implements VirtualAddressSpace.

Definition at line 328 of file armv7/VirtualAddressSpace.cc.

References detachMapping(), and Armv7PhysicalMemoryManager::freePage().

◆ freeUserTables()

void Armv7VirtualAddressSpace::freeUserTables ( )
private

Definition at line 391 of file armv7/VirtualAddressSpace.cc.

◆ getDynamicEnd()

uintptr_t Armv7VirtualAddressSpace::getDynamicEnd ( ) const
inlineoverridevirtual

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

Reimplemented from VirtualAddressSpace.

Definition at line 85 of file kernel/core/processor/armv7/VirtualAddressSpace.h.

◆ getDynamicLinkerAddress()

uintptr_t Armv7VirtualAddressSpace::getDynamicLinkerAddress ( ) const
inlineoverridevirtual

Gets address of the dynamic linker in the address space.

Implements VirtualAddressSpace.

Definition at line 55 of file kernel/core/processor/armv7/VirtualAddressSpace.h.

◆ getDynamicStart()

uintptr_t Armv7VirtualAddressSpace::getDynamicStart ( ) const
inlineoverridevirtual

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 from VirtualAddressSpace.

Definition at line 82 of file kernel/core/processor/armv7/VirtualAddressSpace.h.

◆ getEndOfHeap()

void * Armv7VirtualAddressSpace::getEndOfHeap ( )
overridevirtual

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

Implements VirtualAddressSpace.

Definition at line 450 of file armv7/VirtualAddressSpace.cc.

◆ getGlobalInfoBlock()

uintptr_t Armv7VirtualAddressSpace::getGlobalInfoBlock ( ) const
inlineoverridevirtual

Gets address of the global info block location.

Reimplemented from VirtualAddressSpace.

Definition at line 79 of file kernel/core/processor/armv7/VirtualAddressSpace.h.

◆ getKernelCacheEnd()

uintptr_t Armv7VirtualAddressSpace::getKernelCacheEnd ( ) const
inlineoverridevirtual

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

Implements VirtualAddressSpace.

Definition at line 67 of file kernel/core/processor/armv7/VirtualAddressSpace.h.

◆ getKernelCacheStart()

uintptr_t Armv7VirtualAddressSpace::getKernelCacheStart ( ) const
inlineoverridevirtual

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

Implements VirtualAddressSpace.

Definition at line 64 of file kernel/core/processor/armv7/VirtualAddressSpace.h.

◆ getKernelEventBlockStart()

uintptr_t Armv7VirtualAddressSpace::getKernelEventBlockStart ( ) const
inlineoverridevirtual

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

Implements VirtualAddressSpace.

Definition at line 70 of file kernel/core/processor/armv7/VirtualAddressSpace.h.

◆ getKernelHeapEnd()

uintptr_t Armv7VirtualAddressSpace::getKernelHeapEnd ( ) const
inlineoverridevirtual

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

Implements VirtualAddressSpace.

Definition at line 61 of file kernel/core/processor/armv7/VirtualAddressSpace.h.

◆ getKernelHeapStart()

uintptr_t Armv7VirtualAddressSpace::getKernelHeapStart ( ) const
inlineoverridevirtual

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

Implements VirtualAddressSpace.

Definition at line 58 of file kernel/core/processor/armv7/VirtualAddressSpace.h.

◆ getKernelModulesEnd()

uintptr_t Armv7VirtualAddressSpace::getKernelModulesEnd ( ) const
inlineoverridevirtual

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

Implements VirtualAddressSpace.

Definition at line 76 of file kernel/core/processor/armv7/VirtualAddressSpace.h.

◆ getKernelModulesStart()

uintptr_t Armv7VirtualAddressSpace::getKernelModulesStart ( ) const
inlineoverridevirtual

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

Implements VirtualAddressSpace.

Definition at line 73 of file kernel/core/processor/armv7/VirtualAddressSpace.h.

◆ getKernelStart()

uintptr_t Armv7VirtualAddressSpace::getKernelStart ( ) const
inlineoverridevirtual

Gets start address of the kernel in the address space.

Implements VirtualAddressSpace.

Definition at line 46 of file kernel/core/processor/armv7/VirtualAddressSpace.h.

◆ getMapping()

bool Armv7VirtualAddressSpace::getMapping ( void *  virtualAddress,
physical_uintptr_t &  physicalAddress,
size_t &  flags 
)
overridevirtual

Query the physical address and flags of a mapped or swapped-out page. Returns false without modifying the outputs when no mapping exists. The result does not pin the page; callers must protect its lifetime while using the returned physical address.

Implements VirtualAddressSpace.

Definition at line 181 of file armv7/VirtualAddressSpace.cc.

References VirtualAddressSpace::Execute, VirtualAddressSpace::KernelMode, and VirtualAddressSpace::Write.

Referenced by handleCopyOnWriteFault().

+ Here is the caller graph for this function:

◆ getUserReservedStart()

uintptr_t Armv7VirtualAddressSpace::getUserReservedStart ( ) const
inlineoverridevirtual

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

Implements VirtualAddressSpace.

Definition at line 52 of file kernel/core/processor/armv7/VirtualAddressSpace.h.

◆ getUserStart()

uintptr_t Armv7VirtualAddressSpace::getUserStart ( ) const
inlineoverridevirtual

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

Implements VirtualAddressSpace.

Definition at line 49 of file kernel/core/processor/armv7/VirtualAddressSpace.h.

◆ handleCopyOnWriteFault()

bool Armv7VirtualAddressSpace::handleCopyOnWriteFault ( void *  virtualAddress,
bool  userMode 
)
overridevirtual

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.

Implements VirtualAddressSpace.

Definition at line 262 of file armv7/VirtualAddressSpace.cc.

References VirtualAddressSpace::Borrowed, VirtualAddressSpace::CopyOnWrite, detachMapping(), Armv7PhysicalMemoryManager::freePage(), getMapping(), VirtualAddressSpace::KernelMode, map(), VirtualAddressSpace::NoAccess, VirtualAddressSpace::Shared, VirtualAddressSpace::Swapped, VirtualAddressSpace::Write, and VirtualAddressSpace::WriteProtected.

◆ isAddressValid()

bool Armv7VirtualAddressSpace::isAddressValid ( void *  virtualAddress)
overridevirtual

Is a particular virtual address valid?

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

Implements VirtualAddressSpace.

Definition at line 63 of file armv7/VirtualAddressSpace.cc.

◆ isMapped()

bool Armv7VirtualAddressSpace::isMapped ( void *  virtualAddress)
overridevirtual

Checks whether a mapping the the specific virtual address exists. Pages marked as swapped out are not considered mapped; retained NoAccess pages are.

Note
This function must be valid on all the valid addresses within the virtual address space.
Parameters
[in]virtualAddressthe virtual address
Returns
true, if a mapping exists, false otherwise

Implements VirtualAddressSpace.

Definition at line 121 of file armv7/VirtualAddressSpace.cc.

References VirtualAddressSpace::Swapped.

◆ map()

bool Armv7VirtualAddressSpace::map ( physical_uintptr_t  physicalAddress,
void *  virtualAddress,
size_t  flags 
)
overridevirtual

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

Implements VirtualAddressSpace.

Definition at line 137 of file armv7/VirtualAddressSpace.cc.

References ProcessorBase::invalidate(), and VirtualAddressSpace::KernelMode.

Referenced by allocateStack(), and handleCopyOnWriteFault().

+ Here is the caller graph for this function:

◆ memIsInHeap()

bool Armv7VirtualAddressSpace::memIsInHeap ( void *  pMem)
overridevirtual

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

Implements VirtualAddressSpace.

Definition at line 444 of file armv7/VirtualAddressSpace.cc.

References VirtualAddressSpace::m_Heap, and VirtualAddressSpace::m_HeapEnd.

◆ memIsInKernelHeap()

bool Armv7VirtualAddressSpace::memIsInKernelHeap ( void *  pMem)
overridevirtual

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

Implements VirtualAddressSpace.

Definition at line 439 of file armv7/VirtualAddressSpace.cc.

◆ pageDescriptor()

uint32_t Armv7VirtualAddressSpace::pageDescriptor ( physical_uintptr_t  physical,
size_t  flags 
)
staticprivate

Definition at line 99 of file armv7/VirtualAddressSpace.cc.

◆ revertToKernelAddressSpace()

void Armv7VirtualAddressSpace::revertToKernelAddressSpace ( )
overridevirtual

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'.

Implements VirtualAddressSpace.

Definition at line 427 of file armv7/VirtualAddressSpace.cc.

References ProcessorBase::invalidate(), VirtualAddressSpace::m_Heap, and VirtualAddressSpace::m_HeapEnd.

◆ root()

physical_uintptr_t Armv7VirtualAddressSpace::root ( ) const
inline

◆ setFlags()

void Armv7VirtualAddressSpace::setFlags ( void *  virtualAddress,
size_t  newFlags 
)
overridevirtual

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

Implements VirtualAddressSpace.

Definition at line 217 of file armv7/VirtualAddressSpace.cc.

References panic(), and trySetFlags().

◆ tryDetachUserPage()

bool Armv7VirtualAddressSpace::tryDetachUserPage ( void *  address,
physical_uintptr_t  expected 
)
overridevirtual

Reimplemented from VirtualAddressSpace.

Definition at line 245 of file armv7/VirtualAddressSpace.cc.

◆ tryMapUserPage()

bool Armv7VirtualAddressSpace::tryMapUserPage ( physical_uintptr_t  physical,
void *  address,
size_t  flags,
size_t *  committedTablePages = nullptr 
)
overridevirtual

Reimplemented from VirtualAddressSpace.

Definition at line 155 of file armv7/VirtualAddressSpace.cc.

◆ trySetFlags()

bool Armv7VirtualAddressSpace::trySetFlags ( void *  virtualAddress,
size_t  newFlags 
)
overridevirtual

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

Reimplemented from VirtualAddressSpace.

Definition at line 202 of file armv7/VirtualAddressSpace.cc.

References ProcessorBase::invalidate().

Referenced by setFlags().

+ Here is the caller graph for this function:

◆ unmap()

void Armv7VirtualAddressSpace::unmap ( void *  virtualAddress)
overridevirtual

Remove the page at the specific virtual address from the virtual address space.

Note
This function is only valid on memory that was mapped with VirtualAddressSpace::map() and that is still mapped or marked as swapped out.
Parameters
[in]virtualAddressthe virtual address

Implements VirtualAddressSpace.

Definition at line 254 of file armv7/VirtualAddressSpace.cc.

References detachMapping(), and panic().

Friends And Related Symbol Documentation

◆ ProcessorBase

friend class ProcessorBase
friend

Member Data Documentation

◆ m_KernelSpace

Armv7VirtualAddressSpace Armv7VirtualAddressSpace::m_KernelSpace
staticprivate

◆ m_Lock

Spinlock Armv7VirtualAddressSpace::m_Lock
private

◆ m_Root

physical_uintptr_t Armv7VirtualAddressSpace::m_Root
private

◆ m_StackTop

uintptr_t Armv7VirtualAddressSpace::m_StackTop
private

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