fix(libkernel): report a reservation that find-next lands on as a reservation #27588
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/27588"
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 brajankw on 2026-11-26T18:49:47Z.
What
Problem: a find-next
sceKernelVirtualQuery(flags bit 0) that lands on a virtual reservation reports it as committed flexible memory, while a direct query of the reservation's start reports it as a reservation (not committed, not flexible).Cause:
QueryVirtualRangechecksGuestReservationonly for the queried address. When find-next skips forward, the allocation registry returns the next allocation, and a reservation is registered there like any allocation, so the reply was built from the registry record.Fix: when find-next returns an allocation above the queried address that
GuestReservationreports as reserved, the reply is the reserved range, the same answer a direct query of that address gives. The reply is built the same way for every reservation, so this changes the find-next answer for every title, not only for one memory window. A mapping registered inside a reservation is still reported from its own record.guest_memorygainsCheckVirtualQueryFindsNextReservation: find-next from a free page below a user reservation must return exactly what a direct query of the address it lands on returns, for an untouched reservation, for one whose first half carries a flexible map, and for the reserved half left after that map is unmapped.tools/pr_overlap.py --branchfound no PR with the same lines or exports; it could not compare #21569 (range-name bounds), which edits other functions in the same two files.Tested
x86_64-ucrt-posix-sehr7), Release,-DBUILD_TESTING=ON:ctest --test-dir build -j6 --output-on-failure -R "^(guest_memory|guest_mmap_.*|guest_virtual_query_arguments|guest_amm_placement|guest_amm_pool|guest_ampr_markers|MemoryPoolTest)$": 8/8 passed.-DBUILD_TESTING=ON: the same command: 8/8 passed.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
Summary by CodeRabbit
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-26T19:35:25Z.
Review: APPROVED
Reviewed — looks good
The changed implementation and test additions are complete and support merging at head
ca688dabfa93a7fc4f3d88b78f809abca4f6cdeb; no checks were run in this review.What I ran
Read the prepared diff and all changed lines, plus the relevant
GuestReservationimplementation. No build or tests were run.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
No commands, build, or tests were run during this review. Title behavior was not tested. The author reports 8/8 listed tests on Windows and Linux; those results were not independently verified. Both changed files listed in the manifest were read;
files.jsonwas not present in the review bundle.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by Plyxen on 2026-11-27T03:11:20Z.
Review: APPROVED
Checked head
ca688dabfa. I applied it tomainad7582bad4together with #27587 and #27585, which touch different files. On Windows 11 with WinLibs GCC 15.2 (Release),tools/check_conventions.py --headon each head andtools/debt_fold.py --checkpassed, the build succeeded, and all 4,930 CPU tests passed (I left out the GPU tests).guest_memorypassed. Withmain'sDirectMemory/Export.cppand the new checks, it fails.When a find-next query lands on an allocation that starts inside a reservation, it now returns the reservation's range with the other fields zero. That is the answer a direct query at that address already gives, and the test pins the two as equal with
memcmp. A flexible mapping that starts the reservation is still returned as the mapping, and once it is unmapped, find-next lands on the remaining reserved fragment, as the test checks.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T14:12:30Z.
Review: COMMENTED
Built and ran
guest_memoryon Linux with this head integrated. It passed, including the find-next and direct-query comparison for untouched, partly mapped, and unmapped reservation ranges. The assertions cover the returned range and its committed and flexible status.AI-assisted: yes.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.