feat(libkernel_sys): implement pwrite through the shared POSIX provider #9019

Merged
yabanana merged 15 commits from upstream-pr/9019 into main 2026-11-04 17:34:18 +00:00
yabanana commented 2026-10-21 09:54:06 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by yabanana on 2026-10-21T09:54:06Z.


What

Implement libkernel_sys pwrite through libkernel's existing shared 64-bit POSIX provider, retaining descriptor handling, checked argument precedence, guest-memory read preparation and errno translation. Both public exports use the same implementation through PosixPwrite_nid_no_patch; forwarding public symbols would collide after NID patching.

Windows anonymous shared-memory writes remain bounded in positioned, buffered and scalar paths. Fixed-size metadata survives descriptor duplication/reuse. The existing named-object dispatch still follows the anonymous clamp, preserving named-object locking, access checks and bounds. Harry Zixuan Kang's scalar-write fix remains included with authorship.

The merge with main retains its virtual-directory guard in the shared provider, write-access checks before offset/null errors and WriteSync handling. The typed public pwrite declaration remains unique. Export/signature references: PS5 3.20 table and FreeBSD 11.4 write(2).

The Windows named-memory suite is split into basic lifecycle/permissions, descriptor reuse, resize/read and cross-process resize/write cases. All four run in each of the default, short-temp and long-short-temp modes: 12 CTest cases. Stress function bodies, iteration counts and assertions are retained; TIMEOUT stays 20 and the alias modes retain SKIP_RETURN_CODE 77. PROCESSORS accounts for two-thread and three-process cases. No-argument manual execution still runs all phases.

Tested

4 November review update: remote head 1e6b6947b31ab6dcb75e7c31663438d388a16268 retained, including the maintainer's merge. No source change by this update. BunnyFl's native Windows report tests that head merged cleanly with main f6232fcfda:all15 selected cases pass, including both sys pwrite modes,12 named-memory path/phase cases and mapping, with no skips. Exact integration SHA/toolchain version were not supplied; this remains attributed contributor evidence. The firmware13.42 disassembly supports the syscall476 POSIX wrapper shape, not kernel checks or the unresolved maximum-offset row.

B-Howell's earlier-head validation reports29/29 Windows tests3x including aliases,14 Linux tests3x, and a control where both sys pwrite modes abort with main's throwing export. That report belongs to79b02b3bdb integrated with its stated main, not automatically to this head.

Coordination:#13730 declares dependency on#9019 and reuses the same helper; its separate self-import issue is owned there. The closed#11969 write carrier has been replaced by#12700, whose body preserves the accepted#9019-first order and puts IoWrite/WithIoDescriptor inside PosixPwrite_nid_no_patch. Felipebmaitan's report documents34 sys-provider cases and a failing wrong-boundary control on the composed write tree, with no native Windows/combined#13730 qualification. No title unblock is claimed; Unblocks remains none, consistent with CONTRIBUTING and the reviewer's correction.

29 October refresh: head 79b02b3bdbb4301d6f7638d8026b4374b7e22803, integrated main f7e84c4cf1609cc10bac95a44cd431805e5ebc8a. The Windows test conflict retains main's anonymous-descriptor classification regression byte-for-byte in the basic/all phase, without dropping the existing split cases. The requested maximum-offset discrepancy is recorded in libkernel_sys debt; provider behaviour and errno translation are unchanged. Per the maintainer's 29 October response, #9019 goes before #11969, whose cancellation/admission wrappers must then live inside PosixPwrite_nid_no_patch. No combined cancellation-stack execution is claimed.

18/18 focused Linux full-kernel executions pass, including both pwrite modes, descriptor and shared-memory regressions. Complete public-header audit/compilation passes: 373 libraries / 13,451 exports; conventions and whitespace pass. GCC 13.3, Alpine 6.12.110, QEMU system 8.2.2 TCG, cpu=max,smap=off, two vCPUs, 1536 MiB; fresh SHA256-verified binaries. The Windows fixture's new integration has not been run locally on Windows. Previous SMAP-on failure and native Windows/8.3 limits remain explicit; earlier reports below retain their original revisions.

