fix(libkernel): honor all guest signal mask words #5669

Merged
MarcZX10 merged 2 commits from upstream-pr/5669 into main 2026-10-15 15:03:59 +00:00
MarcZX10 commented 2026-10-14 05:44:51 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-14T05:44:51Z.


What

Honor all four words of GuestSignalSet (signals 1–128) in the process blocked mask and sigpending. Previously, block/unblock/set-mask operations only changed word 0, and sigpending only reported pending blocked signals from word 0. High-numbered signals could therefore be raised while blocked and delivered immediately instead of staying pending.

Keep the existing blockedMask low-word atomic and add storage for words 1–3. This remains source-compatible with open PR #5666, whose sigsuspend implementation currently swaps only word 0; that path will need a follow-up to save, replace, and restore the additional words.

Tested

Linux Release build with Ninja: guest_signal_tests built and passed, including new block/raise/pending/unblock checks for signals 40, 73, and 128. python3 tools/check_conventions.py --base upstream/main and git diff --check passed.

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
  • No unimplemented paths or silent stubs added
  • No notes, investigation files, or images added to the repository
  • No new third-party code or dependencies
  • Generic signal behavior
  • Depends on: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4853528050 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5669). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-14T05:44:51Z. --- ### What Honor all four words of `GuestSignalSet` (signals 1–128) in the process blocked mask and `sigpending`. Previously, block/unblock/set-mask operations only changed word 0, and `sigpending` only reported pending blocked signals from word 0. High-numbered signals could therefore be raised while blocked and delivered immediately instead of staying pending. Keep the existing `blockedMask` low-word atomic and add storage for words 1–3. This remains source-compatible with open PR #5666, whose `sigsuspend` implementation currently swaps only word 0; that path will need a follow-up to save, replace, and restore the additional words. ### Tested Linux Release build with Ninja: `guest_signal_tests` built and passed, including new block/raise/pending/unblock checks for signals 40, 73, and 128. `python3 tools/check_conventions.py --base upstream/main` and `git diff --check` passed. ### 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 - [x] No unimplemented paths or silent stubs added - [x] No notes, investigation files, or images added to the repository - [x] No new third-party code or dependencies - [x] Generic signal behavior - [x] Depends on: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
AlexOfTheForest commented 2026-10-14 06:06:32 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by AlexOfTheForest on 2026-10-14T06:06:32Z.


Logic looks right, and the test covers block, pending and delivery for signals in words 1–3.

Structure suggestion: blockedMask plus blockedMaskExtra[3] makes word 0 a special case everywhere (SignalBlocked, _sigprocmask, sigpending). A single std::atomicstd::uint32_t blockedMask[4] would remove the special case and the word - 1 indexing.

Pre-existing, not from this PR: FreeBSD's sigprocmask silently drops SIGKILL (9) and SIGSTOP (17) from the new mask (SIG_CANTMASK), but _sigprocmask stores word 0 as given, so both can be blocked here. Could be a follow-up, now that the mask is being touched.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6162064295 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5669#issuecomment-6162064295). Originally posted by [AlexOfTheForest](https://github.com/AlexOfTheForest) on 2026-10-14T06:06:32Z. --- Logic looks right, and the test covers block, pending and delivery for signals in words 1–3. Structure suggestion: blockedMask plus blockedMaskExtra[3] makes word 0 a special case everywhere (SignalBlocked, _sigprocmask, sigpending). A single std::atomic<std::uint32_t> blockedMask[4] would remove the special case and the word - 1 indexing. Pre-existing, not from this PR: FreeBSD's sigprocmask silently drops SIGKILL (9) and SIGSTOP (17) from the new mask (SIG_CANTMASK), but _sigprocmask stores word 0 as given, so both can be blocked here. Could be a follow-up, now that the mask is being touched.
MarcZX10 commented 2026-10-14 06:08:17 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-14T06:08:17Z.


