feat(libkernel): accept pipe read ends in sceKernelAddReadEvent #8057

Merged
HQasper merged 2 commits from upstream-pr/8057 into main 2026-10-20 05:31:07 +00:00
HQasper commented 2026-10-19 19:11:36 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by HQasper on 2026-10-19T19:11:36Z.


What

sceKernelAddReadEvent threw for anything but a guest socket, although kevent already accepts EVFILT_READ on the read end of a pipe (FreeBSD filt_piperead). It now registers a read event on a pipe's read end through the same path kevent uses and ignores the size argument there. Host streams, other descriptors and a write event on a pipe still throw, as recorded in docs/dev/debt/libkernel.md.

Tested

Linux (gcc, Release): guest_socket_events passes, including new checks that a pipe read event stays quiet on an empty pipe, reports the readable byte count after a write, wakes a blocked wait when another thread writes, and reports EV_EOF once the write end closes. No title was run.

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:4926044908 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8057). Originally posted by [HQasper](https://github.com/HQasper) on 2026-10-19T19:11:36Z. --- ### What `sceKernelAddReadEvent` threw for anything but a guest socket, although `kevent` already accepts `EVFILT_READ` on the read end of a pipe (FreeBSD `filt_piperead`). It now registers a read event on a pipe's read end through the same path `kevent` uses and ignores the size argument there. Host streams, other descriptors and a write event on a pipe still throw, as recorded in `docs/dev/debt/libkernel.md`. ### Tested Linux (gcc, Release): `guest_socket_events` passes, including new checks that a pipe read event stays quiet on an empty pipe, reports the readable byte count after a write, wakes a blocked wait when another thread writes, and reports `EV_EOF` once the write end closes. No title was run. ### Checklist - [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 - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
HQasper commented 2026-10-19 21:49:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by HQasper on 2026-10-19T21:49:43Z.


Manual check of the files the overlap report could not compare. #7049 and #7509 change Equeue.cpp in CollectTriggered, AddEvent and TriggerEvent, not AddDescriptorEvent. No other open pull request changes sceKernelAddReadEvent: #7075 (EVFILT_WRITE on a pipe's write end) and #7088 (kevent on regular files) change kevent in Kqueue.cpp. #6044 moves GuestSocketEvents.cpp to core/libs/tests/networking/; a merge carries this change's test lines to the new path. The other pull requests share only docs/dev/debt/libkernel.md; merged directly with this branch, each conflicts only where it already conflicts with main.

One wording overlap: #7088's new debt entry ends with "sceKernelAddReadEvent and sceKernelAddWriteEvent still refuse non-socket descriptors", which is no longer true for a pipe's read end once this lands. Whichever merges second should reword that sentence. The pipe entry here now says it is the exception to the sockets-only socket entry before it; that entry itself is left as it is because #7299 edits the line above it. Depends on: none.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6278159763 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8057#issuecomment-6278159763). Originally posted by [HQasper](https://github.com/HQasper) on 2026-10-19T21:49:43Z. --- Manual check of the files the overlap report could not compare. #7049 and #7509 change `Equeue.cpp` in `CollectTriggered`, `AddEvent` and `TriggerEvent`, not `AddDescriptorEvent`. No other open pull request changes `sceKernelAddReadEvent`: #7075 (`EVFILT_WRITE` on a pipe's write end) and #7088 (kevent on regular files) change `kevent` in `Kqueue.cpp`. #6044 moves `GuestSocketEvents.cpp` to `core/libs/tests/networking/`; a merge carries this change's test lines to the new path. The other pull requests share only `docs/dev/debt/libkernel.md`; merged directly with this branch, each conflicts only where it already conflicts with `main`. One wording overlap: #7088's new debt entry ends with "`sceKernelAddReadEvent` and `sceKernelAddWriteEvent` still refuse non-socket descriptors", which is no longer true for a pipe's read end once this lands. Whichever merges second should reword that sentence. The pipe entry here now says it is the exception to the sockets-only socket entry before it; that entry itself is left as it is because #7299 edits the line above it. Depends on: none.
wachi35676 commented 2026-10-19 22:29:08 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by wachi35676 on 2026-10-19T22:29:08Z.


Windows run (the description has Linux only): Windows 11 Home 26300, Ryzen 5 9600X, WinLibs GCC 15.2.0, Release, BUILD_TESTING=ON. This PR merged onto main 9127ea36d.

  • guest_socket_events, including the new pipe checks, passes in every run: 3/3, plus 6 more serial runs.
  • Negative control (Equeue.cpp from main, new test kept): guest_socket_events aborts (0xc0000409).
  • guest_kqueue passes.
  • guest_select is flaky on this loaded machine with or without the change:
    • this PR: 4/8;
    • this PR with Equeue.cpp reverted: 1/8;
    • plain main: 5/6.
      This PR doesn't touch select.
  • Ignoring the size argument for a pipe matches FreeBSD 11.4 filt_piperead. It sets kn_data to the buffered byte count and fires on kn_data > 0 or EOF; it doesn't read NOTE_LOWAT or kn_sdata.

AI-assisted: yes (Claude Code); results above were run on this machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6278777276 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8057#issuecomment-6278777276). Originally posted by [wachi35676](https://github.com/wachi35676) on 2026-10-19T22:29:08Z. --- Windows run (the description has Linux only): Windows 11 Home 26300, Ryzen 5 9600X, WinLibs GCC 15.2.0, Release, BUILD_TESTING=ON. This PR merged onto `main` 9127ea36d. - `guest_socket_events`, including the new pipe checks, passes in every run: 3/3, plus 6 more serial runs. - Negative control (`Equeue.cpp` from `main`, new test kept): `guest_socket_events` aborts (0xc0000409). - `guest_kqueue` passes. - `guest_select` is flaky on this loaded machine with or without the change: - this PR: 4/8; - this PR with `Equeue.cpp` reverted: 1/8; - plain `main`: 5/6. This PR doesn't touch select. - Ignoring the size argument for a pipe matches FreeBSD 11.4 [`filt_piperead`](https://github.com/freebsd/freebsd-src/blob/release/11.4.0/sys/kern/sys_pipe.c#L1790-L1809). It sets `kn_data` to the buffered byte count and fires on `kn_data > 0` or EOF; it doesn't read `NOTE_LOWAT` or `kn_sdata`. AI-assisted: yes (Claude Code); results above were run on this machine.
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!8057
No description provided.