feat(libkernel): map app0.zar archive-backed files #11625

Merged
Felipebmaitan merged 17 commits from upstream-pr/11625 into main 2026-11-21 02:06:59 +00:00
Felipebmaitan commented 2026-10-26 23:23:17 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Felipebmaitan on 2026-10-26T23:23:17Z.


What

Map files from app0.zar through the native regular-file path. Each mapping owns a read-only backing object for the requested guest-page-rounded window, clipped at EOF, with a native offset of zero. Loose files take precedence. The mapping survives close or reuse of the guest descriptor, with the existing protection, partial-unmap and host EOF behavior.

Archive reads check each destination page before advancing the cursor. HostWrite opens watched pages, while the checked copies handle invalid addresses and preserve partial progress. Materialization holds the shared descriptor attachment lock while it copies, serializing reads, seeks and maps on duplicate descriptors.

The branch preserves published head 00a2d202a33c9b09e38321962cefacd1506db1b8 and integrates main through e481b135558fc4316bc3b24e7408156737eff08d. It carries main's Windows fixed-private-map bookkeeping, macOS empty-iovec guards and newer archive-descriptor test expectations. The debt edits use a fragment that preserves main's neighboring entries.

One independent review inspected the full archive diff at 1b8fea2423fe5b4b5e29900a14153f17ed502dc3. The follow-up translates Windows backing-write exhaustion to ENOSPC or EFBIG for the corresponding native error, and checks macOS shared write upgrades against matched loose-file mappings. Windows and Linux still require EACCES for the upgrades, and the tests restore read-only protection before checking guest destination faults.

The Windows reader now opens with read access and no delete-on-close flag. The writer owns file cleanup. Private mappings finish copying before the reader closes, and shared views keep the native section alive after the descriptor closes. Lifetime review

#12682 remains the declared predecessor. A read-only merge preview with its published head 44fde3b660ac816dace9ac0320f2002d23d5787d still conflicts in pread_nid_postfix. The archive branch by itself previews cleanly against main e86afa1936367953144e791327ed2161fdb330ea. After #12682 lands, carry the archive error conversion into its cancellation and pinned-descriptor path and test the combined archive and I/O behavior. #18190's libkernel_sys wrapper refactor separately conflicts in PosixMemory.cpp at its published head dc73ea0d21d3c6fbf9002ab3fee296f312583147. I compared the 37 unique PRs in the refreshed overlap report against main c8d5f91168d7d8c208478de6d555b6a34c1c9acf and against that main composed with this head 4a2b14298c386cf90332d35bbc2e5c8314d2993f. Newly listed #11831 changes stream lifetime and fcloseall; its published head 1c17f817b396eec0d46ddfedccb5a2ab9113493a merges cleanly in both previews. #18112 contributes a libkernel_web export mirror and already conflicts with main. #7447 introduces a separate archive-stdio source at the same libc CMake registration point. #7121's read notifications add conflicts within its already-conflicting Open.cpp and Stdio.cpp when combined with the archive read-error changes. #6936 changes archive seeking and already conflicts with main. The other previews showed the same conflict files and the same conflict blocks in archive-touched files as their main comparisons. These overlaps involve separate functionality. The declared prerequisite is still #12682.

Tested

  • Windows 11 build 26300, WinLibs GCC 15.2, current head 4a2b14298c386cf90332d35bbc2e5c8314d2993f. The native read-only and executable mapping tests created a section from the materialized reader, closed both the section handle and the reader, then verified the mapped bytes. Both passed, and the isolated backing directory had no temporary backing files after unmap. The descriptor-read and truncated-entry cleanup smoke test also passed. The original reader flags passed the native view lifetime reproducer on this host as well.
  • Windows 11 build 26300, WinLibs GCC 15.2, integration head 86b4b73041f30a97b5a2521b4fae801b4b141e5b. The direct backing test passed requested offsets and bytes, read-only access, independent windows, EOF clipping and truncated input. A second test linked the production archive and backing sources with ZArchive and used a real compressed fixture. It passed loose-file precedence, cursor sharing and positioned partial reads with injected copy rejection, and native mapped views that remained readable after closing their handles.
  • Injected WriteFile results ERROR_HANDLE_DISK_FULL and ERROR_FILE_TOO_LARGE returned ENOSPC and EFBIG and closed the backing handle. The production archive fixture passed MinGW syntax checks at that integration head. The four changed libkernel translation units passed syntax checks and are byte-identical to those checked.
  • Conventions against current origin/main, debt fragment validation and committed-diff whitespace checks passed. The initial function-name overlap scan completed against 2,239 open PRs.
  • 26/26 registered Windows guest CTests passed at 4a2b14298c386cf90332d35bbc2e5c8314d2993f in 7.08 seconds on Windows 11 build 26300, WinLibs GCC 15.2, Release. The selection covered all nine app archive modes across libc and libkernel, including archive mmap, backing failure and damaged input. It also covered filesystem, descriptor duplication, file-vector and positioned I/O, AIO, guest memory, and fixed-anonymous and executable mappings. The archive mmap case verified shared and private mapping data after descriptor close or replacement, checked error handling for unwritable guest destinations, and exercised Windows write-watch collection. CMake used the pinned FFmpeg package after its SHA-256 matched the published release. Fresh Linux and macOS execution remains pending.
  • Hosted checks finished for 4a2b14298c386cf90332d35bbc2e5c8314d2993f with 20 successes and two skips (the full Linux and pipe-write jobs). The Windows job passed. Hosted build run
  • MarcZX10 approved the current head after targeted source review of the backing, mapping, and checked-read paths. The Windows runtime results above are the author's runs. Current-head approval
  • Earlier contributor evidence remains pinned to the revisions tested. ycbuzi reported full CTest runs for previous head 00a2d202a33c9b09e38321962cefacd1506db1b8 composed with main. Windows Server 2022 had 2 failures out of 6,495, both reproduced on main. Windows Server 2025 had 0 out of 6,495. Contributor runs
  • XairRrR's Debian tests and negative controls, the macOS support-composition results, and earlier author runs are recorded below at their original revisions.

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: #12682
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
Earlier descriptions and evidence at their historical revisions

What

November 7 maintenance head 00a2d202a33c9b09e38321962cefacd1506db1b8, integrated with main 4138defef7c468835190768e5143e411bce92d6a. This preserves the complete published 6e2918bffa9d95f46f986f8417b08dbe468fe176 history, including maintainer merges and the macOS mmap error-publication fix. The only integration conflict was the libkernel debt file; both the archive mapping text and main's module-unload debt are retained. No archive runtime implementation was replaced with the stale October checkout, and no graphics source or timeout was changed by this maintenance.

Archive-backed mmap uses read-only native backing for the requested guest-page-rounded window, clipped at EOF and mapped from backing offset zero. Mapping lifetime is independent of the guest descriptor and transient backing descriptor. Loose files retain precedence; private writable mappings, shared read-only permissions, protection changes, partial unmaps and descriptor reuse continue through the established regular-file paths. This is host ZArchive packaging, not console PFS.

Checked archive reads remain deliberate: audited scalar, positioned, vector and AIO callers open HostWrite/OpenIovecs, but those guards do not make arbitrary destination pointers fault-safe. Page-bounded checked copies retain invalid-buffer and partial-progress/cursor behavior. Materialization holds the shared attachment mutex for the requested window; contention and copy cost remain the previously documented tradeoffs. No new performance claim is made.

Tested

Fresh execution on the maintenance head:

  • Windows 11 build 26300, WinLibs GCC 15.2, Release, BUILD_TESTING=ON, ANYPS5_ENABLE_SPIRV_TOOLS=ON: full production libs and relinker, plus the selected runtime executables, rebuilt with at most two jobs. 27/27 focused tests pass after restoration of the negative controls. These include archive/plain/mmap/backing-failure/damaged modes, ordinary mmap and memory, duplication, scalar/positioned/vector reads, AIO, filesystem and actual Windows write-watch/HostWrite behavior. Synthetic archive entries and loose files with identical bytes are compared by the production API fixtures. Every focused case finishes below 30 seconds; the archive cases retain their registered 20-second limits.
  • Two temporary Windows production-path negative controls: restoring archived mmap refusal makes all three mmap modes fail with the expected refusal while archive/plain reads still pass; replacing only checked archive descriptor reads with the unchecked main implementation makes the invalid-destination mmap case fault while archive/plain still pass. Both changes were removed, production libraries rebuilt, and the complete 27-case selection passed again. No control instrumentation is committed.
  • Ubuntu 24.04 WSL2, kernel 6.6.87.2-microsoft-standard-WSL2, GCC 13.3, Release, BUILD_TESTING=ON, ANYPS5_ENABLE_SPIRV_TOOLS=OFF: full production libs and relinker plus the focused executables built, then rebuilt/restored after the clean-main control. The original registered selection is 23/24: every archive mode, read/positioned/vector/AIO, duplication, ordinary memory and fixed-anonymous mmap passes; ordinary guest_mmap_executable aborts at GuestMemory.cpp:3583 from its registered DrvFS working directory. A clean checkout of parent main 4138defef7c468835190768e5143e411bce92d6a, with the fixture unchanged and its actual production dependency graph rebuilt, reproduces that same assertion; both main and the archive head pass that executable mode from unique native ext4 working directories. The main artifact lacks the archive mapping helper; restoration reinstates it. The underlying working-directory-dependent cause is not explained here and no unrelated memory code or timeout was changed.
  • Final restored Linux selection: 24/24 with only guest_mmap_executable's working directory moved to a unique verified ext4 directory in an untracked temporary CTest registry. Machine-checked JSON comparison verifies all 24 commands and every other test property, including registered timeouts, match the original registry. All other working directories remain unchanged. guest_filesystem separately passes from a unique ext4 directory. The original 23/24 result and its failure are retained, rather than relabeled as an unmodified CTest pass. Linux reports asynchronous userfaultfd write protection unavailable (EINVAL); HostWrite/data checks execute, but actual Linux write-watch collection is not claimed. Actual collection is asserted by the passing Windows cases. Restored binary hashes and runner definitions/properties are retained in the local validation artifacts.
  • Public-header audit: 407 libraries / 30,931 exports. Conventions and committed-diff whitespace checks pass. The overlap scanner completed against 1,765 open PRs, probing 1,764 at main 87473937d31ca4f64d819805b8f0c2b80ac55b53, and exits 2: 76 comparisons with PRs conflicting with main remain inconclusive. The confirmed #16861 overlap was manually inspected: adjacent libkernel debt edits, with no archive implementation overlap. Live #7447 at dead12ebad24a3c4b01a05c14ab60cc06aacaf7d remains a stdio feature without mmap capability; #6936 at f06949da78cf801f47702e27f0dd987f4b80e184 adds archive seek modes. Their shared integration paths remain open coordination concerns; neither branch was edited or contacted. No clean scan or new ordering agreement is claimed. A read-only merge-tree check against subsequently fetched main 9e47f0c3accfdd390ef5c578c8a6332048200d5d is clean (tree 99ac8c8c3e503ee4c3a54d7d72c5ee01c797f40e); the executed source remains the explicitly pinned maintenance head based on 4138defef7.

Fresh targeted investigation of the November Radeon timeout report:

  • Inspected the raw isolated logs and broad tests-only overlay failure. The isolated profile_draw runs time out near their registered 60-second cap. The broad overlay stops compiling GuestKernelAppArchive.cpp because main lacks AppArchiveMappingDescriptor_nid_no_patch; it never supplies a clean-main graphics runtime control. The report remains unattributed.
  • Built only agc_driver_graphics_tests on clean reported main e772fb25cc72ee5faf77847f06bbc69533016e82 and its exact composition with PR 6e2918bffa9d95f46f986f8417b08dbe468fe176. The latter is diagnostic commit 15a84102eed7321ad8e5bd94e9f8face06231264, merged tree 9be29b4ca2233ca17556fade4c26117a5bc9cbbf. Graphics/recompiler source trees are identical across this pair. This diagnostic commit is not the maintenance PR head or a published feature change.
  • Both controls pass ctest -R '^agc_graphics_profile_draw$' -V --parallel 1 with the original registered TIMEOUT 60 unchanged, same Windows 11 PC, Ryzen 9800X3D, NVIDIA RTX 5080 / NVIDIA 621.14 / Vulkan 1.4.357, GCC 15.2 Release and ANYPS5_ENABLE_SPIRV_TOOLS=ON. Both use ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation. The complete job held Local\AnyPS5GpuValidation; no concurrent GPU validation was run by the I/O owner. Local Khronos nightly validation layer API 1.4.368 was verified available with vulkaninfo.
  • Neither raw CTest log contains the missing-layer message or any VUID- ID; there are no new validation IDs. Main raw log SHA256: ab50509f6f4637815bf8e484722942e05ec2b320774fffaf621f747cca2e8183; exact-composition raw log SHA256: 8300f2ca860929c93b3a88983602688dcd250402319680c7dfd7a980470f459d.
  • This does not reproduce or clear the reported RX 6300 / RADV / Ubuntu environment, and is not GPU execution evidence for the newer graphics source inherited by the final maintenance head. Main independently changed the test registration to 300 seconds in ae97b16d4a2; that was not used for this diagnostic pair or proposed as an archive fix. A targeted same-RADV-machine clean-main/composition followup, requesting last-subcase output and native thread stacks before the original cap, is prepared locally but has not been posted to the contributor.

