test(libkernel): cover the SCE sceKernelMlock and sceKernelMunlock next to their POSIX twins #11577

Merged
milescoviello merged 1 commit from upstream-pr/11577 into main 2026-10-28 23:07:16 +00:00
milescoviello commented 2026-10-26 21:04:27 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-26T21:04:27Z.


What

GuestMlock.cpp checked mlock and munlock but not the SCE exports with the same page logic. Next to the POSIX overflow checks, the SCE pair now returns SCE_KERNEL_ERROR_EINVAL (0x80020016) for a range that wraps past the top of the address space, 0 for a zero length, and 0 for an unaligned one-page lock and unlock of the mapped range.

Until now no test called it.

Changed: core/libs/tests/GuestMlock.cpp. Test only, no change to the library.

Tested

Linux (Ubuntu 26.04, GCC 15.2), Release: cmake --build build --target guest_mlock_tests and ctest -R '^guest_mlock$' --repeat until-fail:3 pass on this branch, which is current main plus the test. tools/check_conventions.py --base upstream/main passes.

  • Windows 11 VM (WinLibs GCC 15.2, Release): guest_mlock passes 3 of 3 at this head (379d9d6615) and on its base main e61a7c7e24.

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

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5024620606 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11577). Originally posted by [milescoviello](https://github.com/milescoviello) on 2026-10-26T21:04:27Z. --- ### What `GuestMlock.cpp` checked `mlock` and `munlock` but not the SCE exports with the same page logic. Next to the POSIX overflow checks, the SCE pair now returns `SCE_KERNEL_ERROR_EINVAL` (0x80020016) for a range that wraps past the top of the address space, 0 for a zero length, and 0 for an unaligned one-page lock and unlock of the mapped range. Until now no test called it. Changed: `core/libs/tests/GuestMlock.cpp`. Test only, no change to the library. ### Tested Linux (Ubuntu 26.04, GCC 15.2), Release: `cmake --build build --target guest_mlock_tests` and `ctest -R '^guest_mlock$' --repeat until-fail:3` pass on this branch, which is current `main` plus the test. `tools/check_conventions.py --base upstream/main` passes. - **Windows 11 VM** (WinLibs GCC 15.2, Release): `guest_mlock` passes 3 of 3 at this head (`379d9d6615`) and on its base `main` `e61a7c7e24`. ### 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 - [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-26 22:18:25 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-26T22:18:25Z.

Review: APPROVED


The added assertions exercise the SCE exports’ overflow error mapping, zero-length success, and an unaligned page-length lock/unlock request. (Because the implementation rounds the address range to page boundaries, the bytes + 1 request can cover two pages.) I manually checked #11042’s overlap warning: it removes mlockall expectations at other lines, not this SCE test block. The author reports three passing Linux runs and conventions; hosted eligibility, conventions, intake and labels pass. Product jobs are skipped by path policy. I did not rerun the test locally.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5659867456 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11577#pullrequestreview-5659867456). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-26T22:18:25Z. **Review:** APPROVED --- The added assertions exercise the SCE exports’ overflow error mapping, zero-length success, and an unaligned page-length lock/unlock request. (Because the implementation rounds the address range to page boundaries, the `bytes + 1` request can cover two pages.) I manually checked #11042’s overlap warning: it removes `mlockall` expectations at other lines, not this SCE test block. The author reports three passing Linux runs and conventions; hosted eligibility, conventions, intake and labels pass. Product jobs are skipped by path policy. I did not rerun the test locally.
THEMANnt commented 2026-10-28 12:36:00 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by THEMANnt on 2026-10-28T12:36:00Z.

Review: APPROVED


Reviewed 379d9d661570891c401fcb5beea44d2ea091828f — approve. The SCE memory-lock wrappers are checked for overflowing ranges, zero length and unaligned valid ranges alongside the existing POSIX cases. SCE error codes remain distinct from errno-style returns.

Windows/GCC 15.3 Release native validation from pinned sources: head: 1 passed, 0 skipped; guest_mlock; author base was source-compared: production sources are unchanged; its runtime was not built or executed for this review. This changes test coverage, not production behavior, so an old-production failure is not required. The build reuses matching dependency source pins and the existing FFmpeg package; no full product or game execution is claimed.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5682658665 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11577#pullrequestreview-5682658665). Originally posted by [THEMANnt](https://github.com/THEMANnt) on 2026-10-28T12:36:00Z. **Review:** APPROVED --- Reviewed `379d9d661570891c401fcb5beea44d2ea091828f` — approve. The SCE memory-lock wrappers are checked for overflowing ranges, zero length and unaligned valid ranges alongside the existing POSIX cases. SCE error codes remain distinct from errno-style returns. Windows/GCC 15.3 Release native validation from pinned sources: head: 1 passed, 0 skipped; `guest_mlock`; author base was source-compared: production sources are unchanged; its runtime was not built or executed for this review. This changes test coverage, not production behavior, so an old-production failure is not required. The build reuses matching dependency source pins and the existing FFmpeg package; no full product or game execution is claimed.
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!11577
No description provided.