fix(libkernel): query non-readable live mappings #1929
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1929"
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 MarcZX10 on 2026-10-09T00:19:18Z.
Closes #1894.
What
This PR carries the live-mapping extent fix from #1731 (the original commit author is preserved), adds support for querying live ranges whose registry protection is
PROT_NONE, and includes the direct-mmappartial-unmap regression test contributed in #2267. The test commit retains Saranxzi as its author.sceKernelVirtualQuerymust report current mapped extents after partial unmaps and still find non-readable mappings; GPU consumers continue using the existing readable-only lease.Without the full-range snapshot,
guest_ampr_markersfails when querying AMPR protection on a mapped range. The regression checks aPROT_NONEmapping and verifies the registered extent and protection. A debug assertion makes explicit that the full-range lease is address-ordered before the coalescing scan relies on that invariant.Tested
Current head
e06c459534fec70b5738d55392794fa963421024is rebased linearly onto upstreammainate51d4e1f21280da4529dc7fe3a3d50d7d7dbc3ec. The complete source diff remains limited to four files.guest_memory_tests;guest_memorypassed (1/1) on this head, exercising flexible-range splits,PROT_NONE, and directmmapafter partial unmap.guest_memorypassed and full CTest passed (510/510) on pre-rebase commit099b8cf0cherry-picked ontomaind70b8998(report); this predates the additional direct-mmaptest. Saranxzi separately reported the direct-mmapregression passing on Windows and Linux on #2267 head8073bda, not on this combined head.python3 tools/check_conventions.py --base upstream/mainandgit diff --check upstream/main...HEADpass.agc_shader_fusion_tests; #2099 fixed that dependency. Eligibility, Conventions, report, and all three relinker jobs pass on this head. The automated PR workflow skipped the full Linux and Windows Build jobs; an authorized collaborator must start Build for those under #2113.Checklist
main; overlap with #2267 is disclosed, and its direct-mmapregression test is included here with original author attribution; coordination with its author is pendingImported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T00:19:29Z.
The PR is based on current upstream
main(f145139676a48306681d3a4d5fabf83938759daf), and the focused Linuxguest_memorytest plus conventions pass locally. No upstream checks are reported for head493000d5787aff60a8fe6a892cb81da1e79c1e13. CONTRIBUTING says fork workflows markedaction_requiredneed maintainer approval; could an authorized maintainer approve Build and Conventions for this head?Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T00:34:50Z.
#1929 now stacks on the exact current #1731 commit
1a301c48a74f879ac3136745056edd8b7bf04403and contains the distinct follow-up for mapped, non-readable ranges. Fork Build 37868880231 passed on the identical source tree: Linux 497/497, Windows 488/488, and relinker CTests on Ubuntu, Windows and macOS. Exact-head Build 37870858453 is queued. Upstream still reports no checks; under CONTRIBUTING's fork workflow policy, could an authorized maintainer approve Build and Conventions for this head?Imported from boykopovar/AnyPS5. Originally posted by klosixgaming-arch on 2026-10-09T00:37:43Z.
Review: APPROVED
Good fix for a real bug: after a partial
munmap,sceKernelVirtualQuerywas reporting the full allocation range instead of the live sub-range. The new logic coalesces contiguous sub-ranges (sameallocationAddress, adjacent addresses) in both directions, so a query inside a fragmented allocation reports the correct live extent and a query in the unmapped hole returns EACCES. The testCheckVirtualQueryAfterPartialUnmapcovers the merged range, the hole, thefindNextflag, and the post-unmap state — exactly the regression this fixes.Minor: the bidirectional merge walks the lease and assumes it is ordered by address; if that invariant is ever relaxed, the coalescing would silently under-merge. An assert (or a one-line note) that the lease is address-ordered would make the assumption explicit.
Written with AI assistance.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T00:53:33Z.
The lease is address-ordered by construction: the registry stores ranges in
std::mapkeyed by address, and both lease functions append them in map iteration order. The updated all-range snapshot preserves the same ordering, so the adjacent-range merge walks stable address order.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T01:01:53Z.
@klosixgaming-arch #1929 now stacks on the exact current #1731 commit and its source tree is unchanged from the fully green fork Build 37868880231. Linux CTest 497/497, Windows CTest 488/488, and all relinker jobs passed. Exact-head Build 37870858453 is running; please re-review the current head after it completes.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T01:43:18Z.
The exact current heads are
#17311a301c48and this PR ee68f671. Upstream Actions created Build and Conventions runs for both fork heads, but all areaction_required; this token has pull-only access on boykopovar/AnyPS5, so I cannot approve those workflows. The same source tree was already validated in our fork Build (Linux CTest 497/497, Windows 488/488, relinker CTests on Ubuntu/Windows/macOS), and #1731 has been approved after full review. Could an authorized maintainer approve the upstream fork workflows? The exact-head runs are Build 37870860630 and Conventions 37870893265 for this PR; #1731 Build 37870628828 and Conventions 37870628839.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T08:07:40Z.
Updated head: rebased the #1731 shared patch plus this follow-up onto current upstream main
25f10087; pushed4ff734c0. On Linux x86_64/GCC 12.2 Release, rebuilt both focused test binaries;guest_memoryandguest_ampr_markerspass (2/2). Conventions and diff checks pass. Fork Build 37902960354 is running on this head.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T08:20:54Z.
Rebased the fully reviewed three-commit diff onto current upstream
main6cc0503dand pushed head8a222b65. The focused Linuxguest_memoryandguest_ampr_markerstests both pass (2/2); conventions andgit diff --checkpass. Fork Build 37904356054 is running on the exact new head. The updated PR description records the previous head’s unrelated missingSPIRV-Headersbuild dependency and points to #2093.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T08:28:21Z.
Build 37904356054 completed: Linux and Windows fail only while compiling
agc_shader_fusion_tests, withVulkanTestDevice.hppmissingspirv/unified1/spirv.hpp; the Ubuntu, Windows and macOS relinker jobs pass. I checked both job logs. This matches #2093’s missingSPIRV-Headerstarget dependency, and the PR description now records that result. The focused tests on this head pass.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T09:21:53Z.
Updated to current upstream
maind9484c71; the four-file diff is unchanged. The PR body now fillsDepends on: none, and exact-head Conventions passes. The focused Linux tests passed on the immediately preceding head, whose source diff is identical. The earlier full Build failed at the missing SPIRV-Headers include; #2099 is now in this base and fixes that dependency. Could an upstream collaborator run the full Build for current PR head103e97ffunder the #2113 policy?Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T09:25:24Z.
@klosixgaming-arch Your review observation about address ordering is now explicit in this head via the
std::is_sortedassertion; the lease is populated from the address-keyed registry map. The PR is rebased to currentmainand Conventions passes. Please re-review head103e97ffwhen convenient. The older full Build hit the header dependency fixed in #2099; an upstream collaborator can now run the manual full Build for this PR under #2113.Imported from boykopovar/AnyPS5. Originally posted by rmz-24 on 2026-10-09T12:26:06Z.
Windows run: Windows 11 Pro 25H2 (10.0.26200.9457), RTX 5060 Ti (NVIDIA 617.42), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release,
-DANYPS5_ENABLE_SPIRV_TOOLS=ON, full build pluslibs. 099b8cf0 cherry-picked onto currentmaind70b8998(applies cleanly).guest_memorypasses.AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T12:37:19Z.
Thanks for the Windows report. It tests the exact PR commit
099b8cf0cherry-picked onto current maind70b8998; the full Windows CTest (510/510) passes, so that closes the Windows validation gap for this source. The upstream PR head still has only Conventions; Linux and the relinker matrix are not yet recorded on this exact head. Could an authorized collaborator run Build and the reviewer recheck the updated address-order assertion?Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T19:08:44Z.
Rebased the existing PR linearly onto current
main(ae3d5f95) at head83983e3c. The full diff remains the same four files, including the address-order assertion requested in review. On this head, Linuxguest_memory_testsbuilds andguest_memorypasses (1/1); local and GitHub Conventions pass. The prior Windows report is preserved in the description and labeled as pre-rebase evidence.\n\nCould a collaborator with write access run the required upstream Build and relinker matrix on this current PR head under #2113?Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T19:55:10Z.
Updated head and validation
I rebased the existing branch linearly onto upstream
mainat8b393b6eand pushed head14d150b5. The complete diff remains the same four files, including the reviewer-requested lease-order assertion. On this head, Linuxguest_memory_testsbuilds andguest_memorypasses (1/1); local Conventions andgit diff --checkpass. The Windows 510/510 result remains labeled as pre-rebase evidence in the description.Could the reviewer recheck the assertion on this current head, and could a collaborator with write access run Actions → Build for PR #1929? The required upstream Linux/Windows and relinker matrix has not run for this head.
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-09T22:06:32Z.
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
main)core/libs/prx/libc/include/GuestAllocations.hppL38core/libs/prx/libc/src/GuestAllocations.cppL436core/libs/prx/libc/include/GuestAllocations.hppL38core/libs/prx/libc/src/GuestAllocations.cppL436core/libs/tests/GuestMemory.cppL1082-1084Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T22:08:06Z.
The overlap scan flagged #2267. I reviewed both diffs: the
sceKernelVirtualQuerybound change (allocationAddress/allocationBytesto live rangeaddress/bytes) is shared. This PR additionally acquires non-readable ranges and tests mprotect/unmap-split flexible mappings; #2267 contributes a directmmappartial-unmap regression. I posted a coordination note there; no dependency is implied, but please resolve the shared implementation and preserve the direct-mmap test contribution before merging.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T22:15:04Z.
I rebased the existing branch onto current
main(e51d4e1f) and carried over the direct-mmappartial-unmap regression from #2267 in commite06c4595, retaining Saranxzi as the commit author. The combinedguest_memorytest now covers flexible-range splits, non-readable mappings, and a directmmaphole/find-next query. Linux Release build and CTest pass (1/1); conventions and diff checks pass. The Windows results from the earlier heads remain labeled as such, and this exact combined head still needs the collaborator-only upstream Build/relinker matrix.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T22:35:29Z.
The latest overlap scan also flags #1324 and #1360 in
GuestAllocations.hpp/.cpp. I reviewed those diffs against this PR; the shared files hold separate APIs and behavior:GuestAllocationsAcquireAll_nid_postfixincludes non-readable live ranges sosceKernelVirtualQuerycan reportPROT_NONEmappings.GuestAllocationsAcquireRange_nid_no_patchand bounded mapping updates/history optimize AGC import lookup and cache validation. #1360 explicitly depends on #1324.I found no duplicate behavior or dependency between these changes. The additions can coexist; the overlap is at the header/implementation files and may need a small insertion-hunk resolution when branches are combined. The separate direct-
mmaptest from #2267 is already preserved here with Saranxzi's authorship.