diff options
| author | 2019-03-04 16:40:17 -0500 | |
|---|---|---|
| committer | 2019-03-04 17:08:55 -0500 | |
| commit | 6c42a23550de8d6181562e969a142004f91c7daf (patch) | |
| tree | 54bb08184bd0645dc30dc1a11a51785bf86a2af5 /src | |
| parent | svc: Migrate address range checking functions to VMManager (diff) | |
| download | yuzu-6c42a23550de8d6181562e969a142004f91c7daf.tar.gz yuzu-6c42a23550de8d6181562e969a142004f91c7daf.tar.xz yuzu-6c42a23550de8d6181562e969a142004f91c7daf.zip | |
vm_manager: Provide address range checking functions for other memory regions
Makes the interface uniform when it comes to checking various memory
regions.
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/hle/kernel/vm_manager.cpp | 19 | ||||
| -rw-r--r-- | src/core/hle/kernel/vm_manager.h | 20 |
2 files changed, 35 insertions, 4 deletions
diff --git a/src/core/hle/kernel/vm_manager.cpp b/src/core/hle/kernel/vm_manager.cpp index 56f3d1f79..e81856bdc 100644 --- a/src/core/hle/kernel/vm_manager.cpp +++ b/src/core/hle/kernel/vm_manager.cpp | |||
| @@ -763,6 +763,11 @@ u64 VMManager::GetCodeRegionSize() const { | |||
| 763 | return code_region_end - code_region_base; | 763 | return code_region_end - code_region_base; |
| 764 | } | 764 | } |
| 765 | 765 | ||
| 766 | bool VMManager::IsWithinCodeRegion(VAddr address, u64 size) const { | ||
| 767 | return IsInsideAddressRange(address, size, GetCodeRegionBaseAddress(), | ||
| 768 | GetCodeRegionEndAddress()); | ||
| 769 | } | ||
| 770 | |||
| 766 | VAddr VMManager::GetHeapRegionBaseAddress() const { | 771 | VAddr VMManager::GetHeapRegionBaseAddress() const { |
| 767 | return heap_region_base; | 772 | return heap_region_base; |
| 768 | } | 773 | } |
| @@ -775,6 +780,11 @@ u64 VMManager::GetHeapRegionSize() const { | |||
| 775 | return heap_region_end - heap_region_base; | 780 | return heap_region_end - heap_region_base; |
| 776 | } | 781 | } |
| 777 | 782 | ||
| 783 | bool VMManager::IsWithinHeapRegion(VAddr address, u64 size) const { | ||
| 784 | return IsInsideAddressRange(address, size, GetHeapRegionBaseAddress(), | ||
| 785 | GetHeapRegionEndAddress()); | ||
| 786 | } | ||
| 787 | |||
| 778 | VAddr VMManager::GetMapRegionBaseAddress() const { | 788 | VAddr VMManager::GetMapRegionBaseAddress() const { |
| 779 | return map_region_base; | 789 | return map_region_base; |
| 780 | } | 790 | } |
| @@ -787,6 +797,10 @@ u64 VMManager::GetMapRegionSize() const { | |||
| 787 | return map_region_end - map_region_base; | 797 | return map_region_end - map_region_base; |
| 788 | } | 798 | } |
| 789 | 799 | ||
| 800 | bool VMManager::IsWithinMapRegion(VAddr address, u64 size) const { | ||
| 801 | return IsInsideAddressRange(address, size, GetMapRegionBaseAddress(), GetMapRegionEndAddress()); | ||
| 802 | } | ||
| 803 | |||
| 790 | VAddr VMManager::GetNewMapRegionBaseAddress() const { | 804 | VAddr VMManager::GetNewMapRegionBaseAddress() const { |
| 791 | return new_map_region_base; | 805 | return new_map_region_base; |
| 792 | } | 806 | } |
| @@ -816,4 +830,9 @@ u64 VMManager::GetTLSIORegionSize() const { | |||
| 816 | return tls_io_region_end - tls_io_region_base; | 830 | return tls_io_region_end - tls_io_region_base; |
| 817 | } | 831 | } |
| 818 | 832 | ||
| 833 | bool VMManager::IsWithinTLSIORegion(VAddr address, u64 size) const { | ||
| 834 | return IsInsideAddressRange(address, size, GetTLSIORegionBaseAddress(), | ||
| 835 | GetTLSIORegionEndAddress()); | ||
| 836 | } | ||
| 837 | |||
| 819 | } // namespace Kernel | 838 | } // namespace Kernel |
diff --git a/src/core/hle/kernel/vm_manager.h b/src/core/hle/kernel/vm_manager.h index 60f36a5b9..88e0b3c02 100644 --- a/src/core/hle/kernel/vm_manager.h +++ b/src/core/hle/kernel/vm_manager.h | |||
| @@ -441,12 +441,12 @@ public: | |||
| 441 | /// Gets the end address of the ASLR region. | 441 | /// Gets the end address of the ASLR region. |
| 442 | VAddr GetASLRRegionEndAddress() const; | 442 | VAddr GetASLRRegionEndAddress() const; |
| 443 | 443 | ||
| 444 | /// Determines whether or not the specified address range is within the ASLR region. | ||
| 445 | bool IsWithinASLRRegion(VAddr address, u64 size) const; | ||
| 446 | |||
| 447 | /// Gets the size of the ASLR region | 444 | /// Gets the size of the ASLR region |
| 448 | u64 GetASLRRegionSize() const; | 445 | u64 GetASLRRegionSize() const; |
| 449 | 446 | ||
| 447 | /// Determines whether or not the specified address range is within the ASLR region. | ||
| 448 | bool IsWithinASLRRegion(VAddr address, u64 size) const; | ||
| 449 | |||
| 450 | /// Gets the base address of the code region. | 450 | /// Gets the base address of the code region. |
| 451 | VAddr GetCodeRegionBaseAddress() const; | 451 | VAddr GetCodeRegionBaseAddress() const; |
| 452 | 452 | ||
| @@ -456,6 +456,9 @@ public: | |||
| 456 | /// Gets the total size of the code region in bytes. | 456 | /// Gets the total size of the code region in bytes. |
| 457 | u64 GetCodeRegionSize() const; | 457 | u64 GetCodeRegionSize() const; |
| 458 | 458 | ||
| 459 | /// Determines whether or not the specified range is within the code region. | ||
| 460 | bool IsWithinCodeRegion(VAddr address, u64 size) const; | ||
| 461 | |||
| 459 | /// Gets the base address of the heap region. | 462 | /// Gets the base address of the heap region. |
| 460 | VAddr GetHeapRegionBaseAddress() const; | 463 | VAddr GetHeapRegionBaseAddress() const; |
| 461 | 464 | ||
| @@ -465,6 +468,9 @@ public: | |||
| 465 | /// Gets the total size of the heap region in bytes. | 468 | /// Gets the total size of the heap region in bytes. |
| 466 | u64 GetHeapRegionSize() const; | 469 | u64 GetHeapRegionSize() const; |
| 467 | 470 | ||
| 471 | /// Determines whether or not the specified range is within the heap region. | ||
| 472 | bool IsWithinHeapRegion(VAddr address, u64 size) const; | ||
| 473 | |||
| 468 | /// Gets the base address of the map region. | 474 | /// Gets the base address of the map region. |
| 469 | VAddr GetMapRegionBaseAddress() const; | 475 | VAddr GetMapRegionBaseAddress() const; |
| 470 | 476 | ||
| @@ -474,6 +480,9 @@ public: | |||
| 474 | /// Gets the total size of the map region in bytes. | 480 | /// Gets the total size of the map region in bytes. |
| 475 | u64 GetMapRegionSize() const; | 481 | u64 GetMapRegionSize() const; |
| 476 | 482 | ||
| 483 | /// Determines whether or not the specified range is within the map region. | ||
| 484 | bool IsWithinMapRegion(VAddr address, u64 size) const; | ||
| 485 | |||
| 477 | /// Gets the base address of the new map region. | 486 | /// Gets the base address of the new map region. |
| 478 | VAddr GetNewMapRegionBaseAddress() const; | 487 | VAddr GetNewMapRegionBaseAddress() const; |
| 479 | 488 | ||
| @@ -483,7 +492,7 @@ public: | |||
| 483 | /// Gets the total size of the new map region in bytes. | 492 | /// Gets the total size of the new map region in bytes. |
| 484 | u64 GetNewMapRegionSize() const; | 493 | u64 GetNewMapRegionSize() const; |
| 485 | 494 | ||
| 486 | /// Determines whether or not the given address range lies within the new map region | 495 | /// Determines whether or not the given address range is within the new map region |
| 487 | bool IsWithinNewMapRegion(VAddr address, u64 size) const; | 496 | bool IsWithinNewMapRegion(VAddr address, u64 size) const; |
| 488 | 497 | ||
| 489 | /// Gets the base address of the TLS IO region. | 498 | /// Gets the base address of the TLS IO region. |
| @@ -495,6 +504,9 @@ public: | |||
| 495 | /// Gets the total size of the TLS IO region in bytes. | 504 | /// Gets the total size of the TLS IO region in bytes. |
| 496 | u64 GetTLSIORegionSize() const; | 505 | u64 GetTLSIORegionSize() const; |
| 497 | 506 | ||
| 507 | /// Determines if the given address range is within the TLS IO region. | ||
| 508 | bool IsWithinTLSIORegion(VAddr address, u64 size) const; | ||
| 509 | |||
| 498 | /// Each VMManager has its own page table, which is set as the main one when the owning process | 510 | /// Each VMManager has its own page table, which is set as the main one when the owning process |
| 499 | /// is scheduled. | 511 | /// is scheduled. |
| 500 | Memory::PageTable page_table; | 512 | Memory::PageTable page_table; |