fix(libkernel): query current guest mapping extents #1731
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1731"
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 praveenkumarappu on 2026-10-08T17:49:20Z.
Superseded by #1929. That PR includes this PR's exact live-extent fix and regression with the original author preserved, plus the correction and regression for mapped non-readable ranges. Closing this PR so the shared change is reviewed and merged once through #1929.
What
After protecting or partially unmapping a flexible allocation,
sceKernelVirtualQuerystill uses the original allocation address and size. This can return an extent crossing a protection boundary or an unmapped hole, andFIND_NEXTcan select a surviving fragment by its former allocation address.Use each registered range’s current address and size for containment, ordering, and returned extents. For a three-page flexible mapping whose middle page becomes read-only, queries now return each current one-page range with its own protection. After the middle page is unmapped,
FIND_NEXTreturns the third page.This isolates range selection from a larger local experimental patch. No shader, memory-release, loader, or game configuration changes are included.
Tested
Windows x64, WinLibs MinGW-w64 GCC 15.2.0, Release/Ninja, rebased onto upstream main
f145139676a48306681d3a4d5fabf83938759daf, PR head1a301c48a74f879ac3136745056edd8b7bf04403:GuestMemory.cpptest executable passes with the fix, including the new regression.FIND_NEXTfrom the hole, and preservation of neighboring contents.python tools/check_conventions.py --base origin/mainandgit diff --checkpass.After rebasing, rebuilt libc/libkernel and reran the complete Windows
GuestMemory.cppexecutable, focused split-range regression, convention checks, andgit diff --check; all passed.Combined validation with dependent follow-up #1929: fork Build 37868880231 tested a tree containing this exact rebased PR tree plus #1929's non-readable mapping fix. Full builds and CTest passed on Linux (497/497) and Windows (488/488), with relinker CTests passing on Ubuntu, Windows, and macOS. Local Windows combined
guest_memory,guest_ampr_markers, and query-probe checks also passed. These combined results include #1929; they do not establish that this isolated PR passes the full suite without that follow-up.Ready for review. Upstream PR workflows require authorized maintainer approval; the fork Build above is separate evidence. Console behavior and gameplay using this isolated branch have not been tested.
Related work checked: #700 reports reservations, #686 handles released direct-memory bookkeeping, and #721 implements checked physical release. This change retains their current-main behavior and addresses existing flexible mapping fragments.
Checklist
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T01:15:42Z.
The overlap with #1929 is resolved as a stacked follow-up: #1929 now depends on this PR, includes your live-range commit, and removes its duplicate range-selection logic. I found the first live-range implementation fails Linux
guest_ampr_markersbecause the readable-only allocation lease omits mapped pages marked non-readable. The follow-up adds an all-range snapshot and a focused regression; locally,guest_memoryandguest_ampr_markerspass together. Full fork CI for the stacked head is running.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T01:29:05Z.
The stacked follow-up in #1929 passed its full fork Build on head
6db0682f0074a37b29a26a019b7a054c9a72f266: Linux CTest 497/497, Windows CTest 488/488, and relinker CTests on Ubuntu, Windows and macOS (run 37868880231). The PR remains explicitly dependent on #1731; the only unique addition is the all-range snapshot and its regression for mapped, non-readable pages.Imported from boykopovar/AnyPS5. Originally posted by praveenkumarappu on 2026-10-09T01:33:24Z.
Thanks @MarcZX100 for resolving the overlap and adding the non-readable range fix. I also tested the combined head
6db0682fon Windows:guest_memory,guest_ampr_markers, and the query probe passed, including split ranges, no-access pages, and unmapped holes. I checked the successful fork CI run as well.I've marked this PR ready for review. Please review it together with the dependent follow-up #1929.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T01:33:51Z.
Thanks for testing the combined head and making the PR ready for review. I reviewed your full diff together with dependent #1929; the combined code passes the full fork Build (Linux 497/497, Windows 488/488, all relinker jobs) and the focused tests. The remaining CONTRIBUTING item before approval is to update this branch to current upstream
main: PR #1731 still has base commit6b56175a, while upstream isf145139676a48306681d3a4d5fabf83938759daf. Please rebase and push the same change; I will recheck the updated head.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T01:38:55Z.
Review: APPROVED
Re-reviewed the rebased head
1a301c48against current upstreamf1451396. The full diff remains limited to live-range selection insceKernelVirtualQueryand its regression test. Conventions andgit diff --checkpass. Full Build 37868880231 passed on a tree containing this exact PR tree plus dependent #1929: Linux CTest 497/497, Windows CTest 488/488, and relinker CTests on Ubuntu, Windows, and macOS. The focused range tests and the AMPR protection regression pass. No blocking issue found.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T01:39:15Z.
I approved the rebased head. One description update remains useful: the Tested section still says Linux and full-project CTest were not run. The combined fork Build 37868880231 used a tree containing the exact #1731 tree plus #1929 and passed Linux 497/497, Windows 488/488, and relinker CTests. Please update the PR description with that evidence. Upstream currently reports no checks for this fork head; CONTRIBUTING says fork workflows may need authorized maintainer approval.
Imported from boykopovar/AnyPS5. Originally posted by praveenkumarappu on 2026-10-09T01:39:19Z.
Thanks @MarcZX100 for rechecking and approving the updated head. I've rebased onto upstream
main(f1451396) and pushed the same change as1a301c48. The Windowsguest_memoryexecutable, focused split-range regression, convention checks, andgit diff --checkpassed. Thanks for the dependent fix in #1929 as well.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T01:40:14Z.
I have now approved rebased head
1a301c48after verifying it is based on current main and that its exact tree is present in the green stacked Build. #1929 has been rebased onto this exact commit; its unique follow-up remains separate and depends on this PR.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T01:40:37Z.
I attempted to update the Tested section with the rebase and combined Build evidence, but GitHub returned 404 because I cannot edit another contributor’s PR description. The PR description remains unchanged; please update it to reflect the rebase and the full combined fork Build. My review approval is on head
1a301c48.Imported from boykopovar/AnyPS5. Originally posted by praveenkumarappu on 2026-10-09T01:45:57Z.
Thanks @MarcZX100, I've now updated the PR description's Tested section with the rebase to
f1451396, head1a301c48, and the combined fork Build evidence: Linux 497/497, Windows 488/488, and relinker tests on all three platforms. It also makes clear that the full-suite results include dependent #1929. Thanks for reviewing and approving the changes.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T05:07:23Z.
Could maintainers consider #1929 as the next follow-up after #1731? It is explicitly based on this PR's current head and adds the separate non-readable-mapping case with regression coverage. Keeping the changes stacked preserves the partial-unmap fix here and makes #1929 available as a focused follow-up.
The approval on #1929 predates its current head, so that head still needs review and any required CI before merge.
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-09T05:31:49Z.
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/tests/GuestMemory.cppL1064-1065Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T08:28:28Z.
Update after checking both live heads: #1929 is based on current upstream
main6cc0503dand includes the exact live-extent change from #1731 with its original commit author preserved. It also adds the all-range snapshot and regression for mappedPROT_NONEranges, which fixes theguest_ampr_markerscase that the readable-only lease misses. The focused tests pass (2/2).#1731 still targets
f1451396; #1929 is the better canonical PR because it contains the same live-extent fix plus the non-readable-range correction on currentmain. Its full Build is currently blocked on both Linux and Windows by the unrelated missing SPIRV-Headers include tracked in #2093; all relinker jobs pass. I recommend closing #1731 as superseded by #1929, rather than merging two PRs for the samesceKernelVirtualQuerychange.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T09:21:55Z.
Update: #1929 is now based on current upstream
main745b775e2d883c68560b2d87f4ab96a01e221ccf. It includes the live-extent change from this PR with the original commit author preserved, plus the distinct non-readable mapping fix and regression. The combined focused tests pass. #1929 is the canonical complete change; please close #1731 as superseded so the shared change merges once.Imported from boykopovar/AnyPS5. Originally posted by praveenkumarappu on 2026-10-09T14:22:52Z.
Thanks @MarcZX100. I compared our
1a301c48commit with the preservedff53c545commit in #1929: both changed-file patches match exactly, and the original author is preserved. #1929 also includes the non-readable mapping correction and regression. I've updated this PR's description and am closing #1731 as superseded by #1929 so the shared fix is reviewed and merged once.Pull request closed