Thanks for the review. I kept blockedMask as the word-0 scalar because open PR #5666 currently exchanges and restores that symbol in sigsuspend; replacing it before that branch is updated would break its current head. I agree a four-word atomic array is cleaner once #5666 moves to the full mask. The SIGKILL/SIGSTOP filtering is a separate existing behavior; I’ll verify its exact FreeBSD contract and handle it as a distinct follow-up rather than broaden this width fix without a regression case.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6162086724 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5669#issuecomment-6162086724). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-14T06:08:17Z. --- Thanks for the review. I kept `blockedMask` as the word-0 scalar because open PR #5666 currently exchanges and restores that symbol in `sigsuspend`; replacing it before that branch is updated would break its current head. I agree a four-word atomic array is cleaner once #5666 moves to the full mask. The SIGKILL/SIGSTOP filtering is a separate existing behavior; I’ll verify its exact FreeBSD contract and handle it as a distinct follow-up rather than broaden this width fix without a regression case.
adriadam10 commented 2026-10-15 11:56:49 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-15T11:56:49Z.


Checked on Linux (merged onto main): build and ctest green, and guest_signals fails without the Signals.cpp change.

One problem, which we fixed in a commit on your branch: sigsuspend (now on main) saved and restored only word 0, so with this PR it reset the blocked state of signals 33-128 to unblocked after every call, and the argument's words 1-3 were not applied during the wait. It now exchanges and restores all four words, with a test that blocks signal 73 across a sigsuspend (fails without the fix), and the debt entry no longer says the mask is limited to 32 signals.

