Memory: Align size and address in posix_munmap (#3418)

* Properly align address and size in munmap

Based on observations of FreeBSD source code, fixes a Windows-related memory issue in War Thunder (CUSA00224)

* Format len and phys_addr in mmap

This should make logs slightly easier to understand, since we format these parameters in other memory calls.

* Update memory.cpp
This commit is contained in:
Stephen Miller
2025-08-15 04:21:59 -05:00
committed by GitHub
parent 51559033ef
commit 1c0a5c60ea
2 changed files with 6 additions and 3 deletions

View File

@@ -570,9 +570,10 @@ s32 PS4_SYSV_ABI sceKernelMemoryPoolBatch(const OrbisKernelMemoryPoolBatchEntry*
}
void* PS4_SYSV_ABI posix_mmap(void* addr, u64 len, s32 prot, s32 flags, s32 fd, s64 phys_addr) {
LOG_INFO(Kernel_Vmm,
"called addr = {}, len = {}, prot = {}, flags = {}, fd = {}, phys_addr = {}",
fmt::ptr(addr), len, prot, flags, fd, phys_addr);
LOG_INFO(
Kernel_Vmm,
"called addr = {}, len = {:#x}, prot = {:#x}, flags = {:#x}, fd = {}, phys_addr = {:#x}",
fmt::ptr(addr), len, prot, flags, fd, phys_addr);
void* addr_out;
auto* memory = Core::Memory::Instance();

View File

@@ -573,6 +573,8 @@ u64 MemoryManager::UnmapBytesFromEntry(VAddr virtual_addr, VirtualMemoryArea vma
s32 MemoryManager::UnmapMemoryImpl(VAddr virtual_addr, u64 size) {
u64 unmapped_bytes = 0;
virtual_addr = Common::AlignDown(virtual_addr, 16_KB);
size = Common::AlignUp(size, 16_KB);
do {
auto it = FindVMA(virtual_addr + unmapped_bytes);
auto& vma_base = it->second;