startup: stop probing unmapped guest memory from the texture and no-op paths #3767

Open
Leyukaka wants to merge 3 commits from upstream-pr/3767 into main
Leyukaka commented 2026-12-01 17:41:45 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-12-01T17:41:45Z.


Takes over #2245 by @Its3rr0rsWRLD, which had no activity for 48 h. Their commits are kept unchanged; I will hand back if they resume. Supersedes #2245.

Changes

Texture publication and the no-op paths no longer probe guest memory that is not mapped yet, and a texture published by address is retried once the mapping exists.

Rebased the original patch onto main 959306d4 and carried forward the merge resolutions by pigalot. The original commit message mentions export ordinal 23. The rebased code uses ordinal 28 and preserves the existing exports. Removed the 30-frame skip from SRV publication so a second call can succeed immediately after mapping. The existing probe fixture still expects one fault for a repeat on an ordinary reservation. The fixture now also maps the texel and samples it through the retried SRV. Also removed a BOM from tests/xmem_mapped_bytes_check.py.

Verification

Commit aeee2fbcb, dev preset, targets xmem_shim startup_queue_probe startup_stream_consumer:

ctest --preset dev --no-tests=error -R '^(xmem_mapped_bytes|startup_queue_probe_(reserved|xmem)_(warp|hardware)|startup_memory_srv_diag_(warp|hardware|supported_control_warp)|startup_address_(srv_(warp|hardware)|(single_element|bc_view|console|volume_srv)_.*)|startup_resource_address_index_missing_control_warp)$' -V

