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

#include <VirtualAddressSpace.h>

+ Inheritance diagram for HostedVirtualAddressSpace:
+ Collaboration diagram for HostedVirtualAddressSpace:

Classes

struct  mapping_t
 

Public Member Functions

virtual bool isAddressValid (void *virtualAddress)
 
virtual bool isMapped (void *virtualAddress)
 
virtual bool map (physical_uintptr_t physAddress, void *virtualAddress, size_t flags)
 
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
 
virtual bool getMapping (void *virtualAddress, physical_uintptr_t &physAddress, size_t &flags)
 
virtual bool handleCopyOnWriteFault (void *virtualAddress, bool userMode)
 
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)
 
MUST_USE_RESULT bool trySetFlags (void *virtualAddress, size_t newFlags) override
 
virtual void unmap (void *virtualAddress)
 
virtual bool detachMapping (void *virtualAddress, physical_uintptr_t &physical, size_t &flags, size_t requiredFlags=0)
 
virtual Stack * allocateStack ()
 
virtual Stack * allocateStack (size_t stackSz)
 
virtual void freeStack (Stack *pStack)
 
virtual bool memIsInHeap (void *pMem)
 
virtual void * getEndOfHeap ()
 
virtual bool memIsInKernelHeap (void *pMem)
 
virtual VirtualAddressSpace * clone (bool copyOnWrite=true)
 
virtual void revertToKernelAddressSpace ()
 
virtual ~HostedVirtualAddressSpace ()
 
virtual uintptr_t getKernelStart () const
 
virtual uintptr_t getUserStart () const
 
virtual uintptr_t getUserReservedStart () const
 
virtual uintptr_t getDynamicLinkerAddress () const
 
virtual uintptr_t getKernelHeapStart () const
 
virtual uintptr_t getKernelHeapEnd () const
 
virtual uintptr_t getDynamicStart () const
 
virtual uintptr_t getDynamicEnd () const
 
virtual uintptr_t getKernelCacheStart () const
 
virtual uintptr_t getKernelCacheEnd () const
 
virtual uintptr_t getKernelEventBlockStart () const
 
virtual uintptr_t getKernelModulesStart () const
 
virtual uintptr_t getKernelModulesEnd () const
 
virtual uintptr_t getKernelVirtualPagestack () 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 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 getKernelVirtualPagestackAdd1 () const
 
virtual uintptr_t getKernelVirtualPagestackAdd2 () const
 
virtual uintptr_t getGlobalInfoBlock () const
 

Private Member Functions

bool tryAccessUserWord (uintptr_t address, size_t width, uintptr_t &value, const uintptr_t *replacement)
 
 HostedVirtualAddressSpace ()
 
 HostedVirtualAddressSpace (void *Heap, void *VirtualStack)
 
 HostedVirtualAddressSpace (const HostedVirtualAddressSpace &)
 
HostedVirtualAddressSpace & operator= (const HostedVirtualAddressSpace &)
 
uint64_t toFlags (size_t flags, bool bFinal=false)
 
size_t fromFlags (uint64_t Flags, bool bFinal=false)
 
Stack * doAllocateStack (size_t sSize)
 
mapping_t * findMapping (void *address)
 

Static Private Member Functions

static void switchAddressSpace (VirtualAddressSpace &oldSpace, VirtualAddressSpace &newSpace)
 

Private Attributes

void * m_pStackTop
 
Vector< Stack * > m_freeStacks
 
bool m_bKernelSpace
 
Spinlock m_Lock
 
Spinlock m_StacksLock
 
mapping_t * m_pKnownMaps
 
HostedMappingIndex m_MappingIndex
 
size_t m_KnownMapsSize
 
size_t m_numKnownMaps
 
size_t m_nLastUnmap
 

Static Private Attributes

static HostedVirtualAddressSpace m_KernelSpace
 

Friends

class HostedProcessor
 
class ProcessorBase
 
class Multiprocessor
 
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

