Skip to content

fix(libkernel): allow sceKernelMprotect on committed host memory outside the guest registry - #3788

Merged
adriadam10 merged 1 commit into
boykopovar:mainfrom
xXPBSXx:fix/libkernel-mprotect-host-memory-v3
Oct 11, 2026
Merged

adriadam10 merged 1 commit into
boykopovar:mainfrom
xXPBSXx:fix/libkernel-mprotect-host-memory-v3

Conversation

@xXPBSXx

@xXPBSXx xXPBSXx commented Oct 11, 2026

Copy link
Copy Markdown
Contributor

What

sceKernelMprotect threw "guest protection or unmap range is not registered" for committed private host memory that is not in the guest allocation registry (seen on a thread stack: 0xf8380000+0x580000, prot 0xc2). On Windows it now sets the native protection for such a range and returns 0 when the range is a committed private region that does not overlap any registered guest allocation. Everything else keeps its previous path. Related: #3143.

Tested

  • Windows 10, MinGW/Ninja build of main a11c8f7 plus this commit: ctest -R "^guest_memory$" passes, including the new CheckMprotectOfHostMemoryOutsideTheGuestRegistry (VirtualAlloc'd region: protect to read/write, write and read back, read-only, read/write again, native protection checked with VirtualQuery). That check failed before the change (verified on the earlier branch version). python tools/check_conventions.py --base upstream/main passes.
  • Found with Resident Evil 4 (PPSA07411) earlier (the range was a thread stack); this exact branch was not run with the title. Not tested: Linux/macOS (the change is _WIN32 only).

Checklist

🤖 Generated with Claude Code

…ide the guest registry

Thread stacks are host-private memory; the call threw instead of setting the native protection.

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

Copy link
Copy Markdown
Collaborator

Checked the diff against DoMprotect: the new branch only applies to committed private regions that do not overlap a registered guest allocation (RegionSize >= bytes), everything else keeps its previous path. Linux build and guest_memory pass; the new code and test are _WIN32 only, so the Windows run in the PR description is what covers them. Merging.

@adriadam10
adriadam10 merged commit dc70a66 into boykopovar:main Oct 11, 2026
13 checks passed
oneandonlydean added a commit that referenced this pull request Oct 12, 2026
…read stack

The Windows path from #3788 changed the protection of any committed private host region outside the guest registry, including a range crossing a guest stack's lower bound. Ranges inside a live guest thread stack keep the path from #2982.
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