kernel: allow munmap across released reservation holes #827
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
GPU
GUI
help wanted
question
Shaders
Video
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/KytyPS5--KytyPS5!827
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-827"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@Pcniado on GitHub · 2026-09-25 15:20 UTC · original
Pcniado:fix/munmap-reserved-holes→main· +56 −4 · 2 files · 2 commits · openSUMMARY
A game can reserve a span of memory, unmap one page, and later unmap the original span. Kyty rejected the final sceKernelMunmap call because its tracked ranges no longer covered every page, even though the missing page had already been released.
CHANGE
KernelMunmap now walks the span, validates released holes against the guest address space, and unmaps the remaining tracked regions.
TESTING
Astro’s Playroom boots fine with this change.
AI assisted with investigating this issue.
@ -2558,0 +2565,4 @@if (!g_guest_address_space->ReleaseFree(current, end - current)) {return KERNEL_ERROR_EACCES;}break;@Copilot on GitHub · 2026-09-25 15:30 UTC · original
ReleaseFreeonly checks that the host address-space placeholder is free and does not require aVirtualRangesentry. Therefore, whenmunmapis called on an entirely untracked address that falls inside the guest placeholder, this branch accepts the span and the function returnsOKeven though there is no mapping to remove. Reject the operation when no tracked chunk has been found, preserving the previousQuerySpanbehavior for arbitrary unmapped addresses.@copilot-pull-request-reviewer[bot] on GitHub · 2026-09-25 15:30 UTC · original · reviewed
Copilot review overview
🟡 Changes recommended
A critical issue allows successful unmapping of an entirely untracked address range.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 1
Open (1)
What changed in this PR
Updates
KernelMunmapto support reserved spans containing previously released holes.Changes:
Review finding: entirely untracked addresses inside the guest placeholder must still be rejected.
tests/VirtualMemoryAllocationTests.cppsrc/kernel/memory.cpp💡 Add a
code-reviewagent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.@coderabbitai[bot] on GitHub · 2026-09-25 15:45 UTC · original
Navigate logical layers of code changes, visualize relationships, and explore their blast radius.
📝 Walkthrough
Walkthrough
KernelMunmapnow walks the requested span, releases untracked gaps thatGuestAddressSpace::ReleaseFreeaccepts, and unmaps tracked chunks. It returnsKERNEL_ERROR_EACCESif it finds no tracked chunks. A new test checks unmapping a reserved span after its middle page has already been released, then checks that repeating the full-span unmap returnsErrorAccess.Suggested reviewers:
nmzikPriority: ➖ Normal
Change: Bug fix
Merge Risk: 🔵 Low · up to
aeb2aA munmap spanning separately released adjacent holes can fail on Windows even when the entire gap is free. This is a bounded edge case that should be fixed or accepted before merging.
Security Architecture Review
Security architecture risk: 🔵 Low · up to
aeb2aUnmapping can now cross released pages, and the gap check does not distinguish a previously released page from other free guest memory. The reviewed path remains limited to guest-owned address space and tracked mappings; no host-memory boundary bypass was established.
Retained concerns
Security review details
Security Blast Radius
Trust Boundaries and Controls
Hardening Proposals
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Comment
@coderabbitai helpto get the list of available commands.@coderabbitai[bot] on GitHub · 2026-09-25 15:45 UTC · original · reviewed
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml
Review profile: CHILL
Plan: Advanced
Run ID:
fc453323-bff2-450b-a48e-66afc3239e09📥 Commits
Reviewing files that changed from the base of the PR and between
5ce4f08364andaeb2a7394e.📒 Files selected for processing (2)
src/kernel/memory.cpptests/VirtualMemoryAllocationTests.cppIncluded review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
@ -2562,0 +2589,4 @@return result;}}return OK;@coderabbitai[bot] on GitHub · 2026-09-25 15:45 UTC · original
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 11121
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 38613
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 3893
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 24359
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 4692
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 10405
Accept gaps spanning adjacent free ranges.
On Windows,
AddFreeUnlockedcan leave adjacent entries inm_freewhenCoalescePlaceholdersfails. After adjacent reserved holes are unmapped separately,KernelMunmapcan pass their combined gap toReleaseFree.FindContainingchecks only the first entry, soKernelMunmapcan returnKERNEL_ERROR_EACCESeven though every page in the gap is free.Make
ReleaseFreewalk contiguous free entries and reject only a real gap.Suggested fix
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.