The HostedVirtualAddressSpace implements the VirtualAddressSpace class for the x64 processor architecture, that means it wraps around the processor's paging functionality.

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

Constructor & Destructor Documentation

◆ ~HostedVirtualAddressSpace()

HostedVirtualAddressSpace::~HostedVirtualAddressSpace ( )
virtual

The destructor cleans up the address space

Definition at line 871 of file hosted/VirtualAddressSpace.cc.

References m_pKnownMaps.

◆ HostedVirtualAddressSpace() [1/3]

HostedVirtualAddressSpace::HostedVirtualAddressSpace ( )
private

The default constructor

Definition at line 875 of file hosted/VirtualAddressSpace.cc.

◆ HostedVirtualAddressSpace() [2/3]

HostedVirtualAddressSpace::HostedVirtualAddressSpace ( void *  Heap,
void *  VirtualStack 
)
private

The constructor for already present paging structures

Parameters
[in]Heapvirtual address of the beginning of the heap
[in]PhysicalPageDirectoryphysical address of the page directory
[in]VirtualStackvirtual address of the top of the next kernel stack
Note
This constructor is only used to construct the kernel VirtualAddressSpace

Definition at line 888 of file hosted/VirtualAddressSpace.cc.

◆ HostedVirtualAddressSpace() [3/3]

HostedVirtualAddressSpace::HostedVirtualAddressSpace ( const HostedVirtualAddressSpace &  )
private

The copy-constructor

Note
NOT implemented

Member Function Documentation

◆ allocateStack() [1/2]

VirtualAddressSpace::Stack * HostedVirtualAddressSpace::allocateStack ( )
virtual

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

Implements VirtualAddressSpace.

Definition at line 768 of file hosted/VirtualAddressSpace.cc.

References doAllocateStack(), and VirtualAddressSpace::getKernelAddressSpace.

Referenced by allocateStack().

+ Here is the caller graph for this function:

◆ allocateStack() [2/2]

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

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

Reimplemented from VirtualAddressSpace.

Definition at line 775 of file hosted/VirtualAddressSpace.cc.

References allocateStack(), and doAllocateStack().

◆ clone()

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

◆ detachMapping()

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

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 584 of file hosted/VirtualAddressSpace.cc.

References Dec, VirtualAddressSpace::detachMapping(), PhysicalMemoryManager::getPageSize(), ProcessorBase::information(), isMapped(), m_Lock, m_nLastUnmap, m_pKnownMaps, page_align(), and VirtualAddressSpace::getKernelAddressSpace.

◆ doAllocateStack()

VirtualAddressSpace::Stack * HostedVirtualAddressSpace::doAllocateStack ( size_t  sSize)
private

◆ findMapping()

HostedVirtualAddressSpace::mapping_t * HostedVirtualAddressSpace::findMapping ( void *  address)
private

Definition at line 118 of file hosted/VirtualAddressSpace.cc.

◆ freeStack()

void HostedVirtualAddressSpace::freeStack ( Stack *  pStack)
virtual

◆ fromFlags()

size_t HostedVirtualAddressSpace::fromFlags ( uint64_t  Flags,
bool  bFinal = false 
)
private

Convert processor's representation of the flags to the processor independant representation

Parameters
[in]Flagsthe processor specific flag representation
[in]bFinalwhether this is for the actual page or just an intermediate PTE/PDE
Returns
the proessor independant flag representation

Definition at line 917 of file hosted/VirtualAddressSpace.cc.

Referenced by getMapping().

+ Here is the caller graph for this function:

◆ getDynamicEnd()

virtual uintptr_t HostedVirtualAddressSpace::getDynamicEnd ( ) const
inlinevirtual

Gets address of the end of dynamic memory mapping area.

Reimplemented from VirtualAddressSpace.

Definition at line 156 of file kernel/core/processor/hosted/VirtualAddressSpace.h.

◆ getDynamicLinkerAddress()

virtual uintptr_t HostedVirtualAddressSpace::getDynamicLinkerAddress ( ) const
inlinevirtual

