Skip to content

fix(libkernel): report live ranges after partial unmap - #2002

Closed
MarcZX10 wants to merge 1 commit into
boykopovar:mainfrom
MarcZX10:fix/virtual-query-partial-unmap
Closed

MarcZX10 wants to merge 1 commit into
boykopovar:mainfrom
MarcZX10:fix/virtual-query-partial-unmap

Conversation

@MarcZX10

@MarcZX10 MarcZX10 commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

What

sceKernelVirtualQuery matched guest allocations by their original allocation extent, even after a partial munmap split the live mapping into separate pieces. It could report the unmapped hole as committed and return a range spanning that hole.

Match queries against the registered live pieces, then join adjacent protection fragments that still belong to the same allocation. A gap now ends the reported range, and SCE_KERNEL_VQ_FIND_NEXT finds the next live piece. Fixes #1894.

Based on current main at f1451396. No open PR implements this fix.

Tested

  • Linux, GCC 12.2, Release: built guest_memory_tests; ctest -R '^guest_memory$' passed (1/1, 0.02 s).
  • The regression covers an intact allocation split by mprotect, partial unmapping of its middle page, failure to query the hole, FIND_NEXT, and the extents on both sides.
  • python3 tools/check_conventions.py --base upstream/main and git diff --check passed.
  • Native Windows was not available locally. Upstream Build and Conventions workflows are pending maintainer approval (action_required); this account cannot approve them.

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; no silent stubs added
  • No notes, investigation .md files or images added to the repository
  • New third-party code is a submodule built from source (none added)
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes, OpenAI Codex

@MarcZX10

MarcZX10 commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

Closing this draft as superseded. The live-fragment query after partial munmap is already proposed in #1731, and my #1929 stacks on that change while adding support for mapped non-readable ranges. This draft contains only the earlier readable-range implementation and has no distinct remaining change, so keeping it open would duplicate the same behavior.

@MarcZX10 MarcZX10 closed this Oct 9, 2026
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.

sceKernelVirtualQuery reports the whole mapping after a partial munmap

1 participant