feat(libkernel): export _sigintr and let signal honour it #8866

Merged
ycbuzi merged 3 commits from upstream-pr/8866 into main 2026-10-22 23:19:09 +00:00
ycbuzi commented 2026-10-21 03:43:13 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ycbuzi on 2026-10-21T03:43:13Z.


What

libkernel.prx exports _sigintr (nQVWJEGHObc), the sigset_t that FreeBSD's libc shares between signal and siginterrupt: signal gives a handler SA_RESTART unless its signal is in the set (lib/libc/gen/signal.c, 11.4). The public SDK's libkernel, libkernel_sys and libkernel_web stub tables declare the object, and no built library provided it, so a registry importing it was reported absent (#8846). The object is 16 bytes (four uint32, the SDK's sys/_sigset.h), zero at start, and signal now reads it under the registration lock when it records a handler.

Not included: siginterrupt, which fills the set. On the console it is a libSceLibcInternal export (the SDK's libSceLibcInternal.c declares it; the three kernel tables do not), which AnyPS5 serves from libc.prx, and libc.prx does not link libkernel.prx (the dependency runs the other way), so it cannot reach the dispositions. A guest that writes the set itself gets FreeBSD's behaviour from signal; the function needs a decision on how libc reaches libkernel's signal state and is left for a follow-up. A debt entry for signal says so. Whether the two kernel variants should provide the object as well is the policy question of #8853.

Tested

Windows 11, MinGW GCC 15.2.0, Release, BUILD_TESTING=ON, on main 05f9995704:

  • guest_signals, extended: the set starts zero; signal records SA_RESTART; with bit 29 set (signal 30) it records flags 0 and keeps the handler; signal 31 still gets SA_RESTART; bit 127 (signal 128) clears it the same way; with the bits cleared SA_RESTART comes back. guest_signals passes (1 of 1).
  • Revert check: with the signal change alone restored to main (object and test kept) the test fails at the first flags-0 check; restored, it passes. It exits with 0xc0000409 (the Require abort) on the reverted build and passes again on the restored one.
  • tools/import_audit.py on #8846's one-line registry against the built libraries: implemented 1, absent 0, exit 0 (the issue measured absent 1).
  • python tools/check_conventions.py --base origin/main --head HEAD passes.
  • Not run: Linux.
  • Overlap: #8411 adds a line in sigaction, a few lines below the changed line in signal, and #8700 adds entry points after sigaction and sigsuspend; whichever merges second rebases a few lines. Neither touches _sigintr.

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 (covers the _sigintr import of #8846; siginterrupt stays open there)
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4946054447 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8866). Originally posted by [ycbuzi](https://github.com/ycbuzi) on 2026-10-21T03:43:13Z. --- ### What `libkernel.prx` exports `_sigintr` (`nQVWJEGHObc`), the `sigset_t` that FreeBSD's libc shares between `signal` and `siginterrupt`: `signal` gives a handler `SA_RESTART` unless its signal is in the set (`lib/libc/gen/signal.c`, 11.4). The public SDK's libkernel, libkernel_sys and libkernel_web stub tables declare the object, and no built library provided it, so a registry importing it was reported absent (#8846). The object is 16 bytes (four `uint32`, the SDK's `sys/_sigset.h`), zero at start, and `signal` now reads it under the registration lock when it records a handler. Not included: `siginterrupt`, which fills the set. On the console it is a libSceLibcInternal export (the SDK's `libSceLibcInternal.c` declares it; the three kernel tables do not), which AnyPS5 serves from `libc.prx`, and `libc.prx` does not link `libkernel.prx` (the dependency runs the other way), so it cannot reach the dispositions. A guest that writes the set itself gets FreeBSD's behaviour from `signal`; the function needs a decision on how libc reaches libkernel's signal state and is left for a follow-up. A debt entry for `signal` says so. Whether the two kernel variants should provide the object as well is the policy question of #8853. ### Tested Windows 11, MinGW GCC 15.2.0, Release, `BUILD_TESTING=ON`, on `main` 05f9995704: - `guest_signals`, extended: the set starts zero; `signal` records `SA_RESTART`; with bit 29 set (signal 30) it records flags 0 and keeps the handler; signal 31 still gets `SA_RESTART`; bit 127 (signal 128) clears it the same way; with the bits cleared `SA_RESTART` comes back. `guest_signals` passes (1 of 1). - Revert check: with the `signal` change alone restored to `main` (object and test kept) the test fails at the first flags-0 check; restored, it passes. It exits with `0xc0000409` (the `Require` abort) on the reverted build and passes again on the restored one. - `tools/import_audit.py` on #8846's one-line registry against the built libraries: `implemented 1, absent 0`, exit 0 (the issue measured `absent 1`). - `python tools/check_conventions.py --base origin/main --head HEAD` passes. - Not run: Linux. - Overlap: #8411 adds a line in `sigaction`, a few lines below the changed line in `signal`, and #8700 adds entry points after `sigaction` and `sigsuspend`; whichever merges second rebases a few lines. Neither touches `_sigintr`. ### 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 - [x] Fixes: none (covers the `_sigintr` import of #8846; `siginterrupt` stays open there) - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
MarcZX10 commented 2026-10-21 04:24:41 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-21T04:24:41Z.


Manual review of the overlap warning: #3986 changes the signal masks, raise, and early portions of GuestSignals.cpp; this PR’s production change is in signal_nid_postfix, and its test block is appended at the end, so those hunks are separate. #7201 only changes macOS alarm exception handling in Signals.cpp; #7622 only changes alarm-thread startup. The debt-file warnings are separate entries. I found no conflicting edits in those overlaps. #8872 is correctly listed as depending on this PR.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6308006924 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8866#issuecomment-6308006924). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-21T04:24:41Z. --- Manual review of the overlap warning: #3986 changes the signal masks, `raise`, and early portions of `GuestSignals.cpp`; this PR’s production change is in `signal_nid_postfix`, and its test block is appended at the end, so those hunks are separate. #7201 only changes macOS alarm exception handling in `Signals.cpp`; #7622 only changes alarm-thread startup. The debt-file warnings are separate entries. I found no conflicting edits in those overlaps. #8872 is correctly listed as depending on this PR.
ycbuzi commented 2026-10-21 04:30:59 +00:00 (Migrated from github.com)

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


Thanks for checking the overlaps by hand. Agreed on the hunks: this PR's production change is the one line in signal plus the object, and the test block only appends; the debt entry stays separate from the others on a rebase.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6308084841 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8866#issuecomment-6308084841). Originally posted by [ycbuzi](https://github.com/ycbuzi) on 2026-10-21T04:30:59Z. --- Thanks for checking the overlaps by hand. Agreed on the hunks: this PR's production change is the one line in `signal` plus the object, and the test block only appends; the debt entry stays separate from the others on a rebase.
mazen320 commented 2026-10-21 20:41:05 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by mazen320 on 2026-10-21T20:41:05Z.


Console measurement (PS5 FTP 192.168.0.144, /system/common/lib). Parsed each modules DT_SYMTAB/DT_STRTAB` (no Ghidra).

_sigintr (nQVWJEGHObc)

Module SHA-256 (prefix) st_info bind st_size storage
libkernel.sprx f89a698bf7a0… STT_OBJECT STB_GLOBAL 16 BSS (zero-init)
libkernel_sys.sprx 60921322b155… STT_OBJECT STB_GLOBAL 16 BSS
libkernel_web.sprx 4ab93ee107e8… STT_OBJECT STB_GLOBAL 16 BSS

String form in those modules is nQVWJEGHObc#I#A. That matches a 16-byte sigset_t (four uint32 words) and the FreeBSD zero-init lead in #8846.

  • libSceLibcInternal.sprx has nQVWJEGHObc#A#B as an undefined import (st_size 0, shndx 0), not a provider.
  • siginterrupt (TsrS8nGDQok) is a STT_FUNC in LibcInternal (st_size 128) and is absent from the three kernel modules` dynsym — consistent with putting the function in libc and the bitmap in libkernel (#8872 / #8866 split).

No title run. AI-assisted parse of the pulled SPRX files.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6326080848 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8866#issuecomment-6326080848). Originally posted by [mazen320](https://github.com/mazen320) on 2026-10-21T20:41:05Z. --- Console measurement (PS5 FTP `192.168.0.144`, `/system/common/lib`). Parsed each module`s `DT_SYMTAB`/`DT_STRTAB` (no Ghidra). ### `_sigintr` (`nQVWJEGHObc`) | Module | SHA-256 (prefix) | `st_info` | bind | `st_size` | storage | | --- | --- | --- | --- | --- | --- | | `libkernel.sprx` | `f89a698bf7a0…` | `STT_OBJECT` | `STB_GLOBAL` | **16** | BSS (zero-init) | | `libkernel_sys.sprx` | `60921322b155…` | `STT_OBJECT` | `STB_GLOBAL` | **16** | BSS | | `libkernel_web.sprx` | `4ab93ee107e8…` | `STT_OBJECT` | `STB_GLOBAL` | **16** | BSS | String form in those modules is `nQVWJEGHObc#I#A`. That matches a 16-byte `sigset_t` (four `uint32` words) and the FreeBSD zero-init lead in #8846. ### Related - `libSceLibcInternal.sprx` has `nQVWJEGHObc#A#B` as an **undefined** import (`st_size` 0, `shndx` 0), not a provider. - `siginterrupt` (`TsrS8nGDQok`) is a **`STT_FUNC`** in LibcInternal (`st_size` 128) and is **absent** from the three kernel modules` dynsym — consistent with putting the function in libc and the bitmap in libkernel (#8872 / #8866 split). No title run. AI-assisted parse of the pulled SPRX files.
mazen320 commented 2026-10-21 21:42:46 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by mazen320 on 2026-10-21T21:42:46Z.


Console siginterrupt (TsrS8nGDQok) in libSceLibcInternal.sprx, Ghidra 12.1.4 headless decompile (x86:LE:64:default:gcc), plus NID resolve:

  • Function body size matches dynsym (st_size 128).
  • It imports/uses _sigintr (nQVWJEGHObc) and calls sigaddset (JUimFtKe0Kc).
  • Control flow matches FreeBSD: sigaction query → if flag==0 clear bit in _sigintr and set SA_RESTART (|= 2), else set bit and clear SA_RESTART (&= ~2) → sigaction install. Stack cookie via f7uOxY9mM1U / Ou3iL1abvng.

This is static evidence from the pulled firmware module; no title run. Aligns with #8866/#8872’s FreeBSD-shaped split (bitmap in libkernel, function in libc).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6327202791 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8866#issuecomment-6327202791). Originally posted by [mazen320](https://github.com/mazen320) on 2026-10-21T21:42:46Z. --- Console `siginterrupt` (`TsrS8nGDQok`) in `libSceLibcInternal.sprx`, Ghidra 12.1.4 headless decompile (x86:LE:64:default:gcc), plus NID resolve: - Function body size matches dynsym (`st_size` 128). - It imports/uses `_sigintr` (`nQVWJEGHObc`) and calls `sigaddset` (`JUimFtKe0Kc`). - Control flow matches FreeBSD: `sigaction` query → if `flag==0` clear bit in `_sigintr` and set `SA_RESTART` (`|= 2`), else set bit and clear `SA_RESTART` (`&= ~2`) → `sigaction` install. Stack cookie via `f7uOxY9mM1U` / `Ou3iL1abvng`. This is static evidence from the pulled firmware module; no title run. Aligns with #8866/#8872’s FreeBSD-shaped split (bitmap in libkernel, function in libc).
EagleBearerYS commented 2026-10-22 00:50:25 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-22T00:50:25Z.


@ycbuzi a merge-order note: #9499 adds a SettleReset(guest) call to signal_nid_postfix, right before the action line this PR changes to honour _sigintr. Both lines stay, so the two compose. This one goes first: #9499 lists it under Depends on and rebases on it.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6329957658 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8866#issuecomment-6329957658). Originally posted by [EagleBearerYS](https://github.com/EagleBearerYS) on 2026-10-22T00:50:25Z. --- @ycbuzi a merge-order note: #9499 adds a `SettleReset(guest)` call to `signal_nid_postfix`, right before the action line this PR changes to honour `_sigintr`. Both lines stay, so the two compose. This one goes first: #9499 lists it under Depends on and rebases on it.
harisibrar1 commented 2026-10-22 05:47:35 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by harisibrar1 on 2026-10-22T05:47:35Z.

Review: APPROVED


Checked against main 4a17c7175 and FreeBSD 11.4 lib/libc/gen/signal.c:

  • signal sets SA_RESTART only when the signal is not in _sigintr (!sigismember(&_sigintr, s)), and that is what Signals.cpp:488 does. SignalInSet's word/bit mapping matches _SIG_WORD/_SIG_BIT, so signal 128 lands on bits[3] bit 31 as the test expects.
  • _sigintr_nid_postfix is a plain extern "C" 16-byte zero-initialised global. Main already exports data objects the same way (optind, signgam), and it fits the STT_OBJECT, 16-byte, BSS measurement above.
  • Nit, optional: the existing sigaction entry in docs/dev/debt/libkernel.md still says signal records its handler "with SA_RESTART and an empty mask". That is now true only when the signal is not in _sigintr. Adding "(unless the signal is in _sigintr, see signal below)" would keep the two entries consistent.

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

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5609774036 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8866#pullrequestreview-5609774036). Originally posted by [harisibrar1](https://github.com/harisibrar1) on 2026-10-22T05:47:35Z. **Review:** APPROVED --- Checked against main 4a17c7175 and FreeBSD 11.4 `lib/libc/gen/signal.c`: - `signal` sets `SA_RESTART` only when the signal is not in `_sigintr` (`!sigismember(&_sigintr, s)`), and that is what `Signals.cpp:488` does. `SignalInSet`'s word/bit mapping matches `_SIG_WORD`/`_SIG_BIT`, so signal 128 lands on `bits[3]` bit 31 as the test expects. - `_sigintr_nid_postfix` is a plain `extern "C"` 16-byte zero-initialised global. Main already exports data objects the same way (`optind`, `signgam`), and it fits the STT_OBJECT, 16-byte, BSS measurement above. - Nit, optional: the existing `sigaction` entry in `docs/dev/debt/libkernel.md` still says `signal` records its handler "with `SA_RESTART` and an empty mask". That is now true only when the signal is not in `_sigintr`. Adding "(unless the signal is in `_sigintr`, see `signal` below)" would keep the two entries consistent. Reviewed with AI assistance (Claude Code); the checks above were run locally on my machine.
ycbuzi commented 2026-10-22 06:14:59 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ycbuzi on 2026-10-22T06:14:59Z.


Thanks for the review and the check against signal.c. I left the sigaction entry as it is: it's already 1,426 characters on main, over check_conventions.py's 1,000-character debt-length limit, so editing it here would make this PR carry that warning. The signal entry right below states the _sigintr exception.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6334129505 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8866#issuecomment-6334129505). Originally posted by [ycbuzi](https://github.com/ycbuzi) on 2026-10-22T06:14:59Z. --- Thanks for the review and the check against signal.c. I left the `sigaction` entry as it is: it's already 1,426 characters on `main`, over `check_conventions.py`'s 1,000-character `debt-length` limit, so editing it here would make this PR carry that warning. The `signal` entry right below states the `_sigintr` exception.
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!8866
No description provided.