Gets address of the dynamic linker in the address space.

Implements VirtualAddressSpace.

Definition at line 136 of file kernel/core/processor/hosted/VirtualAddressSpace.h.

◆ getDynamicStart()

virtual uintptr_t HostedVirtualAddressSpace::getDynamicStart ( ) const
inlinevirtual

Gets address of the start of dynamic memory mapping area.

Reimplemented from VirtualAddressSpace.

Definition at line 151 of file kernel/core/processor/hosted/VirtualAddressSpace.h.

◆ getEndOfHeap()

void * HostedVirtualAddressSpace::getEndOfHeap ( )
virtual

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

Implements VirtualAddressSpace.

Definition at line 86 of file hosted/VirtualAddressSpace.cc.

Referenced by memIsInHeap().

+ Here is the caller graph for this function:

◆ getKernelCacheEnd()

virtual uintptr_t HostedVirtualAddressSpace::getKernelCacheEnd ( ) const
inlinevirtual

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

Implements VirtualAddressSpace.

Definition at line 166 of file kernel/core/processor/hosted/VirtualAddressSpace.h.

◆ getKernelCacheStart()

virtual uintptr_t HostedVirtualAddressSpace::getKernelCacheStart ( ) const
inlinevirtual

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

Implements VirtualAddressSpace.

Definition at line 161 of file kernel/core/processor/hosted/VirtualAddressSpace.h.

◆ getKernelEventBlockStart()

virtual uintptr_t HostedVirtualAddressSpace::getKernelEventBlockStart ( ) const
inlinevirtual

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

Implements VirtualAddressSpace.

Definition at line 171 of file kernel/core/processor/hosted/VirtualAddressSpace.h.

◆ getKernelHeapEnd()

virtual uintptr_t HostedVirtualAddressSpace::getKernelHeapEnd ( ) const
inlinevirtual

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

Implements VirtualAddressSpace.

Definition at line 146 of file kernel/core/processor/hosted/VirtualAddressSpace.h.

◆ getKernelHeapStart()

virtual uintptr_t HostedVirtualAddressSpace::getKernelHeapStart ( ) const
inlinevirtual

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

Implements VirtualAddressSpace.

Definition at line 141 of file kernel/core/processor/hosted/VirtualAddressSpace.h.

◆ getKernelModulesEnd()

virtual uintptr_t HostedVirtualAddressSpace::getKernelModulesEnd ( ) const
inlinevirtual

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

Implements VirtualAddressSpace.

Definition at line 181 of file kernel/core/processor/hosted/VirtualAddressSpace.h.

◆ getKernelModulesStart()

virtual uintptr_t HostedVirtualAddressSpace::getKernelModulesStart ( ) const
inlinevirtual

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

Implements VirtualAddressSpace.

Definition at line 176 of file kernel/core/processor/hosted/VirtualAddressSpace.h.

◆ getKernelStart()

virtual uintptr_t HostedVirtualAddressSpace::getKernelStart ( ) const
inlinevirtual

Gets start address of the kernel in the address space.

Implements VirtualAddressSpace.

Definition at line 121 of file kernel/core/processor/hosted/VirtualAddressSpace.h.

Referenced by tryWriteUser32().

+ Here is the caller graph for this function:

◆ getKernelVirtualPagestack()

virtual uintptr_t HostedVirtualAddressSpace::getKernelVirtualPagestack ( ) const
inlinevirtual

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

Reimplemented from VirtualAddressSpace.

Definition at line 186 of file kernel/core/processor/hosted/VirtualAddressSpace.h.

◆ getMapping()

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

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 212 of file hosted/VirtualAddressSpace.cc.

References fromFlags(), getMapping(), PhysicalMemoryManager::getPageSize(), m_Lock, page_align(), and VirtualAddressSpace::getKernelAddressSpace.

Referenced by freeStack(), and getMapping().

+ Here is the caller graph for this function:

◆ getUserReservedStart()

