Repository navigation
fix(libkernel): report is_committed from sceKernelVirtualQuery only for direct memory, as a PS5 does - #22013
Conversation
PrivacyOnion
left a comment
There was a problem hiding this comment.
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against b56a3a67ac:
- Conventions:
tools/check_conventions.pypassed. - Build:
guest_memory_testsbuilt cleanly. - CTest (
guest_memory,guest_mmap_fixed_anonymous,guest_mmap_executable):1/3 Test #5420: guest_mmap_executable ............ Passed 0.04 sec 2/3 Test #5419: guest_mmap_fixed_anonymous ....... Passed 0.03 sec 3/3 Test #5418: guest_memory ..................... Passed 4.82 sec 100% tests passed, 0 tests failed out of 3 - Negative control: with
core/libs/prx/libkernel/DirectMemory/Export.cpp,core/libs/prx/libkernel/DirectMemory/PosixMemory.cppreverted tomainand the new tests kept, the suite fails:Restoring the change makes it pass again.1/3 Test #5420: guest_mmap_executable ............ Passed 0.03 sec 2/3 Test #5419: guest_mmap_fixed_anonymous ....... Passed 0.03 sec 3/3 Test #5418: guest_memory .....................Subprocess aborted***Exception: 0.61 sec 67% tests passed, 1 tests failed out of 3 - Code reading:
- Verified in Export.cpp:QueryVirtualRange that info->is_committed is correctly set to 1u for direct memory mappings and 0u for flexible/host/other ranges, adhering to real PS5 firmware measurements.
- Verified in PosixMemory.cpp:mincore_nid_postfix that residency is determined by GuestReservation(pageCursor, &reservedStart, &reservedEnd), reporting resident (1) for mapped non-reserved pages and non-resident (0) for reservations.
- Verified GuestReservation usage and pointer arguments (&reservedStart, &reservedEnd) against DirectMemory.hpp declaration.
- Verified debt fragment docs/dev/debt/changes/fix-libkernel-virtual-query-committed-direct-only.md matches AGENTS.md conventions and documentation guidelines.
- Verified test cases in GuestMemory.cpp for wire layout flags, flexible memory query, stack address query, and mincore over direct+reserved ranges.
Looks Good To Me
|
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — looks good
Nothing blocks this change; the inspected code implements the reported direct-memory-only is_committed behavior and checks reservations directly in mincore.
What I ran
Reviewed head b56a3a67ac1125908dd341621250c28c23578a5d. No commands or tests were run in this review; repo_read.py was used to inspect the prepared diff and targeted source ranges. The description reports Linux checks, which were not run by me.
Results
| Check | Result | Note |
|---|---|---|
| Diff and targeted source review | passed | Four changed files inspected |
| Tests in this review | not run | Author-reported results only |
Findings
Blocking
None.
Non-blocking
None.
Not verified
The full text of all four changed files was read, as shown in manifest.json. The behavior of the PS5 payload, title process, pooled memory, Windows and macOS, and author-reported test results were not independently verified. Excluded files: none are listed in the prepared manifest; files.json was not available through the reader.
To get this to a good state
Nothing is required.
|
Windows run at b56a3a67ac, merged onto main 13be6afb21 as 67c91c1840. The merge passes the 12 memory and Existing runs: PrivacyOnion ran Results Tests:
The control uses main's
Mutations Line numbers are in the head files.
Survivors
Host
AI-assisted: yes |
…or direct memory, as a PS5 does sceKernelVirtualQuery set is_committed for every registered or host-queried range. A PS5 payload (firmware 13.590.001) reports it only for direct memory, and 0 for flexible memory whether touched or not, stacks, images and reservations. It is now set only for a direct mapping. mincore was the only reader of is_committed and used it to tell a mapping from a reservation, so it now asks GuestReservation directly and still reports every mapped page as resident and a reserved one as not. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
b56a3a6 to
8f161a0
Compare
|
@Helldiverr Added both probes as checks at
On Linux, M6 now fails |
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — looks good
Nothing blocks this change; the reviewed implementation and focused regression checks support the reported is_committed behavior.
What I ran
Read the prepared diff and relevant changed code at head 8f161a08b244649aff5725ca22a64dceb40be8c2, plus GuestReservation and its callers. No commands or tests were run; repo_read.py was unavailable as a runnable command in this interface.
Results
| Check | Result | Note |
|---|---|---|
| Source review | passed | Four changed files read |
| Tests | not run | Test results in the PR description are author reported |
| Full file coverage | passed | All files listed as reviewed were read |
Findings
Blocking
None.
Non-blocking
None.
Not verified
No tests were run independently. Windows and macOS behavior and console behavior were not verified. Read: core/libs/prx/libkernel/DirectMemory/Export.cpp, core/libs/prx/libkernel/DirectMemory/PosixMemory.cpp, core/libs/tests/GuestMemory.cpp, and docs/dev/debt/changes/fix-libkernel-virtual-query-committed-direct-only.md. The manifest lists all four as included; no changed files were excluded.
To get this to a good state
Nothing is required.
|
Windows run at 8f161a08b2. I cherry-picked the commit onto main 90c248ef7b without conflicts. Main 90c248e passes the same 12 memory and Both new checks fail as you describe on Windows too:
With One small note, not something that has to change: AI-assisted: yes |
What
sceKernelVirtualQuerysetis_committedfor every registered or host-queried range. A PS5 payload (firmware 13.590.001) reports it only for direct memory, and 0 for flexible memory whether touched or not, stacks, images and reservations (thesceKernelVirtualQuery size and flagsentry indocs/dev/debt/libkernel.md, which left it becausemincoreread the field).QueryVirtualRangesetsis_committedonly for a direct mapping; host-queried memory (stacks, the title's own heap) now reports 0 too.mincorewas the only reader: it usedis_committedto tell a mapping from a reservation. It now asksGuestReservationdirectly, so every mapped page is still resident and a reserved page is not.GuestMemory.cpp: flexible pages and a stack address reportis_committed0; the 72-byte wire layout's flag byte is0x01(flexible) for flexible memory;mincoreover a direct page followed by a reserved one gives1, 0, also after the direct page is set to protection 0, which still reportsis_committed; pages of the registered main image (a static global and a function) report neither committed, flexible nor direct. The existingmincorechecks on anonymousmmapmemory still expect 1.is_committedgap from the entry and notes that pooled memory was not measured.Tested
Linux (Debian 13, GCC 14.2.0, Release). Head
8f161a08b2, rebased ontomain11c9e7764ewithout conflicts. The runs after the first two bullets are from the earlier head onmainab5089590a.8f161a08b2, merged with fix(libkernel): answer sysarch XFPUSTATE's measured errors and empty copy, as a PS5 does #22046 and fix(libSceNpUniversalDataSystem): fail the event and property calls before Initialize, as the 13.42 module does #22049 ontomain11c9e7764e:ctest -R '^(guest_sysarch|guest_memory|guest_mmap_fixed_anonymous|guest_virtual_query_arguments|np_uds_events|guest_np_uds_.*|guest_np_trophy_.*)$': 16 passed, andguest_mmap_executableskipped itself (exit 77) in this environment. This head adds Helldiverr's two pins.is_committedfor anything not flexible failsguest_memoryat the new image check;mincoretreating protection 0 as not resident fails it at the new protection-0 check.ctest -R '^guest_memory$': passed.main'sExport.cppandPosixMemory.cppand this branch's test,guest_memoryfails at the first flexible-memoryis_committedcheck.ctest(5893 tests,-j 12) with this branch merged together with my other three branches of this batch: 5877 passed. The 16 failures are the set that fails onmainin the same environment: sixagc_drivercases (agc_driver_image_table_packed_guardspasses when run on its own) and ten that need a.gitdirectory, network or a passwd entry for the user.python3 tools/check_conventions.py --base origin/main: passed.python3 tools/pr_overlap.py --branchat8f161a08b2: no conflicting pull request. feat(libs): mirror libkernel exports through libkernel_sys #18190 and fix(libkernel): bound virtual range names as the console does #21569, which conflict withmain, shareExport.cpp,PosixMemory.cpporGuestMemory.cppand could not be compared; feat(libs): mirror libkernel exports through libkernel_sys #18190 only renamesmincore's export (a textual conflict, not a behaviour one), and fix(libkernel): bound virtual range names as the console does #21569 changes neitheris_committednormincore.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)