From 63bbe08631c4542008f8add31a80a03a5848bc28 Mon Sep 17 00:00:00 2001 From: Stephen Miller Date: Tue, 15 Jul 2025 05:10:55 -0500 Subject: [PATCH] Fix read-only file unmaps Fixes Genshin Impact (CUSA23681) --- src/core/memory.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/core/memory.cpp b/src/core/memory.cpp index 3d9bf58a7..ae809ddad 100644 --- a/src/core/memory.cpp +++ b/src/core/memory.cpp @@ -537,6 +537,7 @@ u64 MemoryManager::UnmapBytesFromEntry(VAddr virtual_addr, VirtualMemoryArea vma vma_base_size - start_in_vma < size ? vma_base_size - start_in_vma : size; const bool has_backing = type == VMAType::Direct || type == VMAType::File; const auto prot = vma_base.prot; + const bool readonly_file = prot == MemoryProt::CpuRead && type == VMAType::File; if (type == VMAType::Free) { return adjusted_size; @@ -555,8 +556,6 @@ u64 MemoryManager::UnmapBytesFromEntry(VAddr virtual_addr, VirtualMemoryArea vma vma.disallow_merge = false; vma.name = ""; const auto post_merge_it = MergeAdjacent(vma_map, new_it); - auto& post_merge_vma = post_merge_it->second; - bool readonly_file = post_merge_vma.prot == MemoryProt::CpuRead && type == VMAType::File; if (type != VMAType::Reserved && type != VMAType::PoolReserved) { // If this mapping has GPU access, unmap from GPU. if (IsValidGpuMapping(virtual_addr, size)) {