33/33 passed.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5591137018 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3767). Originally posted by [Leyukaka](https://github.com/Leyukaka) on 2026-12-01T17:41:45Z. --- Takes over #2245 by @Its3rr0rsWRLD, which had no activity for 48 h. Their commits are kept unchanged; I will hand back if they resume. Supersedes #2245. ## Changes Texture publication and the no-op paths no longer probe guest memory that is not mapped yet, and a texture published by address is retried once the mapping exists. Rebased the original patch onto `main` `959306d4` and carried forward the merge resolutions by pigalot. The original commit message mentions export ordinal 23. The rebased code uses ordinal 28 and preserves the existing exports. Removed the 30-frame skip from SRV publication so a second call can succeed immediately after mapping. The existing probe fixture still expects one fault for a repeat on an ordinary reservation. The fixture now also maps the texel and samples it through the retried SRV. Also removed a BOM from `tests/xmem_mapped_bytes_check.py`. ## Verification Commit `aeee2fbcb`, `dev` preset, targets `xmem_shim startup_queue_probe startup_stream_consumer`: ``` ctest --preset dev --no-tests=error -R '^(xmem_mapped_bytes|startup_queue_probe_(reserved|xmem)_(warp|hardware)|startup_memory_srv_diag_(warp|hardware|supported_control_warp)|startup_address_(srv_(warp|hardware)|(single_element|bc_view|console|volume_srv)_.*)|startup_resource_address_index_missing_control_warp)$' -V ``` 33/33 passed.
R0Y00 commented 2026-12-02 02:09:40 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-02T02:09:40Z.


The Linux job's final failed check is tests/standin_exports_check.py. Please rebase, verify the export expectations against the updated stand-in, and rerun that check.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7332538318 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3767#issuecomment-7332538318). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-12-02T02:09:40Z. --- The Linux job's final failed check is `tests/standin_exports_check.py`. Please rebase, verify the export expectations against the updated stand-in, and rerun that check.
R0Y00 commented 2026-12-02 05:33:34 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-02T05:33:34Z.

Review: COMMENTED


I tested the clean merge tree with main e958b8e8. python -B tests/standin_exports_check.py still fails with xmem entries 56 != 54. The extra name and ordinal are x2w_xmem_mapped_bytes and 28; the current catalog classifies both as unmeasured. On the combined tree, changing the expected total to 56 and unmeasured count to 4 makes all 475 checks and all six mutation controls pass. Please update the expectations and add a named/ordinal equivalence assertion for the new export when rebasing.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6145299231 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3767#pullrequestreview-6145299231). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-12-02T05:33:34Z. **Review:** COMMENTED --- I tested the clean merge tree with main `e958b8e8`. `python -B tests/standin_exports_check.py` still fails with `xmem entries 56 != 54`. The extra name and ordinal are `x2w_xmem_mapped_bytes` and 28; the current catalog classifies both as unmeasured. On the combined tree, changing the expected total to 56 and unmeasured count to 4 makes all 475 checks and all six mutation controls pass. Please update the expectations and add a named/ordinal equivalence assertion for the new export when rebasing.
R0Y00 commented 2026-12-02 22:25:29 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-02T22:25:29Z.

Review: CHANGES_REQUESTED


The current trial merge with main 67862ee4 still fails python -B tests/standin_exports_check.py with xmem entries 56 != 54; this is the same catalog failure as the old Linux job. There is also a lifetime issue in xmem_mapped_bytes(): it caches a GetProcAddress result from GetModuleHandleW indefinitely. The latter leaves the module reference count unchanged, and the graphics shim has no import dependency on xmem.dll, so the cached address can outlive the module. Please keep a reference for the lifetime of the cached pointer, or acquire a scoped reference around each call. The current queue probe loads xmem and keeps it loaded throughout, so it cannot verify this ownership requirement. Microsoft Win32 documentation.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6160120922 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3767#pullrequestreview-6160120922). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-12-02T22:25:29Z. **Review:** CHANGES_REQUESTED --- The current trial merge with `main` `67862ee4` still fails `python -B tests/standin_exports_check.py` with `xmem entries 56 != 54`; this is the same catalog failure as the old Linux job. There is also a lifetime issue in `xmem_mapped_bytes()`: it caches a `GetProcAddress` result from `GetModuleHandleW` indefinitely. The latter leaves the module reference count unchanged, and the graphics shim has no import dependency on `xmem.dll`, so the cached address can outlive the module. Please keep a reference for the lifetime of the cached pointer, or acquire a scoped reference around each call. The current queue probe loads xmem and keeps it loaded throughout, so it cannot verify this ownership requirement. [Microsoft Win32 documentation](https://learn.microsoft.com/en-us/windows/win32/api/libloaderapi/nf-libloaderapi-getmodulehandlew).
R0Y00 commented 2026-12-03 02:44:16 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-03T02:44:16Z.


I verified the export-catalog fix in a clean trial merge of aeee2fb with main at 7db6f197. The XMem catalog has 56 entries: 52 implemented and four unmeasured. The new x2w_xmem_mapped_bytes entry and ordinal 28 both resolve as unmeasured. Updating only the expected totals to 56 and 52/4 gave 481 cases, with all six catalog mutations caught. python -B tests/startup_triage_run_check.py also passed. Please carry the two expectation updates into this PR when updating its base.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7365806094 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3767#issuecomment-7365806094). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-12-03T02:44:16Z. --- I verified the export-catalog fix in a clean trial merge of aeee2fb with main at 7db6f197. The XMem catalog has 56 entries: 52 implemented and four unmeasured. The new x2w_xmem_mapped_bytes entry and ordinal 28 both resolve as unmeasured. Updating only the expected totals to 56 and 52/4 gave 481 cases, with all six catalog mutations caught. python -B tests/startup_triage_run_check.py also passed. Please carry the two expectation updates into this PR when updating its base.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/3767:upstream-pr/3767'
git switch 'upstream-pr/3767'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/3767'
git switch 'upstream-pr/3767'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3767'
git switch 'upstream-pr/3767'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3767'
git switch 'main'
git merge --squash 'upstream-pr/3767'
git switch 'main'
git merge --ff-only 'upstream-pr/3767'
git switch 'main'
git merge 'upstream-pr/3767'
git push origin 'main'
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!3767
No description provided.