feat(libSceAmpr): record and execute native file reads #19060

Merged
mjnhbg3 merged 1 commit from upstream-pr/19060 into main 2026-11-26 04:20:09 +00:00
mjnhbg3 commented 2026-11-12 18:08:54 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by mjnhbg3 on 2026-11-12T18:08:54Z.


What

Record sceAmprAprCommandBufferReadFile using the SDK's 20/24-byte native packet, and execute that format in APR. Previously this export wrote a private 40-byte record and could expand the caller's buffer; APR rejected native packets as malformed. The size query now has its verified four-argument ABI and reports 20 or 24 bytes, or the native invalid-argument result. Other host command formats and their existing execution paths remain supported.

Recording follows numeric validation, null buffer/base, capacity and command-count checks in the observed order. It preserves base/capacity, reports EBUSY without expanding a full buffer, ignores the two state pointers, masks the file ID to 31 bits, and preserves the SDK's packet-copy/count/cursor/flags mutation order even when command memory overlaps the descriptor. Unreadable or unwritable required memory throws through NotImplemented_nid_no_patch; native fault delivery and partial-fault effects are not claimed. The decoder checks header bits, packet extent and destination range before using the existing file-transfer and ReadCursor path. Native kernel scheduling, EOF and completion semantics retain their documented limits.

Evidence comes from the user's local PPSA02530 PRAGMATA 01.300.000 dump: unwrapped libSceAmpr.sprx SHA-256 a99e1a04a6b8eedf9f36478bcac4137770666390606ca141fd748c2ef79c3622. ReadFile NID mQ16-QdKv7k is at 0x2e6d0, forwarding through 0x9e30 to size helper 0x282d0 and encoder 0x28610 (ReadFile arms 0x28568 and 0x28d29). Measure NID vWU-odnS+fU at 0x2f750 takes file ID, destination, size and offset, returning uint32. PRAGMATA calls ReadFile through its wrapper at 0x9dd1a0 (call 0x9dd1bf to PLT 0x8fc5200); wrapper transfers at 0x9dcbbf, 0x9dcd59 and 0x82313f1 establish static use in file loading. It does not import the measure helper. No title-boot or speed improvement is claimed.

The local reference harness executes the unchanged SDK instructions with supplied stack-canary pointer (GOT 0x44220), memcpy import (0x442d0), and stack-failure hook (0x44258). This is local SDK verification, not console measurement or full module initialization. Historical validation at 9ec953f1c38fc1264e9a354c41ba9b222704afee: SDK and fixed host each passed 149,776 calls: 74,896 recorder and 74,880 measure calls. The matrix covers all 65,536 recording-flag values, numeric and capacity/count boundaries, 4,096 deterministic random inputs, 784 descriptor overlaps, ignored unreadable state pointers and page-boundary/error-precedence cases. Whole descriptor/backing bytes and rejection preservation are compared. Seven additional host-only inaccessible-memory calls throw as required. Proprietary libraries and game material stay local and are not included.

Refreshed onto 4b83e9d22346619966e92f78a6953e230694fdee; the current branch head is ef23232b9e937ef70c51b708c8f2d2ad0bbcd466. The latest rebase preserves all added/deleted lines, modes, author and commit, and includes main's APR resolver guest-copy changes from #21585. This addresses the review finding after #22070 merged: the native decoder now forwards the existing int& status to _readResolved, preserving the first read failure through deferred execution and submission completion. It reuses main's status handling rather than adding another mechanism. The six-operation docs/dev/debt/changes/ampr-native-file-reads-rebase.md fragment preserves newer AMPR guest-copy safety information and unrelated kernel entries, and removes the obsolete no-argument measure signature.

Tested