Ordering and limits: #12682 remains the declared predecessor, now published at 32121ca48d0abf5e1c11e7c601636d10ec8cb77d; no unpublished candidate was consumed, no I/O owner's branch was edited, and no combined execution is claimed here. #11732 and #12296 are already merged. A later read-only merge check is also clean against fetched main e9032c8e060b417631ec6a2e3116eb1c649d922f (tree 6656a448012741dfc3145624c95dee20f62127a5); this does not relabel that newer main as the executed base. Linux backing requires memfd_create and /proc/self/fd; Windows retains the ordinary private-file snapshot and whole-page EOF behavior. No new macOS, Radeon, game or console execution, full CTest-suite result, or speed result is claimed. Existing approvals apply to their historical reviewed SHAs, not this integration head. Exact-head upstream CI and current-head maintainer review remain external gates.

Historical evidence and previous PR description; historical revisions only

What

November 5 review follow-up, current head 6e2918bffa9d95f46f986f8417b08dbe468fe176: correct the libc app0.zar debt statement to cover archive-only entries outside archive-aware handling, including ordinary path/module resolution and chdir. Source verification: General.cpp ResolvePath_nid_no_patch and ResolvePathOrRelinkedModule_nid_no_patch call AppArchiveRefuseOnly_nid_no_patch, and chdir does likewise; that helper calls NotImplemented_nid_no_patch for archive-only entries. This is a one-sentence documentation change on top of remote maintainer head afe480cff0ab5128712df07cb49b815f2f94e07b; runtime sources and tests are identical to that head.

XairRrR's APPROVED review treats the checked-copy cost and descriptor-mutex hold time as nonblocking suggestions. Per-page checked copies and their partial-progress/cursor/HostWrite semantics remain. A larger-buffer fallback would need to handle already-written bytes when a bulk checked copy fails, retain page-exact partial counts, and be measured before any speed claim. Materialization currently holds the shared attachment mutex throughout decompression/backing writes, so duplicate-descriptor reads, seeks and maps serialize for that window. Snapshotting the node under a shorter lock is a possible follow-up requiring lifetime/concurrency checks. This update records those tradeoffs without changing the implementation or claiming maintainer acceptance of the existing read cost.

November 1 fix at f5d5756c799d2257de279a0963d93068e9f43fff, published in head 91f8d4b237b99a1d996824de43090f452dbce40e: publish the selected mmap errno after exception/resource cleanup. The macOS report is reproduced; the catch selected EIO (5), then exception cleanup changed the host/guest errno slot to ENOENT (2) before return. Mapping now computes its result/error internally and the public wrapper publishes the error after that work has ended. The error classification stays intact: host backing-directory failures and damaged archive data produce EIO, while supported access/resource failures retain their own codes. A missing host temporary path does not mean the already-open guest archive file is missing. Added SCE wrapper checks require the same error and an untouched output pointer on failure.

Bounded requested-window storage, permission/EOF/lifetime semantics and checked reads are retained. The supplied read-cost explanation/benchmark awaits acceptance; this update makes no speed claim. #11732/#12296 ordering is satisfied by their merges; #12682 remains open and is the declared predecessor. Its November 1 inspection pinned head 0e88eeebc91c233aaba95c056c970a1d8b273b36. No I/O cancellation-stack branch (#12682/#12688/#12700/#12965) was changed.

Implement archive-backed file mappings through the regular-file mapping paths. Loose app0 entries still override app0.zar. This is AnyPS5 host ZArchive packaging, not console PFS.

The backing now contains only the requested guest-page-rounded window, clipped at EOF, stored at native offset zero. Linux uses a sealed memfd reopened read-only; Windows/macOS use read-only temporary disk backing. Each live mapping owns independent native storage. No hidden descriptor remains after mmap returns, preserving close/reuse and dup2 behavior. Failed backing writes retain resource errors and clean up without installing a mapping.

Private writable copies, shared read-only permissions, protections, partial unmaps, offsets and EOF retain the established native mapping contract. Linux requires memfd_create and /proc/self/fd. Windows retains regular-file private snapshots and whole-page EOF rejection; macOS execution evidence uses the separately pinned support composition above.

Read copies remain deliberately checked. I audited all actual ReadArchivedFile/ReadArchivedIovecs callers: sceKernelRead, POSIX pread, both host implementations of sceKernelPread, Windows TransferIovecs, POSIX sceKernelReadv/Preadv, and AIO NativePread. Each holds HostWrite/OpenIovecs over its destination. Those guards open watched pages; they do not validate arbitrary pointers. On Linux GuestArenaBeginHostWrite returns true and the write-watch hook is a no-op; on Windows BeginHostWrite checks tracked views, not all arbitrary private/foreign memory. ZArchive copies with CPU stores, so restoring direct destination reads would reintroduce host faults for protected/unmapped pointers. Page-bounded GuestCopyOut preserves EFAULT-before-progress and partial count/cursor semantics. The nested guards also cover direct internal-helper callers. New scalar/positioned/vector/AIO regressions exercise invalid pointers, partial vectors and watched destinations. The measured cost is recorded below, without a title speed claim.

Ordering: #12682 first (replacement for #11872), then this PR, as previously declared. Its current published head is 55161f97476a8bd413c279829cabb6390307e4d5; no candidate is consumed here, and its branches remain untouched. #12296 merged during validation; its Windows shared-memory checks are retained in this rebase, alongside the archive source descriptor and native window offset. #11732 is also merged; its newer VirtualQuery debt text is preserved. Both older order requests are therefore already resolved by main, and neither is an open prerequisite. Direct replies to the outstanding review and ordering comments are recorded in the conversation below.

Tested

November 5 documentation-only verification at 6e2918bffa9d95f46f986f8417b08dbe468fe176: inspected the resolver/chdir refusal paths and the read/materialization locking/copy paths. Conventions (python3 tools/check_conventions.py --base origin/main) and committed-diff whitespace checks passed in an isolated clone against fetched upstream main e772fb25cc72ee5faf77847f06bbc69533016e82. Runtime tests were not rerun for the sentence change. The overlap scan completed against 1,811 open PRs at that main; it reports #15556 on libkernel debt and exits 2 because conflicting-main comparisons remain inconclusive. No new overlap agreement or clean-scan result is claimed.

Independent evidence, pinned to the revisions actually tested:

  • XairRrR's APPROVED review tested PR 783098aabe1d930b25a10c85280ed02a4c219f1f with main 086c0686c8adff3ee648fdbe34e0b0b647e1d511, merged tree e34c6e0da86340e7048a4bdd82ea4c60d3f5f5d1, Debian 13/GCC 14.2 Release. All 22 focused tests passed. Reverting the mapping path made all three mmap modes fail; reverting checked reads made the invalid-destination mmap test segfault. Restoring the implementation and rebuilding restored all five archive passes. The noexec-storage variant was unavailable; only missing-directory independence ran. This review establishes neither Windows results nor a rerun of the benchmark, and its acceptance is not attributed to the latest head.
  • imellag's independent macOS confirmation tested the PR's own diff at 91f8d4b237 on support branch 05bd71a66b, macOS 27.2/M4 Pro/Apple clang 21/x86-64 Rosetta Release: 19/19 archive and file cases pass, including both repaired errno cases, plus three more 9/9 archive runs. #10552 empty-iovec guards were retained. This is support-composition evidence, not a new full-tree macOS or Windows run.

Windows status on maintainer head afe480cff0ab5128712df07cb49b815f2f94e07b: Build run 41823369138, Windows job 126565422963, is CANCELLED, not failed; Linux is SKIPPED. The Windows relinker job passed, which is separate from runtime validation. The cancelled job could not be rerun through the job-specific retry. A focused workflow-dispatch attempt (build.yml, main, pr=11625, linux=false, select=true) was denied: HTTP 403: Must have admin rights to Repository. API repository permissions show pull=true, push/maintain/admin=false; this local host has no Windows runtime. Fresh focused Windows runtime evidence therefore remains unavailable through this account/environment. No cancelled/skipped job is counted as a pass or failure. Earlier Windows results below remain historical.

#12682 remains OPEN and the declared merge-order predecessor (inspected head 32169af1dc395b182370cdf973687d313d33bfc4). #11732/#12296 ordering is satisfied. No other branch was edited or merged. Existing read-cost acceptance and fresh Windows execution remain external requirements; the review's performance suggestions are nonblocking.

Earlier evidence follows with its original platform/head limits.

November 1 exact published head: 91f8d4b237b99a1d996824de43090f452dbce40e. Preserves the remote maintainer merge 4cb2bc9b2cceab3ef2ff7b8d736f7e04bc89ab9e; integrates upstream main 66e1f7f993c9c1339c2de11264b76bab03218cd2 without rewriting history. Runtime validation built source at fix commit f5d5756c799d2257de279a0963d93068e9f43fff; the final main merge changes none of libc/libkernel/libSceLibcInternal, their test sources or SceTypes.hpp, confirmed by tree comparison.

  • Linux Ubuntu 24.04.5/GCC 13.3, Release, LinuxKit 7.0.12 linux/amd64 container on Apple silicon: rebuilt focused executables and production dependencies. 21/22 focused cases passed, including all archive modes, scalar/vector/positioned read, AIO, duplication and error tests. The remaining guest_memory failure is the zero-length mincore user-boundary errno assertion, now GuestMemory.cpp:4225. A fresh build of main 66e1f7f993c9c1339c2de11264b76bab03218cd2 reproduces the identical assertion. userfaultfd returns EPERM here, so actual Linux write-watch collection is unavailable.
  • macOS 27.0.1 (26A434), Apple M5 Pro, Apple clang 21.0.0, x86-64 Release under Rosetta: matched support composition 05bd71a66bed21dea323da545849781b883fe7f0 + this PR's original a294df92fa own diff against de824c2919 + the two-file f5d5756c79 fix. Both reported modes fail before the fix at the original line 924; ordinary mappings pass. After the fix, 15/15 native tests pass: all guest_app_archive and guest_kernel_app_archive modes, guest_file_vector/guest_file_vector_memory, guest_dup, guest_positioned_race, guest_memory and guest_aio. Both #10552 Apple empty-iovec blocks are preserved after archive read error conversion in this support composition. This is support-branch composition evidence, not an assertion that standalone main or the full published tree builds/runs on macOS.
  • Patched macOS coverage: copied the rebuilt libc/libkernel/libSceLibcInternal, applied production nid_patcher and ad-hoc signing, and ran a temporary public-API driver with patched guest imports (--exec --only-sce). All three modes passed: normal mapping (nonzero offset contents, scalar/vector positioned reads, lifetime after descriptor close), missing temporary directory, and damaged archive. Each failure mode repeats both POSIX and SCE boundary checks eight times, checking EIO and unchanged SCE output/cursor. Fixture compression is linked into the driver so its native codec symbols stay local. The complete host-linked regression executable has native helper/weak-import resolution requirements; patched coverage is this focused driver, while the complete archive suite above runs unpatched.
  • Conventions (python3 tools/check_conventions.py --base origin/main), whitespace and public-header audit pass (399 libraries / 26,750 exports). Overlap scan of f5d5756c79 against main 66e1f7f993 completed across 1,848 open PRs, with confirmed adjacency at #10552 (Stdio) and #12271 (debt text). Other conflicting-main comparisons, including #12965, remain inconclusive and the scanner exits nonzero; no clean-overlap claim or new author agreement is made. #10552 composition was inspected and tested as above. Other threads' branches remain untouched.

The macOS support composition is reproducible from patch hashes: original PR diff SHA256 83a1be116e75086554aaaadfe53494e2374d5b29b60eeabcc10dfcc1f00a87ba; two-file fix diff SHA256 677d4d05aed6d41fcb18d79ebab60a0981ec3e1f1b7ea7fc94ed68172d3bdf4e. Temporary instrumentation, driver and logs are outside the repository. No fresh Windows, complete full-suite, GPU, title/console, performance or combined cancellation-stack run is claimed. Earlier evidence below remains pinned to its original heads.

October 31 refresh: exact head a294df92fa9d61d291251a114691a1e689f4d6b0, preserving published head ebf93ca4f62a55df2ef1001b811d1a013a8ef495 and merging upstream main de824c2919ca65086c6324a1e0388866a7327eea. The bounded backing fix was already published in 1440791c77a7e1bbee1684f0726a903ed999dd94; this refresh retains it, the checked reads, and maintainer changes. No history was rewritten and no other I/O head was pushed.

Fresh validation: Ubuntu 24.04.5 / GCC 13.3 / Release / LinuxKit 7.0.12, linux/amd64 container on Apple silicon. Built the selected test targets and their production libc, libSceLibcInternal, libkernel and libkernel_sys dependencies. Focused CTest selection below: 21/22 passed. Every archive, scalar/vector/positioned-read, AIO and descriptor test passed. guest_memory aborted at GuestMemory.cpp:4084 (mincore(0x800000000000, 0, nullptr) errno expectation); after overlaying upstream main and explicitly rebuilding its changed production sources, the identical assertion failed on main too. This is a reproduced baseline/container limitation, not a passing memory suite. userfaultfd returned EPERM, so write-watch collection was unavailable; no actual Linux write-watch coverage is claimed. The archive mmap test also passed a verbose run, including executable mappings with noexec temporary storage.