The blockedMask array and the SIGKILL/SIGSTOP filtering stay as follow-ups, as discussed above.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6191473144 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5669#issuecomment-6191473144). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-15T11:56:49Z. --- Checked on Linux (merged onto main): build and ctest green, and `guest_signals` fails without the `Signals.cpp` change. One problem, which we fixed in a commit on your branch: `sigsuspend` (now on main) saved and restored only word 0, so with this PR it reset the blocked state of signals 33-128 to unblocked after every call, and the argument's words 1-3 were not applied during the wait. It now exchanges and restores all four words, with a test that blocks signal 73 across a `sigsuspend` (fails without the fix), and the debt entry no longer says the mask is limited to 32 signals. The `blockedMask` array and the SIGKILL/SIGSTOP filtering stay as follow-ups, as discussed above.
github-actions[bot] commented 2026-10-15 12:08:30 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T12:08:30Z.


Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 3891 core/libs/tests/GuestSignals.cpp
docs/dev/debt/libkernel.md
PR 3986 core/libs/prx/libkernel/System/src/Signals.cpp
core/libs/tests/GuestSignals.cpp
PR 4156 core/libs/tests/GuestSignals.cpp
docs/dev/debt/libkernel.md
PR 4396 core/libs/tests/GuestSignals.cpp
docs/dev/debt/libkernel.md
PR 4397 core/libs/tests/GuestSignals.cpp
docs/dev/debt/libkernel.md
PR 4422 core/libs/tests/GuestSignals.cpp
docs/dev/debt/libkernel.md
PR 4423 core/libs/tests/GuestSignals.cpp
docs/dev/debt/libkernel.md
PR 4424 core/libs/tests/GuestSignals.cpp
docs/dev/debt/libkernel.md
PR 4520 core/libs/tests/GuestSignals.cpp
docs/dev/debt/libkernel.md
PR 4521 core/libs/tests/GuestSignals.cpp
docs/dev/debt/libkernel.md
PR 4522 core/libs/tests/GuestSignals.cpp
docs/dev/debt/libkernel.md
PR 4523 core/libs/tests/GuestSignals.cpp
docs/dev/debt/libkernel.md
PR 4566 core/libs/tests/GuestSignals.cpp
docs/dev/debt/libkernel.md
PR 4599 core/libs/tests/GuestSignals.cpp
docs/dev/debt/libkernel.md
PR 4718 core/libs/tests/GuestSignals.cpp
docs/dev/debt/libkernel.md
PR 4740 core/libs/tests/GuestSignals.cpp
docs/dev/debt/libkernel.md
PR 4749 core/libs/tests/GuestSignals.cpp
docs/dev/debt/libkernel.md
PR 4760 core/libs/tests/GuestSignals.cpp
docs/dev/debt/libkernel.md
PR 4813 core/libs/tests/GuestSignals.cpp
docs/dev/debt/libkernel.md
PR 5021 core/libs/tests/GuestSignals.cpp
docs/dev/debt/libkernel.md
PR 5835 docs/dev/debt/libkernel.md
PR 6044 core/libs/tests/GuestSignals.cpp
PR 6222 docs/dev/debt/libkernel.md
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6191684231 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5669#issuecomment-6191684231). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-15T12:08:30Z. --- <!-- pr-overlap --> Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap. | Pull request | Shared files not compared | |---|---| | [PR 3891](https://www.github.com/boykopovar/AnyPS5/pull/3891) | `core/libs/tests/GuestSignals.cpp`<br>`docs/dev/debt/libkernel.md` | | [PR 3986](https://www.github.com/boykopovar/AnyPS5/pull/3986) | `core/libs/prx/libkernel/System/src/Signals.cpp`<br>`core/libs/tests/GuestSignals.cpp` | | [PR 4156](https://www.github.com/boykopovar/AnyPS5/pull/4156) | `core/libs/tests/GuestSignals.cpp`<br>`docs/dev/debt/libkernel.md` | | [PR 4396](https://www.github.com/boykopovar/AnyPS5/pull/4396) | `core/libs/tests/GuestSignals.cpp`<br>`docs/dev/debt/libkernel.md` | | [PR 4397](https://www.github.com/boykopovar/AnyPS5/pull/4397) | `core/libs/tests/GuestSignals.cpp`<br>`docs/dev/debt/libkernel.md` | | [PR 4422](https://www.github.com/boykopovar/AnyPS5/pull/4422) | `core/libs/tests/GuestSignals.cpp`<br>`docs/dev/debt/libkernel.md` | | [PR 4423](https://www.github.com/boykopovar/AnyPS5/pull/4423) | `core/libs/tests/GuestSignals.cpp`<br>`docs/dev/debt/libkernel.md` | | [PR 4424](https://www.github.com/boykopovar/AnyPS5/pull/4424) | `core/libs/tests/GuestSignals.cpp`<br>`docs/dev/debt/libkernel.md` | | [PR 4520](https://www.github.com/boykopovar/AnyPS5/pull/4520) | `core/libs/tests/GuestSignals.cpp`<br>`docs/dev/debt/libkernel.md` | | [PR 4521](https://www.github.com/boykopovar/AnyPS5/pull/4521) | `core/libs/tests/GuestSignals.cpp`<br>`docs/dev/debt/libkernel.md` | | [PR 4522](https://www.github.com/boykopovar/AnyPS5/pull/4522) | `core/libs/tests/GuestSignals.cpp`<br>`docs/dev/debt/libkernel.md` | | [PR 4523](https://www.github.com/boykopovar/AnyPS5/pull/4523) | `core/libs/tests/GuestSignals.cpp`<br>`docs/dev/debt/libkernel.md` | | [PR 4566](https://www.github.com/boykopovar/AnyPS5/pull/4566) | `core/libs/tests/GuestSignals.cpp`<br>`docs/dev/debt/libkernel.md` | | [PR 4599](https://www.github.com/boykopovar/AnyPS5/pull/4599) | `core/libs/tests/GuestSignals.cpp`<br>`docs/dev/debt/libkernel.md` | | [PR 4718](https://www.github.com/boykopovar/AnyPS5/pull/4718) | `core/libs/tests/GuestSignals.cpp`<br>`docs/dev/debt/libkernel.md` | | [PR 4740](https://www.github.com/boykopovar/AnyPS5/pull/4740) | `core/libs/tests/GuestSignals.cpp`<br>`docs/dev/debt/libkernel.md` | | [PR 4749](https://www.github.com/boykopovar/AnyPS5/pull/4749) | `core/libs/tests/GuestSignals.cpp`<br>`docs/dev/debt/libkernel.md` | | [PR 4760](https://www.github.com/boykopovar/AnyPS5/pull/4760) | `core/libs/tests/GuestSignals.cpp`<br>`docs/dev/debt/libkernel.md` | | [PR 4813](https://www.github.com/boykopovar/AnyPS5/pull/4813) | `core/libs/tests/GuestSignals.cpp`<br>`docs/dev/debt/libkernel.md` | | [PR 5021](https://www.github.com/boykopovar/AnyPS5/pull/5021) | `core/libs/tests/GuestSignals.cpp`<br>`docs/dev/debt/libkernel.md` | | [PR 5835](https://www.github.com/boykopovar/AnyPS5/pull/5835) | `docs/dev/debt/libkernel.md` | | [PR 6044](https://www.github.com/boykopovar/AnyPS5/pull/6044) | `core/libs/tests/GuestSignals.cpp` | | [PR 6222](https://www.github.com/boykopovar/AnyPS5/pull/6222) | `docs/dev/debt/libkernel.md` |
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!5669
No description provided.