virtual uintptr_t HostedVirtualAddressSpace::getUserReservedStart ( ) const
inlinevirtual

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

Implements VirtualAddressSpace.

Definition at line 131 of file kernel/core/processor/hosted/VirtualAddressSpace.h.

◆ getUserStart()

virtual uintptr_t HostedVirtualAddressSpace::getUserStart ( ) const
inlinevirtual

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

Implements VirtualAddressSpace.

Definition at line 126 of file kernel/core/processor/hosted/VirtualAddressSpace.h.

Referenced by tryWriteUser32().

+ Here is the caller graph for this function:

◆ handleCopyOnWriteFault()

bool HostedVirtualAddressSpace::handleCopyOnWriteFault ( void *  virtualAddress,
bool  userMode 
)
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.

Implements VirtualAddressSpace.

Definition at line 238 of file hosted/VirtualAddressSpace.cc.

References PhysicalMemoryManager::allocatePage(), VirtualAddressSpace::Borrowed, VirtualAddressSpace::CopyOnWrite, Dec, PhysicalMemoryManager::freePage(), PhysicalMemoryManager::getPageSize(), VirtualAddressSpace::handleCopyOnWriteFault(), Hex, PhysicalMemoryManager::instance(), HostedPhysicalMemoryManager::instance(), isMapped(), VirtualAddressSpace::KernelMode, m_Lock, VirtualAddressSpace::NoAccess, page_align(), panic(), VirtualAddressSpace::Shared, VirtualAddressSpace::Swapped, toFlags(), VirtualAddressSpace::getKernelAddressSpace, VirtualAddressSpace::Write, and VirtualAddressSpace::WriteProtected.

◆ isAddressValid()

bool HostedVirtualAddressSpace::isAddressValid ( void *  virtualAddress)
virtual

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 90 of file hosted/VirtualAddressSpace.cc.

◆ isMapped()

bool HostedVirtualAddressSpace::isMapped ( void *  virtualAddress)
virtual

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 97 of file hosted/VirtualAddressSpace.cc.

References PhysicalMemoryManager::getPageSize(), VirtualAddressSpace::isMapped(), m_Lock, page_align(), and VirtualAddressSpace::getKernelAddressSpace.

Referenced by detachMapping(), freeStack(), handleCopyOnWriteFault(), map(), revertToKernelAddressSpace(), setFlags(), switchAddressSpace(), trySetFlags(), and unmap().

+ Here is the caller graph for this function:

◆ map()

bool HostedVirtualAddressSpace::map ( physical_uintptr_t  physicalAddress,
void *  virtualAddress,
size_t  flags 
)
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

Implements VirtualAddressSpace.

Definition at line 123 of file hosted/VirtualAddressSpace.cc.

References Dec, PhysicalMemoryManager::getPageSize(), Hex, HostedPhysicalMemoryManager::instance(), isMapped(), VirtualAddressSpace::KernelMode, m_KnownMapsSize, m_Lock, m_nLastUnmap, m_numKnownMaps, m_pKnownMaps, VirtualAddressSpace::map(), page_align(), panic(), toFlags(), UNLIKELY, and VirtualAddressSpace::getKernelAddressSpace.

Referenced by doAllocateStack().

+ Here is the caller graph for this function:

◆ memIsInHeap()

bool HostedVirtualAddressSpace::memIsInHeap ( void *  pMem)
virtual

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

Implements VirtualAddressSpace.

Definition at line 68 of file hosted/VirtualAddressSpace.cc.

References getEndOfHeap(), and VirtualAddressSpace::m_Heap.

◆ memIsInKernelHeap()

bool HostedVirtualAddressSpace::memIsInKernelHeap ( void *  pMem)
virtual

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

Implements VirtualAddressSpace.

Definition at line 77 of file hosted/VirtualAddressSpace.cc.

◆ operator=()

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

The copy-constructor

Note
Not implemented

◆ revertToKernelAddressSpace()

