From 257a4fdd127791805e02f7db60b3672526c8e94c Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Wed, 27 Dec 2017 19:33:02 -0800 Subject: [PATCH] arm64jit: Reprotect fixed code after icache flush. --- Common/CodeBlock.h | 4 ++++ Core/MIPS/ARM64/Arm64Jit.cpp | 1 + 2 files changed, 5 insertions(+) diff --git a/Common/CodeBlock.h b/Common/CodeBlock.h index 03ae3f860..a0f5dd55f 100644 --- a/Common/CodeBlock.h +++ b/Common/CodeBlock.h @@ -68,6 +68,10 @@ public: // If not WX Exclusive, no need to call ProtectMemoryPages because we never change the protection from RWX. PoisonMemory(offset); ResetCodePtr(offset); + if (PlatformIsWXExclusive()) { + // Need to re-protect the part we didn't clear. + ProtectMemoryPages(region, offset, MEM_PROT_READ | MEM_PROT_EXEC); + } } // BeginWrite/EndWrite assume that we keep appending. diff --git a/Core/MIPS/ARM64/Arm64Jit.cpp b/Core/MIPS/ARM64/Arm64Jit.cpp index ae9b6b8f4..d656c0f95 100644 --- a/Core/MIPS/ARM64/Arm64Jit.cpp +++ b/Core/MIPS/ARM64/Arm64Jit.cpp @@ -129,6 +129,7 @@ void Arm64Jit::ClearCache() { ILOG("ARM64Jit: Clearing the cache!"); blocks.Clear(); ClearCodeSpace(jitStartOffset); + FlushIcacheSection(region + jitStartOffset, region + region_size - jitStartOffset); } void Arm64Jit::InvalidateCacheAt(u32 em_address, int length) {