feat(libSceAmpr): add From*OnCompletion measure helpers #12061
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/12061"
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-10-27T18:16:06Z.
What
Cross-checked KytyPS5 (
src/libs/, ~1,554 registered exports) against this tree's export table by resolving every NID against the full aerolib database. Almost every apparent gap was already covered under a different naming form, module grouping, or mangled C++ spelling. This PR takes the residue that is portable 1:1 — no Kyty code is copied; the convention already lives here and only needed three more exports.libSceAmpr — three missing measure helpers.
sceAmprMeasureCommandSizeWriteAddressFromTimeCounterOnCompletion,sceAmprMeasureCommandSizeWriteAddressFromCounterOnCompletionandsceAmprMeasureCommandSizeWriteAddressFromCounterPairOnCompletionare real firmware exports (aerolib) whoseCommandBufferWrite*siblings already exist. They mirror the_04_00measure convention exactly:ValidWriteAddressargument checks andsizeof(Apr::WriteAddressFromCounterCommand)= 0x18 on success,MeasureInvalidon failure — 0x18 becauseAppendCommandstampsheader.bytes = sizeof(command)and the kernel APR executor_reads that exact struct for these opcodes. (Kyty's flat 0x20 is a padded slot size; itsWriteCounterOnCompletionappends a 0x20 no-op, not a record.)GuestAmpr.cppgains focused assertions for all three: valid arguments return the record size, nullptr returnsMeasureInvalid, and the pair helper rejects an odd counter.Tested
Windows 11 (MinGW build, i7-10700):
ctest -R guest_ampr—guest_ampr_markers,guest_ampr_threads,guest_ampr_cpp_errorall pass (3/3). Conventions check clean.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-10-27T18:25:58Z.
Review: CHANGES_REQUESTED
I built the exact PR head on Linux (Release) and ran
guest_ampr_testsandguest_json_testsunderqemu-x86_64 -cpu Haswell; both exited 0.python3 tools/check_conventions.py --base refs/remotes/upstream/mainalso passes. Native execution is blocked on this host because its Xeon lacks the AVX2/BMI/LZCNT features the test runner requires.I found a concrete mismatch in the three new AMPR measurement helpers. The PR description says each returns
0x20, matching the Kyty reference, but all three implementations returnsizeof(Apr::WriteAddressFromCounterCommand). In this tree that structure is 24 bytes (CommandHeader8 + address 8 + two 32-bit counters), and I called each built export directly: valid inputs returned0x18, not0x20. The cited reference at pinned Kyty commit0685bffb2f060bf470aa8528a405ebbe17130076returns the constant0x20for all three functions:github.com/KytyPS5/KytyPS5@0685bffb2f/src/libs/libAmpr.cpp (L1652-L1670)Please resolve the size discrepancy before merge: either implement and test the reported
0x20result, or provide target-specific evidence that the unversioned helpers should return0x18and correct the PR's claim that the behavior matches Kyty. Please add focused assertions for these three new exports; the current AMPR tests cover the_04_00siblings but not these symbols. I have not approved this head.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-27T18:51:50Z.
Review: APPROVED
Follow-up review of exact head
6d7182b3f66b55e5935f58a010a41a421694462f; this resolves my prior measurement-helper concern. The body now distinguishes Kyty’s padded 0x20 slot from this tree’s 24-byte command record: the writer storessizeof(command)in the record header, the APR executor reads the sameWriteAddressFromCounterCommandlayout, and the existing_04_00measurement siblings return that layout size. The new assertions cover all three helpers plus null and odd-pair rejection. Console behavior is still unmeasured, so I am relying on this explicit in-tree contract rather than claiming a PS5 measurement.\n\nI builtguest_ampr_testsandguest_json_testsfrom this exact head and ran both underqemu-x86_64 -cpu Haswell; both exited 0. Exact-head conventions andgit diff --checkpass. Hosted Windows is still pending; native execution here cannot run on the host Xeon because of its missing AVX2/BMI/LZCNT features.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-27T19:00:53Z.
Review: CHANGES_REQUESTED
The Ampr portion has a coherent in-tree basis: the record is 0x18 bytes, the matching
_04_00helpers return that size, and the reported focused tests cover valid and invalid inputs. The Json2 portion cannot stay in this PR, though. Open #10378 already replaces the same C2/D2 stubs with C1/D1 forwarders and removes the corresponding debt entries. I fetched both exact heads and confirmed the pairwise merge conflicts inExport.cpp,InventoryExports.cpp, anddocs/dev/debt/libSceJson2.md; this also combines two unrelated topics. Please drop the Json2 changes and keep the Ampr helpers as the single topic, then rerun the required checks. I am changing my review because this overlap was identified after my earlier approval.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-27T20:45:47Z.
Review: CHANGES_REQUESTED
The AMPR implementation itself now has a clear in-tree contract and focused assertions, and the earlier unrelated Json2 overlap has been removed. One integration issue remains: open #11936 declares the same three exports as throwing placeholders. The exact branches merge textually, but combining them leaves duplicate/conflicting declarations and two definitions for each export; accepting both as-is is not safe. Please coordinate with #11936's author and record which PR supersedes the other, or an explicit landing order/rebase that results in exactly one declaration and one implementation. The current checklist still says Depends on: none and the overlap comment's 'either rebases to a no-op' needs a concrete resolution before merge.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T04:39:26Z.
Review: APPROVED
Reviewed — looks good
The exact-head AMPR implementation follows the existing 0x18-byte command-record contract, its focused tests pass under QEMU, and the former overlap with #11936 is resolved because that PR is closed.
What I ran
PR head
0f21aac195687ffe257906ec021926d789d19f20; current basemainb433c40f2f46aa2e59e19806010a839ac8572d64. The merge preview is clean (tree8893520a96689b4efe3766efd994b38b3bde31e4). Linux x86_64, GCC 12.2.0, Release; native CPU is Intel Xeon E5-1620 v2. QEMU user-mode emulation used the Haswell CPU model for execution.Results
guest_ampr_tests,guest_ampr_threads_tests, andguest_ampr_cpp_error_testsbuiltAll conventions checks passed.mainExport.cppin #7081; manual diff shows only three CRT forwarding renames, unrelated to these exports. Search found no other open PR for the three new AMPR exports. #11936 is closed.Raw command output
cmake --buildcompleted with:Native CTest output:
The three QEMU executions returned exit code
0. Theguest_ampr_cpp_error_testsoutput ended with:Convention output:
git diff --checkproduced no output and returned 0. The merge command printed:GitHub check runs are all attached to exact head
0f21aac195687ffe257906ec021926d789d19f20:The overlap scan reported only:
Negative control
Findings
Blocking
None found in the reviewed diff.
Non-blocking
The PR explicitly does not claim console measurement. The 0x18 return size is supported by this tree's command header/record layout and matching
_04_00measurement helpers; the current tests establish the in-tree contract, not PS5 behavior.Sources
Not verified
Native execution on a supported CPU and the Windows run in the PR description were not independently reproduced. Linux hosted product CI is skipped. Console behavior remains unmeasured as stated by the author.
To get this to a good state
No change is needed for this review. If the head changes, I will rerun the same build, focused tests, convention, diff, merge-preview, and overlap checks against the new SHA.