Latest refresh validation on Windows, clean ef23232b9e937ef70c51b708c8f2d2ad0bbcd466 based on main 4b83e9d22346619966e92f78a6953e230694fdee:

  • Cached full configuration and build of eight selected targets passed with WinLibs GCC 15.2.0 r7, Release and Python 3.13.7. The runtime revision header and libc.prx embed this exact new head. This was a scoped incremental build, not a new uncached full-runtime build.
  • 19/19 CTest cases passed, zero skipped, in 7.72 seconds including invocation overhead: all 17 APR/AMPR/placement cases plus guest_libressl3_ec_parameters and guest_libressl3_asn1. These were run once with original logs and JUnit retained locally. The prior hosted Windows failure on 8bd88a7 had exactly those two LibreSSL failures, also present on exact main 1adc0e2; current main contains the #22388 revert. This PR adds no LibreSSL change and does not waive the failed historical run.
  • Conventions, base-to-head diff checks and the rebase-preservation audit passed. The native packet decoder and its read, status forwarding remain intact after #21585.
  • Fresh overlap scan against main 4b83e9d retained exit 2: expected old-head self-comparison with #19060, the previously reviewed #21552 helper insertion, and an unresolved comparison with #22108. Manual original-patch review at #21552 0942212497c32d9a39c139291828e760430720be and #22108 781588cbb7ae25f21024498f1f787af42cb85466 found no competing native ReadFile implementation or semantic prerequisite. #22108 changes resolver error-index copyout; those resolver/test blocks are unchanged by this PR. #21552 requires retaining both independent helper additions at the shared insertion point. No whole-peer build or author agreement is claimed.

Fresh synchronize CI is required for this head; the results below describe the earlier local validation and remain historical.

Previous validation: clean 8bd88a763422acbf4a03d0a72f997b656c467743, based on 99d95b9e267785ee3f5641f42493e6a18875ed2b, on Windows with WinLibs GCC 15.2.0 r7 x64 Release, Ninja and Python 3.13. All required dependency checkouts use their exact committed pins.

  • Fresh full configure and uncached build of all six focused targets succeeded, including fresh libc, libkernel and libSceAmpr runtime inputs. Compiler launchers were empty and CCACHE_DISABLE=1. The first run exposed an incorrect null-pointer EFAULT test fixture (16/17 passed); the fixture was corrected to tracked, read-only guest memory, as in main's existing APR error test. Production and dependency inputs were unchanged by that correction. The six targets were rebuilt on the final clean head before rerunning the complete focused suite.

  • ctest --test-dir b -R "^(guest_ampr_|guest_amm_placement|guest_apr_read_)" -V --output-on-failure --output-junit focused-ampr.xml --parallel 1 --no-tests=error: 17/17 passed, zero skipped, CTest total 3.79 seconds (4.05 seconds including invocation overhead). The registered names were checked against the previous 17-case inventory. Every case finished below 30 seconds; the native packet case passed in 0.112 seconds. Existing sparse offsets beyond 4 GiB, mixed host/native reads, gather/scatter cursors, deferred snapshots, malformed packets, EOF, priorities, placement and AMPR error checks all remain covered.

  • The passing native case includes eight error combinations on Windows; four are also enabled on non-Windows. Both 20/24-byte packet formats and waits before/after the failing read verify successful submission/result with an execution error returned by wait, stable repeated waits, first-error preservation across a later generic EIO, unchanged destination before release, and successful execution of a trailing native read. ENOENT cases are shared across platforms; EFAULT uses tracked read-only guest memory on Windows. Linux/macOS execution was not run for this refresh.

  • Public declaration/umbrella audit passed: 413 libraries and 34,705 exports, with unique declarations and umbrella coverage verified.

  • python tools/debt_fold.py --check passed for all current fragments.

  • python tools/check_conventions.py --base origin/main and git diff --check passed. The reviewed working tree was clean.

  • The rebase audit confirmed that the prior contribution's added/deleted lines, modes, author and commit were preserved before applying this review fix. The deliberate refresh changes are confined to the native status argument and its regression test.

The historical SDK differential results in What belong to 9ec953f1c38fc1264e9a354c41ba9b222704afee; that proprietary SDK harness has not been rerun for this refresh. No fresh Linux/macOS, console, title-boot, gameplay or performance result is claimed. GPU testing is n/a for these CPU-side APR changes. Earlier upstream full-build results precede this head; a maintainer rerun is needed to validate the refreshed PR in upstream full CI.

