runtime: serve a refused slot 148 upload page from a CPU reserve #3732

Merged
lambirou merged 5 commits from upstream-pr/3732 into main 2026-12-03 06:50:46 +00:00
lambirou commented 2026-12-01 12:44:32 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by lambirou on 2026-12-01T12:44:32Z.


Problem

The console builder module fills 32-byte records through the pointer command-list slot 148 returns and never checks it. In a local full-stack x64 run at 164.71 s (a local integration of main at e1161e43 with #3728) the first 8-byte store of that loop faulted at address 0: mov [rcx+rsi], rax with rcx = 0, rsi = 0, reported parameters 0x1 (write) and 0x0.

The line logged immediately before it named the producer:

x2w-render slot148 list=... stage=CreateCommittedResource hr=0x8007000e bytes=560 alignment=16 pageBytes=65536 open=1 closeFailed=0 device=1 recording=1

x2w_upload::Arena::allocate creates one desktop upload page per recording on its first request, and CreateCommittedResource returned E_OUTOFMEMORY under the run's memory pressure. The same interval logged DirectStorage out of memory and a list Close failure with 0x8007000e. The arena returned an empty allocation, slot 148 returned null, and the title stored through it.

Change

A slot 148 request that no upload page can back is served from a bounded, process-wide CPU reserve (src/startup_stubs/list_upload_pages.h):

  • Allocation::cpu_only marks the slice: zeroed, aligned, writable, gpu = 0, no resource.
  • CpuReserve asks for one region with VirtualAlloc (4 MiB, falling back to 256 KiB and then 64 KiB) when an upload page first succeeds, so the memory exists before the run needs it. It is bounded and never grows.
  • Arena::range and Arena::translate only see page-backed allocations, so a reserved range has no desktop address. The index-view, root-SRV and indirect-record paths already refuse a range they cannot map; a graphics root SRV falls back to the existing 64 KiB title-memory copy.
  • Slot 148 logs -> CPU reserve, no GPU address, or the previous null line once the reserve is spent, and the presentation heartbeat reports the slice count and bytes.

Evidence and tests

Windows 11 26200, MSVC 14.44, cmake --preset release (warm tree, full build exit 0):

ctest --preset release --no-tests=error -R '^(startup_upload_reserve|startup_upload_arena_warp|startup_upload_arena_hardware|startup_upload_lifetime_warp|startup_slot148_acceptance_warp|startup_slot148_acceptance_hardware|startup_resource_budget_warp_debug0|startup_indirect_draw_indexed_warp|startup_indirect_translated_indexed_upload_warp|startup_list_dispatch|startup_list_dispatch_native_warp|startup_address_srv_warp|upload_reservation|cpu_srv_upload|startup_list_copy_warp)$'

Result: 15 passed, 0 failed, 0 skipped. The hardware cases ran on AMD Radeon RX 9060 XT, driver 32.0.32029.2010, debug layer as configured by each test. tests/docs_links_check.py passed (208 Markdown files, 802 links).

The new fixture tests/startup_upload_reserve.cpp (registered as startup_upload_reserve from tests/cmake/startup_upload_reserve.cmake, added to the pr build targets and test filter) replaces the page maker, so both outcomes run without a device or an upload heap:

  • the page maker succeeds: the allocation is page-backed, translate maps the full range and refuses a longer one, the page rolls over when it cannot cover a request, and 17 32-byte records fill and read back;
  • the page maker fails with E_OUTOFMEMORY as in the observed run: the allocation is non-null and cpu_only, translate/range refuse it, and the same record fill lands in the reserve without touching address 0;
  • a request larger than the reserve: empty allocation and the record fill writes nothing; a 16-byte allocation refuses a two-record fill and stays zeroed.

Negative control: with Arena::allocate changed to return {} after a failed page (one line), the fixture fails with upload reserve contract failed: refused page returned null (exit 5). Restored, it passes.

Limits

  • This adds no memory back to the recording. The records have no desktop upload page, so any GPU read of them depends on the existing title-memory copy path.
  • Once the 4 MiB reserve is spent, slot 148 returns null again and the store can fault. That case is logged.
  • The fixture exercises the arena and the builder's store pattern without a device; it does not run the title. A fresh full-stack run still needs to show whether the stop moves past this site.
  • The stack in the trap log is a module-address scan, not an unwind. The nearest builder frames were +0x1c667, +0x13a32, +0xd772, +0xec7e and +0x216e1, and its d3d12_xs.dll+0x6290 entry is the first byte of a nine-byte function, so that entry is a candidate rather than a return address. No PDB exists for that local build.

Refs #870
Refs #3451
Refs #3639

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5585937247 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3732). Originally posted by [lambirou](https://github.com/lambirou) on 2026-12-01T12:44:32Z. --- ## Problem The console builder module fills 32-byte records through the pointer command-list slot 148 returns and never checks it. In a local full-stack x64 run at 164.71 s (a local integration of `main` at `e1161e43` with #3728) the first 8-byte store of that loop faulted at address 0: `mov [rcx+rsi], rax` with `rcx = 0`, `rsi = 0`, reported parameters `0x1` (write) and `0x0`. The line logged immediately before it named the producer: ```text x2w-render slot148 list=... stage=CreateCommittedResource hr=0x8007000e bytes=560 alignment=16 pageBytes=65536 open=1 closeFailed=0 device=1 recording=1 ``` `x2w_upload::Arena::allocate` creates one desktop upload page per recording on its first request, and `CreateCommittedResource` returned `E_OUTOFMEMORY` under the run's memory pressure. The same interval logged DirectStorage `out of memory` and a list `Close` failure with `0x8007000e`. The arena returned an empty allocation, slot 148 returned null, and the title stored through it. ## Change A slot 148 request that no upload page can back is served from a bounded, process-wide CPU reserve (`src/startup_stubs/list_upload_pages.h`): - `Allocation::cpu_only` marks the slice: zeroed, aligned, writable, `gpu = 0`, no resource. - `CpuReserve` asks for one region with `VirtualAlloc` (4 MiB, falling back to 256 KiB and then 64 KiB) when an upload page first succeeds, so the memory exists before the run needs it. It is bounded and never grows. - `Arena::range` and `Arena::translate` only see page-backed allocations, so a reserved range has no desktop address. The index-view, root-SRV and indirect-record paths already refuse a range they cannot map; a graphics root SRV falls back to the existing 64 KiB title-memory copy. - Slot 148 logs `-> CPU reserve, no GPU address`, or the previous null line once the reserve is spent, and the presentation heartbeat reports the slice count and bytes. ## Evidence and tests Windows 11 26200, MSVC 14.44, `cmake --preset release` (warm tree, full build exit 0): ```powershell ctest --preset release --no-tests=error -R '^(startup_upload_reserve|startup_upload_arena_warp|startup_upload_arena_hardware|startup_upload_lifetime_warp|startup_slot148_acceptance_warp|startup_slot148_acceptance_hardware|startup_resource_budget_warp_debug0|startup_indirect_draw_indexed_warp|startup_indirect_translated_indexed_upload_warp|startup_list_dispatch|startup_list_dispatch_native_warp|startup_address_srv_warp|upload_reservation|cpu_srv_upload|startup_list_copy_warp)$' ``` Result: 15 passed, 0 failed, 0 skipped. The hardware cases ran on AMD Radeon RX 9060 XT, driver 32.0.32029.2010, debug layer as configured by each test. `tests/docs_links_check.py` passed (208 Markdown files, 802 links). The new fixture `tests/startup_upload_reserve.cpp` (registered as `startup_upload_reserve` from `tests/cmake/startup_upload_reserve.cmake`, added to the `pr` build targets and test filter) replaces the page maker, so both outcomes run without a device or an upload heap: - the page maker succeeds: the allocation is page-backed, `translate` maps the full range and refuses a longer one, the page rolls over when it cannot cover a request, and 17 32-byte records fill and read back; - the page maker fails with `E_OUTOFMEMORY` as in the observed run: the allocation is non-null and `cpu_only`, `translate`/`range` refuse it, and the same record fill lands in the reserve without touching address 0; - a request larger than the reserve: empty allocation and the record fill writes nothing; a 16-byte allocation refuses a two-record fill and stays zeroed. Negative control: with `Arena::allocate` changed to `return {}` after a failed page (one line), the fixture fails with `upload reserve contract failed: refused page returned null` (exit 5). Restored, it passes. ## Limits - This adds no memory back to the recording. The records have no desktop upload page, so any GPU read of them depends on the existing title-memory copy path. - Once the 4 MiB reserve is spent, slot 148 returns null again and the store can fault. That case is logged. - The fixture exercises the arena and the builder's store pattern without a device; it does not run the title. A fresh full-stack run still needs to show whether the stop moves past this site. - The stack in the trap log is a module-address scan, not an unwind. The nearest builder frames were `+0x1c667`, `+0x13a32`, `+0xd772`, `+0xec7e` and `+0x216e1`, and its `d3d12_xs.dll+0x6290` entry is the first byte of a nine-byte function, so that entry is a candidate rather than a return address. No PDB exists for that local build. Refs #870 Refs #3451 Refs #3639
Leyukaka commented 2026-12-01 14:14:04 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-12-01T14:14:04Z.

Review: COMMENTED


Please handle CPU-reserve addresses explicitly in the graphics root SRV path. They are absent from the arena lookup, so with the bind-time copy enabled, list_root_srv treats a reserve slice as general application memory and uses a readable window of up to 64 KiB. That window can extend past the slice into adjacent allocations in the same committed region and can trigger another upload while under memory pressure.

Could the bind reject reserve addresses, or bound the copy to the originating slice? A regression check with two adjacent slices would cover this path. The current fixture checks the arena lookup only.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6133012909 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3732#pullrequestreview-6133012909). Originally posted by [Leyukaka](https://github.com/Leyukaka) on 2026-12-01T14:14:04Z. **Review:** COMMENTED --- Please handle CPU-reserve addresses explicitly in the graphics root SRV path. They are absent from the arena lookup, so with the bind-time copy enabled, list_root_srv treats a reserve slice as general application memory and uses a readable window of up to 64 KiB. That window can extend past the slice into adjacent allocations in the same committed region and can trigger another upload while under memory pressure. Could the bind reject reserve addresses, or bound the copy to the originating slice? A regression check with two adjacent slices would cover this path. The current fixture checks the arena lookup only.
R0Y00 commented 2026-12-02 18:46:47 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-02T18:46:47Z.

Review: COMMENTED


A trial merge of 5222b238 into main after #3727 conflicts in CMakePresets.json. Please retain both startup_upload_reserve and startup_mesh86_present_warp in the PR filter. I also checked the earlier root SRV finding on this revision. list_root_srv still falls through to the generic readable_window copy for a reserve address when the address has no GPU mapping and bind-time copy is enabled. Please address that review point before the next Windows run.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6156780800 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3732#pullrequestreview-6156780800). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-12-02T18:46:47Z. **Review:** COMMENTED --- A trial merge of `5222b238` into main after #3727 conflicts in `CMakePresets.json`. Please retain both `startup_upload_reserve` and `startup_mesh86_present_warp` in the PR filter. I also checked the earlier root SRV finding on this revision. `list_root_srv` still falls through to the generic `readable_window` copy for a reserve address when the address has no GPU mapping and bind-time copy is enabled. Please address that review point before the next Windows run.
R0Y00 commented 2026-12-03 06:50:38 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-03T06:50:38Z.

Review: APPROVED


Independently reviewed c5afb411 against main 2710917d, including the slot 148 caller and lifetime of the process-wide reserve. The pre-existing argument and recording checks still run before allocation. CPU-only slices are not inserted in the lookup that supplies desktop addresses. On Windows 11 build 26300, I built tests/startup_upload_reserve.cpp as C++17 with MSVC and ran it; backed allocations, injected E_OUTOFMEMORY, the CPU-only mapping guard and the oversized refusal passed. Replacing the reserve return with an empty allocation failed with exit 5 and refused page returned null. The PR author reports 15/15 on Windows, including WARP and RX 9060 XT; my independent test is the device-free fixture. The reserve is bounded and does not supply a GPU upload page.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6164961835 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3732#pullrequestreview-6164961835). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-12-03T06:50:38Z. **Review:** APPROVED --- Independently reviewed c5afb411 against main 2710917d, including the slot 148 caller and lifetime of the process-wide reserve. The pre-existing argument and recording checks still run before allocation. CPU-only slices are not inserted in the lookup that supplies desktop addresses. On Windows 11 build 26300, I built tests/startup_upload_reserve.cpp as C++17 with MSVC and ran it; backed allocations, injected E_OUTOFMEMORY, the CPU-only mapping guard and the oversized refusal passed. Replacing the reserve return with an empty allocation failed with exit 5 and refused page returned null. The PR author reports 15/15 on Windows, including WARP and RX 9060 XT; my independent test is the device-free fixture. The reserve is bounded and does not supply a GPU upload page.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows!3732
No description provided.