Skip to content

feat(libSceMat): implement host allocator and tracker model - #29159

Draft
MertCtn wants to merge 1 commit into
boykopovar:mainfrom
MertCtn:feat/libscemat-host-model
Draft

MertCtn wants to merge 1 commit into
boykopovar:mainfrom
MertCtn:feat/libscemat-host-model

Conversation

@MertCtn

@MertCtn MertCtn commented Dec 5, 2026

Copy link
Copy Markdown

What

Implements all 52 libSceMat exports as a host-side allocator and tracker (previously parameterless NotImplemented_nid_no_patch stubs with unverified signatures).

  • Heap, mspace and pool allocators backed by host malloc, with capacity accounting; frees of unknown or arena-mismatched pointers are ignored.
  • Validated id registries for owners, resources, types, groups and their AGC twins; marker, tag, bookmark, frame and thread state; virtual-range reservations.
  • Guest memory goes through GuestCopyIn/GuestCopyOut with errno preserved; EINVAL for argument errors, EFAULT for unreadable or unwritable guest pointers, ENOMEM for host exhaustion.
  • Physical and direct-memory operations validate their arguments and report ENOSYS instead of throwing: the host has no console memory to back them. Nothing here is a silent stub — every path either implements the tracking or reports an error — so the new entries go under Functional, not Silent stubs.
  • Signatures follow the in-repo sceLibcMspace convention and stay unverified: no libSceMat.sprx ships in retail firmware (absent from ps5dumps/unp.index.csv across 44 versions 1.00 through 12.70, no sceMat string in PS5UPDATE1.PUP.dec, no import in the PPSA28769 executable). Gaps are recorded in the new Functional debt entries; the pending docs-libscemat-absent-1360 fragment still applies cleanly.

Tested

Windows, MinGW-w64 GCC (ucrt64), Release build:

  • cmake --build build --target libSceMat guest_mat_tests, then ctest --test-dir build -R "^guest_mat$" --output-on-failure: 1/1 passed (Mat tests passed).
  • python3 tools/guest_pointer_audit.py libSceMat: 0 findings.
  • python3 core/libs/tests/test_public_headers.py --audit-only: 413 libraries, 35106 exports verified.
  • python3 tools/debt_fold.py --check: clean. python3 tools/check_conventions.py: no findings on these files (1 pre-existing error and 2 warnings in unrelated fragments remain).

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 and the licence notice of code adapted from upstream (see AGENTS.md)
  • 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

All 52 exports were parameterless stubs throwing through
NotImplemented_nid_no_patch with unverified signatures. They now form a
host-side allocator and tracker: malloc-backed heap, mspace and pool
allocators with capacity accounting, validated id registries for
owners, resources, types and groups and their AGC twins, marker, tag
and bookmark state, and virtual-range reservations. Guest memory goes
through GuestCopyIn and GuestCopyOut with errno preserved; argument
errors report EINVAL, unreadable or unwritable guest pointers EFAULT
and host exhaustion ENOMEM. Physical and direct-memory operations
validate their arguments and report ENOSYS instead of throwing: the
host has no console memory to back them.

No libSceMat.sprx ships in retail firmware (absent from
ps5dumps/unp.index.csv across 44 versions, no sceMat string in
PS5UPDATE1.PUP.dec, no import in the PPSA28769 executable), so the
signatures follow the in-repo sceLibcMspace convention and stay
unverified; the gaps are recorded in the new Functional debt entries.

Evidence: guest_mat (new, covers all 52 exports) passes,
guest_pointer_audit is clean and the public_headers audit verifies
the rewritten Api.hpp.
@coderabbitai

coderabbitai Bot commented Dec 5, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — no blocking findings

The host allocator and tracker implementation has no verified blocking defect, but the exported signatures and behavior remain unverified against the console.

What I ran

Reviewed head 88a745aa24453f0df504ae7413d5d30bcf3c322c using the prepared review files and inspected the changed implementation and tests. No tests or builds were run. An attempt to use repo_read.py failed because it could not append to its read log in the read-only workspace.

Results

Check Result Note
Changed files passed All six reviewed files were read
Tests and build not run Would require executing or compiling code
Reader source context not run Read-only log error

Negative control

Not run; the test executable was not run.

Findings

Blocking

None.

Non-blocking

None.

Sources

The allocator and tracker behavior reviewed here is in Export.cpp at the reviewed head. The PR records the signatures and behavior as unverified technical debt in libSceMat.md at the reviewed head.

Not verified

Could not inspect repository callers or surrounding source through repo_read.py; its log append failed in the read-only workspace. Console ABI, signatures, and behavior were not verified. The author reports Windows MinGW-w64 tests and checks, but those were not run during this review. Read: core/libs/CMakeLists.txt, core/libs/prx/libSceMat/Export.cpp, core/libs/prx/libSceMat/include/Api.hpp, core/libs/tests/GuestMat.cpp, docs/dev/debt/changes/feat-libscemat-host-model.md, and docs/dev/debt/libSceMat.md. Excluded by rule: none.

To get this to a good state

Nothing is required. Optional: verify the modeled signatures and behavior against console evidence when available.

@github-actions

github-actions Bot commented Dec 5, 2026

Copy link
Copy Markdown

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 7275 core/libs/CMakeLists.txt
PR 9302 core/libs/CMakeLists.txt
PR 12130 core/libs/CMakeLists.txt
PR 16793 core/libs/CMakeLists.txt
PR 23395 core/libs/CMakeLists.txt
PR 23975 core/libs/CMakeLists.txt
PR 27750 core/libs/CMakeLists.txt

@MertCtn

MertCtn commented Dec 5, 2026

Copy link
Copy Markdown
Author

Manual overlap review for the pr_overlap note above (re-checked with fresh PR heads).

  • No open PR implements the same functions: pr_overlap found no export overlap, and none of the 7 listed PRs touches core/libs/prx/libSceMat/*, core/libs/tests/GuestMat.cpp, docs/dev/debt/libSceMat.md or the new debt fragment (verified with git diff main <head> -- <those paths>; all empty).
  • The apparent libSceMat deletion in PR feat(libkernel_sys): implement kmq_notify registration #9302 is staleness, not overlap: its merge-base with main (4ec064d29b) predates the commit that introduced the libSceMat stubs (b6ba6c8cf7), so that branch never contained these files. Its topic (kmq_notify) is unrelated.
  • The remaining core/libs/CMakeLists.txt diffs in those branches are likewise stale-branch deletions and context lines around the guest_abstract_youtube block, not edits at this PR's anchor. This PR only appends one 13-line guest_mat registration block between that block's endif() and the PostScriptInfo.cmake include.

Conclusion: no functional or same-line overlap with any of the 7; no Depends on needed. If any of those branches rebases onto current main, the usual test-block conflict resolution applies.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants