fix(libkernel): model direct-memory initialization #24063
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/24063"
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 malekaifa on 2026-11-20T03:44:00Z.
What
Model the firmware 13.60 direct-memory initialization state while matching title startup:
sceKernelAvailableDirectMemorySizestill reportsEBADFbefore direct memory is initialized, but libkernel now callsDirectMemoryTouch()duringProgramNameRegistration, before libc program-name registration and before guest module entry. Titles therefore enter guest code with direct memory initialized, matching the console startup path noted by @oneandonlydean.The availability query itself still does not initialize the state. Invalid non-power-of-two alignment remains
EINVALbefore the initialization check, and the existing largest-free-range/output behavior is retained after initialization.The overlap scan reports #18112 and #18190 because they mirror the same NIDs through
libkernel_webandlibkernel_sys; neither implements thislibkernelbehavior.Tested
Machine
main, Windows 11, MinGW-w64 GCC 16.2.0, Release,BUILD_TESTING=ON, exact head3ac4d05336c9:guest_direct_memory_initialization_tests,guest_direct_memory_for_app_tests, andMemoryPoolTest.guest_direct_memory_initialization: 5/5 passed; the first valid availability query succeeds without a prior guest direct-memory API call.guest_direct_memory_for_app: 5/5 passed.MemoryPoolTest: 5/5 passed.EINVALand preserves output values.tools/check_conventions.py: passed.tools/debt_fold.py --check: passed.git diff --check: passed.Independent Linux validation on the earlier source head also built and passed the direct-memory tests and negative control; the final follow-up changes only startup initialization and the matching initialization test.
Checklist
main; no other open PR implements this behavior (#18112 and #18190 mirror the NIDs through other modules only)Imported from boykopovar/AnyPS5. Originally posted by copilot-pull-request-reviewer[bot] on 2026-11-20T03:44:09Z.
Review: COMMENTED
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-20T03:46:02Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
b36322c46c:tools/check_conventions.pypassed.guest_direct_memory_for_app_tests,guest_direct_memory_initialization_testsbuilt cleanly.guest_direct_memory_for_app,guest_direct_memory_initialization):core/libs/prx/libkernel/DirectMemory/DirectMemory.cpp,core/libs/prx/libkernel/DirectMemory/DirectMemory.hpp,core/libs/prx/libkernel/DirectMemory/Export.cpp,core/libs/prx/libkernel/DirectMemory/MemoryPool.cppreverted tomainand the new tests kept, the suite fails: Restoring the change makes it pass again.Looks Good To Me
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T05:19:21Z.
Review: APPROVED
Reviewed — looks good
The change models the reported pre-initialization error and retains the existing availability search after direct memory is touched; I found no verified blocking defect in the changed code.
What I ran
Reviewed head
b36322c46c314fec9a6af008ec5362c3f8894f4b. I read the prepared description, commit list, manifest, diff, and all eight changed files listed in the manifest. I also read the availability-query caller, test call sites, and direct-memory initialization code throughrepo_read.py. No commands or tests were run in this review.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
I did not run the test suite, reproduce the firmware probe, or independently verify the author-reported Windows and Linux results. The changed files were all included and read; no changed file was excluded by the manifest.
To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-22T13:11:47Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the optional documentation point below can be addressed separately.
What I ran
Reviewed head
37442eeaf1e51b093d6fcbdf2ae4d77141246b6eusingrepo_read.pythrough the supplied reader. No build or tests were run in this review; the description reports Windows and Linux test runs.Results
Findings
Blocking
None.
Non-blocking
docs/dev/debt/libkernel.mdentry forsceKernelAvailableDirectMemorySizestill says the call “always searches the pool.” The new behavior changes that before initialization. Consider updating the existing entry so it does not contradict the new debt note. Changed line:docs/dev/debt/changes/fix-libkernel-available-direct-memory-size-ebadf.md:7.Not verified
No checks were executed. The broader
guest_memorysuite and console behavior were not verified in this review. The author reports that the broader suite was not tested. Read all nine changed files listed as reviewed inmanifest.json; no changed files were excluded byfiles.json.To get this to a good state
Nothing is required. Optionally update the existing
sceKernelAvailableDirectMemorySizedescription indocs/dev/debt/libkernel.mdto reflect the initialization behavior.Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-23T01:07:53Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
3ac4d05336:tools/check_conventions.pypassed.MemoryPoolTest,guest_direct_memory_for_app_tests,guest_direct_memory_initialization_testsbuilt cleanly.MemoryPoolTest,guest_direct_memory_for_app,guest_direct_memory_initialization):core/libs/prx/libkernel/DirectMemory/DirectMemory.cpp,core/libs/prx/libkernel/DirectMemory/DirectMemory.hpp,core/libs/prx/libkernel/DirectMemory/Export.cpp,core/libs/prx/libkernel/DirectMemory/MemoryPool.cpp,core/libs/prx/libkernel/System/src/Process.cppreverted tomainand the new tests kept, the suite fails: Restoring the change makes it pass again.Looks Good To Me
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-23T01:20:06Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the reviewed code supports the described startup initialization and query behavior.
What I ran
Reviewed head
3ac4d05336c92e269db715ac8bce16b07e51873d. No commands or tests were run. The author reports Windows 11/MinGW test and convention checks indescription.md; these were not independently run.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
No test suite, build, or convention checks were run. The reported console behavior and author-reported Windows and Linux results were not independently confirmed.
files.jsonwas not available to read; manifest lists nine changed files, all marked included, and each was read. No files were excluded according to the supplied manifest.To get this to a good state
Nothing is required.
Pull request closed