feat(libkernel): answer getrlimit for FreeBSD resources #3765

Merged
pushkarreddyy merged 1 commit from upstream-pr/3765 into main 2026-10-12 11:44:49 +00:00
pushkarreddyy commented 2026-10-11 16:35:14 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by pushkarreddyy on 2026-10-11T16:35:14Z.


What

This pull request implements FreeBSD 11 process-0 baseline resource limits in getrlimit within libkernel:

  • getrlimit(resource, limit):
    • Populates RLIM_INFINITY (
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4820597580 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3765). Originally posted by [pushkarreddyy](https://github.com/pushkarreddyy) on 2026-10-11T16:35:14Z. --- ### What This pull request implements FreeBSD 11 process-0 baseline resource limits in getrlimit within libkernel: - **getrlimit(resource, limit)**: - Populates RLIM_INFINITY (
adriadam10 commented 2026-10-11 16:37:03 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T16:37:03Z.

Review: DISMISSED


Thanks. The getrlimit part checks out: the nine values match FreeBSD 11.4 proc0_init (sys/kern/init_main.c, all limits start at RLIM_INFINITY; only NOFILE/NPROC/DATA/STACK/RSS/MEMLOCK are overridden, and those are the ones you keep throwing). Tests pass locally and fail without the change.

One blocker:

  • wait (Process.cpp:293, GuestWaitpid.cpp:14-23, the wait and waitpid TechnicalDebt line) is already implemented by the open #3715 (same forwarding to waitpid(-1, status, 0), same test), opened earlier. CONTRIBUTING doesn't allow two open PRs implementing the same function.

Please drop the wait parts and keep this PR to getrlimit (restore the original waitpid TechnicalDebt line, add only the getrlimit one, and update the title/body, with "Depends on: none"). It can then be merged independently of #3715.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5484077143 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3765#pullrequestreview-5484077143). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-11T16:37:03Z. **Review:** DISMISSED --- Thanks. The `getrlimit` part checks out: the nine values match FreeBSD 11.4 `proc0_init` (`sys/kern/init_main.c`, all limits start at `RLIM_INFINITY`; only NOFILE/NPROC/DATA/STACK/RSS/MEMLOCK are overridden, and those are the ones you keep throwing). Tests pass locally and fail without the change. One blocker: - `wait` (`Process.cpp:293`, `GuestWaitpid.cpp:14-23`, the `wait and waitpid` TechnicalDebt line) is already implemented by the open #3715 (same forwarding to `waitpid(-1, status, 0)`, same test), opened earlier. CONTRIBUTING doesn't allow two open PRs implementing the same function. Please drop the `wait` parts and keep this PR to `getrlimit` (restore the original `waitpid` TechnicalDebt line, add only the `getrlimit` one, and update the title/body, with "Depends on: none"). It can then be merged independently of #3715.
pushkarreddyy commented 2026-10-11 16:41:39 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by pushkarreddyy on 2026-10-11T16:41:39Z.


Implementation Details & Expedited Testing Request

Hi @adriadam10, @MarcZX100, @blawesom,

This PR directly addresses the start-up crashes across PS5MC (PPSA99420), XPSemu (PPSA97358), and VLC (PPSA85300) as reported in #3733:

  1. wait(status) (ldVb3lc75PE):

    • wait was completely missing from libkernel, causing PS5MC (PPSA99420) to halt immediately on dynamic relocation (FAIL: unresolved ELF import ldVb3lc75PE from libkernel.prx).
    • Implemented by delegating directly to waitpid(-1, status, 0). When no children exist, it preserves the caller's status buffer and returns -1 with errno = ECHILD (10), matching FreeBSD 11.4 lib/libc/gen/wait.c (8c639945).
  2. getrlimit Process-0 FreeBSD Baseline Defaults:

    • Previously hard-threw getrlimit: unsupported resource on every resource other than RLIMIT_DATA (2).
    • PS5MC (PPSA99420) queries RLIMIT_CORE (4) at 7 call sites during its initialization (what(): getrlimit: unsupported resource 4).
    • Extended to report RLIM_INFINITY (
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6111277903 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3765#issuecomment-6111277903). Originally posted by [pushkarreddyy](https://github.com/pushkarreddyy) on 2026-10-11T16:41:39Z. --- ### Implementation Details & Expedited Testing Request Hi @adriadam10, @MarcZX100, @blawesom, This PR directly addresses the start-up crashes across **PS5MC** (PPSA99420), **XPSemu** (PPSA97358), and **VLC** (PPSA85300) as reported in #3733: 1. **wait(status) (ldVb3lc75PE)**: - wait was completely missing from libkernel, causing PS5MC (PPSA99420) to halt immediately on dynamic relocation (FAIL: unresolved ELF import ldVb3lc75PE from libkernel.prx). - Implemented by delegating directly to waitpid(-1, status, 0). When no children exist, it preserves the caller's status buffer and returns -1 with errno = ECHILD (10), matching FreeBSD 11.4 lib/libc/gen/wait.c (8c639945). 2. **getrlimit Process-0 FreeBSD Baseline Defaults**: - Previously hard-threw getrlimit: unsupported resource <n> on every resource other than RLIMIT_DATA (2). - PS5MC (PPSA99420) queries RLIMIT_CORE (4) at 7 call sites during its initialization (what(): getrlimit: unsupported resource 4). - Extended to report RLIM_INFINITY (
pushkarreddyy commented 2026-10-11 16:47:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by pushkarreddyy on 2026-10-11T16:47:43Z.


Clean Scope Update

To maintain strict one-topic focus and avoid any duplicate export collisions with @Lorkydey's PR #3715 (which exports wait), this PR has been narrowed purely to getrlimit ( eat(libkernel): answer getrlimit for FreeBSD resources):

  • Answers the 9 process-0 FreeBSD baseline resource limits (RLIMIT_CPU, FSIZE, CORE, SBSIZE, VMEM/AS, NPTS, SWAP, KQUEUES, UMTXP).
  • Resolves the 7 RLIMIT_CORE abort sites in PS5MC (PPSA99420), XPSemu (PPSA97358) limit queries, and VLC (PPSA85300) RLIMIT_AS queries.
  • Zero collision or overlap with PR #3715 or any open PR.
  • Both PRs can merge independently and cleanly.
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6111334655 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3765#issuecomment-6111334655). Originally posted by [pushkarreddyy](https://github.com/pushkarreddyy) on 2026-10-11T16:47:43Z. --- ### Clean Scope Update To maintain strict one-topic focus and avoid any duplicate export collisions with @Lorkydey's PR #3715 (which exports wait), this PR has been narrowed purely to getrlimit ( eat(libkernel): answer getrlimit for FreeBSD resources): - Answers the 9 process-0 FreeBSD baseline resource limits (RLIMIT_CPU, FSIZE, CORE, SBSIZE, VMEM/AS, NPTS, SWAP, KQUEUES, UMTXP). - Resolves the 7 RLIMIT_CORE abort sites in PS5MC (PPSA99420), XPSemu (PPSA97358) limit queries, and VLC (PPSA85300) RLIMIT_AS queries. - Zero collision or overlap with PR #3715 or any open PR. - Both PRs can merge independently and cleanly.
pushkarreddyy commented 2026-10-11 16:51:08 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by pushkarreddyy on 2026-10-11T16:51:08Z.


Hi @adriadam10,

Thank you for the review and confirmation on the FreeBSD 11.4 proc0_init values!

I have addressed the blocker exactly as requested:

  1. Dropped wait completely: Removed wait_nid_postfix from Process.cpp and restored GuestWaitpid.cpp to main.
  2. Restored TechnicalDebt: Preserved the original waitpid line in docs/dev/TechnicalDebt.md untouched, and added only the getrlimit functional debt line.
  3. Dedicated Scope: Updated the PR title to eat(libkernel): answer getrlimit for FreeBSD resources and the body with Depends on: none, keeping this PR 100% focused on getrlimit so it merges independently of #3715.
  4. CI & Conventions: Conventions passed with 0 comments in C++ source files, and unit tests in guest_getrlimit pass.

Ready for re-review and merge. Thank you!

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6111366361 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3765#issuecomment-6111366361). Originally posted by [pushkarreddyy](https://github.com/pushkarreddyy) on 2026-10-11T16:51:08Z. --- Hi @adriadam10, Thank you for the review and confirmation on the FreeBSD 11.4 proc0_init values! I have addressed the blocker exactly as requested: 1. **Dropped wait completely**: Removed wait_nid_postfix from Process.cpp and restored GuestWaitpid.cpp to main. 2. **Restored TechnicalDebt**: Preserved the original waitpid line in docs/dev/TechnicalDebt.md untouched, and added only the getrlimit functional debt line. 3. **Dedicated Scope**: Updated the PR title to eat(libkernel): answer getrlimit for FreeBSD resources and the body with Depends on: none, keeping this PR 100% focused on getrlimit so it merges independently of #3715. 4. **CI & Conventions**: Conventions passed with 0 comments in C++ source files, and unit tests in guest_getrlimit pass. Ready for re-review and merge. Thank you!
pushkarreddyy commented 2026-10-12 02:09:34 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by pushkarreddyy on 2026-10-12T02:09:34Z.


Hi @adriadam10 and @oneandonlydean,

Rebased cleanly onto latest origin/main (d371ed307) on commit d051126d:

  • All merge conflicts in docs/dev/TechnicalDebt.md cleanly resolved.
  • Strict 0-comment rule in C++ source files verified ( ools/check_conventions.py --base origin/main passes 100%).
  • Dedicated pure getrlimit scope answering FreeBSD process-0 limits for RLIMIT_CPU, RLIMIT_FSIZE, RLIMIT_CORE, RLIMIT_SBSIZE, RLIMIT_VMEM/AS, RLIMIT_NPTS, RLIMIT_SWAP, RLIMIT_KQUEUES, RLIMIT_UMTXP.
  • Unit tests in GuestGetrlimit.cpp cover all supported resources, null pointer checks, and unknown resource rejection.

Branch is clean (mergeable: true) and ready for review and merge when convenient! Thank you!

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6116497813 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3765#issuecomment-6116497813). Originally posted by [pushkarreddyy](https://github.com/pushkarreddyy) on 2026-10-12T02:09:34Z. --- Hi @adriadam10 and @oneandonlydean, Rebased cleanly onto latest origin/main (d371ed307) on commit d051126d: - All merge conflicts in docs/dev/TechnicalDebt.md cleanly resolved. - Strict 0-comment rule in C++ source files verified ( ools/check_conventions.py --base origin/main passes 100%). - Dedicated pure getrlimit scope answering FreeBSD process-0 limits for RLIMIT_CPU, RLIMIT_FSIZE, RLIMIT_CORE, RLIMIT_SBSIZE, RLIMIT_VMEM/AS, RLIMIT_NPTS, RLIMIT_SWAP, RLIMIT_KQUEUES, RLIMIT_UMTXP. - Unit tests in GuestGetrlimit.cpp cover all supported resources, null pointer checks, and unknown resource rejection. Branch is clean (mergeable: true) and ready for review and merge when convenient! Thank you!
pushkarreddyy commented 2026-10-12 07:50:25 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by pushkarreddyy on 2026-10-12T07:50:25Z.


Hi @adriadam10, following up on your earlier review: as requested, wait was completely removed to avoid overlap with #3715, and this PR is now strictly scoped to the 9 FreeBSD process-0 getrlimit defaults (RLIMIT_CPU, FSIZE, CORE, SBSIZE, VMEM, NPTS, SWAP, KQUEUES, UMTXP). Rebased cleanly on latest main with all 14 CI checks passing (mergeable: true). Whenever you have a chance to re-review, thank you!

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6120036632 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3765#issuecomment-6120036632). Originally posted by [pushkarreddyy](https://github.com/pushkarreddyy) on 2026-10-12T07:50:25Z. --- Hi @adriadam10, following up on your earlier review: as requested, wait was completely removed to avoid overlap with #3715, and this PR is now strictly scoped to the 9 FreeBSD process-0 getrlimit defaults (RLIMIT_CPU, FSIZE, CORE, SBSIZE, VMEM, NPTS, SWAP, KQUEUES, UMTXP). Rebased cleanly on latest main with all 14 CI checks passing (mergeable: true). Whenever you have a chance to re-review, thank you!
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!3765
No description provided.