feat(libkernel): export the AMM mapper and command-buffer functions from libkernel too #18035
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/18035"
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 akkadbakkad89 on 2026-11-10T06:47:10Z.
What
Final Fantasy XVI (PPSA10665, 01.003.000) imports
sceKernelCallIndirectBuffer,sceKernelCallIndirectBuffer2,sceKernelGiveDirectMemoryToMapper,sceKernelMapperGetParam,sceKernelWaitCommandBufferCompletionand thesceKernelWrite*CommandGPU-mask writers (sceKernelWriteMapCommand2,sceKernelWriteMapDirectCommand,sceKernelWriteMapDirectWithGpuMaskIdCommand,sceKernelWriteMapWithGpuMaskIdCommand,sceKernelWriteMultiMapCommand,sceKernelWriteMultiMapWithGpuMaskIdCommand,sceKernelWriteRemapCommand,sceKernelWriteRemapWithGpuMaskIdCommand,sceKernelWriteModifyProtectCommand,sceKernelWriteModifyProtectWithGpuMaskIdCommand,sceKernelWriteModifyMtypeProtectWithGpuMaskIdCommand,sceKernelWriteUnmapCommand) under thelibkernellibrary, but onlylibkernel_sys.prxexported them, so the imports failed to resolve.The definitions move to
core/libs/prx/libkernel/SysExports.Mapper.cpp, compiled into bothlibkernel.prxandlibkernel_sys.prx. The AMM command-writer helpers shared withlibkernel_sys's remaining writers (sceKernelWriteMapCommand,sceKernelCallIndirectBuffer3, etc.) move intocore/libs/prx/libkernel/Apr/include/AmmExportCommands.hpp. The moved debt entries sit indocs/dev/debt/libkernel.md.Tested
Windows 11, MinGW build. Relinked Final Fantasy XVI
eboot.bin(unwrapped SELF) and rantools/import_audit.pyagainst the built libraries: before the change the audit reported 17library_mismatchentries (libkernel.prxnamed,libkernel_sys.prxproviding); after rebuilding and NID-patching both libraries it reports 0 mismatches, 0 absent, 0 stubs. Verified the patched PE export tables directly: all 17 NIDs are exported bylibkernel.prx(2090 names) and still exported bylibkernel_sys.prx(1111 names);sceKernelMapperGetParamfills the full 0x38-byte param block (7 qwords) matching main's updated body.ctestfocused set: 55/57 kernel_sys/kernel_process_exports pass, 2 skipped on their configured condition.check_conventions.py --base origin/mainpasses;pr_overlap.pyreports no overlap.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)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T14:22:46Z.
Review: COMMENTED
Reviewed — comments
Nothing blocks the export move, but the review found a test gap and a documented edge case that can produce an invalid AMM range.
What I ran
Reviewed head
ec3d47c2fc9ce6e88674def90d146ea8005e4295againstmainusing the prepared diff andrepo_read.py. No build or test commands were run; the test results in the PR description are author-reported.Results
Findings
Blocking
None.
Non-blocking
core/libs/prx/libkernel/Apr/include/AmmExportCommands.hpp:33:address + size <= endcan accept a range whose addition wraps arounduint64_t, as the debt note itself describes. Since this helper guards PRT map/unmap command creation, check thataddress + sizedoes not overflow before comparing it withend.core/libs/tests/GuestKernelMapperExportParity.cpp:47: the added test verifies that each library resolves all listed exports, but does not verify that each library owns the exports. A test can therefore pass when one library resolves a symbol through the other library's dependencies, which would not catch a provider-attribution regression. Check the module's own export table for each NID.Not verified
No tests or build were run in this review. The PR description's reported results were not independently verified. Files listed as included in the manifest were available; the prepared review listing showed no excluded files. The changed implementation, declarations, build wiring, parity test, and debt documentation were read; unchanged callers and runtime behavior were not exhaustively checked.
To get this to a good state
Nothing is required. Optional: guard range addition against overflow and make the parity test verify exports owned by each library.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-22T05:32:20Z.
Review: COMMENTED
Reviewed — comments
The implementation is read, but several changed files and the reported checks were not independently verified.
What I ran
Reviewed head
bf7b49d659d1ac7beba53d0180500b6181b43988using the prepared diff and pinned reader. No build or tests were run. Readcore/libs/prx/libkernel/SysExports.Mapper.cpp,core/libs/prx/libkernel/Apr/include/AprCommandBuffer.hpp,core/libs/tests/GuestKernelMapperExportParity.cpp, and the first 50 lines ofcore/libs/prx/libkernel_sys/Export.Discovery.cpp; reviewed the prepared diff, description, commits, and manifest. Other changed file bodies were not read.Results
Negative control
Not run; no tests were executed.
Findings
Blocking
None verified in the code read.
Non-blocking
The change description reports build, import-audit, and focused test results, but those checks were not independently run. The debt notes also describe known differences from console behavior in command validation and encoding; those limitations are documented in
docs/dev/debt/libkernel.md:723-727.Sources
Not verified
The remaining changed files were not read:
core/libs/CMakeLists.txt,core/libs/prx/libkernel/CMakeLists.txt,core/libs/prx/libkernel/include/Api.hpp,core/libs/prx/libkernel_sys/CMakeLists.txt,core/libs/prx/libkernel_sys/include/Api.hpp, and both debt files in full. The implementation was not built or tested here; claimed Windows build, import audit, PE export inspection, ctest, convention check, and overlap check remain author-reported.To get this to a good state
Nothing is required. Optional: independently run the reported checks and complete review of the unread changed files before relying on approval.
Imported from boykopovar/AnyPS5. Originally posted by Superseabas on 2026-11-22T11:01:44Z.
Review: COMMENTED
Windows check of head
bf7b49d659with GCC 16, merged ontomain6c70b74203(f36af3e74d, clean merge).Setup: Windows 11 Home 10.0.26200, Ryzen 7 7700X, WinLibs GCC 16.2.0 (
x86_64-ucrt-posix-seh, r3), CMake 4.4.4, Ninja 1.13.2, Release full build, run from PowerShell..prxexport tables (exact names fromobjdump -p),main'slibkernel.prxexports 0 of the 17 functions andlibkernel_sys.prx17. With this PR both export all 17.^guest_(kernel_sys|kernel_mapper|apr|amm|kernel_process_exports|kernel_amm)):main84 of 84, and with this PR 86 of 86 in 3 of 3 runs. The two new ones areguest_kernel_mapper_export_parityand_patched.SysExports.Mapper.cpptaken out oflibkernel's sources,libkernel.prxexports none of the 17, and both parity tests fail. The other 84 still pass.GetProcAddress, which reads only that DLL's own export table, so here it does check that each library provides them itself. The dependency fallback applies todlsymon Linux.main6c70b74203,tools/check_conventions.py --base upstream/mainandtools/debt_fold.py --checkpass.Debt files, worth fixing. At this head
docs/dev/debt/libkernel_sys.mdstill carries entries for code the PR moves out oflibkernel_sys, next to their new copies inlibkernel.md:libkernel_sys/Export.Discovery.cpp. None of those functions is defined inlibkernel_sysany more; they're all inlibkernel/SysExports.Mapper.cpp. Only thesceKernelCallIndirectBuffer2andsceKernelWaitCommandBufferCompletionentries were removed.scePthreadMutexInitForInternalLibc, scePthreadMutexattrInitForInternalLibcentry twice. It's once onmain, so it looks like a merge artefact.CONTRIBUTING.mdnow asks for debt changes to go through a fragment indocs/dev/debt/changes/. Doing the move that way (remove thelibkernel_sysentries, add thelibkernelones) would also avoid both of these.AmmExportCommands.hpp:33'saddress + size <= end, which MarcZX10 noted can wrap, is the same linemainhas inlibkernel_sys/Export.Discovery.cpp:74, moved unchanged, so it isn't new here.Not run: Linux and macOS, and PPSA10665 itself (I don't have it).
AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-22T20:22:31Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the implementation and export parity are supported by the inspected source and existing focused tests.
What I ran
Reviewed head
13da2bfe9c968356d959b69fb61217c7b44ac787. No commands or tests were run in this review; the build and test results in the PR description are author-reported.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
The reported MinGW build, CTest results, import audit, PE export tables, conventions check, overlap check, and title behavior were not independently run or confirmed. The repository files listed in the manifest were all included;
files.jsonwas not available through the reader, so no additional exclusions were confirmed. I read the prepared description, commits, manifest and diff, plus the changed source and test files, related AMM implementation and existing tests, and the debt fragment and related debt entries.To get this to a good state
Nothing is required.