vm_manager: Provide address range checking functions for other memory regions

Makes the interface uniform when it comes to checking various memory
regions.
This commit is contained in:
Lioncash 2019-03-04 16:40:17 -05:00
parent 0be8fffc99
commit 6c42a23550
2 changed files with 35 additions and 4 deletions

View File

@ -763,6 +763,11 @@ u64 VMManager::GetCodeRegionSize() const {
return code_region_end - code_region_base; return code_region_end - code_region_base;
} }
bool VMManager::IsWithinCodeRegion(VAddr address, u64 size) const {
return IsInsideAddressRange(address, size, GetCodeRegionBaseAddress(),
GetCodeRegionEndAddress());
}
VAddr VMManager::GetHeapRegionBaseAddress() const { VAddr VMManager::GetHeapRegionBaseAddress() const {
return heap_region_base; return heap_region_base;
} }
@ -775,6 +780,11 @@ u64 VMManager::GetHeapRegionSize() const {
return heap_region_end - heap_region_base; return heap_region_end - heap_region_base;
} }
bool VMManager::IsWithinHeapRegion(VAddr address, u64 size) const {
return IsInsideAddressRange(address, size, GetHeapRegionBaseAddress(),
GetHeapRegionEndAddress());
}
VAddr VMManager::GetMapRegionBaseAddress() const { VAddr VMManager::GetMapRegionBaseAddress() const {
return map_region_base; return map_region_base;
} }
@ -787,6 +797,10 @@ u64 VMManager::GetMapRegionSize() const {
return map_region_end - map_region_base; return map_region_end - map_region_base;
} }
bool VMManager::IsWithinMapRegion(VAddr address, u64 size) const {
return IsInsideAddressRange(address, size, GetMapRegionBaseAddress(), GetMapRegionEndAddress());
}
VAddr VMManager::GetNewMapRegionBaseAddress() const { VAddr VMManager::GetNewMapRegionBaseAddress() const {
return new_map_region_base; return new_map_region_base;
} }
@ -816,4 +830,9 @@ u64 VMManager::GetTLSIORegionSize() const {
return tls_io_region_end - tls_io_region_base; return tls_io_region_end - tls_io_region_base;
} }
bool VMManager::IsWithinTLSIORegion(VAddr address, u64 size) const {
return IsInsideAddressRange(address, size, GetTLSIORegionBaseAddress(),
GetTLSIORegionEndAddress());
}
} // namespace Kernel } // namespace Kernel

View File

@ -441,12 +441,12 @@ public:
/// Gets the end address of the ASLR region. /// Gets the end address of the ASLR region.
VAddr GetASLRRegionEndAddress() const; VAddr GetASLRRegionEndAddress() const;
/// Determines whether or not the specified address range is within the ASLR region.
bool IsWithinASLRRegion(VAddr address, u64 size) const;
/// Gets the size of the ASLR region /// Gets the size of the ASLR region
u64 GetASLRRegionSize() const; u64 GetASLRRegionSize() const;
/// Determines whether or not the specified address range is within the ASLR region.
bool IsWithinASLRRegion(VAddr address, u64 size) const;
/// Gets the base address of the code region. /// Gets the base address of the code region.
VAddr GetCodeRegionBaseAddress() const; VAddr GetCodeRegionBaseAddress() const;
@ -456,6 +456,9 @@ public:
/// Gets the total size of the code region in bytes. /// Gets the total size of the code region in bytes.
u64 GetCodeRegionSize() const; u64 GetCodeRegionSize() const;
/// Determines whether or not the specified range is within the code region.
bool IsWithinCodeRegion(VAddr address, u64 size) const;
/// Gets the base address of the heap region. /// Gets the base address of the heap region.
VAddr GetHeapRegionBaseAddress() const; VAddr GetHeapRegionBaseAddress() const;
@ -465,6 +468,9 @@ public:
/// Gets the total size of the heap region in bytes. /// Gets the total size of the heap region in bytes.
u64 GetHeapRegionSize() const; u64 GetHeapRegionSize() const;
/// Determines whether or not the specified range is within the heap region.
bool IsWithinHeapRegion(VAddr address, u64 size) const;
/// Gets the base address of the map region. /// Gets the base address of the map region.
VAddr GetMapRegionBaseAddress() const; VAddr GetMapRegionBaseAddress() const;
@ -474,6 +480,9 @@ public:
/// Gets the total size of the map region in bytes. /// Gets the total size of the map region in bytes.
u64 GetMapRegionSize() const; u64 GetMapRegionSize() const;
/// Determines whether or not the specified range is within the map region.
bool IsWithinMapRegion(VAddr address, u64 size) const;
/// Gets the base address of the new map region. /// Gets the base address of the new map region.
VAddr GetNewMapRegionBaseAddress() const; VAddr GetNewMapRegionBaseAddress() const;
@ -483,7 +492,7 @@ public:
/// Gets the total size of the new map region in bytes. /// Gets the total size of the new map region in bytes.
u64 GetNewMapRegionSize() const; u64 GetNewMapRegionSize() const;
/// Determines whether or not the given address range lies within the new map region /// Determines whether or not the given address range is within the new map region
bool IsWithinNewMapRegion(VAddr address, u64 size) const; bool IsWithinNewMapRegion(VAddr address, u64 size) const;
/// Gets the base address of the TLS IO region. /// Gets the base address of the TLS IO region.
@ -495,6 +504,9 @@ public:
/// Gets the total size of the TLS IO region in bytes. /// Gets the total size of the TLS IO region in bytes.
u64 GetTLSIORegionSize() const; u64 GetTLSIORegionSize() const;
/// Determines if the given address range is within the TLS IO region.
bool IsWithinTLSIORegion(VAddr address, u64 size) const;
/// Each VMManager has its own page table, which is set as the main one when the owning process /// Each VMManager has its own page table, which is set as the main one when the owning process
/// is scheduled. /// is scheduled.
Memory::PageTable page_table; Memory::PageTable page_table;