28 October refresh: head d0ac6078bf381adce895d321fb459c33083d5c01, main c02d287bd0eb9fe0718940b2735811e97c2eb509 integrated by normal merge, preserving published ancestry. 18/18 focused Linux full-kernel executions pass on SHA256-verified binaries (GCC 13.3, Alpine 6.12.110, QEMU system 8.2.2 TCG, two vCPUs, 1536 MiB, cpu=max,smap=off). Tests/assertions were not changed. With SMAP enabled, the general kernel test hits a kernel fault at the new upstream context-restore IRET and times out; this CPU profile is not qualified by this refresh. No blanket native-hardware or zero-failure claim is made. Public-header ownership audit passes (368 libraries / 13,051 exports); conventions and whitespace checks pass. Fresh supported Windows runtime/full maintainer CI remains required. Earlier results below retain their original revisions.

Earlier 26 October head 82fafdc208f5f1ab7e4784a98bf90e0f3f02705e, main 84ffc1ae2d968f506505498e49405430ef2f804b integrated with a normal merge; no published-history rewrite.

23/23 Linux full-kernel executions pass: both pwrite DLL modes, common filesystem/vector regressions, descriptor/dup/fcntl/append suites, six named-memory suites, explicit sync/fcntl-sync checks and archive/plain/mmap directory regressions. The fixture also checks read-only access precedence with a null buffer and negative offset. GCC 13.3 cross compiler hosted on ARM64 / Ubuntu 24.04; SHA256-verified binaries execute in Alpine 6.12.110-0-virt under QEMU system 8.2.2 TCG cpu=max, two vCPUs, 1536 MiB. CPU execution is emulated; syscalls execute in the guest kernel.

All-library public-header audit, standalone and combined compilation pass: 368 libraries, 12,234 exports, using native ARM64 Python with the x86-64 cross compiler and unchanged ABI asserts. 33 skip-checker tests, conventions and whitespace checks pass. The actual CMake registration block produces all 12 combinations with the expected arguments, unchanged timeouts/skip policy and processor accounting; all four existing stress-function bodies compare byte-for-byte with the preceding head.

Changed Windows providers and the final named-memory fixture pass MinGW 13.2 UCRT syntax checks; the pwrite fixture cross-links with the available MinGW 13.2 runtime. This is not supported-toolchain native execution.

ycbuzi's latest native rerun tests this exact 82fafdc208 head merged cleanly onto the then-current main (integration SHA not supplied): Windows 11 Home 10.0.26200, WinLibs GCC 15.2.0 r7 UCRT Release, Ryzen 9 7900. Both pwrite modes and all four default-path named-memory phases pass three times idle and three times with 12 CPU-burning loops: 36 successful executions. Every supported phase stays below 0.7 s. All eight alias-mode cases skip with 77 because the drives lack 8.3 aliases; they are not covered by that report. The load is CPU-only, distinct from the earlier parallel build's CPU/disk workload, so the earlier 21.04 s timeout is not treated as an equivalent-load comparison.

Please dispatch fresh full Linux/Windows CI on a runner with 8.3 alias creation and run ctest --repeat until-fail:3 -R '^(guest_kernel_sys_pwrite(_patched)?|guest_named_shm_windows.*)$' --output-on-failure on WinLibs, including a representative CPU/disk workload. All eight alias-mode cases need a volume with 8.3 alias creation. No local native Windows, macOS, console or title execution was performed for this documentation update; the native results above are attributed to the contributor.

