diff options
| -rw-r--r-- | src/core/memory.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/core/memory.cpp b/src/core/memory.cpp index cc1ed16b6..ce62666d7 100644 --- a/src/core/memory.cpp +++ b/src/core/memory.cpp | |||
| @@ -118,6 +118,11 @@ boost::optional<T> ReadSpecial(VAddr addr); | |||
| 118 | 118 | ||
| 119 | template <typename T> | 119 | template <typename T> |
| 120 | T Read(const VAddr vaddr) { | 120 | T Read(const VAddr vaddr) { |
| 121 | if ((vaddr >> PAGE_BITS) >= PAGE_TABLE_NUM_ENTRIES) { | ||
| 122 | LOG_ERROR(HW_Memory, "Read%lu after page table @ 0x%016" PRIX64, sizeof(T) * 8, vaddr); | ||
| 123 | return 0; | ||
| 124 | } | ||
| 125 | |||
| 121 | const PageType type = current_page_table->attributes[vaddr >> PAGE_BITS]; | 126 | const PageType type = current_page_table->attributes[vaddr >> PAGE_BITS]; |
| 122 | switch (type) { | 127 | switch (type) { |
| 123 | case PageType::Unmapped: | 128 | case PageType::Unmapped: |
| @@ -146,6 +151,12 @@ bool WriteSpecial(VAddr addr, const T data); | |||
| 146 | 151 | ||
| 147 | template <typename T> | 152 | template <typename T> |
| 148 | void Write(const VAddr vaddr, const T data) { | 153 | void Write(const VAddr vaddr, const T data) { |
| 154 | if ((vaddr >> PAGE_BITS) >= PAGE_TABLE_NUM_ENTRIES) { | ||
| 155 | LOG_ERROR(HW_Memory, "Write%lu after page table 0x%08X @ 0x%016" PRIX64, sizeof(data) * 8, | ||
| 156 | (u32)data, vaddr); | ||
| 157 | return; | ||
| 158 | } | ||
| 159 | |||
| 149 | const PageType type = current_page_table->attributes[vaddr >> PAGE_BITS]; | 160 | const PageType type = current_page_table->attributes[vaddr >> PAGE_BITS]; |
| 150 | switch (type) { | 161 | switch (type) { |
| 151 | case PageType::Unmapped: | 162 | case PageType::Unmapped: |