ctest --test-dir /tmp/anyps5-build -R "^(guest_kernel_app_archive_.*|guest_app_archive_.*|guest_memory|guest_dup|guest_file_vector.*|guest_positioned_race|guest_aio.*|guest_kernel_sys_aio)$" --output-on-failure

Conventions (--base origin/main), whitespace and public-header audit passed (393 libraries / 24,536 exports). Fresh overlap scan ran in an isolated clone at this exact head against 1,558 open PRs: confirmed adjacency with #12271 and #12597 (debt text) and #12868 (Stdio readv/preadv return lines). Manually inspected #12868 at 619546539e534ea4c05e66460f4b79b30d92895a: retain its private-descriptor admission while keeping this PR's archive result-to-SCE conversion. These are integration seams, not duplicate implementations. No new author agreement is claimed; conflicting-main comparisons remain inconclusive and the scan exits nonzero, as designed. The earlier #11732/#12296 order requests are resolved by their merges; #12682 remains the declared predecessor.

Native macOS configuration was attempted but stopped on pre-existing empty LibAtrac9 checkout contents; the original dirty submodules were preserved. No fresh Windows, macOS runtime, full-suite, GPU, title/console, performance, or combined unmerged-stack execution is claimed. The Windows/WSL runs and synthetic benchmark below are historical, pinned to their stated heads; the archive read/backing sources and archive regression file are unchanged between ebf93ca4f6 and this refresh.

Historical evidence follows.

Maintenance source head: ebf93ca4f62a55df2ef1001b811d1a013a8ef495, rebased on fetched main 08a10d225306ad102b57408e2ef7566bcfb829b2. The bounded-window implementation is commit 1440791c77a (before the latest main refresh: 9c840020b8e3b0252cf18c9206f39ee6a42cc37c). Earlier approvals and external bare-metal results at e97bbf0451 are historical, not validation of this head.

On that exact integrated head:

  • Windows 11, WinLibs GCC 15.2, Release, BUILD_TESTING=ON: full production build (libs and relinker) plus focused test executables passed. CTest selection: 24/24 passed, zero skips, longest 2.50 s.
  • Ubuntu 24.04 under WSL2, kernel 6.6.87.2-microsoft-standard-WSL2, GCC 13.3, Release: full production build (libs and relinker) plus focused test executables passed. Same applicable selection: 22/22 passed, zero skips, longest 0.94 s. The two Windows-only cases are excluded.
  • Selection: guest_kernel_app_archive_* (archive/plain/mmap/mmap-failure/mmap-damaged), guest_app_archive_*, guest_memory, guest_dup, guest_file_vector*, guest_positioned_race, guest_aio*, guest_kernel_sys_aio, and Windows windows_write_watch. This covers requested-window backing size/content, offset rebasing, COW/shared permissions, protections, partial unmaps, concurrent maps, descriptor duplication/close/reuse, native-handle cleanup, bad pointers and partial vector progress, HostWrite and AIO destinations. Linux additionally constrains RLIMIT_FSIZE: a one-page window of a larger entry succeeds; a two-page request fails with EFBIG, without leaks/cursor changes, and retries after restoring the limit.
  • Actual Windows write collection passed. WSL asynchronous userfaultfd write watch is unavailable (EINVAL), so Linux uses the comparison fallback; no Linux write-watch support is claimed. Executable mappings with noexec temporary storage are exercised by the Linux archive mmap test.
  • tools/check_conventions.py --base origin/main, git diff --check, and public-header audit passed (373 libraries, 14,243 exports). Required overlap scan completed. The complete GPU/non-GPU CTest suite was not run; unrelated test executables are not part of the full production build command.

Same-machine synthetic archive read measurements, Windows 11, Ryzen 7 9800X3D, WinLibs GCC 15.2, Release. Benchmark source pins: main 1189ec3003672bb364dd9f3119ead7b3976e3c83 versus final integrated implementation ebf93ca4f62a55df2ef1001b811d1a013a8ef495. Main is the baseline fetched at the start of this maintenance pass; it is not relabeled as the later main revision. identical benchmark executable, archive and APIs (sceKernelOpen/Read/Lseek/Close). Three alternating main/change runs, one warm-up per workload per process, seven recorded samples each (21 samples per cell). Large workload: 256 MiB in 256 reads of 1 MiB. Small workload: 65,536 sequential reads of 64 bytes (4 MiB). First/last bytes and checksums are verified per call; archive creation is outside timing. Host compiler jobs were active, so ranges include contention and these are synthetic cost measurements, not controlled game/scene performance evidence. No trace_digest/game speed claim is made.

Workload main median / range (ms) change median / range (ms)
256 MiB, 1 MiB reads 30.205 / 25.129–40.496 122.651 / 110.839–148.501
65,536 × 64-byte reads 10.802 / 9.907–11.638 74.214 / 66.172–84.626

The checked copy has a substantial measured cost. It is retained to preserve the fault/partial-progress contract; HostWrite alone is insufficient. The implementation bounds mapping storage independently of this read-path tradeoff.

No macOS runtime, PS5/console, title, GPU or combined unmerged-dependency runtime result is claimed unless separately pinned below.

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
  • 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: #12682 (agreed merge ordering; replaces #11872)
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
Reproducible synthetic read benchmark
#include "prx/libkernel/include/Api.hpp"
#include "prx/libkernel/File/include/FileFlags.hpp"
#include "prx/libkernel/File/include/File.hpp"
#include "AppArchiveFixture.hpp"
#include <chrono>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <filesystem>
#include <vector>

int main(int argc, char** argv) {
    if (argc != 3) return 2;
    const auto root = std::filesystem::absolute(argv[1]);
    constexpr std::size_t size = 256 * 1024 * 1024;
    if (std::strcmp(argv[2], "setup") == 0) {
        std::filesystem::create_directories(root / "app0" / "sce_sys");
        AppArchiveFixture::WriteArchive(root / "app0.zar", {{"bench.bin", AppArchiveFixture::Pattern(size)}});
        return 0;
    }
    std::filesystem::current_path(root);
    const int fd = sceKernelOpen("/app0/bench.bin", SCE_KERNEL_O_RDONLY, 0);
    if (fd < 0) return 3;
    for (const std::size_t chunk : {std::size_t{1024 * 1024}, std::size_t{64}}) {
        const std::size_t count = chunk == 64 ? 65536 : size / chunk;
        std::vector<char> buffer(chunk);
        for (int sample = -1; sample < 7; ++sample) {
            if (sceKernelLseek(fd, 0, 0) != 0) return 4;
            std::uint64_t checksum = 0;
            const auto begin = std::chrono::steady_clock::now();
            for (std::size_t call = 0; call < count; ++call) {
                if (sceKernelRead(fd, buffer.data(), chunk) != static_cast<std::int64_t>(chunk)) return 5;
                const auto offset = call * chunk;
                if (buffer.front() != static_cast<char>((offset * 7 + offset / 4096) & 0xff) ||
                    buffer.back() != static_cast<char>(((offset + chunk - 1) * 7 + (offset + chunk - 1) / 4096) & 0xff)) return 6;
                checksum += static_cast<unsigned char>(buffer.front()) + static_cast<unsigned char>(buffer.back());
            }
            const auto seconds = std::chrono::duration<double>(std::chrono::steady_clock::now() - begin).count();
            if (sample >= 0) std::printf("{\"sample\":%d,\"chunk\":%zu,\"bytes\":%zu,\"calls\":%zu,\"seconds\":%.9f,\"checksum\":%llu}\n", sample, chunk, chunk * count, count, seconds, static_cast<unsigned long long>(checksum));
        }
    }
    return sceKernelClose(fd) == 0 ? 0 : 7;
}

main 1048576 21 median_ms 30.2049 min 25.1288 max 40.495999999999995
main 64 21 median_ms 10.801699999999999 min 9.9066 max 11.6379
change 1048576 21 median_ms 122.6511 min 110.8392 max 148.5008
change 64 21 median_ms 74.2136 min 66.1716 max 84.6263
archive-read-bench.cpp 409adbe25a2953bca74f574e81d7f1389449c79da1cf4d970769f9968902e8a6
archive-read-bench.exe 2d65d0ed373c3bcc54ccf167e001f4624687cb5a950e89e70fbb0aea2c4aab53
bench-root/app0.zar 06277dbaeed6c5b4b726114361b7a0cd8c55f8661910a8eac072bcd56d06bb47
bench-main/libc.prx 8bf7bd86fc5a488e0eebe2495638f9629038159477ba270de07d224da0726fe7
bench-main/libkernel.prx 23945a6bc4c968f6166d2236da3ab08aec4aded58cf21cb8d6cb452db6d5e9fe
bench-change/libc.prx bbe7f79999dacb46061c39f52e02f2c3d34da0a60d4ba9792dbd9226d5ddb40b
bench-change/libkernel.prx 498587106aff954a7ba581e7d1cff83b939156dae794918cfa81a2c89c45a47b

Historical overlap scan on ebf93ca4f6 (isolated scan clone, branch alias archive-maint-review, same exact SHA): completed against 1,453 open PRs on main 08a10d225306. Confirmed overlaps are this PR itself (same new file), #12682 (Stdio.cpp, declared predecessor), and docs adjacency with #8965 and #12271. The doc-adjacency order is not agreed; no agreement is invented and no contributor message was sent. Other shared-file comparisons that conflict with main remain inconclusive. The earlier #12296 and #11732 requests are already resolved by their merges.

For the later #12682 integration, retain its POSIX Io, descriptor-admission and HostWrite/OpenIovecs scopes, applying the archive native-error conversion separately at the POSIX and SCE return boundaries. The published predecessor head inspected on October 31 is 55161f97476a8bd413c279829cabb6390307e4d5. #12688 transport and #12700 writes remain open downstream of it; they are not additional direct prerequisites of this archive PR. No combined execution with an unpublished refresh is claimed.

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5026139600 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11625). Originally posted by [Felipebmaitan](https://github.com/Felipebmaitan) on 2026-10-26T23:23:17Z. --- ### What Map files from `app0.zar` through the native regular-file path. Each mapping owns a read-only backing object for the requested guest-page-rounded window, clipped at EOF, with a native offset of zero. Loose files take precedence. The mapping survives close or reuse of the guest descriptor, with the existing protection, partial-unmap and host EOF behavior. Archive reads check each destination page before advancing the cursor. HostWrite opens watched pages, while the checked copies handle invalid addresses and preserve partial progress. Materialization holds the shared descriptor attachment lock while it copies, serializing reads, seeks and maps on duplicate descriptors. The branch preserves published head `00a2d202a33c9b09e38321962cefacd1506db1b8` and integrates main through `e481b135558fc4316bc3b24e7408156737eff08d`. It carries main's Windows fixed-private-map bookkeeping, macOS empty-iovec guards and newer archive-descriptor test expectations. The debt edits use a fragment that preserves main's neighboring entries. One independent review inspected the full archive diff at `1b8fea2423fe5b4b5e29900a14153f17ed502dc3`. The follow-up translates Windows backing-write exhaustion to `ENOSPC` or `EFBIG` for the corresponding native error, and checks macOS shared write upgrades against matched loose-file mappings. Windows and Linux still require `EACCES` for the upgrades, and the tests restore read-only protection before checking guest destination faults. The Windows reader now opens with read access and no delete-on-close flag. The writer owns file cleanup. Private mappings finish copying before the reader closes, and shared views keep the native section alive after the descriptor closes. [Lifetime review](https://github.com/boykopovar/AnyPS5/pull/11625#pullrequestreview-5997790960) #12682 remains the declared predecessor. A read-only merge preview with its published head `44fde3b660ac816dace9ac0320f2002d23d5787d` still conflicts in `pread_nid_postfix`. The archive branch by itself previews cleanly against main `e86afa1936367953144e791327ed2161fdb330ea`. After #12682 lands, carry the archive error conversion into its cancellation and pinned-descriptor path and test the combined archive and I/O behavior. #18190's libkernel_sys wrapper refactor separately conflicts in `PosixMemory.cpp` at its published head `dc73ea0d21d3c6fbf9002ab3fee296f312583147`. I compared the 37 unique PRs in the refreshed overlap report against main `c8d5f91168d7d8c208478de6d555b6a34c1c9acf` and against that main composed with this head `4a2b14298c386cf90332d35bbc2e5c8314d2993f`. Newly listed #11831 changes stream lifetime and `fcloseall`; its published head `1c17f817b396eec0d46ddfedccb5a2ab9113493a` merges cleanly in both previews. #18112 contributes a libkernel_web export mirror and already conflicts with main. #7447 introduces a separate archive-stdio source at the same libc CMake registration point. #7121's read notifications add conflicts within its already-conflicting `Open.cpp` and `Stdio.cpp` when combined with the archive read-error changes. #6936 changes archive seeking and already conflicts with main. The other previews showed the same conflict files and the same conflict blocks in archive-touched files as their main comparisons. These overlaps involve separate functionality. The declared prerequisite is still #12682. ### 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. --> - Windows 11 build 26300, WinLibs GCC 15.2, current head `4a2b14298c386cf90332d35bbc2e5c8314d2993f`. The native read-only and executable mapping tests created a section from the materialized reader, closed both the section handle and the reader, then verified the mapped bytes. Both passed, and the isolated backing directory had no temporary backing files after unmap. The descriptor-read and truncated-entry cleanup smoke test also passed. The original reader flags passed the native view lifetime reproducer on this host as well. - Windows 11 build 26300, WinLibs GCC 15.2, integration head `86b4b73041f30a97b5a2521b4fae801b4b141e5b`. The direct backing test passed requested offsets and bytes, read-only access, independent windows, EOF clipping and truncated input. A second test linked the production archive and backing sources with ZArchive and used a real compressed fixture. It passed loose-file precedence, cursor sharing and positioned partial reads with injected copy rejection, and native mapped views that remained readable after closing their handles. - Injected `WriteFile` results `ERROR_HANDLE_DISK_FULL` and `ERROR_FILE_TOO_LARGE` returned `ENOSPC` and `EFBIG` and closed the backing handle. The production archive fixture passed MinGW syntax checks at that integration head. The four changed libkernel translation units passed syntax checks and are byte-identical to those checked. - Conventions against current `origin/main`, debt fragment validation and committed-diff whitespace checks passed. The initial function-name overlap scan completed against 2,239 open PRs. - **26/26 registered Windows guest CTests passed** at `4a2b14298c386cf90332d35bbc2e5c8314d2993f` in 7.08 seconds on Windows 11 build 26300, WinLibs GCC 15.2, Release. The selection covered all nine app archive modes across libc and libkernel, including archive `mmap`, backing failure and damaged input. It also covered filesystem, descriptor duplication, file-vector and positioned I/O, AIO, guest memory, and fixed-anonymous and executable mappings. The archive `mmap` case verified shared and private mapping data after descriptor close or replacement, checked error handling for unwritable guest destinations, and exercised Windows write-watch collection. CMake used the pinned FFmpeg package after its SHA-256 matched the published release. Fresh Linux and macOS execution remains pending. - Hosted checks finished for `4a2b14298c386cf90332d35bbc2e5c8314d2993f` with 20 successes and two skips (the full Linux and pipe-write jobs). The Windows job passed. [Hosted build run](https://github.com/boykopovar/AnyPS5/actions/runs/44797265854) - MarcZX10 approved the current head after targeted source review of the backing, mapping, and checked-read paths. The Windows runtime results above are the author's runs. [Current-head approval](https://github.com/boykopovar/AnyPS5/pull/11625#pullrequestreview-5998050315) - Earlier contributor evidence remains pinned to the revisions tested. ycbuzi reported full CTest runs for previous head `00a2d202a33c9b09e38321962cefacd1506db1b8` composed with main. Windows Server 2022 had 2 failures out of 6,495, both reproduced on main. Windows Server 2025 had 0 out of 6,495. [Contributor runs](https://github.com/ycbuzi/AnyPS5/actions/runs/44722887145) - XairRrR's Debian tests and negative controls, the macOS support-composition results, and earlier author runs are recorded below at their original revisions. ### 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: <!-- #PR, or none --> #12682 - [x] Fixes: <!-- issue it closes as Fixes #N, or none --> none - [x] Unblocks: <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> none - [x] GPUs tested: <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> n/a - [x] AI-assisted: <!-- yes / no --> yes <details> <summary>Earlier descriptions and evidence at their historical revisions</summary> #### What November 7 maintenance head `00a2d202a33c9b09e38321962cefacd1506db1b8`, integrated with main `4138defef7c468835190768e5143e411bce92d6a`. This preserves the complete published `6e2918bffa9d95f46f986f8417b08dbe468fe176` history, including maintainer merges and the macOS mmap error-publication fix. The only integration conflict was the libkernel debt file; both the archive mapping text and main's module-unload debt are retained. No archive runtime implementation was replaced with the stale October checkout, and no graphics source or timeout was changed by this maintenance. Archive-backed mmap uses read-only native backing for the requested guest-page-rounded window, clipped at EOF and mapped from backing offset zero. Mapping lifetime is independent of the guest descriptor and transient backing descriptor. Loose files retain precedence; private writable mappings, shared read-only permissions, protection changes, partial unmaps and descriptor reuse continue through the established regular-file paths. This is host ZArchive packaging, not console PFS. Checked archive reads remain deliberate: audited scalar, positioned, vector and AIO callers open HostWrite/OpenIovecs, but those guards do not make arbitrary destination pointers fault-safe. Page-bounded checked copies retain invalid-buffer and partial-progress/cursor behavior. Materialization holds the shared attachment mutex for the requested window; contention and copy cost remain the previously documented tradeoffs. No new performance claim is made. #### 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. --> Fresh execution on the maintenance head: - Windows 11 build 26300, WinLibs GCC 15.2, Release, `BUILD_TESTING=ON`, `ANYPS5_ENABLE_SPIRV_TOOLS=ON`: full production `libs` and `relinker`, plus the selected runtime executables, rebuilt with at most two jobs. **27/27** focused tests pass after restoration of the negative controls. These include archive/plain/mmap/backing-failure/damaged modes, ordinary mmap and memory, duplication, scalar/positioned/vector reads, AIO, filesystem and actual Windows write-watch/HostWrite behavior. Synthetic archive entries and loose files with identical bytes are compared by the production API fixtures. Every focused case finishes below 30 seconds; the archive cases retain their registered 20-second limits. - Two temporary Windows production-path negative controls: restoring archived mmap refusal makes all three mmap modes fail with the expected refusal while archive/plain reads still pass; replacing only checked archive descriptor reads with the unchecked main implementation makes the invalid-destination mmap case fault while archive/plain still pass. Both changes were removed, production libraries rebuilt, and the complete 27-case selection passed again. No control instrumentation is committed. - Ubuntu 24.04 WSL2, kernel 6.6.87.2-microsoft-standard-WSL2, GCC 13.3, Release, `BUILD_TESTING=ON`, `ANYPS5_ENABLE_SPIRV_TOOLS=OFF`: full production `libs` and `relinker` plus the focused executables built, then rebuilt/restored after the clean-main control. The original registered selection is **23/24**: every archive mode, read/positioned/vector/AIO, duplication, ordinary memory and fixed-anonymous mmap passes; ordinary `guest_mmap_executable` aborts at `GuestMemory.cpp:3583` from its registered DrvFS working directory. A clean checkout of parent main `4138defef7c468835190768e5143e411bce92d6a`, with the fixture unchanged and its actual production dependency graph rebuilt, reproduces that same assertion; both main and the archive head pass that executable mode from unique native ext4 working directories. The main artifact lacks the archive mapping helper; restoration reinstates it. The underlying working-directory-dependent cause is not explained here and no unrelated memory code or timeout was changed. - Final restored Linux selection: **24/24** with only `guest_mmap_executable`'s working directory moved to a unique verified ext4 directory in an untracked temporary CTest registry. Machine-checked JSON comparison verifies all 24 commands and every other test property, including registered timeouts, match the original registry. All other working directories remain unchanged. `guest_filesystem` separately passes from a unique ext4 directory. The original 23/24 result and its failure are retained, rather than relabeled as an unmodified CTest pass. Linux reports asynchronous userfaultfd write protection unavailable (`EINVAL`); HostWrite/data checks execute, but actual Linux write-watch collection is not claimed. Actual collection is asserted by the passing Windows cases. Restored binary hashes and runner definitions/properties are retained in the local validation artifacts. - Public-header audit: **407 libraries / 30,931 exports**. Conventions and committed-diff whitespace checks pass. The overlap scanner completed against 1,765 open PRs, probing 1,764 at main `87473937d31ca4f64d819805b8f0c2b80ac55b53`, and exits **2**: 76 comparisons with PRs conflicting with main remain inconclusive. The confirmed #16861 overlap was manually inspected: adjacent libkernel debt edits, with no archive implementation overlap. Live #7447 at `dead12ebad24a3c4b01a05c14ab60cc06aacaf7d` remains a stdio feature without mmap capability; #6936 at `f06949da78cf801f47702e27f0dd987f4b80e184` adds archive seek modes. Their shared integration paths remain open coordination concerns; neither branch was edited or contacted. No clean scan or new ordering agreement is claimed. A read-only merge-tree check against subsequently fetched main `9e47f0c3accfdd390ef5c578c8a6332048200d5d` is clean (tree `99ac8c8c3e503ee4c3a54d7d72c5ee01c797f40e`); the executed source remains the explicitly pinned maintenance head based on 4138defef7c. Fresh targeted investigation of [the November Radeon timeout report](https://github.com/boykopovar/AnyPS5/pull/11625#issuecomment-6664628747): - Inspected the raw isolated logs and broad tests-only overlay failure. The isolated profile_draw runs time out near their registered 60-second cap. The broad overlay stops compiling `GuestKernelAppArchive.cpp` because main lacks `AppArchiveMappingDescriptor_nid_no_patch`; it never supplies a clean-main graphics runtime control. The report remains **unattributed**. - Built only `agc_driver_graphics_tests` on clean reported main `e772fb25cc72ee5faf77847f06bbc69533016e82` and its exact composition with PR `6e2918bffa9d95f46f986f8417b08dbe468fe176`. The latter is diagnostic commit `15a84102eed7321ad8e5bd94e9f8face06231264`, merged tree `9be29b4ca2233ca17556fade4c26117a5bc9cbbf`. Graphics/recompiler source trees are identical across this pair. This diagnostic commit is not the maintenance PR head or a published feature change. - Both controls **pass** `ctest -R '^agc_graphics_profile_draw$' -V --parallel 1` with the **original registered TIMEOUT 60 unchanged**, same Windows 11 PC, Ryzen 9800X3D, NVIDIA RTX 5080 / NVIDIA 621.14 / Vulkan 1.4.357, GCC 15.2 Release and `ANYPS5_ENABLE_SPIRV_TOOLS=ON`. Both use `ANYPS5_REQUIRE_VULKAN=1`, `ANYPS5_NO_SHADER_CACHE=1`, `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation`. The complete job held `Local\AnyPS5GpuValidation`; no concurrent GPU validation was run by the I/O owner. Local Khronos nightly validation layer API 1.4.368 was verified available with vulkaninfo. - Neither raw CTest log contains the missing-layer message or any `VUID-` ID; there are no new validation IDs. Main raw log SHA256: `ab50509f6f4637815bf8e484722942e05ec2b320774fffaf621f747cca2e8183`; exact-composition raw log SHA256: `8300f2ca860929c93b3a88983602688dcd250402319680c7dfd7a980470f459d`. - This does **not** reproduce or clear the reported RX 6300 / RADV / Ubuntu environment, and is not GPU execution evidence for the newer graphics source inherited by the final maintenance head. Main independently changed the test registration to 300 seconds in `ae97b16d4a2`; that was not used for this diagnostic pair or proposed as an archive fix. A targeted same-RADV-machine clean-main/composition followup, requesting last-subcase output and native thread stacks before the original cap, is prepared locally but has not been posted to the contributor. Ordering and limits: #12682 remains the declared predecessor, now published at `32121ca48d0abf5e1c11e7c601636d10ec8cb77d`; no unpublished candidate was consumed, no I/O owner's branch was edited, and no combined execution is claimed here. #11732 and #12296 are already merged. A later read-only merge check is also clean against fetched main `e9032c8e060b417631ec6a2e3116eb1c649d922f` (tree `6656a448012741dfc3145624c95dee20f62127a5`); this does not relabel that newer main as the executed base. Linux backing requires `memfd_create` and `/proc/self/fd`; Windows retains the ordinary private-file snapshot and whole-page EOF behavior. No new macOS, Radeon, game or console execution, full CTest-suite result, or speed result is claimed. Existing approvals apply to their historical reviewed SHAs, not this integration head. Exact-head upstream CI and current-head maintainer review remain external gates. <details> <summary>Historical evidence and previous PR description; historical revisions only</summary> #### What November 5 review follow-up, current head `6e2918bffa9d95f46f986f8417b08dbe468fe176`: correct the libc app0.zar debt statement to cover archive-only entries outside archive-aware handling, including ordinary path/module resolution and chdir. Source verification: General.cpp ResolvePath_nid_no_patch and ResolvePathOrRelinkedModule_nid_no_patch call AppArchiveRefuseOnly_nid_no_patch, and chdir does likewise; that helper calls NotImplemented_nid_no_patch for archive-only entries. This is a one-sentence documentation change on top of remote maintainer head `afe480cff0ab5128712df07cb49b815f2f94e07b`; runtime sources and tests are identical to that head. XairRrR's APPROVED review treats the checked-copy cost and descriptor-mutex hold time as nonblocking suggestions. Per-page checked copies and their partial-progress/cursor/HostWrite semantics remain. A larger-buffer fallback would need to handle already-written bytes when a bulk checked copy fails, retain page-exact partial counts, and be measured before any speed claim. Materialization currently holds the shared attachment mutex throughout decompression/backing writes, so duplicate-descriptor reads, seeks and maps serialize for that window. Snapshotting the node under a shorter lock is a possible follow-up requiring lifetime/concurrency checks. This update records those tradeoffs without changing the implementation or claiming maintainer acceptance of the existing read cost. November 1 fix at `f5d5756c799d2257de279a0963d93068e9f43fff`, published in head `91f8d4b237b99a1d996824de43090f452dbce40e`: publish the selected mmap errno after exception/resource cleanup. The macOS report is reproduced; the catch selected EIO (5), then exception cleanup changed the host/guest errno slot to ENOENT (2) before return. Mapping now computes its result/error internally and the public wrapper publishes the error after that work has ended. The error classification stays intact: host backing-directory failures and damaged archive data produce EIO, while supported access/resource failures retain their own codes. A missing host temporary path does not mean the already-open guest archive file is missing. Added SCE wrapper checks require the same error and an untouched output pointer on failure. Bounded requested-window storage, permission/EOF/lifetime semantics and checked reads are retained. The supplied read-cost explanation/benchmark awaits acceptance; this update makes no speed claim. #11732/#12296 ordering is satisfied by their merges; #12682 remains open and is the declared predecessor. Its November 1 inspection pinned head `0e88eeebc91c233aaba95c056c970a1d8b273b36`. No I/O cancellation-stack branch (#12682/#12688/#12700/#12965) was changed. Implement archive-backed file mappings through the regular-file mapping paths. Loose app0 entries still override app0.zar. This is AnyPS5 host ZArchive packaging, not console PFS. The backing now contains only the requested guest-page-rounded window, clipped at EOF, stored at native offset zero. Linux uses a sealed memfd reopened read-only; Windows/macOS use read-only temporary disk backing. Each live mapping owns independent native storage. No hidden descriptor remains after mmap returns, preserving close/reuse and dup2 behavior. Failed backing writes retain resource errors and clean up without installing a mapping. Private writable copies, shared read-only permissions, protections, partial unmaps, offsets and EOF retain the established native mapping contract. Linux requires memfd_create and /proc/self/fd. Windows retains regular-file private snapshots and whole-page EOF rejection; macOS execution evidence uses the separately pinned support composition above. Read copies remain deliberately checked. I audited all actual ReadArchivedFile/ReadArchivedIovecs callers: sceKernelRead, POSIX pread, both host implementations of sceKernelPread, Windows TransferIovecs, POSIX sceKernelReadv/Preadv, and AIO NativePread. Each holds HostWrite/OpenIovecs over its destination. Those guards open watched pages; they do not validate arbitrary pointers. On Linux GuestArenaBeginHostWrite returns true and the write-watch hook is a no-op; on Windows BeginHostWrite checks tracked views, not all arbitrary private/foreign memory. ZArchive copies with CPU stores, so restoring direct destination reads would reintroduce host faults for protected/unmapped pointers. Page-bounded GuestCopyOut preserves EFAULT-before-progress and partial count/cursor semantics. The nested guards also cover direct internal-helper callers. New scalar/positioned/vector/AIO regressions exercise invalid pointers, partial vectors and watched destinations. The measured cost is recorded below, without a title speed claim. Ordering: #12682 first (replacement for #11872), then this PR, as previously declared. Its current published head is `55161f97476a8bd413c279829cabb6390307e4d5`; no candidate is consumed here, and its branches remain untouched. #12296 merged during validation; its Windows shared-memory checks are retained in this rebase, alongside the archive source descriptor and native window offset. #11732 is also merged; its newer VirtualQuery debt text is preserved. Both older order requests are therefore already resolved by main, and neither is an open prerequisite. Direct replies to the outstanding review and ordering comments are recorded in the conversation below. #### Tested November 5 documentation-only verification at `6e2918bffa9d95f46f986f8417b08dbe468fe176`: inspected the resolver/chdir refusal paths and the read/materialization locking/copy paths. Conventions (`python3 tools/check_conventions.py --base origin/main`) and committed-diff whitespace checks passed in an isolated clone against fetched upstream main `e772fb25cc72ee5faf77847f06bbc69533016e82`. Runtime tests were not rerun for the sentence change. The overlap scan completed against 1,811 open PRs at that main; it reports #15556 on libkernel debt and exits 2 because conflicting-main comparisons remain inconclusive. No new overlap agreement or clean-scan result is claimed. Independent evidence, pinned to the revisions actually tested: - [XairRrR's APPROVED review](https://github.com/boykopovar/AnyPS5/pull/11625#pullrequestreview-5759305712) tested PR `783098aabe1d930b25a10c85280ed02a4c219f1f` with main `086c0686c8adff3ee648fdbe34e0b0b647e1d511`, merged tree `e34c6e0da86340e7048a4bdd82ea4c60d3f5f5d1`, Debian 13/GCC 14.2 Release. All 22 focused tests passed. Reverting the mapping path made all three mmap modes fail; reverting checked reads made the invalid-destination mmap test segfault. Restoring the implementation and rebuilding restored all five archive passes. The noexec-storage variant was unavailable; only missing-directory independence ran. This review establishes neither Windows results nor a rerun of the benchmark, and its acceptance is not attributed to the latest head. - [imellag's independent macOS confirmation](https://github.com/boykopovar/AnyPS5/pull/11625#issuecomment-6572166998) tested the PR's own diff at `91f8d4b237` on support branch `05bd71a66b`, macOS 27.2/M4 Pro/Apple clang 21/x86-64 Rosetta Release: 19/19 archive and file cases pass, including both repaired errno cases, plus three more 9/9 archive runs. #10552 empty-iovec guards were retained. This is support-composition evidence, not a new full-tree macOS or Windows run. Windows status on maintainer head `afe480cff0ab5128712df07cb49b815f2f94e07b`: Build run `41823369138`, Windows job `126565422963`, is **CANCELLED**, not failed; Linux is **SKIPPED**. The Windows relinker job passed, which is separate from runtime validation. The cancelled job could not be rerun through the job-specific retry. A focused workflow-dispatch attempt (`build.yml`, main, pr=11625, linux=false, select=true) was denied: `HTTP 403: Must have admin rights to Repository.` API repository permissions show pull=true, push/maintain/admin=false; this local host has no Windows runtime. Fresh focused Windows runtime evidence therefore remains unavailable through this account/environment. No cancelled/skipped job is counted as a pass or failure. Earlier Windows results below remain historical. #12682 remains OPEN and the declared merge-order predecessor (inspected head `32169af1dc395b182370cdf973687d313d33bfc4`). #11732/#12296 ordering is satisfied. No other branch was edited or merged. Existing read-cost acceptance and fresh Windows execution remain external requirements; the review's performance suggestions are nonblocking. Earlier evidence follows with its original platform/head limits. November 1 exact published head: `91f8d4b237b99a1d996824de43090f452dbce40e`. Preserves the remote maintainer merge `4cb2bc9b2cceab3ef2ff7b8d736f7e04bc89ab9e`; integrates upstream main `66e1f7f993c9c1339c2de11264b76bab03218cd2` without rewriting history. Runtime validation built source at fix commit `f5d5756c799d2257de279a0963d93068e9f43fff`; the final main merge changes none of libc/libkernel/libSceLibcInternal, their test sources or SceTypes.hpp, confirmed by tree comparison. - Linux Ubuntu 24.04.5/GCC 13.3, Release, LinuxKit 7.0.12 linux/amd64 container on Apple silicon: rebuilt focused executables and production dependencies. **21/22** focused cases passed, including all archive modes, scalar/vector/positioned read, AIO, duplication and error tests. The remaining guest_memory failure is the zero-length mincore user-boundary errno assertion, now GuestMemory.cpp:4225. A fresh build of main `66e1f7f993c9c1339c2de11264b76bab03218cd2` reproduces the identical assertion. userfaultfd returns EPERM here, so actual Linux write-watch collection is unavailable. - macOS 27.0.1 (26A434), Apple M5 Pro, Apple clang 21.0.0, x86-64 Release under Rosetta: matched support composition `05bd71a66bed21dea323da545849781b883fe7f0` + this PR's original a294df92fa own diff against de824c2919 + the two-file f5d5756c79 fix. Both reported modes fail before the fix at the original line 924; ordinary mappings pass. After the fix, **15/15** native tests pass: all guest_app_archive and guest_kernel_app_archive modes, guest_file_vector/guest_file_vector_memory, guest_dup, guest_positioned_race, guest_memory and guest_aio. Both #10552 Apple empty-iovec blocks are preserved after archive read error conversion in this support composition. This is support-branch composition evidence, not an assertion that standalone main or the full published tree builds/runs on macOS. - Patched macOS coverage: copied the rebuilt libc/libkernel/libSceLibcInternal, applied production nid_patcher and ad-hoc signing, and ran a temporary public-API driver with patched guest imports (`--exec --only-sce`). All three modes passed: normal mapping (nonzero offset contents, scalar/vector positioned reads, lifetime after descriptor close), missing temporary directory, and damaged archive. Each failure mode repeats both POSIX and SCE boundary checks eight times, checking EIO and unchanged SCE output/cursor. Fixture compression is linked into the driver so its native codec symbols stay local. The complete host-linked regression executable has native helper/weak-import resolution requirements; patched coverage is this focused driver, while the complete archive suite above runs unpatched. - Conventions (`python3 tools/check_conventions.py --base origin/main`), whitespace and public-header audit pass (399 libraries / 26,750 exports). Overlap scan of f5d5756c79 against main 66e1f7f993 completed across 1,848 open PRs, with confirmed adjacency at #10552 (Stdio) and #12271 (debt text). Other conflicting-main comparisons, including #12965, remain inconclusive and the scanner exits nonzero; no clean-overlap claim or new author agreement is made. #10552 composition was inspected and tested as above. Other threads' branches remain untouched. The macOS support composition is reproducible from patch hashes: original PR diff SHA256 `83a1be116e75086554aaaadfe53494e2374d5b29b60eeabcc10dfcc1f00a87ba`; two-file fix diff SHA256 `677d4d05aed6d41fcb18d79ebab60a0981ec3e1f1b7ea7fc94ed68172d3bdf4e`. Temporary instrumentation, driver and logs are outside the repository. No fresh Windows, complete full-suite, GPU, title/console, performance or combined cancellation-stack run is claimed. Earlier evidence below remains pinned to its original heads. October 31 refresh: exact head `a294df92fa9d61d291251a114691a1e689f4d6b0`, preserving published head `ebf93ca4f62a55df2ef1001b811d1a013a8ef495` and merging upstream main `de824c2919ca65086c6324a1e0388866a7327eea`. The bounded backing fix was already published in `1440791c77a7e1bbee1684f0726a903ed999dd94`; this refresh retains it, the checked reads, and maintainer changes. No history was rewritten and no other I/O head was pushed. Fresh validation: Ubuntu 24.04.5 / GCC 13.3 / Release / LinuxKit 7.0.12, linux/amd64 container on Apple silicon. Built the selected test targets and their production libc, libSceLibcInternal, libkernel and libkernel_sys dependencies. Focused CTest selection below: **21/22 passed**. Every archive, scalar/vector/positioned-read, AIO and descriptor test passed. `guest_memory` aborted at GuestMemory.cpp:4084 (`mincore(0x800000000000, 0, nullptr)` errno expectation); after overlaying upstream main and explicitly rebuilding its changed production sources, the identical assertion failed on main too. This is a reproduced baseline/container limitation, not a passing memory suite. userfaultfd returned EPERM, so write-watch collection was unavailable; no actual Linux write-watch coverage is claimed. The archive mmap test also passed a verbose run, including executable mappings with noexec temporary storage. ``` ctest --test-dir /tmp/anyps5-build -R "^(guest_kernel_app_archive_.*|guest_app_archive_.*|guest_memory|guest_dup|guest_file_vector.*|guest_positioned_race|guest_aio.*|guest_kernel_sys_aio)$" --output-on-failure ``` Conventions (`--base origin/main`), whitespace and public-header audit passed (393 libraries / 24,536 exports). Fresh overlap scan ran in an isolated clone at this exact head against 1,558 open PRs: confirmed adjacency with #12271 and #12597 (debt text) and #12868 (Stdio readv/preadv return lines). Manually inspected #12868 at `619546539e534ea4c05e66460f4b79b30d92895a`: retain its private-descriptor admission while keeping this PR's archive result-to-SCE conversion. These are integration seams, not duplicate implementations. No new author agreement is claimed; conflicting-main comparisons remain inconclusive and the scan exits nonzero, as designed. The earlier #11732/#12296 order requests are resolved by their merges; #12682 remains the declared predecessor. Native macOS configuration was attempted but stopped on pre-existing empty LibAtrac9 checkout contents; the original dirty submodules were preserved. No fresh Windows, macOS runtime, full-suite, GPU, title/console, performance, or combined unmerged-stack execution is claimed. The Windows/WSL runs and synthetic benchmark below are historical, pinned to their stated heads; the archive read/backing sources and archive regression file are unchanged between ebf93ca4f6 and this refresh. Historical evidence follows. Maintenance source head: `ebf93ca4f62a55df2ef1001b811d1a013a8ef495`, rebased on fetched main `08a10d225306ad102b57408e2ef7566bcfb829b2`. The bounded-window implementation is commit `1440791c77a` (before the latest main refresh: `9c840020b8e3b0252cf18c9206f39ee6a42cc37c`). Earlier approvals and external bare-metal results at e97bbf0451 are historical, not validation of this head. On that exact integrated head: - Windows 11, WinLibs GCC 15.2, Release, BUILD_TESTING=ON: full production build (`libs` and `relinker`) plus focused test executables passed. CTest selection: 24/24 passed, zero skips, longest 2.50 s. - Ubuntu 24.04 under WSL2, kernel 6.6.87.2-microsoft-standard-WSL2, GCC 13.3, Release: full production build (`libs` and `relinker`) plus focused test executables passed. Same applicable selection: 22/22 passed, zero skips, longest 0.94 s. The two Windows-only cases are excluded. - Selection: `guest_kernel_app_archive_*` (archive/plain/mmap/mmap-failure/mmap-damaged), `guest_app_archive_*`, `guest_memory`, `guest_dup`, `guest_file_vector*`, `guest_positioned_race`, `guest_aio*`, `guest_kernel_sys_aio`, and Windows `windows_write_watch`. This covers requested-window backing size/content, offset rebasing, COW/shared permissions, protections, partial unmaps, concurrent maps, descriptor duplication/close/reuse, native-handle cleanup, bad pointers and partial vector progress, HostWrite and AIO destinations. Linux additionally constrains RLIMIT_FSIZE: a one-page window of a larger entry succeeds; a two-page request fails with EFBIG, without leaks/cursor changes, and retries after restoring the limit. - Actual Windows write collection passed. WSL asynchronous userfaultfd write watch is unavailable (EINVAL), so Linux uses the comparison fallback; no Linux write-watch support is claimed. Executable mappings with noexec temporary storage are exercised by the Linux archive mmap test. - `tools/check_conventions.py --base origin/main`, `git diff --check`, and public-header audit passed (373 libraries, 14,243 exports). Required overlap scan completed. The complete GPU/non-GPU CTest suite was not run; unrelated test executables are not part of the full production build command. Same-machine synthetic archive read measurements, Windows 11, Ryzen 7 9800X3D, WinLibs GCC 15.2, Release. Benchmark source pins: main `1189ec3003672bb364dd9f3119ead7b3976e3c83` versus final integrated implementation `ebf93ca4f62a55df2ef1001b811d1a013a8ef495`. Main is the baseline fetched at the start of this maintenance pass; it is not relabeled as the later main revision. identical benchmark executable, archive and APIs (sceKernelOpen/Read/Lseek/Close). Three alternating main/change runs, one warm-up per workload per process, seven recorded samples each (21 samples per cell). Large workload: 256 MiB in 256 reads of 1 MiB. Small workload: 65,536 sequential reads of 64 bytes (4 MiB). First/last bytes and checksums are verified per call; archive creation is outside timing. Host compiler jobs were active, so ranges include contention and these are synthetic cost measurements, not controlled game/scene performance evidence. No trace_digest/game speed claim is made. | Workload | main median / range (ms) | change median / range (ms) | |---|---:|---:| | 256 MiB, 1 MiB reads | 30.205 / 25.129–40.496 | 122.651 / 110.839–148.501 | | 65,536 × 64-byte reads | 10.802 / 9.907–11.638 | 74.214 / 66.172–84.626 | The checked copy has a substantial measured cost. It is retained to preserve the fault/partial-progress contract; HostWrite alone is insufficient. The implementation bounds mapping storage independently of this read-path tradeoff. No macOS runtime, PS5/console, title, GPU or combined unmerged-dependency runtime result is claimed unless separately pinned below. <!-- 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. --> #### 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) - [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: #12682 (agreed merge ordering; replaces #11872) <!-- #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 --> <details> <summary>Reproducible synthetic read benchmark</summary> ```cpp #include "prx/libkernel/include/Api.hpp" #include "prx/libkernel/File/include/FileFlags.hpp" #include "prx/libkernel/File/include/File.hpp" #include "AppArchiveFixture.hpp" #include <chrono> #include <cstdio> #include <cstdlib> #include <cstring> #include <filesystem> #include <vector> int main(int argc, char** argv) { if (argc != 3) return 2; const auto root = std::filesystem::absolute(argv[1]); constexpr std::size_t size = 256 * 1024 * 1024; if (std::strcmp(argv[2], "setup") == 0) { std::filesystem::create_directories(root / "app0" / "sce_sys"); AppArchiveFixture::WriteArchive(root / "app0.zar", {{"bench.bin", AppArchiveFixture::Pattern(size)}}); return 0; } std::filesystem::current_path(root); const int fd = sceKernelOpen("/app0/bench.bin", SCE_KERNEL_O_RDONLY, 0); if (fd < 0) return 3; for (const std::size_t chunk : {std::size_t{1024 * 1024}, std::size_t{64}}) { const std::size_t count = chunk == 64 ? 65536 : size / chunk; std::vector<char> buffer(chunk); for (int sample = -1; sample < 7; ++sample) { if (sceKernelLseek(fd, 0, 0) != 0) return 4; std::uint64_t checksum = 0; const auto begin = std::chrono::steady_clock::now(); for (std::size_t call = 0; call < count; ++call) { if (sceKernelRead(fd, buffer.data(), chunk) != static_cast<std::int64_t>(chunk)) return 5; const auto offset = call * chunk; if (buffer.front() != static_cast<char>((offset * 7 + offset / 4096) & 0xff) || buffer.back() != static_cast<char>(((offset + chunk - 1) * 7 + (offset + chunk - 1) / 4096) & 0xff)) return 6; checksum += static_cast<unsigned char>(buffer.front()) + static_cast<unsigned char>(buffer.back()); } const auto seconds = std::chrono::duration<double>(std::chrono::steady_clock::now() - begin).count(); if (sample >= 0) std::printf("{\"sample\":%d,\"chunk\":%zu,\"bytes\":%zu,\"calls\":%zu,\"seconds\":%.9f,\"checksum\":%llu}\n", sample, chunk, chunk * count, count, seconds, static_cast<unsigned long long>(checksum)); } } return sceKernelClose(fd) == 0 ? 0 : 7; } ``` ```text main 1048576 21 median_ms 30.2049 min 25.1288 max 40.495999999999995 main 64 21 median_ms 10.801699999999999 min 9.9066 max 11.6379 change 1048576 21 median_ms 122.6511 min 110.8392 max 148.5008 change 64 21 median_ms 74.2136 min 66.1716 max 84.6263 archive-read-bench.cpp 409adbe25a2953bca74f574e81d7f1389449c79da1cf4d970769f9968902e8a6 archive-read-bench.exe 2d65d0ed373c3bcc54ccf167e001f4624687cb5a950e89e70fbb0aea2c4aab53 bench-root/app0.zar 06277dbaeed6c5b4b726114361b7a0cd8c55f8661910a8eac072bcd56d06bb47 bench-main/libc.prx 8bf7bd86fc5a488e0eebe2495638f9629038159477ba270de07d224da0726fe7 bench-main/libkernel.prx 23945a6bc4c968f6166d2236da3ab08aec4aded58cf21cb8d6cb452db6d5e9fe bench-change/libc.prx bbe7f79999dacb46061c39f52e02f2c3d34da0a60d4ba9792dbd9226d5ddb40b bench-change/libkernel.prx 498587106aff954a7ba581e7d1cff83b939156dae794918cfa81a2c89c45a47b ``` </details> Historical overlap scan on ebf93ca4f6 (isolated scan clone, branch alias `archive-maint-review`, same exact SHA): completed against 1,453 open PRs on main `08a10d225306`. Confirmed overlaps are this PR itself (same new file), #12682 (Stdio.cpp, declared predecessor), and docs adjacency with #8965 and #12271. The doc-adjacency order is not agreed; no agreement is invented and no contributor message was sent. Other shared-file comparisons that conflict with main remain inconclusive. The earlier #12296 and #11732 requests are already resolved by their merges. For the later #12682 integration, retain its POSIX Io, descriptor-admission and HostWrite/OpenIovecs scopes, applying the archive native-error conversion separately at the POSIX and SCE return boundaries. The published predecessor head inspected on October 31 is `55161f97476a8bd413c279829cabb6390307e4d5`. #12688 transport and #12700 writes remain open downstream of it; they are not additional direct prerequisites of this archive PR. No combined execution with an unpublished refresh is claimed. </details> </details>
MarcZX10 commented 2026-10-26 23:36:18 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-26T23:36:18Z.

Review: APPROVED


Reviewed exact head e97bbf045122e4326b0f5332a9844df37bd1d5dc. Archive mappings materialize a request-local read-only backing object, preserve loose-file precedence and descriptor cursor/lifetime semantics, and retain the regular-file mapping path for validation, protections and unmaps. The archive read changes scatter through checked guest writes and translate EFAULT at the public wrappers. The tests cover offset/alignment/EOF behavior, private/shared protections, descriptor replacement/close, partial unmaps, damage and backing failures. Hosted conventions, eligibility, intake, labels, report, register-context, relinker, ASan and write-watch checks pass; product build jobs are skipped by path policy. The author reports Windows and WSL full builds and focused tests, with the DrvFS-only inotify failure explicitly excluded; I did not independently rerun the local suite. I found no blocking issue.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5660519252 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11625#pullrequestreview-5660519252). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-26T23:36:18Z. **Review:** APPROVED --- Reviewed exact head `e97bbf045122e4326b0f5332a9844df37bd1d5dc`. Archive mappings materialize a request-local read-only backing object, preserve loose-file precedence and descriptor cursor/lifetime semantics, and retain the regular-file mapping path for validation, protections and unmaps. The archive read changes scatter through checked guest writes and translate `EFAULT` at the public wrappers. The tests cover offset/alignment/EOF behavior, private/shared protections, descriptor replacement/close, partial unmaps, damage and backing failures. Hosted conventions, eligibility, intake, labels, report, register-context, relinker, ASan and write-watch checks pass; product build jobs are skipped by path policy. The author reports Windows and WSL full builds and focused tests, with the DrvFS-only inotify failure explicitly excluded; I did not independently rerun the local suite. I found no blocking issue.
jotitadev commented 2026-10-27 01:16:48 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-27T01:16:48Z.

Review: COMMENTED


First bare-metal Linux run, since the Linux results in the PR are from WSL2 and the memfd + /proc/self/fd backing is Linux-only.

Exact head e97bbf045122e4326b0f5332a9844df37bd1d5dc, merged on main cb45ae2dd. Linux x86_64 (bare metal, ext4), i7-8700, Ubuntu 26.04, kernel 7.0, GCC 15.2, glibc 2.43, CMake 4.2.3, Ninja, Release, BUILD_TESTING=ON, full build.

  • The 5 guest_kernel_app_archive_* tests (archive, plain, mmap, mmap-failure, mmap-damaged) pass, 3 of 3 runs.
  • guest_filesystem passes here, so the inotify assertion that failed on DrvFS is fine on a native filesystem.
  • A wider subset of 76 file, stdio, mmap and app-archive tests (guest_kernel*, guest_stdio*, guest_file*, guest_mmap*, guest_app*, ...) passes. Full non-GPU suite on the same main without the PR: 1361/1361.
  • With the implementation reverted to main (AppArchive*, the libc CMakeLists.txt, PosixMemory.cpp, ArchivedFile.cpp, Open.cpp, Stdio.cpp; new tests and their CMake modes kept), mmap, mmap-failure and mmap-damaged abort with mmap on a file read from app0.zar, fd=7 not implemented; archive and plain still pass.

Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5661143820 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11625#pullrequestreview-5661143820). Originally posted by [jotitadev](https://github.com/jotitadev) on 2026-10-27T01:16:48Z. **Review:** COMMENTED --- First bare-metal Linux run, since the Linux results in the PR are from WSL2 and the `memfd` + `/proc/self/fd` backing is Linux-only. Exact head `e97bbf045122e4326b0f5332a9844df37bd1d5dc`, merged on `main` `cb45ae2dd`. Linux x86_64 (bare metal, ext4), i7-8700, Ubuntu 26.04, kernel 7.0, GCC 15.2, glibc 2.43, CMake 4.2.3, Ninja, Release, `BUILD_TESTING=ON`, full build. - The 5 `guest_kernel_app_archive_*` tests (`archive`, `plain`, `mmap`, `mmap-failure`, `mmap-damaged`) pass, 3 of 3 runs. - `guest_filesystem` passes here, so the inotify assertion that failed on DrvFS is fine on a native filesystem. - A wider subset of 76 file, stdio, mmap and app-archive tests (`guest_kernel*`, `guest_stdio*`, `guest_file*`, `guest_mmap*`, `guest_app*`, ...) passes. Full non-GPU suite on the same `main` without the PR: 1361/1361. - With the implementation reverted to `main` (`AppArchive*`, the libc `CMakeLists.txt`, `PosixMemory.cpp`, `ArchivedFile.cpp`, `Open.cpp`, `Stdio.cpp`; new tests and their CMake modes kept), `mmap`, `mmap-failure` and `mmap-damaged` abort with `mmap on a file read from app0.zar, fd=7 not implemented`; `archive` and `plain` still pass. Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
XairRrR commented 2026-11-03 20:52:42 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-11-03T20:52:42Z.

Review: APPROVED


Reviewed — approved

mmap on app0.zar files now goes through the regular-file mapping path, backed by a separate read-only copy of the requested window for each mapping. The change builds, the focused tests pass on Linux, and both negative controls fail as expected. I found nothing blocking. There are three non-blocking notes; the main one is the cost of the read path.

What I ran

Head 783098aabe1d930b25a10c85280ed02a4c219f1f, main 086c0686c8adff3ee648fdbe34e0b0b647e1d511, merged with --no-ff in a clean worktree (merged tree e34c6e0da86340e7048a4bdd82ea4c60d3f5f5d1). Debian 13 VM, 2× Xeon Gold 6136, GCC 14.2.0, Release, Ninja, BUILD_TESTING=ON.

git diff --check 086c0686c8adff3ee648fdbe34e0b0b647e1d511...783098aabe1d930b25a10c85280ed02a4c219f1f
python3 tools/check_conventions.py --base 086c0686c8adff3ee648fdbe34e0b0b647e1d511
ctest --test-dir build -j8 --test-load 32 --output-on-failure -R "^(guest_kernel_app_archive_.*|guest_app_archive_.*|guest_memory|guest_dup|guest_file_vector.*|guest_positioned_race|guest_aio.*|guest_kernel_sys_aio)$"
ctest --test-dir build -V -R "^guest_kernel_app_archive_mmap"
# negative control A: PosixMemory.cpp from main
git show 086c0686c8adff3ee648fdbe34e0b0b647e1d511:core/libs/prx/libkernel/DirectMemory/PosixMemory.cpp > core/libs/prx/libkernel/DirectMemory/PosixMemory.cpp
ninja -C build -j32 -l32 guest_kernel_app_archive_tests
ctest --test-dir build -R "^guest_kernel_app_archive_" --output-on-failure
# negative control B: merged tree, but AppArchiveDescriptorRead_nid_no_patch body replaced by main's direct read
ninja -C build -j32 -l32 guest_kernel_app_archive_tests
ctest --test-dir build -R "^guest_kernel_app_archive_" --output-on-failure
# restore merged files, rebuild, rerun
git show e34c6e0da86340e7048a4bdd82ea4c60d3f5f5d1:<path> > <path>
ninja -C build -j32 -l32 guest_kernel_app_archive_tests
ctest --test-dir build -R "^guest_kernel_app_archive_"
git status --porcelain

Results

Check Result
Merge into main clean
git diff --check clean
check_conventions.py All conventions checks passed
Configure / build / libs (script) ok
Script test run (3759 tests selected) 0 new failures, 0 timeouts; 9 known failures that also fail on main; guest_net_ctl skip also happens on main
Focused selection (22 tests) 22/22 passed, total 1.82 s
guest_kernel_app_archive_mmap, -mmap-failure, -mmap-damaged passed, 0.01–0.03 s each
Vulkan validation not applicable (no AGC, shader or VideoOut files changed)
Notes from the verbose mmap run
3486: no writable noexec temporary filesystem available; missing-directory backing independence passed
1/3 Test #3486: guest_kernel_app_archive_mmap ...........   Passed    0.03 sec
2/3 Test #3487: guest_kernel_app_archive_mmap-failure ...   Passed    0.02 sec
3/3 Test #3488: guest_kernel_app_archive_mmap-damaged ...   Passed    0.02 sec

On this machine the noexec-storage branch of MappingStorageIndependence was skipped. Only the missing-directory variant ran.

guest_memory passed here. The author's container run failed it on the zero-length mincore assertion, which they also reproduced on main. That failure does not happen on this machine.

Negative control

  • A: mapping path reverted (PosixMemory.cpp from main, everything else merged). All three mmap modes fail, and archive and plain still pass:
    3/5 Test #3486: guest_kernel_app_archive_mmap ...........Subprocess aborted***Exception
      what():  mmap on a file read from app0.zar, fd=7 not implemented
    4/5 Test #3487: guest_kernel_app_archive_mmap-failure ...Subprocess aborted***Exception
    5/5 Test #3488: guest_kernel_app_archive_mmap-damaged ...Subprocess aborted***Exception
    
  • B: checked read reverted. Merged tree, but AppArchiveDescriptorRead_nid_no_patch uses main's direct AppArchiveRead into the destination. guest_kernel_app_archive_mmap then crashes the host process (***Exception: SegFault), and the other four modes pass. So the bounce-buffer copy is what keeps the new invalid-destination cases (MappingReadDestinations) from crashing. This adds evidence to the second question in oneandonlydean's comment: the outer HostWrite guard alone does not prevent the crash.
  • After restoring the merged files and rebuilding, all 5 archive tests pass again, and git status --porcelain is empty.

Findings

Blocking

None.

Non-blocking

  1. Every app0.zar read now pays the per-page checked copy (core/libs/prx/libc/src/AppArchive.cpp:258 and :277). This affects all archive reads, not only mappings. Each 4 KiB chunk costs one AppArchiveRead plus one GuestCopyOut. The author's own figures show about 4× slower large reads and about 7× slower small reads. Control B confirms the check is needed for safety. However, partial progress only has to be page-exact when a copy fails.
    • Suggested fix: copy through a larger buffer (for example 64 KiB, the size AppArchiveMaterialize_nid_no_patch already uses), and fall back to page-by-page copying only when a chunk's GuestCopyOut fails. That keeps the EFAULT-before-progress and partial-count behaviour and should recover most of the cost on valid destinations.
    • Scope: this read-path hardening is also a separate topic from mapping. The maintainer's acceptance of the cost is still open in the thread.
  2. Window materialization holds the descriptor mutex (core/libs/prx/libc/src/AppArchive.cpp:244-246). AppArchiveMaterialize_nid_no_patch decompresses and writes the whole requested window while holding file->mutex. Reads, seeks and other mappings on the same descriptor, and on its duplicates, which share the attachment, block for the whole copy. That can be a long wait for a large window. It is correct, but the file node could be copied under the lock and the materialization run after releasing it.
  3. The libc debt entry is narrower than the code (docs/dev/debt/libc.md:273 in the merged tree). The rewritten entry lists only fopen, access, lstat and fdopen as unsupported. However, ResolvePath_nid_no_patch and ResolvePathOrRelinkedModule_nid_no_patch (core/libs/prx/libc/src/General.cpp:862-872) still throw for any archive-only path, and so does the chdir path (General.cpp:920). The previous wording ("any call other than the archive-aware libkernel ones throws") was the accurate gap statement. Consider keeping that general sentence instead of the short list.

Not verified

  • Windows (CreateFileW / ReOpenFile delete-on-close backing, private snapshot path) and macOS (mkstemp + unlink backing, the errno-publication fix in f5d5756c79). This machine is Linux only. The macOS fix is covered by imellag's confirmation on the support branch, not by me.
  • The noexec temporary-storage branch of MappingStorageIndependence: no writable noexec filesystem was available here.
  • The author's read benchmark figures. I did not rerun them.
  • Combined behaviour with the declared predecessor #12682 (still open). This PR builds and passes on main without it, so the dependency looks like merge ordering only.
  • Title or console behaviour.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5759305712 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11625#pullrequestreview-5759305712). Originally posted by [XairRrR](https://github.com/XairRrR) on 2026-11-03T20:52:42Z. **Review:** APPROVED --- # Reviewed — approved `mmap` on `app0.zar` files now goes through the regular-file mapping path, backed by a separate read-only copy of the requested window for each mapping. The change builds, the focused tests pass on Linux, and both negative controls fail as expected. I found nothing blocking. There are three non-blocking notes; the main one is the cost of the read path. ## What I ran Head `783098aabe1d930b25a10c85280ed02a4c219f1f`, `main` `086c0686c8adff3ee648fdbe34e0b0b647e1d511`, merged with `--no-ff` in a clean worktree (merged tree `e34c6e0da86340e7048a4bdd82ea4c60d3f5f5d1`). Debian 13 VM, 2× Xeon Gold 6136, GCC 14.2.0, Release, Ninja, `BUILD_TESTING=ON`. ``` git diff --check 086c0686c8adff3ee648fdbe34e0b0b647e1d511...783098aabe1d930b25a10c85280ed02a4c219f1f python3 tools/check_conventions.py --base 086c0686c8adff3ee648fdbe34e0b0b647e1d511 ctest --test-dir build -j8 --test-load 32 --output-on-failure -R "^(guest_kernel_app_archive_.*|guest_app_archive_.*|guest_memory|guest_dup|guest_file_vector.*|guest_positioned_race|guest_aio.*|guest_kernel_sys_aio)$" ctest --test-dir build -V -R "^guest_kernel_app_archive_mmap" # negative control A: PosixMemory.cpp from main git show 086c0686c8adff3ee648fdbe34e0b0b647e1d511:core/libs/prx/libkernel/DirectMemory/PosixMemory.cpp > core/libs/prx/libkernel/DirectMemory/PosixMemory.cpp ninja -C build -j32 -l32 guest_kernel_app_archive_tests ctest --test-dir build -R "^guest_kernel_app_archive_" --output-on-failure # negative control B: merged tree, but AppArchiveDescriptorRead_nid_no_patch body replaced by main's direct read ninja -C build -j32 -l32 guest_kernel_app_archive_tests ctest --test-dir build -R "^guest_kernel_app_archive_" --output-on-failure # restore merged files, rebuild, rerun git show e34c6e0da86340e7048a4bdd82ea4c60d3f5f5d1:<path> > <path> ninja -C build -j32 -l32 guest_kernel_app_archive_tests ctest --test-dir build -R "^guest_kernel_app_archive_" git status --porcelain ``` ## Results | Check | Result | |---|---| | Merge into `main` | clean | | `git diff --check` | clean | | `check_conventions.py` | All conventions checks passed | | Configure / build / `libs` (script) | ok | | Script test run (3759 tests selected) | 0 new failures, 0 timeouts; 9 known failures that also fail on `main`; `guest_net_ctl` skip also happens on `main` | | Focused selection (22 tests) | 22/22 passed, total 1.82 s | | `guest_kernel_app_archive_mmap`, `-mmap-failure`, `-mmap-damaged` | passed, 0.01–0.03 s each | | Vulkan validation | not applicable (no AGC, shader or VideoOut files changed) | <details><summary>Notes from the verbose mmap run</summary> ``` 3486: no writable noexec temporary filesystem available; missing-directory backing independence passed 1/3 Test #3486: guest_kernel_app_archive_mmap ........... Passed 0.03 sec 2/3 Test #3487: guest_kernel_app_archive_mmap-failure ... Passed 0.02 sec 3/3 Test #3488: guest_kernel_app_archive_mmap-damaged ... Passed 0.02 sec ``` On this machine the noexec-storage branch of `MappingStorageIndependence` was skipped. Only the missing-directory variant ran. </details> `guest_memory` passed here. The author's container run failed it on the zero-length `mincore` assertion, which they also reproduced on `main`. That failure does not happen on this machine. ## Negative control - **A: mapping path reverted** (`PosixMemory.cpp` from `main`, everything else merged). All three mmap modes fail, and `archive` and `plain` still pass: ``` 3/5 Test #3486: guest_kernel_app_archive_mmap ...........Subprocess aborted***Exception what(): mmap on a file read from app0.zar, fd=7 not implemented 4/5 Test #3487: guest_kernel_app_archive_mmap-failure ...Subprocess aborted***Exception 5/5 Test #3488: guest_kernel_app_archive_mmap-damaged ...Subprocess aborted***Exception ``` - **B: checked read reverted.** Merged tree, but `AppArchiveDescriptorRead_nid_no_patch` uses `main`'s direct `AppArchiveRead` into the destination. `guest_kernel_app_archive_mmap` then crashes the host process (`***Exception: SegFault`), and the other four modes pass. So the bounce-buffer copy is what keeps the new invalid-destination cases (`MappingReadDestinations`) from crashing. This adds evidence to the second question in oneandonlydean's comment: the outer `HostWrite` guard alone does not prevent the crash. - After restoring the merged files and rebuilding, all 5 archive tests pass again, and `git status --porcelain` is empty. ## Findings ### Blocking None. ### Non-blocking 1. **Every `app0.zar` read now pays the per-page checked copy** (`core/libs/prx/libc/src/AppArchive.cpp:258` and `:277`). This affects all archive reads, not only mappings. Each 4 KiB chunk costs one `AppArchiveRead` plus one `GuestCopyOut`. The author's own figures show about 4× slower large reads and about 7× slower small reads. Control B confirms the check is needed for safety. However, partial progress only has to be page-exact when a copy fails. - Suggested fix: copy through a larger buffer (for example 64 KiB, the size `AppArchiveMaterialize_nid_no_patch` already uses), and fall back to page-by-page copying only when a chunk's `GuestCopyOut` fails. That keeps the EFAULT-before-progress and partial-count behaviour and should recover most of the cost on valid destinations. - Scope: this read-path hardening is also a separate topic from mapping. The maintainer's acceptance of the cost is still open in the thread. 2. **Window materialization holds the descriptor mutex** (`core/libs/prx/libc/src/AppArchive.cpp:244-246`). `AppArchiveMaterialize_nid_no_patch` decompresses and writes the whole requested window while holding `file->mutex`. Reads, seeks and other mappings on the same descriptor, and on its duplicates, which share the attachment, block for the whole copy. That can be a long wait for a large window. It is correct, but the file node could be copied under the lock and the materialization run after releasing it. 3. **The libc debt entry is narrower than the code** (`docs/dev/debt/libc.md:273` in the merged tree). The rewritten entry lists only `fopen`, `access`, `lstat` and `fdopen` as unsupported. However, `ResolvePath_nid_no_patch` and `ResolvePathOrRelinkedModule_nid_no_patch` (`core/libs/prx/libc/src/General.cpp:862-872`) still throw for any archive-only path, and so does the `chdir` path (`General.cpp:920`). The previous wording ("any call other than the archive-aware libkernel ones throws") was the accurate gap statement. Consider keeping that general sentence instead of the short list. ## Not verified - Windows (`CreateFileW` / `ReOpenFile` delete-on-close backing, private snapshot path) and macOS (`mkstemp` + unlink backing, the errno-publication fix in `f5d5756c79`). This machine is Linux only. The macOS fix is covered by imellag's confirmation on the support branch, not by me. - The noexec temporary-storage branch of `MappingStorageIndependence`: no writable noexec filesystem was available here. - The author's read benchmark figures. I did not rerun them. - Combined behaviour with the declared predecessor #12682 (still open). This PR builds and passes on `main` without it, so the dependency looks like merge ordering only. - Title or console behaviour. <!-- anyps5-bots job=2079 head=783098aabe1d930b25a10c85280ed02a4c219f1f -->
MarcZX10 commented 2026-11-14 07:10:34 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-14T07:10:34Z.

Review: COMMENTED


Reviewed — comments

The archive mapping implementation and targeted tests were inspected at head 00a2d202a33c9b09e38321962cefacd1506db1b8; material review requirements remain because not every changed file was read.

What I ran

  • Read the prepared description, commit list, manifest, diff, and selected changed-file and caller ranges through the pinned reader.
  • No build or tests were run in this review; reported test results are author-provided.

Results

Check Result Note
Changed code inspection not run Review was targeted, not exhaustive
Build and tests not run Results in the description are author-reported

Findings

Blocking

None identified in the code inspected.

Non-blocking

None.

Not verified

The full contents of core/libs/prx/libc/CMakeLists.txt, core/libs/prx/libc/include/AppArchive.hpp, core/libs/prx/libkernel/CMakeLists.txt, core/libs/prx/libkernel/File/src/Open.cpp, core/libs/prx/libkernel/File/src/Stdio.cpp, and docs/dev/debt/libc.md and docs/dev/debt/libkernel.md were not read. The full test additions in core/libs/tests/GuestKernelAppArchive.cpp were not read. No build or test was run independently.

To get this to a good state

Nothing is required. Optional: complete inspection of the unread changed-file portions before making a formal approval decision.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5902527439 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11625#pullrequestreview-5902527439). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-14T07:10:34Z. **Review:** COMMENTED --- # Reviewed — comments The archive mapping implementation and targeted tests were inspected at head `00a2d202a33c9b09e38321962cefacd1506db1b8`; material review requirements remain because not every changed file was read. ## What I ran - Read the prepared description, commit list, manifest, diff, and selected changed-file and caller ranges through the pinned reader. - No build or tests were run in this review; reported test results are author-provided. ## Results | Check | Result | Note | |---|---|---| | Changed code inspection | not run | Review was targeted, not exhaustive | | Build and tests | not run | Results in the description are author-reported | ## Findings ### Blocking None identified in the code inspected. ### Non-blocking None. ## Not verified The full contents of `core/libs/prx/libc/CMakeLists.txt`, `core/libs/prx/libc/include/AppArchive.hpp`, `core/libs/prx/libkernel/CMakeLists.txt`, `core/libs/prx/libkernel/File/src/Open.cpp`, `core/libs/prx/libkernel/File/src/Stdio.cpp`, and `docs/dev/debt/libc.md` and `docs/dev/debt/libkernel.md` were not read. The full test additions in `core/libs/tests/GuestKernelAppArchive.cpp` were not read. No build or test was run independently. ## To get this to a good state Nothing is required. Optional: complete inspection of the unread changed-file portions before making a formal approval decision.
MarcZX10 commented 2026-11-20 18:50:11 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T18:50:11Z.

Review: CHANGES_REQUESTED


Reviewed — changes requested

Changes are required before merge: fix the Windows backing handle lifetime so archive mappings remain readable after the temporary descriptor is closed.

What I ran

Reviewed head 86b4b73041f30a97b5a2521b4fae801b4b141e5b using the prepared diff and repo_read.py for targeted source context. No build or test command was run; reported test results are author supplied.

Results

Check Result Note
Source review failed Windows backing lifetime defect
Build and tests not run Current-head runs reported by author

Findings

Blocking

  • core/libs/prx/libc/src/AppArchiveBacking.cpp:104: ReOpenFile opens the reader handle with FILE_FLAG_DELETE_ON_CLOSE. Windows delete-on-close marks the file for deletion when that reader handle closes, regardless of the writer handle still being open. Map then closes the returned descriptor when its local ArchiveMappingDescriptor is destroyed (core/libs/prx/libkernel/DirectMemory/PosixMemory.cpp:62-68), so the backing file can be deleted immediately after mmap returns. For Windows private mappings, MapPrivateFileCopy reads from that descriptor only after returning from the materializer, and Windows shared mappings also need the backing file to stay present for DoMapFileBacked_nid_no_patch; this can cause mapping failure or break later file-backed operations. Avoid delete-on-close on the reader handle and retain a lifetime mechanism that removes the temporary file only after the mapping source is no longer needed.

Non-blocking

None.

Not verified

  • No commands or tests were run in this review. Current-head Windows harnesses and syntax checks are reported in the PR description, not independently verified here; end-to-end guest mmap and fresh Linux/macOS execution are reported as pending.
  • Reviewed all 10 changed files listed in manifest.json; all are marked included. The description, commits, manifest, and diff were read. files.json was not available from the review reader.
  • The remaining 7 lines of description.md and test implementation outside the targeted ranges were not read.

To get this to a good state

Remove the reader handle's delete-on-close behavior and ensure temporary backing storage remains available for the lifetime required by the Windows mapping implementation. Then rerun the Windows archive mmap tests, including mapping survival after the source descriptor closes.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5997790960 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11625#pullrequestreview-5997790960). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-20T18:50:11Z. **Review:** CHANGES_REQUESTED --- # Reviewed — changes requested Changes are required before merge: fix the Windows backing handle lifetime so archive mappings remain readable after the temporary descriptor is closed. ## What I ran Reviewed head `86b4b73041f30a97b5a2521b4fae801b4b141e5b` using the prepared diff and `repo_read.py` for targeted source context. No build or test command was run; reported test results are author supplied. ## Results | Check | Result | Note | |---|---|---| | Source review | failed | Windows backing lifetime defect | | Build and tests | not run | Current-head runs reported by author | ## Findings ### Blocking - `core/libs/prx/libc/src/AppArchiveBacking.cpp:104`: `ReOpenFile` opens the reader handle with `FILE_FLAG_DELETE_ON_CLOSE`. Windows delete-on-close marks the file for deletion when that reader handle closes, regardless of the writer handle still being open. `Map` then closes the returned descriptor when its local `ArchiveMappingDescriptor` is destroyed (`core/libs/prx/libkernel/DirectMemory/PosixMemory.cpp:62-68`), so the backing file can be deleted immediately after `mmap` returns. For Windows private mappings, `MapPrivateFileCopy` reads from that descriptor only after returning from the materializer, and Windows shared mappings also need the backing file to stay present for `DoMapFileBacked_nid_no_patch`; this can cause mapping failure or break later file-backed operations. Avoid delete-on-close on the reader handle and retain a lifetime mechanism that removes the temporary file only after the mapping source is no longer needed. ### Non-blocking None. ## Not verified - No commands or tests were run in this review. Current-head Windows harnesses and syntax checks are reported in the PR description, not independently verified here; end-to-end guest mmap and fresh Linux/macOS execution are reported as pending. - Reviewed all 10 changed files listed in `manifest.json`; all are marked included. The description, commits, manifest, and diff were read. `files.json` was not available from the review reader. - The remaining 7 lines of `description.md` and test implementation outside the targeted ranges were not read. ## To get this to a good state Remove the reader handle's delete-on-close behavior and ensure temporary backing storage remains available for the lifetime required by the Windows mapping implementation. Then rerun the Windows archive mmap tests, including mapping survival after the source descriptor closes.
MarcZX10 commented 2026-11-20 19:12:33 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T19:12:33Z.

Review: APPROVED


Reviewed — looks good

The inspected archive mapping and read paths appear sound; the prepared report records successful Windows checks, while I did not run checks in this review.

What I ran

  • Reviewed head 4a2b14298c386cf90332d35bbc2e5c8314d2993f using the prepared description, commits, manifest, diff, and targeted source ranges through repo_read.py.
  • No commands or tests were run by me. The Windows test results below are reported by the author.

Results

Check Result Note
Targeted source review passed Mapping, backing and checked reads inspected
Windows CTest passed 26/26, author reported
Linux and macOS execution not run Fresh execution remains pending

Findings

Blocking

None in the inspected code.

Non-blocking

  • The materialization path intentionally holds the shared descriptor mutex while copying the requested archive window. Large mappings can therefore serialize reads, seeks and maps through duplicate descriptors; the description records this tradeoff and does not claim a performance improvement.

Sources

Not verified

  • I did not run builds or tests. Windows 11 / WinLibs GCC 15.2 results, including 26/26 registered guest CTests, are author reported in description.md, not independently verified here.
  • Fresh Linux and macOS execution, physical console behavior, and the full repository test suite were not verified.
  • All 10 changed files marked included in manifest.json were read through the prepared diff or targeted source reads; full source text was read for AppArchive.cpp, PosixMemory.cpp, and ArchivedFile.cpp. I did not read every line of GuestKernelAppArchive.cpp, AppArchiveBacking.cpp, Open.cpp, Stdio.cpp, either CMake file, or the debt document. files.json was unavailable through the reader, so excluded-by-rule files were not verified.

To get this to a good state

Nothing is required. Optional: consider measuring the mutex hold time for large mappings before changing the serialization strategy.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5998050315 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11625#pullrequestreview-5998050315). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-20T19:12:33Z. **Review:** APPROVED --- # Reviewed — looks good The inspected archive mapping and read paths appear sound; the prepared report records successful Windows checks, while I did not run checks in this review. ## What I ran - Reviewed head `4a2b14298c386cf90332d35bbc2e5c8314d2993f` using the prepared description, commits, manifest, diff, and targeted source ranges through `repo_read.py`. - No commands or tests were run by me. The Windows test results below are reported by the author. ## Results | Check | Result | Note | |---|---|---| | Targeted source review | passed | Mapping, backing and checked reads inspected | | Windows CTest | passed | 26/26, author reported | | Linux and macOS execution | not run | Fresh execution remains pending | ## Findings ### Blocking None in the inspected code. ### Non-blocking - The materialization path intentionally holds the shared descriptor mutex while copying the requested archive window. Large mappings can therefore serialize reads, seeks and maps through duplicate descriptors; the description records this tradeoff and does not claim a performance improvement. ## Sources - [PosixMemory.cpp at reviewed head](https://github.com/boykopovar/AnyPS5/blob/4a2b14298c386cf90332d35bbc2e5c8314d2993f/core/libs/prx/libkernel/DirectMemory/PosixMemory.cpp) - [AppArchive.cpp at reviewed head](https://github.com/boykopovar/AnyPS5/blob/4a2b14298c386cf90332d35bbc2e5c8314d2993f/core/libs/prx/libc/src/AppArchive.cpp) - [AppArchiveBacking.cpp at reviewed head](https://github.com/boykopovar/AnyPS5/blob/4a2b14298c386cf90332d35bbc2e5c8314d2993f/core/libs/prx/libc/src/AppArchiveBacking.cpp) ## Not verified - I did not run builds or tests. Windows 11 / WinLibs GCC 15.2 results, including 26/26 registered guest CTests, are author reported in `description.md`, not independently verified here. - Fresh Linux and macOS execution, physical console behavior, and the full repository test suite were not verified. - All 10 changed files marked included in `manifest.json` were read through the prepared diff or targeted source reads; full source text was read for `AppArchive.cpp`, `PosixMemory.cpp`, and `ArchivedFile.cpp`. I did not read every line of `GuestKernelAppArchive.cpp`, `AppArchiveBacking.cpp`, `Open.cpp`, `Stdio.cpp`, either CMake file, or the debt document. `files.json` was unavailable through the reader, so excluded-by-rule files were not verified. ## To get this to a good state Nothing is required. Optional: consider measuring the mutex hold time for large mappings before changing the serialization strategy.
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!11625
No description provided.