Repository navigation
fix(libc): alias non-contiguous shared guest views on Windows - #4367
Conversation
|
@MarcZX100 here is the Windows validation this draft asks for, plus a title run that needs exactly this change. Unit tests on Windows, on exactly this head (5573e32). Windows 11 Pro 26200, Ryzen 7 7730U, WinLibs GCC 15.2.0 r7, Release. Sword of the Sea (PPSA25344). Its main menu binds a 368 MiB buffer across two adjacent direct memory ranges (320.75 MiB + 47.3 MiB). Each range is its own allocation, so the pair is views of two sections. An import that covers the buffer needs an alias across both, and on Reading the change. I compared it with an alias-run version we had written for the same case. Both group the 16 KiB views into runs of one section's consecutive pages. Both map each run into a split placeholder, so no run needs 64 KiB alignment, and both refuse a range with a page that is not a shared view. Where they differ, yours is better:
Your tests cover what ours did: a run that starts at an offset into its section, two sections in one call, the views per run, the freed range after unmapping, and the refusal of a private page. So I'd drop ours. One thing I'd add to the PR. The host-import entry in AI-assisted: yes (Claude Code) |
|
Windows test: head AI-assisted (Claude Code). |
|
Tested on Windows at this head (
I reviewed the change against a local equivalent I wrote for #4260 (one placeholder split into one view per run of section offsets). The two do the same thing, so I'm dropping mine in favour of this PR. In Palworld (PPSA23126) the local version made the 43 spans that failed at the alias import, and the CPU copies of the regions under them went from 2–56 GB per 10 s to 0. I'll run this PR together with oneandonlydean's AI-assisted (Claude Code) |
98a7d00 to
2ddb06a
Compare
|
The Windows runs above cover what the draft was waiting for, so please mark it ready. One change first: the host-import entry in |
|
Thanks, that debt sentence is stale. The current limitation is that alias creation refuses a run if any page is not a shared view; non-contiguous section offsets alone are now supported. I have not changed the PR text or marked it ready yet. I will correct the debt entry and then mark the PR ready once that edit is on the branch. |
On Windows, a host import of shared guest memory goes through a read-write alias from WindowsMappings::MapAlias. The alias was a single MapViewOfFile3 of one section, so MapAlias threw when the views of the range were not one contiguous run of that section. One sceKernelMapDirectMemory over two adjacent direct memory allocations gives such a range, as each allocation has its own section, and so do pages remapped in place to another physical order. Such ranges are now aliased run by run: a placeholder reservation is split at each run of consecutive pages of one section, and each run maps that section at its offset. UnmapAlias unmaps every run and forgets the alias even when one unmap fails. A contiguous range keeps the single view, and a range with a page that is not a shared view is still refused. guest_memory maps two adjacent direct memory allocations of two pages and one page with one call, and two pages in reverse physical order. It reads and writes every page through the alias. The first test also checks that the alias has one view per run and that unmapping it frees its pages. A range whose second page is flexible memory is still refused. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit fc6868d)
2ddb06a to
c4a61ea
Compare
|
Addressed the debt wording in |
What
Carries Angel21PC's alias-run implementation from closed PR #2254, preserving the original commit author. It lets
WindowsMappings::MapAliascompose one alias from adjacent shared pages even when they come from different sections or nonconsecutive section offsets. The existing single-view path remains for contiguous pages, and ranges containing private pages are still rejected.This covers the Windows alias part of #4260. It does not add host imports across registered ranges; that separate change remains outside this PR.
Tested
guest_memorypassed on code head5573e3238with all three alias checks;windows_exceptionsandfiberpassed too. The non-GPU suite was 589/590, withlog_macrosfailing the same way onmain.mainreaches a 368 MiB buffer spanning two direct-memory allocations;MapAliasrefuses it on the current base, forcing CPU copies. The exact current-main rebased head has not been run on Windows or in the title yet.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository