runtime: define the XMem physical-page allocation pair #885
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/892"
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 rasptum on 2026-11-23T16:14:34Z.
Refs #880 and #870.
Desktop
xmem.dllexportsXMemAllocatePhysicalPages(ordinal 7) andXMemFreePhysicalPages(ordinal 8), backed by a new page-number registry,src/era_physical.{h,cpp}. There are nope_mapchanges. Mapping, scatter mapping and transfer remain follow-ups.Source-built comparison and negative controls
cpu_native_xmem_physical_pairtests/cpu/xmem_physical_pair.asmimports the pair by name fromxmem.dlland starts throughexe_startup.asm/finish_exe. The same EXE runs under the Windows loader and underpe_map_run. It returns0x880when all 10 steps pass, or0xF00plus the failing step. The steps cover a valid two-page grant (count unchanged, distinct nonzero numbers, canary intact), a refused short-count release, a valid release afterwards, a refused double free, a refused bad flag (count reset to 0, three canaries intact) and a refused null-array release. The negative controlsfull_countandskip_releasegive0xf04and0xf06on both loaders. A provider missing either export stops the mapping before entry withunresolved import xmem.dll!<name>.era_physical_controlsERA_PHYSICAL_LENIENT_RELEASE, a SlimEra-style release that clears any listed page. Each of 7 controls (short count, long count, single page of a grant, double free, never-issued page, forged mix, duplicate entry) is refused by the policy with the granted total unchanged, and accepted by the lenient build. This shows each control detects wrong ownership or page-count handling.xmem_shim_physical_pagesera_physical_lifetimexmem_shim_exportsCompanion fixture and credit: triggered02's draft #887 holds their independent fixture and negative controls (CTest
cpu_native_xmem_physical, branchxmem-physical-pages,7dcc36d/3d206a1). This PR does not copy that code and does not reuse its CTest name; the test here iscpu_native_xmem_physical_pair. The EXE comparison here follows its design: Windows loader vspe_map, a canary-filled page array and a missing-provider control. This version adds thefinish_exewrapper, so success is the nonzero code0x880rather than a bare return of 0, plus the two mutation variants. Native-start tests found that a bare entry return can end the process with a worker thread's code 0. Co-authored-by is in the commit.Evidence and proposed desktop policy
The Microsoft Xbox-GDK-Samples (MIT,
b1e77b6) establish the 64 KiB allocate/free pairing, the in/out count with aPULONG_PTRpage array, and theBOOLsuccess check. SeeAdvancedESRAM/PageAllocator.cppL193-232 andFSR3FrameInterpolation.cppL146-167.The following is proposed desktop policy, labeled as such in the code comments and in
docs/experiments.md:MEM_64K_PAGES(0x20400000) is accepted. Any other bit, including the upper 32, returnsFALSE.*count = 0, the array is untouched, and the error isERROR_INVALID_PARAMETERorERROR_NOT_ENOUGH_MEMORY. The samples do not settle count or array mutation on failure.FALSE/ERROR_INVALID_PARAMETERand changes nothing. The samples do not settle whether partial release is permitted.Results
Windows 10 Pro 10.0.19045.6466, MSVC 19.44.35207.1 x64, CMake/Ninja, commit
729bfa1(rebased onorigin/main406e14a). CPU-only tests, so no adapter or debug layer is involved.release): 19/19 passed.tests/form_coverage_check.py,tests/docs_links_check.py,tests/bidi_controls_check.pyandtests/xmem_attribute_scan_check.pypass.cpu_native_shim_startup. triggered02 reports it passing in Release with their shim.Open contract questions (for #870)
ULONG_PTRorDWORDon the console?ULONG_PTRis inferred from one sample's cast.XMEM_2MB_CLUSTERS, and in which units are the count and array then given? The flag is refused here.No game files, dumps or binaries. All inputs are synthetic.
🤖 Generated with Claude Code
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T16:26:57Z.
Review update at
d0bf29a. The desktop contract now says the count and output buffer are separate, and page numbers can be reused after release. The same-EXE, missing-provider, grant-lifetime and existing XMem regression checks passed 9/9 in Debug and 9/9 in Release. The comparison validates the proposed 64 KiB bookkeeping policy. Actual backing, mapping and console parity remain separate.