Historical overlap evidence for the previous refresh:

  • Function-name lookup scanned 1,717 open PRs and found only this PR for sceAmprAprCommandBufferReadFile and sceAmprMeasureCommandSizeReadFile. The final branch check for 8bd88a763422acbf4a03d0a72f997b656c467743 scanned 1,719 open PRs against main 5a23c6303baf68166689edbfcc78adf7160b05cd and completed with exit 0. It reports the expected old-head self-comparison at d4e087096ba6ffdd44b17d6dd8b1fe602cad6d5d and the mechanical #21552 insertion conflict; exit 0 does not mean there are no overlaps. The touched AMPR/APR source and tests are unchanged between the build's main pin and that newer scan base.

  • Pinned independent review of #21552 at 0942212497c32d9a39c139291828e760430720be found a shared insertion point after ValidRead: retain this PR's ReadFileBytes and the peer's GuestBufferBase/UpdateRecording helpers, plus both downstream feature bodies. It does not duplicate the native ReadFile writer or MeasureReadFile. No author agreement or combined build is claimed.

  • Pinned independent review also checked #21585 at 421155f04d47a4927523d801c55ee2fcd198fa4b (resolver guest copies), #20633 at a3470677b6f42a61ba90735a44b01f42509e9fb8 (other command-buffer copies/gathers), #11446 at 5c5b61fc844b49358dff28854c5ac87866a83663 (resolver cache/tests), and #18190 at 1515d5dffca40b5e8daa621bbcd9d2ea1966cf69 (libkernel_sys mirrors). No competing native ReadFile encoder/decoder was identified in those exact patches; shared helper/selector insertions can require mechanical rebasing. This review does not claim those branches merge or build together.

  • #18515 at c87be26205f607ae7ffbb3b5ba2f4bef2caa4fff is now closed. Its status-propagation work is on main through merged #22070 and is accounted for by this refresh. It is not an open prerequisite.

