From 6885f9a6d853972c6be299d2faf40447f8d9890f Mon Sep 17 00:00:00 2001 From: Merry Date: Sun, 24 Jul 2022 13:49:01 +0100 Subject: [PATCH] backend/arm64: Invalidation fixes --- .../backend/arm64/a32_address_space.cpp | 4 ++++ src/dynarmic/backend/arm64/a32_interface.cpp | 23 ++++++++++++++----- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/src/dynarmic/backend/arm64/a32_address_space.cpp b/src/dynarmic/backend/arm64/a32_address_space.cpp index dafb4f92..c0cf9d5b 100644 --- a/src/dynarmic/backend/arm64/a32_address_space.cpp +++ b/src/dynarmic/backend/arm64/a32_address_space.cpp @@ -113,6 +113,8 @@ void A32AddressSpace::EmitPrelude() { prelude_info.write_memory_64 = EmitCallTrampoline<&A32::UserCallbacks::MemoryWrite64>(code, conf.callbacks); prelude_info.end_of_prelude = code.ptr(); + + mem.invalidate_all(); } size_t A32AddressSpace::GetRemainingSize() { @@ -132,6 +134,8 @@ EmittedBlockInfo A32AddressSpace::Emit(IR::Block block) { }); Link(block_info); + mem.invalidate(reinterpret_cast(block_info.entry_point), block_info.size); + mem.protect(); return block_info; diff --git a/src/dynarmic/backend/arm64/a32_interface.cpp b/src/dynarmic/backend/arm64/a32_interface.cpp index 26844d58..74ed9cdc 100644 --- a/src/dynarmic/backend/arm64/a32_interface.cpp +++ b/src/dynarmic/backend/arm64/a32_interface.cpp @@ -56,6 +56,8 @@ struct Jit::Impl final { HaltReason Run() { ASSERT(!jit_interface->is_executing); + PerformRequestedCacheInvalidation(); + jit_interface->is_executing = true; SCOPE_EXIT { jit_interface->is_executing = false; @@ -63,13 +65,15 @@ struct Jit::Impl final { HaltReason hr = core.Run(current_address_space, current_state, &halt_reason); - RequestCacheInvalidation(); + PerformRequestedCacheInvalidation(); return hr; } HaltReason Step() { ASSERT(!jit_interface->is_executing); + PerformRequestedCacheInvalidation(); + jit_interface->is_executing = true; SCOPE_EXIT { jit_interface->is_executing = false; @@ -77,7 +81,7 @@ struct Jit::Impl final { ASSERT_FALSE("Unimplemented"); - RequestCacheInvalidation(); + PerformRequestedCacheInvalidation(); return HaltReason{}; } @@ -161,11 +165,18 @@ struct Jit::Impl final { } private: - void RequestCacheInvalidation() { - // ASSERT_FALSE("Unimplemented"); + void PerformRequestedCacheInvalidation() { + if (invalidate_entire_cache) { + current_address_space.ClearCache(); - invalidate_entire_cache = false; - invalid_cache_ranges.clear(); + invalidate_entire_cache = false; + invalid_cache_ranges.clear(); + return; + } + + if (!invalid_cache_ranges.empty()) { + ASSERT_FALSE("Unimplemented"); + } } Jit* jit_interface;