runtime: define the physical-page mapping contracts for startup #895
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/902"
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?
Imported from R0Y00/Xbox2Windows. Originally posted by Holastor on 2026-11-23T16:33:04Z.
Refs #870 and follow-up to #880.
Overview
Following physical-page allocation (#880, #892) and virtual memory reservation, titles map physical pages into the reserved virtual address space via
xmem.dll!XMemMapPhysicalPagesandxmem.dll!XMemMapPhysicalPagesScatter.This PR establishes the contract through an independent, source-built caller and controlled recording-provider fixture without changing the production XMem shim:
cpu_map_pages_caller.exe(tests/cpu/map_pages_caller.asm): standalone MASM x64 executable importing both functions fromxmem.dllby name and executing 7 contract validation steps:NULLpage array), returning the base address.TRUE(1).NULLpage array), returningTRUE(1).NULL).NULL).FALSE).Exits with milestone status
0x870on success.cpu_map_pages_provider(tests/cpu/map_pages_provider.cpp/.def): recording provider validating the 64 KiB alignment requirement (address % 65536 == 0), nonzero counts, unmapping via null page array, and recording call and unmap counts for both contiguous and scatter paths.pe_mapcomparison and negative controls (tests/cpu/map_pages_check.py):pe_map(in-process loader) produce identical exit code0x870.xmem.dllis missing,pe_maphalts at map time before entry withSTATUS["unresolved"]and diagnosticunresolved import xmem.dll!XMemMapPhysicalPages.Verification
Environment: Windows 11 x64, MSVC 19.51, CMake/Ninja, Python 3.11 (
out/pe-env).Dev preset
Output:
Release preset
Output:
Documentation & pure-Python checks
All passed:
docs_links_check.py: Checked 13 Markdown files and 180 links.bidi_controls_check.py: Checked 723 tracked source, script and build/CI files: no bidirectional controls.form_coverage_check.py: form coverage checks passed.git diff --check: 0 issues.Checklist
docs/experiments.mdwith the new capability and reproduction commands.Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T16:50:15Z.
The source-built caller is a useful way to record proposed call shapes. Before this fixture can land, please scope the README/docs to the controlled provider's choices. The two loaders consuming the same stub cannot establish the console return types or that NULL unmaps, alignment is required, or the reservation survives. Please cite the independent ABI basis where known, and label the rest as hypotheses. Reuse exe_startup.asm and cpu_exe_io!finish_exe with the live-worker control and mapped return. The current four counters are read only from the mapped process. Please record or check the actual call arguments and outcome in both runs, and withhold each named mapping export independently. Keep #892's physical registry and the shared-backing/readback follow-up separate from this recorder.
Imported from R0Y00/Xbox2Windows. Originally posted by Holastor on 2026-11-23T16:56:46Z.
Updated in
24e58eb:Startup wrapper and lifetime control:
cpu_map_pages_callernow starts throughtests/cpu/exe_startup.asmand callsfinish_exefromcpu_exe_io.dll.CPU_CRC_TEST_LIVE_WORKER=1is exercised to ensure clean process exit underfinish_exeeven with a live worker thread.pe_map,finish_exepreserves the host return without exiting the host process.Per-process verification of call counters:
map_pages_caller.asmnow queries the provider's call counters (get_map_pages_call_count,get_map_pages_unmap_count,get_scatter_map_call_count,get_scatter_unmap_count) directly within step 8 ofnative_entrybefore returning0x870. Both the native child process andpe_maphost-mapped run verify the counters internally.Independent negative controls:
map_pages_check.pynow independently withholds each named mapping export:XMemMapPhysicalPageswhile providingXMemMapPhysicalPagesScatterhalts at map time withunresolved import xmem.dll!XMemMapPhysicalPages.XMemMapPhysicalPagesScatterwhile providingXMemMapPhysicalPageshalts at map time withunresolved import xmem.dll!XMemMapPhysicalPagesScatter.Documentation scoping & ABI basis:
docs/experiments.mdnow explicitly cites the public declarations (SlimEraera.h, WinDurangokernelx.h) and clarifies that return types, 64 KiB alignment requirement, and NULL unmapping remain controlled provider policies and open hypotheses until physical registry tracking and readback are proven.Passes
cpu_native_map_pagesunder bothdevandreleasepresets, plus all pure-Python checks (docs_links_check.py,bidi_controls_check.py,form_coverage_check.py, andgit diff --check).Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T17:02:28Z.
24e58ebaddresses the startup wrapper, in-process counters and the two missing-export cases. One acceptance gap remains before resolving the docs conflict: the recorder currently checks the shape and tally, but a wrong page number or swapped scatter destinations can still satisfy the caller. Please make the trace or assertions distinguish the expected count, page IDs and ordered addresses, with a changed-argument control. Keep those exact values labeled as fixture inputs.Imported from R0Y00/Xbox2Windows. Originally posted by Holastor on 2026-11-23T17:11:48Z.
Updated in
379b0d6:Distinguish expected count, page IDs, and ordered addresses:
recorded_map_address,recorded_map_count,recorded_map_pages,recorded_scatter_addresses,recorded_scatter_count,recorded_scatter_pages).map_pages_check.pyasserts the recorded trace against the expected fixture inputs:0x10000000, page count:2, page IDs:[1, 2].[0x10000000, 0x10010000], page count:2, page IDs:[1, 2].Changed-argument controls:
argument_mismatches:[999, 888]), returningNULL.[0x10010000, 0x10000000]), returning0.map_pages_caller.asmexercises both changed-argument controls (steps 8 and 9) and verifies both rejections.Fixture input labeling:
docs/experiments.md,map_pages_check.py, andmap_pages_provider.cppexplicitly label0x10000000,cPages = 2,[1, 2], and[0x10000000, 0x10010000]as synthetic fixture inputs chosen for this test.Independently passed
cpu_native_map_pagesunderdevandreleasepresets, plus all pure-Python checks (docs_links_check.py,bidi_controls_check.py,form_coverage_check.py, andgit diff --check).Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T17:14:54Z.
Thanks for adding the exact arguments and the two changed-argument cases. I resolved the CMake and documentation conflicts with the landed XMem fixtures in
f9ecbb5. The contiguous/scatter recorder and tools-memory fixture passed 2/2 in Debug and Release. Both loaders returned the fixture's expected result, the recorder checked the ordered addresses and page values, and withholding either import stopped before entry with its exact name. Fresh CI is running. This PR covers the recorder; shared backing, aliasing, and map/unmap policy remain follow-up work.