Skip to content

docs(libkernel): name what FreeBSD and the emulators do for an unaligned sceKernelMunmap length - #13866

Merged
adriadam10 merged 2 commits into
boykopovar:mainfrom
xXPBSXx:docs/libkernel-munmap-unaligned
Nov 1, 2026
Merged

adriadam10 merged 2 commits into
boykopovar:mainfrom
xXPBSXx:docs/libkernel-munmap-unaligned

Conversation

@xXPBSXx

@xXPBSXx xXPBSXx commented Oct 31, 2026

Copy link
Copy Markdown
Contributor

What

Adds one entry to the libkernel technical debt: sceKernelMunmap fails a length that is not a multiple of the 16 KiB guest page with EINVAL, which was taken over from an earlier throw and which no console run has checked. FreeBSD 11.4's kern_munmap (vm_mmap.c#L535-L542) rounds the address down and the length up instead, shadPS4 and fpPS4 round as well, and KytyPS5 does not check the alignment. The guest munmap already rounds like FreeBSD (#10550); sceKernelMunmap has its own path. The entry does not say which behaviour is right and no code or test changes. Forty of the 53 local titles import sceKernelMunmap.

Tested

Documentation only. tools/check_conventions.py --base upstream/main passes. Based on main 809c7fa2df, and it merges with main 2db749ef2e without a conflict (checked 2026-10-31 10:12 UTC). I read FreeBSD's vm_mmap.c (the blob matches release/11.4.0) and the three emulators at the commits named in the entry (KytyPS5 5e837a9beac82c031868eaad9348d6a48245fb99, shadPS4 0614ce324be092791b758d79f93d9f1ca5b10a81, fpPS4 04cefd43e6fddd1ab033e7980cd356d14c964905), and our DoMunmap and munmap_nid_postfix. Not run: a build or a test, because nothing but the debt file changes.

Overlap