void HostedVirtualAddressSpace::revertToKernelAddressSpace ( )
virtual

◆ setFlags()

void HostedVirtualAddressSpace::setFlags ( void *  virtualAddress,
size_t  newFlags 
)
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

Implements VirtualAddressSpace.

Definition at line 447 of file hosted/VirtualAddressSpace.cc.

References Dec, PhysicalMemoryManager::getPageSize(), isMapped(), VirtualAddressSpace::KernelMode, m_Lock, page_align(), VirtualAddressSpace::setFlags(), toFlags(), and VirtualAddressSpace::getKernelAddressSpace.

◆ switchAddressSpace()

void HostedVirtualAddressSpace::switchAddressSpace ( VirtualAddressSpace &  oldSpace,
VirtualAddressSpace &  newSpace 
)
staticprivate

◆ toFlags()

uint64_t HostedVirtualAddressSpace::toFlags ( size_t  flags,
bool  bFinal = false 
)
private

Convert the processor independant flags to the processor's representation of the flags

Parameters
[in]flagsthe processor independant flag representation
[in]bFinalwhether this is for the actual page or just an intermediate PTE/PDE
Returns
the proessor specific flag representation

Definition at line 901 of file hosted/VirtualAddressSpace.cc.

References VirtualAddressSpace::Execute, VirtualAddressSpace::NoAccess, VirtualAddressSpace::Swapped, VirtualAddressSpace::Write, and VirtualAddressSpace::WriteProtected.

Referenced by clone(), handleCopyOnWriteFault(), map(), setFlags(), switchAddressSpace(), and trySetFlags().

+ Here is the caller graph for this function:

◆ tryAccessUserWord()

bool HostedVirtualAddressSpace::tryAccessUserWord ( uintptr_t  address,
size_t  width,
uintptr_t &  value,
const uintptr_t *  replacement 
)
private

Definition at line 366 of file hosted/VirtualAddressSpace.cc.

◆ tryCompareExchangeUser32()

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

A successful access may still report a failed comparison.

Reimplemented from VirtualAddressSpace.

Definition at line 352 of file hosted/VirtualAddressSpace.cc.

◆ tryDetachUserPage()

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

Reimplemented from VirtualAddressSpace.

Definition at line 518 of file hosted/VirtualAddressSpace.cc.

◆ tryMapUserPage()

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

Reimplemented from VirtualAddressSpace.

Definition at line 473 of file hosted/VirtualAddressSpace.cc.

◆ tryReadUser32()

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

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

Reimplemented from VirtualAddressSpace.

Definition at line 339 of file hosted/VirtualAddressSpace.cc.

◆ tryReadUserPointer()

bool HostedVirtualAddressSpace::tryReadUserPointer ( uintptr_t  address,
uintptr_t &  value 
)
virtual

Reimplemented from VirtualAddressSpace.

Definition at line 348 of file hosted/VirtualAddressSpace.cc.

◆ trySetFlags()

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

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

Reimplemented from VirtualAddressSpace.

Definition at line 541 of file hosted/VirtualAddressSpace.cc.

References PhysicalMemoryManager::getPageSize(), isMapped(), m_Lock, page_align(), toFlags(), VirtualAddressSpace::trySetFlags(), and VirtualAddressSpace::getKernelAddressSpace.

◆ tryWriteUser32()

bool HostedVirtualAddressSpace::tryWriteUser32 ( uintptr_t  address,
uint32_t  value 
)
virtual

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

Definition at line 411 of file hosted/VirtualAddressSpace.cc.

References VirtualAddressSpace::CopyOnWrite, getKernelStart(), PhysicalMemoryManager::getPageSize(), getUserStart(), HostedPhysicalMemoryManager::instance(), VirtualAddressSpace::KernelMode, m_Lock, VirtualAddressSpace::NoAccess, VirtualAddressSpace::Swapped, VirtualAddressSpace::Write, and VirtualAddressSpace::WriteProtected.

◆ unmap()