Checklist

  • Based on current main; no other open PR implements the same functions

  • One topic per PR; follow-ups go in a new PR

  • No comments in code except technical debt and the licence notice of code adapted from upstream (see AGENTS.md)

  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file

  • No notes, investigation .md files or images added to the repository (attach them to this PR)

  • New third-party code is a submodule built from source

  • Generic behaviour, not specific to one title

  • Depends on: none

  • Fixes: none

  • Unblocks: none

  • GPUs tested: n/a

  • AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5282707257 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/19060). Originally posted by [mjnhbg3](https://github.com/mjnhbg3) on 2026-11-12T18:08:54Z. --- ### What Record `sceAmprAprCommandBufferReadFile` using the SDK's 20/24-byte native packet, and execute that format in APR. Previously this export wrote a private 40-byte record and could expand the caller's buffer; APR rejected native packets as malformed. The size query now has its verified four-argument ABI and reports 20 or 24 bytes, or the native invalid-argument result. Other host command formats and their existing execution paths remain supported. Recording follows numeric validation, null buffer/base, capacity and command-count checks in the observed order. It preserves base/capacity, reports EBUSY without expanding a full buffer, ignores the two state pointers, masks the file ID to 31 bits, and preserves the SDK's packet-copy/count/cursor/flags mutation order even when command memory overlaps the descriptor. Unreadable or unwritable required memory throws through NotImplemented_nid_no_patch; native fault delivery and partial-fault effects are not claimed. The decoder checks header bits, packet extent and destination range before using the existing file-transfer and ReadCursor path. Native kernel scheduling, EOF and completion semantics retain their documented limits. Evidence comes from the user's local PPSA02530 PRAGMATA 01.300.000 dump: unwrapped libSceAmpr.sprx SHA-256 a99e1a04a6b8eedf9f36478bcac4137770666390606ca141fd748c2ef79c3622. ReadFile NID mQ16-QdKv7k is at 0x2e6d0, forwarding through 0x9e30 to size helper 0x282d0 and encoder 0x28610 (ReadFile arms 0x28568 and 0x28d29). Measure NID vWU-odnS+fU at 0x2f750 takes file ID, destination, size and offset, returning uint32. PRAGMATA calls ReadFile through its wrapper at 0x9dd1a0 (call 0x9dd1bf to PLT 0x8fc5200); wrapper transfers at 0x9dcbbf, 0x9dcd59 and 0x82313f1 establish static use in file loading. It does not import the measure helper. No title-boot or speed improvement is claimed. The local reference harness executes the unchanged SDK instructions with supplied stack-canary pointer (GOT 0x44220), memcpy import (0x442d0), and stack-failure hook (0x44258). This is local SDK verification, not console measurement or full module initialization. Historical validation at `9ec953f1c38fc1264e9a354c41ba9b222704afee`: SDK and fixed host each passed 149,776 calls: 74,896 recorder and 74,880 measure calls. The matrix covers all 65,536 recording-flag values, numeric and capacity/count boundaries, 4,096 deterministic random inputs, 784 descriptor overlaps, ignored unreadable state pointers and page-boundary/error-precedence cases. Whole descriptor/backing bytes and rejection preservation are compared. Seven additional host-only inaccessible-memory calls throw as required. Proprietary libraries and game material stay local and are not included. Refreshed onto `4b83e9d22346619966e92f78a6953e230694fdee`; the current branch head is `ef23232b9e937ef70c51b708c8f2d2ad0bbcd466`. The latest rebase preserves all added/deleted lines, modes, author and commit, and includes main's APR resolver guest-copy changes from #21585. This addresses the review finding after #22070 merged: the native decoder now forwards the existing `int& status` to `_readResolved`, preserving the first read failure through deferred execution and submission completion. It reuses main's status handling rather than adding another mechanism. The six-operation `docs/dev/debt/changes/ampr-native-file-reads-rebase.md` fragment preserves newer AMPR guest-copy safety information and unrelated kernel entries, and removes the obsolete no-argument measure signature. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Latest refresh validation on Windows, clean `ef23232b9e937ef70c51b708c8f2d2ad0bbcd466` based on main `4b83e9d22346619966e92f78a6953e230694fdee`: - Cached full configuration and build of eight selected targets passed with WinLibs GCC 15.2.0 r7, Release and Python 3.13.7. The runtime revision header and `libc.prx` embed this exact new head. This was a scoped incremental build, not a new uncached full-runtime build. - **19/19 CTest cases passed, zero skipped**, in 7.72 seconds including invocation overhead: all 17 APR/AMPR/placement cases plus `guest_libressl3_ec_parameters` and `guest_libressl3_asn1`. These were run once with original logs and JUnit retained locally. The prior hosted Windows failure on `8bd88a7` had exactly those two LibreSSL failures, also present on exact main `1adc0e2`; current main contains the #22388 revert. This PR adds no LibreSSL change and does not waive the failed historical run. - Conventions, base-to-head diff checks and the rebase-preservation audit passed. The native packet decoder and its `read, status` forwarding remain intact after #21585. - Fresh overlap scan against main `4b83e9d` retained exit 2: expected old-head self-comparison with #19060, the previously reviewed #21552 helper insertion, and an unresolved comparison with #22108. Manual original-patch review at #21552 `0942212497c32d9a39c139291828e760430720be` and #22108 `781588cbb7ae25f21024498f1f787af42cb85466` found no competing native ReadFile implementation or semantic prerequisite. #22108 changes resolver error-index copyout; those resolver/test blocks are unchanged by this PR. #21552 requires retaining both independent helper additions at the shared insertion point. No whole-peer build or author agreement is claimed. Fresh synchronize CI is required for this head; the results below describe the earlier local validation and remain historical. Previous validation: clean `8bd88a763422acbf4a03d0a72f997b656c467743`, based on `99d95b9e267785ee3f5641f42493e6a18875ed2b`, on Windows with WinLibs GCC 15.2.0 r7 x64 Release, Ninja and Python 3.13. All required dependency checkouts use their exact committed pins. - Fresh full configure and uncached build of all six focused targets succeeded, including fresh `libc`, `libkernel` and `libSceAmpr` runtime inputs. Compiler launchers were empty and `CCACHE_DISABLE=1`. The first run exposed an incorrect null-pointer EFAULT test fixture (16/17 passed); the fixture was corrected to tracked, read-only guest memory, as in main's existing APR error test. Production and dependency inputs were unchanged by that correction. The six targets were rebuilt on the final clean head before rerunning the complete focused suite. - `ctest --test-dir b -R "^(guest_ampr_|guest_amm_placement|guest_apr_read_)" -V --output-on-failure --output-junit focused-ampr.xml --parallel 1 --no-tests=error`: **17/17 passed, zero skipped**, CTest total 3.79 seconds (4.05 seconds including invocation overhead). The registered names were checked against the previous 17-case inventory. Every case finished below 30 seconds; the native packet case passed in 0.112 seconds. Existing sparse offsets beyond 4 GiB, mixed host/native reads, gather/scatter cursors, deferred snapshots, malformed packets, EOF, priorities, placement and AMPR error checks all remain covered. - The passing native case includes eight error combinations on Windows; four are also enabled on non-Windows. Both 20/24-byte packet formats and waits before/after the failing read verify successful submission/result with an execution error returned by wait, stable repeated waits, first-error preservation across a later generic EIO, unchanged destination before release, and successful execution of a trailing native read. ENOENT cases are shared across platforms; EFAULT uses tracked read-only guest memory on Windows. Linux/macOS execution was not run for this refresh. - Public declaration/umbrella audit passed: **413 libraries and 34,705 exports**, with unique declarations and umbrella coverage verified. - `python tools/debt_fold.py --check` passed for all current fragments. - `python tools/check_conventions.py --base origin/main` and `git diff --check` passed. The reviewed working tree was clean. - The rebase audit confirmed that the prior contribution's added/deleted lines, modes, author and commit were preserved before applying this review fix. The deliberate refresh changes are confined to the native status argument and its regression test. The historical SDK differential results in What belong to `9ec953f1c38fc1264e9a354c41ba9b222704afee`; that proprietary SDK harness has not been rerun for this refresh. No fresh Linux/macOS, console, title-boot, gameplay or performance result is claimed. GPU testing is n/a for these CPU-side APR changes. Earlier upstream full-build results precede this head; a maintainer rerun is needed to validate the refreshed PR in upstream full CI. Historical overlap evidence for the previous refresh: - Function-name lookup scanned 1,717 open PRs and found only this PR for `sceAmprAprCommandBufferReadFile` and `sceAmprMeasureCommandSizeReadFile`. The final branch check for `8bd88a763422acbf4a03d0a72f997b656c467743` scanned 1,719 open PRs against main `5a23c6303baf68166689edbfcc78adf7160b05cd` and completed with exit 0. It reports the expected old-head self-comparison at `d4e087096ba6ffdd44b17d6dd8b1fe602cad6d5d` and the mechanical #21552 insertion conflict; exit 0 does not mean there are no overlaps. The touched AMPR/APR source and tests are unchanged between the build's main pin and that newer scan base. - Pinned independent review of #21552 at `0942212497c32d9a39c139291828e760430720be` found a shared insertion point after `ValidRead`: retain this PR's `ReadFileBytes` and the peer's `GuestBufferBase`/`UpdateRecording` helpers, plus both downstream feature bodies. It does not duplicate the native ReadFile writer or MeasureReadFile. No author agreement or combined build is claimed. - Pinned independent review also checked #21585 at `421155f04d47a4927523d801c55ee2fcd198fa4b` (resolver guest copies), #20633 at `a3470677b6f42a61ba90735a44b01f42509e9fb8` (other command-buffer copies/gathers), #11446 at `5c5b61fc844b49358dff28854c5ac87866a83663` (resolver cache/tests), and #18190 at `1515d5dffca40b5e8daa621bbcd9d2ea1966cf69` (libkernel_sys mirrors). No competing native ReadFile encoder/decoder was identified in those exact patches; shared helper/selector insertions can require mechanical rebasing. This review does not claim those branches merge or build together. - #18515 at `c87be26205f607ae7ffbb3b5ba2f4bef2caa4fff` is now closed. Its status-propagation work is on main through merged #22070 and is accounted for by this refresh. It is not an open prerequisite. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) and the licence notice of code adapted from upstream (see AGENTS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none <!-- #PR, or none --> - [x] Fixes: none <!-- issue it closes as Fixes #N, or none --> - [x] Unblocks: none <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> - [x] GPUs tested: n/a <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> - [x] AI-assisted: yes <!-- yes / no -->
PrivacyOnion commented 2026-11-12 21:08:10 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-12T21:08:10Z.

Review: APPROVED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 9ec953f1c3:

  • Conventions: tools/check_conventions.py passed; git diff --check clean.
  • Build: guest_ampr_tests, guest_apr_read_tests built cleanly.
  • CTest (guest_ampr_div_and_buffer_size, guest_ampr_markers, guest_ampr_threads, guest_ampr_cpp_error, guest_apr_read_host, guest_apr_read_direct, guest_apr_read_eof, guest_apr_read_errors, guest_apr_read_streams, guest_apr_read_priorities, guest_apr_read_order, guest_apr_read_queries, guest_apr_read_native):
    3/13 Test #2895: guest_ampr_threads ...............   Passed    0.27 sec
    4/13 Test #4419: guest_apr_read_direct ............   Passed    0.10 sec
    5/13 Test #4422: guest_apr_read_streams ...........   Passed    0.44 sec
    6/13 Test #4418: guest_apr_read_host ..............   Passed    0.10 sec
    7/13 Test #4781: guest_apr_read_native ............   Passed    0.04 sec
    8/13 Test #4423: guest_apr_read_priorities ........   Passed    0.06 sec
    9/13 Test #2893: guest_ampr_markers ...............   Passed    0.04 sec
    10/13 Test #4424: guest_apr_read_order .............   Passed    0.04 sec
    11/13 Test #4425: guest_apr_read_queries ...........   Passed    0.04 sec
    12/13 Test #4420: guest_apr_read_eof ...............   Passed    0.04 sec
    13/13 Test #4421: guest_apr_read_errors ............   Passed    0.04 sec
    100% tests passed, 0 tests failed out of 13
    
  • Negative control: with core/libs/prx/libSceAmpr/Export.cpp, core/libs/prx/libSceAmpr/include/Api.hpp, core/libs/prx/libkernel/Apr/src/Apr.cpp reverted to main, the new tests do not build/link without the change; restoring it makes them build and pass.
  • Code reading:
    • core/libs/prx/libSceAmpr/Export.cpp: verified exact error precedence in sceAmprAprCommandBufferReadFile (!ValidRead returning SCE_KERNEL_ERROR_EINVAL, !buffer returning SCE_KERNEL_ERROR_EINVAL, base == 0 returning SCE_KERNEL_ERROR_EPERM, capacity < bytes || current > capacity - bytes returning SCE_KERNEL_ERROR_EBUSY, and count > 0x7ffffffeu returning SCE_KERNEL_ERROR_EINVAL).
    • core/libs/prx/libSceAmpr/Export.cpp: verified 20-byte vs 24-byte native packet encoding and bit packing in ReadFileBytes and command array (header format 0x428u/0x528u with offset bits 0-17 in word 0, size - 1 in word 1, 31-bit masked fileId in word 2, destination address bits 0-31 in word 3, offset bits 18-31 OR-ed with destination bits 32-47 in word 4, and offset bits 32-39 in word 5).
    • core/libs/prx/libSceAmpr/Export.cpp: verified descriptor aliasing and mutation order in sceAmprAprCommandBufferReadFile, correctly reloading numCommands after GuestCopyOut_nid_no_patch before incrementing, advancing offset by bytes, and setting bit 16 in flags (0x10000u) to assert Apr::ScatterGatherValid.
    • core/libs/prx/libkernel/Apr/src/Apr.cpp: verified native packet decoding in _execute for opcode 0x28u, validating header format (0x428u or 0x528u), packet buffer truncation (bytes > buffer.offset - cursor), reserved flag bits (words[2] bit 31, words[4] bits 16-17, words[5] > 0xffu), and destination range limits (destination > userLimit || size > userLimit - destination).
    • core/libs/prx/libkernel/Apr/src/Apr.cpp: verified lossless 40-bit offset reconstruction ((words[5] << 32) | (words[4] & 0xfffc0000u) | (first >> 12u)) and 48-bit destination reconstruction ((words[4] & 0xffffu) << 32 | words[3]) passed into _readResolved.
    • core/libs/prx/libSceAmpr/Export.cpp & Api.hpp: verified sceAmprMeasureCommandSizeReadFile 4-argument signature and return values (returning SCE_KERNEL_ERROR_EINVAL on invalid read range, otherwise 20u or 24u depending on offset magnitude).
    • AGENTS.md & docs/dev/debt: verified strict absence of comments in all added/modified code, conventional commit PR title, and proper technical debt updates in docs/dev/debt/libSceAmpr.md and docs/dev/debt/libkernel.md.

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5882038396 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/19060#pullrequestreview-5882038396). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-12T21:08:10Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `9ec953f1c3`: - **Conventions**: `tools/check_conventions.py` passed; `git diff --check` clean. - **Build**: `guest_ampr_tests`, `guest_apr_read_tests` built cleanly. - **CTest** (`guest_ampr_div_and_buffer_size`, `guest_ampr_markers`, `guest_ampr_threads`, `guest_ampr_cpp_error`, `guest_apr_read_host`, `guest_apr_read_direct`, `guest_apr_read_eof`, `guest_apr_read_errors`, `guest_apr_read_streams`, `guest_apr_read_priorities`, `guest_apr_read_order`, `guest_apr_read_queries`, `guest_apr_read_native`): ``` 3/13 Test #2895: guest_ampr_threads ............... Passed 0.27 sec 4/13 Test #4419: guest_apr_read_direct ............ Passed 0.10 sec 5/13 Test #4422: guest_apr_read_streams ........... Passed 0.44 sec 6/13 Test #4418: guest_apr_read_host .............. Passed 0.10 sec 7/13 Test #4781: guest_apr_read_native ............ Passed 0.04 sec 8/13 Test #4423: guest_apr_read_priorities ........ Passed 0.06 sec 9/13 Test #2893: guest_ampr_markers ............... Passed 0.04 sec 10/13 Test #4424: guest_apr_read_order ............. Passed 0.04 sec 11/13 Test #4425: guest_apr_read_queries ........... Passed 0.04 sec 12/13 Test #4420: guest_apr_read_eof ............... Passed 0.04 sec 13/13 Test #4421: guest_apr_read_errors ............ Passed 0.04 sec 100% tests passed, 0 tests failed out of 13 ``` - **Negative control**: with `core/libs/prx/libSceAmpr/Export.cpp`, `core/libs/prx/libSceAmpr/include/Api.hpp`, `core/libs/prx/libkernel/Apr/src/Apr.cpp` reverted to `main`, the new tests do not build/link without the change; restoring it makes them build and pass. - **Code reading**: - core/libs/prx/libSceAmpr/Export.cpp: verified exact error precedence in sceAmprAprCommandBufferReadFile (!ValidRead returning SCE_KERNEL_ERROR_EINVAL, !buffer returning SCE_KERNEL_ERROR_EINVAL, base == 0 returning SCE_KERNEL_ERROR_EPERM, capacity < bytes || current > capacity - bytes returning SCE_KERNEL_ERROR_EBUSY, and count > 0x7ffffffeu returning SCE_KERNEL_ERROR_EINVAL). - core/libs/prx/libSceAmpr/Export.cpp: verified 20-byte vs 24-byte native packet encoding and bit packing in ReadFileBytes and command array (header format 0x428u/0x528u with offset bits 0-17 in word 0, size - 1 in word 1, 31-bit masked fileId in word 2, destination address bits 0-31 in word 3, offset bits 18-31 OR-ed with destination bits 32-47 in word 4, and offset bits 32-39 in word 5). - core/libs/prx/libSceAmpr/Export.cpp: verified descriptor aliasing and mutation order in sceAmprAprCommandBufferReadFile, correctly reloading numCommands after GuestCopyOut_nid_no_patch before incrementing, advancing offset by bytes, and setting bit 16 in flags (0x10000u) to assert Apr::ScatterGatherValid. - core/libs/prx/libkernel/Apr/src/Apr.cpp: verified native packet decoding in _execute for opcode 0x28u, validating header format (0x428u or 0x528u), packet buffer truncation (bytes > buffer.offset - cursor), reserved flag bits (words[2] bit 31, words[4] bits 16-17, words[5] > 0xffu), and destination range limits (destination > userLimit || size > userLimit - destination). - core/libs/prx/libkernel/Apr/src/Apr.cpp: verified lossless 40-bit offset reconstruction ((words[5] << 32) | (words[4] & 0xfffc0000u) | (first >> 12u)) and 48-bit destination reconstruction ((words[4] & 0xffffu) << 32 | words[3]) passed into _readResolved. - core/libs/prx/libSceAmpr/Export.cpp & Api.hpp: verified sceAmprMeasureCommandSizeReadFile 4-argument signature and return values (returning SCE_KERNEL_ERROR_EINVAL on invalid read range, otherwise 20u or 24u depending on offset magnitude). - AGENTS.md & docs/dev/debt: verified strict absence of comments in all added/modified code, conventional commit PR title, and proper technical debt updates in docs/dev/debt/libSceAmpr.md and docs/dev/debt/libkernel.md. Looks Good To Me
MarcZX10 commented 2026-11-22 08:28:57 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-22T08:28:57Z.

Review: APPROVED


Reviewed — looks good

Nothing blocks merging this change; the inspected implementation and reported checks support the native ReadFile recording and execution paths.

What I ran

  • Reviewed head ef23232b9e937ef70c51b708c8f2d2ad0bbcd466 against the prepared patch; no commands or tests were run.
  • Read description.md, commits.md, manifest.json, and all 551 lines of diff.patch. Read the changed code in core/libs/prx/libSceAmpr/Export.cpp (lines 205–235, 465–525, 790–815) and core/libs/prx/libkernel/Apr/src/Apr.cpp (lines 650–730). The manifest marks all seven changed files as included; the additional changed tests and debt fragment are represented in the diff. files.json was not available through the reader.

Results

Check Result Note
Patch and changed code review passed Native packet encode/decode and status forwarding inspected
Author-reported build and CTest not run Description reports scoped Windows build and 19/19 CTest pass
Console and Linux/macOS behavior not run Not claimed for this head

Findings

Blocking

None.

Non-blocking

None.

Not verified

I did not independently run the reported build, CTest, SDK differential harness, or console checks. The full changed-file texts for core/libs/prx/libkernel/tests/cmake/guest_apr_read_tests.cmake, core/libs/tests/GuestAmpr.cpp, core/libs/tests/GuestAprRead.cpp, and docs/dev/debt/changes/ampr-native-file-reads-rebase.md were not read outside their patch hunks; their complete contents were included in the diff. files.json was unavailable, so exclusions by rule could not be confirmed.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6011230828 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/19060#pullrequestreview-6011230828). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-22T08:28:57Z. **Review:** APPROVED --- # Reviewed — looks good Nothing blocks merging this change; the inspected implementation and reported checks support the native ReadFile recording and execution paths. ## What I ran - Reviewed head `ef23232b9e937ef70c51b708c8f2d2ad0bbcd466` against the prepared patch; no commands or tests were run. - Read `description.md`, `commits.md`, `manifest.json`, and all 551 lines of `diff.patch`. Read the changed code in `core/libs/prx/libSceAmpr/Export.cpp` (lines 205–235, 465–525, 790–815) and `core/libs/prx/libkernel/Apr/src/Apr.cpp` (lines 650–730). The manifest marks all seven changed files as included; the additional changed tests and debt fragment are represented in the diff. `files.json` was not available through the reader. ## Results | Check | Result | Note | |---|---|---| | Patch and changed code review | passed | Native packet encode/decode and status forwarding inspected | | Author-reported build and CTest | not run | Description reports scoped Windows build and 19/19 CTest pass | | Console and Linux/macOS behavior | not run | Not claimed for this head | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified I did not independently run the reported build, CTest, SDK differential harness, or console checks. The full changed-file texts for `core/libs/prx/libkernel/tests/cmake/guest_apr_read_tests.cmake`, `core/libs/tests/GuestAmpr.cpp`, `core/libs/tests/GuestAprRead.cpp`, and `docs/dev/debt/changes/ampr-native-file-reads-rebase.md` were not read outside their patch hunks; their complete contents were included in the diff. `files.json` was unavailable, so exclusions by rule could not be confirmed. ## To get this to a good state Nothing is required.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!19060
No description provided.