Maximum-offset limitation (now recorded in debt; follow-up inputs outstanding): the console EFBIG row still lacks exact count/flags/payload. The prior c1082f49d3 probe through both real providers returned 0 for count 0 and guest EINVAL for counts 1/2 at INT64_MAX on an ordinary O_RDWR file. That evidence remains tied to its original head. No blanket EINVAL remapping was added; the exact console inputs remain requested in the existing thread. Separate macOS append work stays in #10543.

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: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4949697879 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9019). Originally posted by [yabanana](https://github.com/yabanana) on 2026-10-21T09:54:06Z. --- ### What Implement libkernel_sys pwrite through libkernel's existing shared 64-bit POSIX provider, retaining descriptor handling, checked argument precedence, guest-memory read preparation and errno translation. Both public exports use the same implementation through PosixPwrite_nid_no_patch; forwarding public symbols would collide after NID patching. Windows anonymous shared-memory writes remain bounded in positioned, buffered and scalar paths. Fixed-size metadata survives descriptor duplication/reuse. The existing named-object dispatch still follows the anonymous clamp, preserving named-object locking, access checks and bounds. Harry Zixuan Kang's scalar-write fix remains included with authorship. The merge with main retains its virtual-directory guard in the shared provider, write-access checks before offset/null errors and WriteSync handling. The typed public pwrite declaration remains unique. Export/signature references: [PS5 3.20 table](https://github.com/DNNDHH/PS5-3.20_Libs/blob/b2a77c09cd71c01f34c790cfbe98c751a13262ad/libkernel_sys.c) and [FreeBSD 11.4 write(2)](https://github.com/freebsd/freebsd-src/blob/release/11.4.0/lib/libc/sys/write.2). The Windows named-memory suite is split into basic lifecycle/permissions, descriptor reuse, resize/read and cross-process resize/write cases. All four run in each of the default, short-temp and long-short-temp modes: 12 CTest cases. Stress function bodies, iteration counts and assertions are retained; TIMEOUT stays 20 and the alias modes retain SKIP_RETURN_CODE 77. PROCESSORS accounts for two-thread and three-process cases. No-argument manual execution still runs all phases. ### Tested 4 November review update: remote head `1e6b6947b31ab6dcb75e7c31663438d388a16268` retained, including the maintainer's merge. No source change by this update. [BunnyFl's native Windows report](https://github.com/boykopovar/AnyPS5/pull/9019#pullrequestreview-5747074548) tests that head merged cleanly with main f6232fcfda:all15 selected cases pass, including both sys pwrite modes,12 named-memory path/phase cases and mapping, with no skips. Exact integration SHA/toolchain version were not supplied; this remains attributed contributor evidence. The firmware13.42 disassembly supports the syscall476 POSIX wrapper shape, not kernel checks or the unresolved maximum-offset row. [B-Howell's earlier-head validation](https://github.com/boykopovar/AnyPS5/pull/9019#issuecomment-6586787760) reports29/29 Windows tests3x including aliases,14 Linux tests3x, and a control where both sys pwrite modes abort with main's throwing export. That report belongs to79b02b3bdb integrated with its stated main, not automatically to this head. Coordination:#13730 declares dependency on#9019 and reuses the same helper; its separate self-import issue is owned there. The closed#11969 write carrier has been replaced by#12700, whose body preserves the accepted#9019-first order and puts IoWrite/WithIoDescriptor inside PosixPwrite_nid_no_patch. [Felipebmaitan's report](https://github.com/boykopovar/AnyPS5/pull/9019#issuecomment-6591784751) documents34 sys-provider cases and a failing wrong-boundary control on the composed write tree, with no native Windows/combined#13730 qualification. No title unblock is claimed; Unblocks remains none, consistent with CONTRIBUTING and the reviewer's correction. 29 October refresh: head `79b02b3bdbb4301d6f7638d8026b4374b7e22803`, integrated main `f7e84c4cf1609cc10bac95a44cd431805e5ebc8a`. The Windows test conflict retains main's anonymous-descriptor classification regression byte-for-byte in the basic/all phase, without dropping the existing split cases. The requested maximum-offset discrepancy is recorded in libkernel_sys debt; provider behaviour and errno translation are unchanged. Per the maintainer's 29 October response, #9019 goes before #11969, whose cancellation/admission wrappers must then live inside PosixPwrite_nid_no_patch. No combined cancellation-stack execution is claimed. 18/18 focused Linux full-kernel executions pass, including both pwrite modes, descriptor and shared-memory regressions. Complete public-header audit/compilation passes: 373 libraries / 13,451 exports; conventions and whitespace pass. GCC 13.3, Alpine 6.12.110, QEMU system 8.2.2 TCG, cpu=max,smap=off, two vCPUs, 1536 MiB; fresh SHA256-verified binaries. The Windows fixture's new integration has not been run locally on Windows. Previous SMAP-on failure and native Windows/8.3 limits remain explicit; earlier reports below retain their original revisions. 28 October refresh: head `d0ac6078bf381adce895d321fb459c33083d5c01`, main `c02d287bd0eb9fe0718940b2735811e97c2eb509` integrated by normal merge, preserving published ancestry. 18/18 focused Linux full-kernel executions pass on SHA256-verified binaries (GCC 13.3, Alpine 6.12.110, QEMU system 8.2.2 TCG, two vCPUs, 1536 MiB, **cpu=max,smap=off**). Tests/assertions were not changed. With SMAP enabled, the general kernel test hits a kernel fault at the new upstream context-restore IRET and times out; this CPU profile is not qualified by this refresh. No blanket native-hardware or zero-failure claim is made. Public-header ownership audit passes (368 libraries / 13,051 exports); conventions and whitespace checks pass. Fresh supported Windows runtime/full maintainer CI remains required. Earlier results below retain their original revisions. <!-- 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. --> Earlier 26 October head `82fafdc208f5f1ab7e4784a98bf90e0f3f02705e`, main `84ffc1ae2d968f506505498e49405430ef2f804b` integrated with a normal merge; no published-history rewrite. **23/23 Linux full-kernel executions pass:** both pwrite DLL modes, common filesystem/vector regressions, descriptor/dup/fcntl/append suites, six named-memory suites, explicit sync/fcntl-sync checks and archive/plain/mmap directory regressions. The fixture also checks read-only access precedence with a null buffer and negative offset. GCC 13.3 cross compiler hosted on ARM64 / Ubuntu 24.04; SHA256-verified binaries execute in Alpine 6.12.110-0-virt under QEMU system 8.2.2 TCG cpu=max, two vCPUs, 1536 MiB. CPU execution is emulated; syscalls execute in the guest kernel. All-library public-header audit, standalone and combined compilation pass: 368 libraries, 12,234 exports, using native ARM64 Python with the x86-64 cross compiler and unchanged ABI asserts. 33 skip-checker tests, conventions and whitespace checks pass. The actual CMake registration block produces all 12 combinations with the expected arguments, unchanged timeouts/skip policy and processor accounting; all four existing stress-function bodies compare byte-for-byte with the preceding head. Changed Windows providers and the final named-memory fixture pass MinGW 13.2 UCRT syntax checks; the pwrite fixture cross-links with the available MinGW 13.2 runtime. This is not supported-toolchain native execution. [ycbuzi's latest native rerun](https://github.com/boykopovar/AnyPS5/pull/9019#issuecomment-6421584276) tests this exact `82fafdc208` head merged cleanly onto the then-current main (integration SHA not supplied): Windows 11 Home 10.0.26200, WinLibs GCC 15.2.0 r7 UCRT Release, Ryzen 9 7900. Both pwrite modes and all four default-path named-memory phases pass three times idle and three times with 12 CPU-burning loops: **36 successful executions**. Every supported phase stays below 0.7 s. All eight alias-mode cases skip with 77 because the drives lack 8.3 aliases; they are not covered by that report. The load is CPU-only, distinct from the earlier parallel build's CPU/disk workload, so the earlier 21.04 s timeout is not treated as an equivalent-load comparison. Please dispatch fresh full Linux/Windows CI on a runner with 8.3 alias creation and run `ctest --repeat until-fail:3 -R '^(guest_kernel_sys_pwrite(_patched)?|guest_named_shm_windows.*)$' --output-on-failure` on WinLibs, including a representative CPU/disk workload. All eight alias-mode cases need a volume with 8.3 alias creation. No local native Windows, macOS, console or title execution was performed for this documentation update; the native results above are attributed to the contributor. **Maximum-offset limitation (now recorded in debt; follow-up inputs outstanding):** the console EFBIG row still lacks exact count/flags/payload. The prior c1082f49d3 probe through both real providers returned 0 for count 0 and guest EINVAL for counts 1/2 at INT64_MAX on an ordinary O_RDWR file. That evidence remains tied to its original head. No blanket EINVAL remapping was added; the exact console inputs remain requested in the existing thread. Separate macOS append work stays in #10543. ### 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: none <!-- #PR, or none --> - [x] Fixes: none <!-- issue it closes as Fixes #N, or none --> - [x] Unblocks: none <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> - [x] GPUs tested: n/a <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> - [x] AI-assisted: yes <!-- yes / no -->
yabanana commented 2026-10-21 12:25:22 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by yabanana on 2026-10-21T12:25:22Z.


The vector-test verification gap is now closed on the unchanged PR head aaad8e9b8a.

I ran the exact main and candidate ELF binaries in a complete Linux x86-64 guest: Alpine kernel 6.12.110-0-virt, QEMU system 8.2.2 TCG, 2 vCPUs and 1536 MiB RAM. guest_file_vector and guest_file_vector_memory pass on both revisions, including inaccessible iovec tables. All seven candidate executions pass. Main's five existing tests pass; both new pwrite cases fail at the original stub as expected. SHA256 checks confirm all 24 copied test/library binaries match the original builds.

No product code, test expectations or syscall handling changed. The earlier ENOSYS was specific to QEMU user-mode; the full guest kernel executes process_vm_readv. This is still emulated CPU execution, not physical x86-64 or Windows validation. The PR description now records the completed check and preserves the original failure history. Maintainer-dispatched full CI remains pending.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6315842861 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9019#issuecomment-6315842861). Originally posted by [yabanana](https://github.com/yabanana) on 2026-10-21T12:25:22Z. --- The vector-test verification gap is now closed on the unchanged PR head aaad8e9b8a7b2393a170d0dd2d6f5144117a3b00. I ran the exact main and candidate ELF binaries in a complete Linux x86-64 guest: Alpine kernel 6.12.110-0-virt, QEMU system 8.2.2 TCG, 2 vCPUs and 1536 MiB RAM. `guest_file_vector` and `guest_file_vector_memory` pass on both revisions, including inaccessible iovec tables. All seven candidate executions pass. Main's five existing tests pass; both new pwrite cases fail at the original stub as expected. SHA256 checks confirm all 24 copied test/library binaries match the original builds. No product code, test expectations or syscall handling changed. The earlier ENOSYS was specific to QEMU user-mode; the full guest kernel executes `process_vm_readv`. This is still emulated CPU execution, not physical x86-64 or Windows validation. The PR description now records the completed check and preserves the original failure history. Maintainer-dispatched full CI remains pending.
ycbuzi commented 2026-10-21 17:50:59 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ycbuzi on 2026-10-21T17:50:59Z.


Windows run of aaad8e9b8a merged onto main 745b394629 (c72b1a55b4, clean), the build and runtime the description lists as not tested. Windows 11 Home 10.0.26200, MinGW-w64 GCC 15.2.0 (ucrt-posix-seh r7), Release, BUILD_TESTING=ON.

libkernel_sys builds, but guest_kernel_sys_pwrite_tests does not link, and once it does the test stops twice before the end. In order:

  1. Link. undefined reference to '__gxx_personality_v0' from GuestKernelSysPwrite.cpp, NidCompute.cpp and Sha1.cpp. core/libs compiles with -fno-asynchronous-unwind-tables, which on MinGW selects DWARF unwinding, so the objects need the DWARF personality. Tests normally get it from libc, and this target does not link libc. patched_libraries_tests is in the same position and adds -fasynchronous-unwind-tables on MinGW. With that one line the target links:
    target_compile_options(guest_kernel_sys_pwrite_tests PRIVATE -fasynchronous-unwind-tables)
    
  2. Symbol lookup. Both modes then stop at line 51: Missing symbol __error_nid_postfix (unpatched) and Missing symbol 9BcDykPmo1I (patched). libkernel.prx imports __error; libc.prx exports it (objdump -p of both). dlsym on a handle also searches the library's dependencies, but GetProcAddress looks only in that module. Loading libc.prx as well and taking __error from it gets past this on Windows and is the same on Linux.
  3. Past the end of a shared memory object. With both changes, both modes stop at line 138: writeAt(shared, "tail", 4, 0x3ffe) on the 0x4000-byte SHM_ANON object returns 4, not 2. This is not the forwarding: in the same run, libkernel's own pwrite on that object also returns 4. Afterwards lseek(shared, 0, SEEK_END) returns 0x4002 and pread of 8 bytes at 0x3ff8 returns 8. So on Windows, main's pwrite extends an anonymous shared memory object, and this test is the first to check that there.

Every check before line 138 passes in both modes once 1 and 2 are applied. Not run: lines 139 onward, a fix for the shared memory write, a title.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6322736582 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9019#issuecomment-6322736582). Originally posted by [ycbuzi](https://github.com/ycbuzi) on 2026-10-21T17:50:59Z. --- Windows run of aaad8e9b8a merged onto `main` 745b394629 (c72b1a55b4, clean), the build and runtime the description lists as not tested. Windows 11 Home 10.0.26200, MinGW-w64 GCC 15.2.0 (ucrt-posix-seh r7), Release, `BUILD_TESTING=ON`. `libkernel_sys` builds, but `guest_kernel_sys_pwrite_tests` does not link, and once it does the test stops twice before the end. In order: 1. **Link.** `undefined reference to '__gxx_personality_v0'` from `GuestKernelSysPwrite.cpp`, `NidCompute.cpp` and `Sha1.cpp`. `core/libs` compiles with `-fno-asynchronous-unwind-tables`, which on MinGW selects DWARF unwinding, so the objects need the DWARF personality. Tests normally get it from `libc`, and this target does not link `libc`. `patched_libraries_tests` is in the same position and adds `-fasynchronous-unwind-tables` on MinGW. With that one line the target links: ```cmake target_compile_options(guest_kernel_sys_pwrite_tests PRIVATE -fasynchronous-unwind-tables) ``` 2. **Symbol lookup.** Both modes then stop at line 51: `Missing symbol __error_nid_postfix` (unpatched) and `Missing symbol 9BcDykPmo1I` (patched). `libkernel.prx` imports `__error`; `libc.prx` exports it (`objdump -p` of both). `dlsym` on a handle also searches the library's dependencies, but `GetProcAddress` looks only in that module. Loading `libc.prx` as well and taking `__error` from it gets past this on Windows and is the same on Linux. 3. **Past the end of a shared memory object.** With both changes, both modes stop at line 138: `writeAt(shared, "tail", 4, 0x3ffe)` on the 0x4000-byte `SHM_ANON` object returns 4, not 2. This is not the forwarding: in the same run, libkernel's own `pwrite` on that object also returns 4. Afterwards `lseek(shared, 0, SEEK_END)` returns 0x4002 and `pread` of 8 bytes at 0x3ff8 returns 8. So on Windows, `main`'s `pwrite` extends an anonymous shared memory object, and this test is the first to check that there. Every check before line 138 passes in both modes once 1 and 2 are applied. Not run: lines 139 onward, a fix for the shared memory write, a title.
harisibrar1 commented 2026-10-24 13:36:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by harisibrar1 on 2026-10-24T13:36:43Z.

Review: COMMENTED


Checked against main 522e32e3b6:

  • The branch conflicts with main again, in DescriptorControl.hpp/.cpp: 2d1fa5aea5 added bool pipe as the third member of Entry (DescriptorControl.cpp:117-121) and copies it with Entry{false, source.status, source.pipe} (:608), exactly where this PR adds fixedSizeWrites.
  • When you resolve it, please keep both fields but avoid the positional Entry{false, original.status, original.fixedSizeWrites} (:569) and Entry{..., fixedSizeWrites} (:559) forms. With both members present those still compile, but put the SHM flag into pipe, so a dup'ed SHM_ANON descriptor would lose the clamp and be treated as a pipe, and shm_open would mark its descriptor as a pipe. Copying the whole entry (Entry copy = source; copy.closeOnExec = false;) or designated initializers avoid that.
  • Small confirmation: dropping the PwriteSharedMemory_nid_no_patch call from NativePositionedTransfer loses nothing on Windows, since IsHostSharedMemoryDescriptor is Linux-only on main.

Reviewed with AI assistance (Claude Code); the checks above were run locally on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5638434977 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9019#pullrequestreview-5638434977). Originally posted by [harisibrar1](https://github.com/harisibrar1) on 2026-10-24T13:36:43Z. **Review:** COMMENTED --- Checked against main 522e32e3b6: - The branch conflicts with main again, in `DescriptorControl.hpp`/`.cpp`: 2d1fa5aea5 added `bool pipe` as the third member of `Entry` (DescriptorControl.cpp:117-121) and copies it with `Entry{false, source.status, source.pipe}` (:608), exactly where this PR adds `fixedSizeWrites`. - When you resolve it, please keep both fields but avoid the positional `Entry{false, original.status, original.fixedSizeWrites}` (:569) and `Entry{..., fixedSizeWrites}` (:559) forms. With both members present those still compile, but put the SHM flag into `pipe`, so a dup'ed `SHM_ANON` descriptor would lose the clamp and be treated as a pipe, and `shm_open` would mark its descriptor as a pipe. Copying the whole entry (`Entry copy = source; copy.closeOnExec = false;`) or designated initializers avoid that. - Small confirmation: dropping the `PwriteSharedMemory_nid_no_patch` call from `NativePositionedTransfer` loses nothing on Windows, since `IsHostSharedMemoryDescriptor` is Linux-only on main. Reviewed with AI assistance (Claude Code); the checks above were run locally on my machine.
CnRJay commented 2026-11-01 20:04:53 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by CnRJay on 2026-11-01T20:04:53Z.

Review: COMMENTED


Correction (2026-11-01): this review's claim that maintainers close PRs without a title ID is wrong. CONTRIBUTING allows Unblocks: none; a title is only required when the PR fixes a title. The technical points below are unaffected.

These exports come from the libkernel_sys discovery list and the PR names no title ID ("Unblocks: none") and no log line showing a title calling pwrite through libkernel_sys on main. The reference given is a PS5 3.20 export table and FreeBSD man pages, which show that the symbol exists, not that anything running reaches it. Please add the title and the log line; without them export-only work is routinely closed.

Two smaller points: the diff also changes SharedMemory.cpp, Open.cpp and Stdio.cpp (Windows anonymous shared-memory bounding and WriteSync handling), which is a behavior change to existing paths beyond wiring one export; could that be a separate PR with its own reproduction? And the branch has conflicted with main more than once in DescriptorControl, so the merge result should be re-tested on the final head.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5729973300 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9019#pullrequestreview-5729973300). Originally posted by [CnRJay](https://github.com/CnRJay) on 2026-11-01T20:04:53Z. **Review:** COMMENTED --- **Correction (2026-11-01):** this review's claim that maintainers close PRs without a title ID is wrong. CONTRIBUTING allows `Unblocks: none`; a title is only required when the PR fixes a title. The technical points below are unaffected. These exports come from the libkernel_sys discovery list and the PR names no title ID ("Unblocks: none") and no log line showing a title calling `pwrite` through libkernel_sys on `main`. The reference given is a PS5 3.20 export table and FreeBSD man pages, which show that the symbol exists, not that anything running reaches it. Please add the title and the log line; without them export-only work is routinely closed. Two smaller points: the diff also changes `SharedMemory.cpp`, `Open.cpp` and `Stdio.cpp` (Windows anonymous shared-memory bounding and `WriteSync` handling), which is a behavior change to existing paths beyond wiring one export; could that be a separate PR with its own reproduction? And the branch has conflicted with `main` more than once in `DescriptorControl`, so the merge result should be re-tested on the final head.
BunnyFl commented 2026-11-03 03:55:07 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by BunnyFl on 2026-11-03T03:55:07Z.

Review: APPROVED


Windows run of the current head, plus a firmware check of the wrapper.

Windows 11, WinLibs GCC, Release, BUILD_TESTING=ON, head 1e6b6947b3 merged onto current main f6232fcfda (clean merge). All 15 selected tests pass:

  • guest_kernel_sys_pwrite and _patched;
  • the twelve guest_named_shm_windows* cases (lifecycle, reuse, resize/read, resize/write, each in the default, short_temp and long_short_temp modes), with no skips on this machine;
  • guest_named_shm_windows_mapping.

I didn't run a negative control. The tests call the new pwrite exports, which presumably can't pass on main's throwing stub, but I didn't swap files to show it.

Firmware 13.42: system/common/lib/libkernel_sys.sprx (sha256 3d361753f6c472cd5442bf92652b4a1dee04051297a0155fe197ede0c2002d4a) supports the FreeBSD model. This is disassembly only, not measured on a console. The pwrite export (C2kJ-byS5rM, 0x13630) is jmp 0x1f90, and 0x1f90 is a bare mov $0x1dc,%rax; mov %rcx,%r10; syscall that jumps to the errno setter at 0xd4 on carry. That's FreeBSD's syscall 476, pwrite, which suggests the POSIX -1/errno contract this PR follows is the console's shape. The kernel-side checks, such as your recorded INT64_MAX row, remain unmeasured, as the debt entry says.

@harisibrar1's Entry concern is addressed. RememberDescriptor uses designated initialisers, and duplication copies the whole entry (pipe and fixedSizeWrites included) before clearing closeOnExec (core/libs/prx/libkernel/File/src/DescriptorControl.cpp on this head).

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5747074548 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9019#pullrequestreview-5747074548). Originally posted by [BunnyFl](https://github.com/BunnyFl) on 2026-11-03T03:55:07Z. **Review:** APPROVED --- Windows run of the current head, plus a firmware check of the wrapper. **Windows 11, WinLibs GCC, Release, `BUILD_TESTING=ON`,** head `1e6b6947b3` merged onto current `main` `f6232fcfda` (clean merge). All 15 selected tests pass: - `guest_kernel_sys_pwrite` and `_patched`; - the twelve `guest_named_shm_windows*` cases (lifecycle, reuse, resize/read, resize/write, each in the default, `short_temp` and `long_short_temp` modes), with no skips on this machine; - `guest_named_shm_windows_mapping`. I didn't run a negative control. The tests call the new `pwrite` exports, which presumably can't pass on `main`'s throwing stub, but I didn't swap files to show it. **Firmware 13.42:** `system/common/lib/libkernel_sys.sprx` (sha256 `3d361753f6c472cd5442bf92652b4a1dee04051297a0155fe197ede0c2002d4a`) supports the FreeBSD model. This is disassembly only, not measured on a console. The `pwrite` export (`C2kJ-byS5rM`, `0x13630`) is `jmp 0x1f90`, and `0x1f90` is a bare `mov $0x1dc,%rax; mov %rcx,%r10; syscall` that jumps to the errno setter at `0xd4` on carry. That's FreeBSD's syscall 476, `pwrite`, which suggests the POSIX `-1`/errno contract this PR follows is the console's shape. The kernel-side checks, such as your recorded `INT64_MAX` row, remain unmeasured, as the debt entry says. @harisibrar1's `Entry` concern is addressed. `RememberDescriptor` uses designated initialisers, and duplication copies the whole entry (`pipe` and `fixedSizeWrites` included) before clearing `closeOnExec` (`core/libs/prx/libkernel/File/src/DescriptorControl.cpp` on this head).
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!9019
No description provided.