Skip to content

kernelx: XMemMapPhysicalPagesScatter with no page array unmaps - #495

Draft
notdxbi wants to merge 1 commit into
ivall:mainfrom
notdxbi:pr-scatter-null-unmaps
Draft

notdxbi wants to merge 1 commit into
ivall:mainfrom
notdxbi:pr-scatter-null-unmaps

Conversation

@notdxbi

@notdxbi notdxbi commented Nov 24, 2026 •

Copy link
Copy Markdown

A retail game unmaps addresses while it streams its world with XMemMapPhysicalPagesScatter(addresses, n, NULL). It checks the result and runs into its own int3 when the call fails (+0xb18de7; the function at +0xb18dc0 calls the scatter through its IAT slot and breaks on 0), then its crash reporter. XCL refused a NULL page array with ERROR_INVALID_PARAMETER. Page 0 already means "unmap this address" in a scatter, so no array is now taken as page 0 for every address. Part of #175 (#175 (comment)).

What is in it

  • hle/kernelx.rs: XMemMapPhysicalPagesScatter with a NULL page array unmaps each address (through the existing page-0 path).
  • Test scatter_without_pages_unmaps: two pages mapped and written, unmapped with no array (the call succeeds, the addresses are no longer committed), mapped again they read what was written. Without the change it fails ("no page array: unmapped, not refused").

Tested

  • RTX 5060 8 GB (NVIDIA 595.112.07), Ryzen 7 5700X, Linux under Wine 11.22 Staging (vkd3d-proton master with the two from_iface checks relaxed and -Db_ndebug=true, as in Linux: docs/linux.md, scripts/linux and Wine start-up checks for vkd3d-proton and DXVK (#154, #241) #257; DXVK 3.1.1 dxgi), Rust stable x86_64-pc-windows-gnu (cross-built), release
  • lib suite on this branch (main 2997c9a + this commit): CPU tests --skip gpu:: --test-threads=4: 364 passed, 0 failed, 3 ignored; GPU tests gpu:: --test-threads=1: 271 passed, 0 failed, 18 ignored (run serially: with 4 threads this card sometimes loses the device, NVRM Xid 109, in tests this change does not touch). mesh_dispatch::tests::gpu_* / paired_* were excluded: they hang this GPU on main too.
  • SKIPPED on this adapter: gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware (no wave64)
  • Retail title (Series S profile, where the run reached it first): before, int3 at +0xb18de7 at ~113 s; after, the run went on past it.

Regression run

  • None: scripts/smoke.ps1 needs Windows (see Not tested).

Not tested

  • Windows: no Windows machine here, so no scripts/smoke.ps1 blocks and no MSVC build; this PR needs someone to run the regression on Windows before it can be merged.
  • AMD.
  • Once these unmaps succeed, the next stop on this 8 GB card was a GPU fault from tiles unmapped ahead of work in flight; that is fixed separately (D3D12.X: unmap sparse tiles after the work the title's queues were given #496).

AI use

  • Claude Code with Claude Opus 5.5: found the cause, wrote the change, the test and this description. The runs and numbers are real, on the hardware above; the PR is opened by me after checking them.

🤖 Generated with Claude Code

A retail game unmaps addresses while it streams its world with
XMemMapPhysicalPagesScatter(addresses, n, NULL); it checks the result
and runs into its own int3 when the call fails (+0xb18de7, then its
crash reporter). XCL refused a NULL page array with
ERROR_INVALID_PARAMETER. Page 0 already means "unmap this address" in a
scatter, so no array is taken as page 0 for every address.

Test scatter_without_pages_unmaps: two pages mapped and written, unmapped
with no array (the call succeeds, the addresses are no longer committed),
mapped again they read what was written. It fails without the change
("refused").

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant