citra-emu
/
citra-canary
Archived
1
0
Fork 0

ldr_ro: Use ranged instruction cache invalidation

This commit is contained in:
MerryMage 2017-09-11 13:00:14 +01:00
parent 647e553f64
commit a9af4be363
2 changed files with 7 additions and 4 deletions

View File

@ -5,6 +5,8 @@
#include "common/alignment.h" #include "common/alignment.h"
#include "common/logging/log.h" #include "common/logging/log.h"
#include "common/scope_exit.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" #include "core/hle/service/ldr_ro/cro_helper.h"
namespace Service { namespace Service {
@ -61,9 +63,11 @@ ResultCode CROHelper::ApplyRelocation(VAddr target_address, RelocationType reloc
case RelocationType::AbsoluteAddress: case RelocationType::AbsoluteAddress:
case RelocationType::AbsoluteAddress2: case RelocationType::AbsoluteAddress2:
Memory::Write32(target_address, symbol_address + addend); Memory::Write32(target_address, symbol_address + addend);
Core::CPU().InvalidateCacheRange(target_address, sizeof(u32));
break; break;
case RelocationType::RelativeAddress: case RelocationType::RelativeAddress:
Memory::Write32(target_address, symbol_address + addend - target_future_address); Memory::Write32(target_address, symbol_address + addend - target_future_address);
Core::CPU().InvalidateCacheRange(target_address, sizeof(u32));
break; break;
case RelocationType::ThumbBranch: case RelocationType::ThumbBranch:
case RelocationType::ArmBranch: case RelocationType::ArmBranch:
@ -86,6 +90,7 @@ ResultCode CROHelper::ClearRelocation(VAddr target_address, RelocationType reloc
case RelocationType::AbsoluteAddress2: case RelocationType::AbsoluteAddress2:
case RelocationType::RelativeAddress: case RelocationType::RelativeAddress:
Memory::Write32(target_address, 0); Memory::Write32(target_address, 0);
Core::CPU().InvalidateCacheRange(target_address, sizeof(u32));
break; break;
case RelocationType::ThumbBranch: case RelocationType::ThumbBranch:
case RelocationType::ArmBranch: case RelocationType::ArmBranch:

View File

@ -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(), LOG_INFO(Service_LDR, "CRO \"%s\" loaded at 0x%08X, fixed_end=0x%08X", cro.ModuleName().data(),
cro_address, cro_address + fix_size); cro_address, cro_address + fix_size);
@ -535,7 +535,7 @@ static void UnloadCRO(Interface* self) {
memory_synchronizer.RemoveMemoryBlock(cro_address, cro_buffer_ptr); memory_synchronizer.RemoveMemoryBlock(cro_address, cro_buffer_ptr);
} }
Core::CPU().ClearInstructionCache(); Core::CPU().InvalidateCacheRange(cro_address, fixed_size);
rb.Push(result); rb.Push(result);
} }
@ -588,7 +588,6 @@ static void LinkCRO(Interface* self) {
} }
memory_synchronizer.SynchronizeOriginalMemory(); memory_synchronizer.SynchronizeOriginalMemory();
Core::CPU().ClearInstructionCache();
rb.Push(result); rb.Push(result);
} }
@ -641,7 +640,6 @@ static void UnlinkCRO(Interface* self) {
} }
memory_synchronizer.SynchronizeOriginalMemory(); memory_synchronizer.SynchronizeOriginalMemory();
Core::CPU().ClearInstructionCache();
rb.Push(result); rb.Push(result);
} }