diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/arm/nce/patch.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/core/arm/nce/patch.cpp b/src/core/arm/nce/patch.cpp index bc4b73634..30c3c6cdd 100644 --- a/src/core/arm/nce/patch.cpp +++ b/src/core/arm/nce/patch.cpp | |||
| @@ -20,6 +20,7 @@ using namespace oaknut::util; | |||
| 20 | using NativeExecutionParameters = Kernel::KThread::NativeExecutionParameters; | 20 | using NativeExecutionParameters = Kernel::KThread::NativeExecutionParameters; |
| 21 | 21 | ||
| 22 | constexpr size_t MaxRelativeBranch = 128_MiB; | 22 | constexpr size_t MaxRelativeBranch = 128_MiB; |
| 23 | constexpr u32 ModuleCodeIndex = 0x24 / sizeof(u32); | ||
| 23 | 24 | ||
| 24 | Patcher::Patcher() : c(m_patch_instructions) {} | 25 | Patcher::Patcher() : c(m_patch_instructions) {} |
| 25 | 26 | ||
| @@ -42,7 +43,7 @@ void Patcher::PatchText(const Kernel::PhysicalMemory& program_image, | |||
| 42 | std::span<const u32>{reinterpret_cast<const u32*>(text.data()), text.size() / sizeof(u32)}; | 43 | std::span<const u32>{reinterpret_cast<const u32*>(text.data()), text.size() / sizeof(u32)}; |
| 43 | 44 | ||
| 44 | // Loop through instructions, patching as needed. | 45 | // Loop through instructions, patching as needed. |
| 45 | for (u32 i = 0; i < static_cast<u32>(text_words.size()); i++) { | 46 | for (u32 i = ModuleCodeIndex; i < static_cast<u32>(text_words.size()); i++) { |
| 46 | const u32 inst = text_words[i]; | 47 | const u32 inst = text_words[i]; |
| 47 | 48 | ||
| 48 | const auto AddRelocations = [&] { | 49 | const auto AddRelocations = [&] { |
| @@ -161,8 +162,8 @@ void Patcher::RelocateAndCopy(Common::ProcessAddress load_base, | |||
| 161 | } | 162 | } |
| 162 | 163 | ||
| 163 | // Cortex-A57 seems to treat all exclusives as ordered, but newer processors do not. | 164 | // Cortex-A57 seems to treat all exclusives as ordered, but newer processors do not. |
| 164 | // Convert to ordered to preserve this assumption | 165 | // Convert to ordered to preserve this assumption. |
| 165 | for (u32 i = 0; i < static_cast<u32>(text_words.size()); i++) { | 166 | for (u32 i = ModuleCodeIndex; i < static_cast<u32>(text_words.size()); i++) { |
| 166 | const u32 inst = text_words[i]; | 167 | const u32 inst = text_words[i]; |
| 167 | if (auto exclusive = Exclusive{inst}; exclusive.Verify()) { | 168 | if (auto exclusive = Exclusive{inst}; exclusive.Verify()) { |
| 168 | text_words[i] = exclusive.AsOrdered(); | 169 | text_words[i] = exclusive.AsOrdered(); |