void HostedVirtualAddressSpace::unmap ( void *  virtualAddress)
virtual

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 559 of file hosted/VirtualAddressSpace.cc.

References Dec, PhysicalMemoryManager::getPageSize(), isMapped(), m_Lock, m_nLastUnmap, m_pKnownMaps, page_align(), VirtualAddressSpace::unmap(), and VirtualAddressSpace::getKernelAddressSpace.

Referenced by freeStack().

+ Here is the caller graph for this function:

Friends And Related Symbol Documentation

◆ HostedProcessor

friend class HostedProcessor
friend

Processor::switchAddressSpace() needs access to m_PhysicalPML4

Definition at line 72 of file kernel/core/processor/hosted/VirtualAddressSpace.h.

◆ Multiprocessor

friend class Multiprocessor
friend

Multiprocessor::initialise() needs access to m_PhysicalPML4

Definition at line 75 of file kernel/core/processor/hosted/VirtualAddressSpace.h.

◆ ProcessorBase

friend class ProcessorBase
friend

◆ VirtualAddressSpace::create

VirtualAddressSpace::create needs access to the constructor

◆ VirtualAddressSpace::getKernelAddressSpace

Member Data Documentation

◆ m_bKernelSpace

bool HostedVirtualAddressSpace::m_bKernelSpace
private

Is this the kernel space?

Definition at line 244 of file kernel/core/processor/hosted/VirtualAddressSpace.h.

◆ m_freeStacks

Vector<Stack*> HostedVirtualAddressSpace::m_freeStacks
private

List of free stacks

Definition at line 242 of file kernel/core/processor/hosted/VirtualAddressSpace.h.

Referenced by clone(), doAllocateStack(), and freeStack().

◆ m_KernelSpace

HostedVirtualAddressSpace HostedVirtualAddressSpace::m_KernelSpace
staticprivate

◆ m_KnownMapsSize

size_t HostedVirtualAddressSpace::m_KnownMapsSize
private

Tracks the size of the known mappings list.

Definition at line 253 of file kernel/core/processor/hosted/VirtualAddressSpace.h.

Referenced by clone(), map(), revertToKernelAddressSpace(), and switchAddressSpace().

◆ m_Lock

Spinlock HostedVirtualAddressSpace::m_Lock
private

◆ m_MappingIndex

HostedMappingIndex HostedVirtualAddressSpace::m_MappingIndex
private

◆ m_nLastUnmap

size_t HostedVirtualAddressSpace::m_nLastUnmap
private

Last unmap for easier finding of places to fit entries.

Definition at line 257 of file kernel/core/processor/hosted/VirtualAddressSpace.h.

Referenced by clone(), detachMapping(), map(), revertToKernelAddressSpace(), and unmap().

◆ m_numKnownMaps

size_t HostedVirtualAddressSpace::m_numKnownMaps
private

Tracks the number of known mappings we have.

Definition at line 255 of file kernel/core/processor/hosted/VirtualAddressSpace.h.

Referenced by clone(), and map().

◆ m_pKnownMaps

mapping_t* HostedVirtualAddressSpace::m_pKnownMaps
private

Tracks the current mappings made in this address space.

Definition at line 250 of file kernel/core/processor/hosted/VirtualAddressSpace.h.

Referenced by clone(), detachMapping(), map(), revertToKernelAddressSpace(), switchAddressSpace(), unmap(), and ~HostedVirtualAddressSpace().

◆ m_pStackTop

void* HostedVirtualAddressSpace::m_pStackTop
private

Current top of the stacks

Definition at line 240 of file kernel/core/processor/hosted/VirtualAddressSpace.h.

Referenced by clone(), and doAllocateStack().

◆ m_StacksLock

Spinlock HostedVirtualAddressSpace::m_StacksLock
private

Lock to guard against multiprocessor reentrancy for stack reuse.

Definition at line 248 of file kernel/core/processor/hosted/VirtualAddressSpace.h.

Referenced by clone(), doAllocateStack(), and freeStack().


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