mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 22:40:52 +01:00
[PR #417] xmem: commits into placeholder windows, title page-size bits, window release (RT-XMEM-WINDOWS) #468
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#468
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/417
Author: @Kokonotcu
Created: 11/24/2026
Status: 🔄 Open
Base:
main← Head:pr/xmem-window-commit-free📝 Commits (2)
f2de415xmem: commits into placeholder windows, title page-size bits, window release (RT-XMEM-WINDOWS)ba26fe9xmem: releasing a window frees the whole original reservation, committed parts included (review of #417)📊 Changes
2 files changed (+268 additions, -6 deletions)
View changed files
📝
runtime/shims/xmem.cpp(+125 -3)📝
runtime/test/xmem_test.cpp(+143 -3)📄 Description
Claim: RT-XMEM-WINDOWS (#14).
Three ways the title's memory calls fail on the host with the current window model (reserve-only 64 KiB windows kept as placeholders, physical pages mapped into them):
MEM_RESERVE(the measured0x20401000shape) into a placeholder range fails withERROR_INVALID_ADDRESS: the host cannot commit a placeholder. When the host refuses such a commit, each placeholder piece is now replaced by committed memory (VirtualAlloc2withMEM_REPLACE_PLACEHOLDER), plain reserved or committed pieces are committed in place, and a range with a page mapped or a free piece fails before anything changes. The committed part leaves the window map; the rest of the window still takes physical pages.kernel32!VirtualAlloc. The title's ownVirtualAllocpassedMEM_LARGE_PAGES(needsSeLockMemoryPrivilegeon the host) and 64 KiB pages (MEM_LARGE_PAGES | MEM_PHYSICAL, invalid on the host) straight through. Both now takeXMemVirtualAlloc's path (guest page size as alignment and rounding, 4 KiB host pages);MEM_PHYSICALalone is dropped.VirtualFree(base, 0, MEM_RELEASE)freed only the first piece and leftg_mappednaming views at addresses the host hands out again.VirtualFreeis now shimmed next toVirtualAllocfor the title's memory DLLs: a release at a window's base unmaps its pages, releases every piece and forgets the window; every other call passes through.Tests (
xmem_test, new checks): commit into a window, including a piece that had a page mapped and unmapped, and the rest of the window still maps; titleVirtualAllocwith each page mode, aligned and writable, and a plain commit into a 64 KiB title reservation; a window with two pages mapped released whole (every 64 KiB free afterwards), taking no pages after, and the same pages mapping into a new window and holding data.The existing check "writing to 512 of them charges about those 512 pages" reads the system-wide commit charge, so another process allocating or freeing tens of MB in the window fails it; it now measures up to two more windows of untouched pages before failing. The neighbouring "mapping them does not charge them" check has the same weakness and still fails about one run in fifteen while builds run beside it; left as is here.
Tested on Windows 10, i7-11800H, RTX 3080 Laptop (no GPU needed), on
maind2cd6c0d9:xmemandd3d12_xmem_placedpass;xmem_testrun 15 times, the new checks never failed.🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.