From a9af4be363aca2b0ff92e53de68ca02207a2802a Mon Sep 17 00:00:00 2001 From: MerryMage Date: Mon, 11 Sep 2017 13:00:14 +0100 Subject: [PATCH] ldr_ro: Use ranged instruction cache invalidation --- src/core/hle/service/ldr_ro/cro_helper.cpp | 5 +++++ src/core/hle/service/ldr_ro/ldr_ro.cpp | 6 ++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/core/hle/service/ldr_ro/cro_helper.cpp b/src/core/hle/service/ldr_ro/cro_helper.cpp index f78545f37..acecceeb7 100644 --- a/src/core/hle/service/ldr_ro/cro_helper.cpp +++ b/src/core/hle/service/ldr_ro/cro_helper.cpp @@ -5,6 +5,8 @@ #include "common/alignment.h" #include "common/logging/log.h" #include "common/scope_exit.h" +#include "core/arm/arm_interface.h" +#include "core/core.h" #include "core/hle/service/ldr_ro/cro_helper.h" namespace Service { @@ -61,9 +63,11 @@ ResultCode CROHelper::ApplyRelocation(VAddr target_address, RelocationType reloc case RelocationType::AbsoluteAddress: case RelocationType::AbsoluteAddress2: Memory::Write32(target_address, symbol_address + addend); + Core::CPU().InvalidateCacheRange(target_address, sizeof(u32)); break; case RelocationType::RelativeAddress: Memory::Write32(target_address, symbol_address + addend - target_future_address); + Core::CPU().InvalidateCacheRange(target_address, sizeof(u32)); break; case RelocationType::ThumbBranch: case RelocationType::ArmBranch: @@ -86,6 +90,7 @@ ResultCode CROHelper::ClearRelocation(VAddr target_address, RelocationType reloc case RelocationType::AbsoluteAddress2: case RelocationType::RelativeAddress: Memory::Write32(target_address, 0); + Core::CPU().InvalidateCacheRange(target_address, sizeof(u32)); break; case RelocationType::ThumbBranch: case RelocationType::ArmBranch: diff --git a/src/core/hle/service/ldr_ro/ldr_ro.cpp b/src/core/hle/service/ldr_ro/ldr_ro.cpp index 7255ea026..c500d69f1 100644 --- a/src/core/hle/service/ldr_ro/ldr_ro.cpp +++ b/src/core/hle/service/ldr_ro/ldr_ro.cpp @@ -439,7 +439,7 @@ static void LoadCRO(Interface* self, bool link_on_load_bug_fix) { } } - Core::CPU().ClearInstructionCache(); + Core::CPU().InvalidateCacheRange(cro_address, cro_size); LOG_INFO(Service_LDR, "CRO \"%s\" loaded at 0x%08X, fixed_end=0x%08X", cro.ModuleName().data(), cro_address, cro_address + fix_size); @@ -535,7 +535,7 @@ static void UnloadCRO(Interface* self) { memory_synchronizer.RemoveMemoryBlock(cro_address, cro_buffer_ptr); } - Core::CPU().ClearInstructionCache(); + Core::CPU().InvalidateCacheRange(cro_address, fixed_size); rb.Push(result); } @@ -588,7 +588,6 @@ static void LinkCRO(Interface* self) { } memory_synchronizer.SynchronizeOriginalMemory(); - Core::CPU().ClearInstructionCache(); rb.Push(result); } @@ -641,7 +640,6 @@ static void UnlinkCRO(Interface* self) { } memory_synchronizer.SynchronizeOriginalMemory(); - Core::CPU().ClearInstructionCache(); rb.Push(result); }