sceKernelVirtualQuery reports the whole mapping after a partial munmap #1894
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by hikazey on 2026-10-08T22:54:59Z.
What
After
munmapof part of a mapping,sceKernelVirtualQuerykeeps answering for the whole original mapping: an address in the unmapped part returns success, and the extent it reports for the pages that are left still spans the hole. The host has unmapped the page (Windows reports itMEM_RESERVE, and Linux's/proc/self/mapsno longer lists it). Only once the last piece is unmapped does the query fail.Repro
With the guest's
mmap/munmap(PrivateAnonymous0x1002, 16 KiB pages):Output of a probe test, Windows 11 (MinGW GCC 15.2.0, Release) on
maind64134f0(DirectMemory/andGuestAllocationsunchanged onf1451396). The part after|is the host's own view of the address:Linux (Ubuntu 24.04 container, GCC 14.2, Release), same
main, same results:FreeBSD splits the map entry on a partial
munmap, so I'd expect the unmapped page to beEACCES(0x8002000D, as the last line returns), the next mapping (page 2) withSCE_KERNEL_VQ_FIND_NEXT, and page 0 and page 2 each to be reported as their own extent. That's from FreeBSD's behaviour, not measured on a console.Where
sceKernelVirtualQuerymatches and reports each registry range byallocationAddress/allocationBytes. After a partial unmap,UnmapRegisteredleaves the surviving pieces with their ownaddress/bytesbut the originalallocationAddress/allocationBytes, so any surviving piece matches the whole allocation. The comment above it says titles need the whole allocation rather than a page, so a fix probably has to match on the live pieces while keeping that whole-allocation answer for allocations nothing was unmapped from.sceKernelQueryMemoryProtectiongoes through the same query. I ran into this while writingmsync(#1857), which uses the query to find unmapped pages; its TechnicalDebt line records the limitation.AI-assisted: yes (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T04:50:36Z.
I opened #2002 with a fix and a
guest_memoryregression covering partial unmap, the surviving extents, andSCE_KERNEL_VQ_FIND_NEXT. The Linux test and local conventions check pass. The PR is a draft because upstream Build and Conventions workflows are waiting on maintainer approval (action_required); Windows CI has not run yet.