test(libkernel): cover the block sceKernelAllocateMainDirectMemory returns and its type #11681

Merged
milescoviello merged 3 commits from upstream-pr/11681 into main 2026-10-29 08:31:08 +00:00
milescoviello commented 2026-10-27 02:36:29 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-27T02:36:29Z.


What

GuestMemory.cpp gets a CheckAllocateMainDirectMemory case after CheckReusedDirectMemorySections. Two 16 KiB pages of type 3 with two-page alignment come back aligned, inside sceKernelGetDirectMemorySize(), and sceKernelGetDirectMemoryType reports that type over exactly that range.

It is called by PPSA01494, PPSA18194, PPSA21564, PPSA30839 and PPSA31162 (call sites found through the import's PLT stub in each title's relinked eboot.bin), and until now no test called it.

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

Tested

Linux (Ubuntu 26.04, GCC 15.2), Release: cmake --build build --target guest_memory_tests and ctest -R '^guest_memory$' --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_memory passes 3 of 3 at this head (3d1463aef6) and on its base main abed035468.

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:5027715129 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11681). Originally posted by [milescoviello](https://github.com/milescoviello) on 2026-10-27T02:36:29Z. --- ### What `GuestMemory.cpp` gets a `CheckAllocateMainDirectMemory` case after `CheckReusedDirectMemorySections`. Two 16 KiB pages of type 3 with two-page alignment come back aligned, inside `sceKernelGetDirectMemorySize()`, and `sceKernelGetDirectMemoryType` reports that type over exactly that range. It is called by PPSA01494, PPSA18194, PPSA21564, PPSA30839 and PPSA31162 (call sites found through the import's PLT stub in each title's relinked `eboot.bin`), and until now no test called it. Changed: `core/libs/tests/GuestMemory.cpp`. Test only, no change to the library. ### Tested Linux (Ubuntu 26.04, GCC 15.2), Release: `cmake --build build --target guest_memory_tests` and `ctest -R '^guest_memory$' --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_memory` passes 3 of 3 at this head (`3d1463aef6`) and on its base `main` `abed035468`. ### 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-27 02:40:01 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-27T02:40:01Z.

Review: APPROVED


Reviewed exact head 3134ed1658c4da281d3b77346fa804e0c6a67a94. The new case exercises successful allocation/alignment, verifies the reported type and exact range, releases the allocation, and checks invalid length/alignment/null-output refusals preserve the output sentinel. The test is registered in the existing GuestMemory suite, and the current implementation returns these error paths as expected. check_conventions.py and git diff --check pass against refreshed upstream main. The PR reports three passing focused Linux CTest repeats; I could not independently execute that binary here because this host fails the repository's static Zen 2 CPU compatibility guard. Hosted product tests are skipped by path policy. No code issue found.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5661617007 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11681#pullrequestreview-5661617007). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-27T02:40:01Z. **Review:** APPROVED --- Reviewed exact head `3134ed1658c4da281d3b77346fa804e0c6a67a94`. The new case exercises successful allocation/alignment, verifies the reported type and exact range, releases the allocation, and checks invalid length/alignment/null-output refusals preserve the output sentinel. The test is registered in the existing GuestMemory suite, and the current implementation returns these error paths as expected. `check_conventions.py` and `git diff --check` pass against refreshed upstream main. The PR reports three passing focused Linux CTest repeats; I could not independently execute that binary here because this host fails the repository's static Zen 2 CPU compatibility guard. Hosted product tests are skipped by path policy. No code issue found.
MarcZX10 commented 2026-10-27 04:36:21 +00:00 (Migrated from github.com)

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

Review: APPROVED


Re-reviewed exact head 3d1463aef6ba25b976f024f4004713f31844cf80. The revision removed the four unmeasured error-code assertions, leaving the successful allocation, alignment, range/type verification, and release case. check_conventions.py and git diff --check pass against refreshed upstream main. The author reports guest_memory and guest_mmap_fixed_anonymous passing 3/3 on both main and this head on the same Windows 11 VM; hosted product jobs are skipped by path policy. I could not independently run the CTest binary on this host because it fails the static Zen 2 CPU compatibility guard. No issue found in the revised test.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5662260189 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11681#pullrequestreview-5662260189). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-27T04:36:21Z. **Review:** APPROVED --- Re-reviewed exact head `3d1463aef6ba25b976f024f4004713f31844cf80`. The revision removed the four unmeasured error-code assertions, leaving the successful allocation, alignment, range/type verification, and release case. `check_conventions.py` and `git diff --check` pass against refreshed upstream main. The author reports `guest_memory` and `guest_mmap_fixed_anonymous` passing 3/3 on both main and this head on the same Windows 11 VM; hosted product jobs are skipped by path policy. I could not independently run the CTest binary on this host because it fails the static Zen 2 CPU compatibility guard. No issue found in the revised test.
THEMANnt commented 2026-10-28 12:49:19 +00:00 (Migrated from github.com)

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

Review: APPROVED


Reviewed 3d1463aef6ba25b976f024f4004713f31844cf80 — approve. The main-direct-memory case checks alignment, bounds, reported type/range and release of the allocation. It reuses the existing guest-memory fixture and leaves no test allocation intentionally outstanding.

Windows/GCC 15.3 Release native validation from pinned sources: head: 2 passed, 0 skipped; guest_memory, guest_mmap_fixed_anonymous; 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:5682817251 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11681#pullrequestreview-5682817251). Originally posted by [THEMANnt](https://github.com/THEMANnt) on 2026-10-28T12:49:19Z. **Review:** APPROVED --- Reviewed `3d1463aef6ba25b976f024f4004713f31844cf80` — approve. The main-direct-memory case checks alignment, bounds, reported type/range and release of the allocation. It reuses the existing guest-memory fixture and leaves no test allocation intentionally outstanding. Windows/GCC 15.3 Release native validation from pinned sources: head: 2 passed, 0 skipped; `guest_memory`, `guest_mmap_fixed_anonymous`; 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!11681
No description provided.