From ae833aa9c0c26865c2b7d091a09c19212e894018 Mon Sep 17 00:00:00 2001 From: Fernando Sahmkow Date: Wed, 7 Feb 2024 23:47:42 +0100 Subject: [PATCH] SMMU: Ensure the backing address range matches the current --- src/core/device_memory_manager.inc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/core/device_memory_manager.inc b/src/core/device_memory_manager.inc index b026f4220..6dfee806c 100644 --- a/src/core/device_memory_manager.inc +++ b/src/core/device_memory_manager.inc @@ -532,6 +532,7 @@ void DeviceMemoryManager::UpdatePagesCachedCount(DAddr addr, size_t size cache_bytes = 0; } }; + size_t old_vpage = (base_vaddress >> Memory::YUZU_PAGEBITS) - 1; for (; page != page_end; ++page) { CounterAtomicType& count = cached_pages->at(page >> subentries_shift).Count(page); auto [asid_2, vpage] = ExtractCPUBacking(page); @@ -547,6 +548,12 @@ void DeviceMemoryManager::UpdatePagesCachedCount(DAddr addr, size_t size memory_device_inter = registered_processes[asid_2.id]; } + if (vpage != old_vpage + 1) [[unlikely]] { + release_pending(); + } + + old_vpage = vpage; + // Adds or subtracts 1, as count is a unsigned 8-bit value count.fetch_add(static_cast(delta), std::memory_order_release);