Checked on 2026-10-31 against main 809c7fa2dfb1b21e2b31b3114b7d51bc14ee88ab (1591 open pull requests, listed at 06:39 UTC; the merge checks ran from 08:54 UTC to 09:05 UTC). I took the changed files of each from git diff --name-only against its merge base (one ref, #13454, could not be fetched; the GitHub file list shows it does not change docs/dev/debt/libkernel.md). 92 of them change that file. git merge-tree of this head with each of the 92: 39 conflict, and every one of the 39 also conflicts with main on its own, so none conflicts because of this entry. I put the line after the Locked memory on macOS entry because, after the mincore entry, it conflicted with #12854 and #11042, which each change a neighbouring line. Checked once more on 2026-10-31 at 09:59 UTC against main 2db749ef2e: of the 63 pull requests opened since 06:30 UTC, five change that file (#13790, #13798, #13824, #13832, #13854) and none of them conflicts with this entry.

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

AI-assisted (Claude Code).

🤖 Generated with Claude Code

…ned sceKernelMunmap length

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

@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 — looks good

This documentation-only change accurately distinguishes the current sceKernelMunmap behavior from the cited alternatives and does not claim the unmeasured console behavior is settled.

What I ran

Reviewed head d7ce0daa231696bfa8ba305d47789025a0151dad against base 049619c202f00698b6d559817577726fbeb1ca4d; the merge preview was clean. Environment: Linux x86_64, Python 3.11.2. I ran:

python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 13866

Results

Check Result
Diff check and conventions/template Passed
Current-base merge preview Clean
Build/tests Not applicable; only a debt-documentation line changed
Hosted CI Still queued at final check
Unedited convention check output
All conventions checks passed.

Not verified

The precheck's test-quality heuristic could not run because tools/pr_test_quality.py is absent from its isolated PR checkout. No build or test was run, and hosted checks were queued. Neither limitation affects this documentation-only diff.

@github-actions github-actions Bot added the docs label Oct 31, 2026
@github-actions

github-actions Bot commented Oct 31, 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 4630 docs/dev/debt/libkernel.md
PR 5021 docs/dev/debt/libkernel.md
PR 6936 docs/dev/debt/libkernel.md
PR 7088 docs/dev/debt/libkernel.md
PR 7105 docs/dev/debt/libkernel.md
PR 7121 docs/dev/debt/libkernel.md
PR 7135 docs/dev/debt/libkernel.md
PR 7149 docs/dev/debt/libkernel.md
PR 7192 docs/dev/debt/libkernel.md
PR 7447 docs/dev/debt/libkernel.md
PR 7464 docs/dev/debt/libkernel.md
PR 7509 docs/dev/debt/libkernel.md
PR 7804 docs/dev/debt/libkernel.md
PR 8605 docs/dev/debt/libkernel.md
PR 9156 docs/dev/debt/libkernel.md
PR 9199 docs/dev/debt/libkernel.md
PR 9242 docs/dev/debt/libkernel.md
PR 9293 docs/dev/debt/libkernel.md
PR 9297 docs/dev/debt/libkernel.md
PR 9302 docs/dev/debt/libkernel.md
PR 9326 docs/dev/debt/libkernel.md
PR 9389 docs/dev/debt/libkernel.md
PR 9557 docs/dev/debt/libkernel.md
PR 9566 docs/dev/debt/libkernel.md
PR 9843 docs/dev/debt/libkernel.md
PR 9938 docs/dev/debt/libkernel.md
PR 10025 docs/dev/debt/libkernel.md
PR 10319 docs/dev/debt/libkernel.md
PR 10442 docs/dev/debt/libkernel.md
PR 10558 docs/dev/debt/libkernel.md
PR 10645 docs/dev/debt/libkernel.md
PR 11002 docs/dev/debt/libkernel.md
PR 11215 docs/dev/debt/libkernel.md
PR 11628 docs/dev/debt/libkernel.md
PR 11661 docs/dev/debt/libkernel.md
PR 11689 docs/dev/debt/libkernel.md
PR 11698 docs/dev/debt/libkernel.md
PR 11896 docs/dev/debt/libkernel.md
PR 11939 docs/dev/debt/libkernel.md
PR 12560 docs/dev/debt/libkernel.md
PR 12682 docs/dev/debt/libkernel.md
PR 12688 docs/dev/debt/libkernel.md
PR 12700 docs/dev/debt/libkernel.md
PR 12925 docs/dev/debt/libkernel.md
PR 12965 docs/dev/debt/libkernel.md
PR 13582 docs/dev/debt/libkernel.md
PR 13587 docs/dev/debt/libkernel.md
PR 14108 docs/dev/debt/libkernel.md
PR 14128 docs/dev/debt/libkernel.md
PR 14212 docs/dev/debt/libkernel.md

@oneandonlydean

Copy link
Copy Markdown
Collaborator

@xXPBSXx the entry says "a length of 0 and a range with nothing mapped are measured". I could not find where. Neither libkernel.md nor the sceKernelMunmap tests or comments in the tree cite a console run for them, and this entry does not either. Please add the source (firmware, and the PR or comment with the run), or say they follow the existing code and have not been measured. As written, a reader will take the first sentence as console-verified while the alignment case next to it is not.

The rest checks out against the cited sources: FreeBSD 11.4 kern_munmap (L535-L542) returns EINVAL for a zero length, rounds the address down and rounds the length plus that offset up. Of the three emulators, the two PS4 ones round (the first aligns the address down and the size up in UnmapMemory, the second aligns the offset down and rounds the length plus the offset up in Release), and the PS5 one only rejects a zero length and an overflowing range.

…results come from

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@xXPBSXx

xXPBSXx commented Oct 31, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for checking. The source is prosper's console oracle, which #3937 cites: kernelx.golden.tsv at 6efa3fdd4ec6 has kx_fmem_munmap_unmapped (a never-mapped range) and kx_fmem_unmap_again (a range just unmapped) returning 0, and kx_fmem_munmap_len_zero returning 0x80020016. The file's header says captured: 2026-10-08 and the oracle's own notes say a person ran it on their own PS5, but neither records a firmware version, so I cannot give one.

I changed the entry accordingly: it now says that a length of 0 and a range with nothing mapped follow prosper's console oracle (PR #3937, firmware not recorded), instead of "are measured". The alignment case still says that it is not measured. The new commit only rewords this entry: besides that sentence it shortens "no console run has checked it" to "is not measured" and drops "instead of failing" after the rounding sentence.

AI-assisted (Claude Code).

@adriadam10 adriadam10 self-assigned this Nov 1, 2026
@adriadam10
adriadam10 merged commit 2e704e9 into boykopovar:main Nov 1, 2026
9 checks passed
@adriadam10

Copy link
Copy Markdown
Collaborator

Checked the prosper oracle rows and the cited FreeBSD/emulator sources against the entry; docs only, conventions green; merged.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants