Repository navigation
XG: fix CopyFromSubresource 7-argument ABI and guard destination span - #684
JGonzalezRodriguez wants to merge 1 commit into
Conversation
CopyFromSubresource (vtable slot xcl-dev#9) takes an extra u32 argument before src: (dst, plane, sub, arg4, src, row_pitch, slice_pitch). With the old 6-argument signature, src was decoded as row_pitch and rows were copied far outside dst, causing access violations (xcl-dev#477, xcl-dev#662). Update copy_from and xg_oracle to the 7-argument ABI, validate row_pitch, 3D slice_pitch, and destination span readability before writing (logging a bounded warning and returning E_INVALIDARG on invalid spans), and add 2D, 3D, and invalid-span unit tests. Fixes xcl-dev#477 Part of xcl-dev#662
|
This branch seems to fix #477 on Linux! |
|
Hardware check of Tested
Regression run PR ( Not tested
AI use
|
|
@odd/tasks/draft-pr684-comment.md |
|
A retail run that reaches the call, on native Windows – the reports above cover the suite and the 60 s regression pair, which stay on the title's first screens. Tested
Not tested: AMD and Intel GPUs; One thing you may want: I had the same fix with a test of the title's own first call – BC7 512×512 with its full mip chain through both methods, level by level, nothing written between or after the rows; on AI use: Claude Code with Claude Fable 5.2 ran the builds, tests and runs and wrote this report; every number is from a run on the machine named. No game files are attached. |
|
Tested - Tool: OpenCode with DeepSeek V4.1 Flash 1017
Tested - native Windows, AMD RDNA2
Not tested: the #477 crash through a retail title ( AI use: OpenCode with DeepSeek V4.1 Flash 1017 ran the tests and drafted this report. |
|
Linux (Wine) run that reaches the call, with details for the one-line Linux report above. Tested
What came after
Not tested: Windows. The workspace suite: XCL doesn't build or run tests on Linux, so only the cross-built binaries ran. This PR without #273 on a run that reaches the call. AI use: Claude Code (Claude Opus 5.5) built the branches, read the logs and the kernel journal, and drafted this comment. The runs are mine, on the hardware above. |
|
Test report on native Windows for e56dbc3 (this PR's head), since the description has no Windows run yet. Written with Claude Code (Claude Fable 5.2) from runs on my machine; the blocks below are the unedited output of Tested
Regression run (a retail title, 60 s, no input) main (91f9a5e, this PR's merge base): this PR (e56dbc3): Not tested
|
|
Code audit + NVIDIA RTX 5080 test run on Review
Tested
Not tested
AI use: code review and test run orchestrated with Antigravity (Gemini 4 Neon) on the hardware listed above. |
Integrates upstream PR xcl-dev#684 while retaining read_committed on sparse or partially-committed source ranges: - Fix vtable slot xcl-dev#9 signature to (dst, plane, sub, arg4, src, row_pitch, slice_pitch) so src is no longer misinterpreted as pitch. - Validate row_pitch, 3D slice_pitch, and destination span before copying.
Integrates upstream PR xcl-dev#684 while retaining read_committed on sparse or partially-committed source ranges: - Fix vtable slot xcl-dev#9 signature to (dst, plane, sub, arg4, src, row_pitch, slice_pitch) so src is no longer misinterpreted as pitch. - Validate row_pitch, 3D slice_pitch, and destination span before copying.
Test stack: upstream PRs xcl-dev#684, xcl-dev#541 and xcl-dev#273 on main
Integrates upstream PR xcl-dev#684 while retaining read_committed on sparse or partially-committed source ranges: - Fix vtable slot xcl-dev#9 signature to (dst, plane, sub, arg4, src, row_pitch, slice_pitch) so src is no longer misinterpreted as pitch. - Validate row_pitch, 3D slice_pitch, and destination span before copying.
|
Linux + NVIDIA run that reaches the call: Setup: Fedora 44 (kernel 7.2.9), Wine 11.21 Staging (X11), vkd3d-proton 3.1 with the relaxed-vtable patch from #175 and a local dxil-spirv patch,
The fault on
With the PR, the title presented for about 14 s more and then stopped, and its watchdog ended it 29 s later. Not tested: the AI use: Claude Code (Claude Fable 5.2) read the diff, ran both builds of the title on my machine with |
Integrates upstream PR xcl-dev#684 while retaining read_committed on sparse or partially-committed source ranges: - Fix vtable slot xcl-dev#9 signature to (dst, plane, sub, arg4, src, row_pitch, slice_pitch) so src is no longer misinterpreted as pitch. - Validate row_pitch, 3D slice_pitch, and destination span before copying.
Integrates upstream PR xcl-dev#684 while retaining read_committed on sparse or partially-committed source ranges: - Fix vtable slot xcl-dev#9 signature to (dst, plane, sub, arg4, src, row_pitch, slice_pitch) so src is no longer misinterpreted as pitch. - Validate row_pitch, 3D slice_pitch, and destination span before copying.
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Thanks! |
CopyFromSubresource takes an extra argument before the source pointer. The old signature reads the pointer as the row pitch and copies rows outside the destination, causing the loading-screen access violation. Integrate xcl-dev#684, upstream commit e56dbc3, without unrelated changes. This preserves the proposed 2D/3D copy tests and destination span checks. AI use: Codex (GPT-6) applied the existing upstream patch and ran local validation. The patch was authored upstream; see PR xcl-dev#684 for its AI use. Assisted-by: Codex (GPT-6)
…1860, xcl-dev#1913, xcl-dev#2192, xcl-dev#1946, xcl-dev#2237 Integrates XG CopyFromSubresource 7-arg ABI (xcl-dev#684), DirectStorage physical-page list re-read (xcl-dev#1405), vkd3d-proton in-place vtable patching with UnadoptGuard composition (xcl-dev#1395), single-back-edge Direct DXIL CFG (xcl-dev#1860), wave64 graphics Direct DXIL guard (xcl-dev#1913), and AMD RDNA2-4 DXIL fuzz fixes (xcl-dev#2192, xcl-dev#1946, xcl-dev#2237).
…1946, xcl-dev#1803, xcl-dev#2297, xcl-dev#2320, xcl-dev#2333 Carries forward still-open high-value upstream PRs onto upstream/main (2898511) + our updated Wine PR stack (xcl-dev#867, xcl-dev#1395-successor, xcl-dev#871, xcl-dev#877, xcl-dev#1732). Preserves UnadoptGuard in xcl-dev#2320 KickoffX reset_one. Assisted-by: Antigravity (Gemini 4 Neon)
…1946, xcl-dev#1803, xcl-dev#2297, xcl-dev#2320, xcl-dev#2333 Carries forward still-open high-value upstream PRs onto upstream/main (2898511) + our updated Wine PR stack (xcl-dev#867, xcl-dev#1395-successor, xcl-dev#871, xcl-dev#877, xcl-dev#1732). Preserves UnadoptGuard in xcl-dev#2320 KickoffX reset_one. Assisted-by: Antigravity (Gemini 4 Neon)
|
Confirmed on a second retail title, GTA (Xbox Series, gta5.exe), native Windows, RTX 3050 8 GB, 32 GB RAM, xcl main 0829441. Without the extra argument, CopyFromSubresource reads the source pointer as the row pitch (0x458a9000). The copy is refused (destination span 0x227fbd7800 is not committed), and the game then crashes: read of 0xffffffffffffffff at gta5.exe+0x5228010. With slot 9 as (dst, plane, sub, flags, src, row_pitch, slice_pitch), row pitch is 0x800 or 0x100, the copy succeeds, and that crash is gone. The title gets into shader compilation. |
bmjask
left a comment
There was a problem hiding this comment.
P1: copy_from validates dst with gpu::shader::readable, which accepts committed PAGE_READONLY pages, then raw copy_nonoverlapping writes and can AV. Validate writability or use a fault-safe process write; validate src before raw slice/detile too. P2: readable rejects spans >256 MiB, but valid XG 16,384x16,384 4-Bpp subresources reach 1 GiB, so valid calls become E_INVALIDARG. Use a destination-specific region validator without this cap/iterate regions. Add read-only dst, invalid src, and >256 MiB valid-span tests.
Fix
XGTextureAddressComputer::CopyFromSubresource(vtable slot #9) taking 7 arguments instead of 6, and validate the destination span before writing rows.CopyFromSubresourcereceives an extrau32parameter beforesrc(dst, plane, sub, arg4, src, row_pitch, slice_pitch). With the previous 6-argument signature,srcwas read asrow_pitch, causingcopy_nonoverlappingto stride rows by the low 32 bits of the source pointer and trigger access violations (#477, first crash in #662).Supersedes #539 (the other parts of #539 have either landed on
mainin #435 / #451 / #486 / #574 / #602 / #634 / #636, are covered by focused open PRs, or need a separate single-purpose PR).Fixes #477
Part of #662
What is in it
crates/xcl/src/hle/xg.rs:copy_from(vtable slot Olympus: harden DXIL cache identity and validation #9) and the module doc comment to the 7-argument signature(dst, plane, sub, arg4, src, row_pitch, slice_pitch).row_pitch, 3Dslice_pitch, and destination span readability (gpu::shader::readable) before copying, logging a bounded warning and returningE_INVALIDARGon invalid spans.copy_into_and_copy_from_round_trip,copy_from_3d_round_trip, andcopy_from_rejects_invalid_dst_span.crates/xcl/tests/xg_oracle.rs:CopyFromSubresourcecall insubresource_copies_match_the_console_libraryto the 7-argument signature.Tested
rustc 1.98.1, debug,x86_64-pc-windows-msvcviaclang-cl+lld-link+xwin):cargo check --workspace --target x86_64-pc-windows-msvc --tests: passed (0 errors, 0 warnings).wine-11.0) on AMD Ryzen 9 7950X3D + NVIDIA GeForce RTX 4090 (driver610.57.04), debug:xcl --lib hle::xg::tests: 6 passed, 0 failed, 0 ignored (rgba8_64kb_s_layout,d16s8_is_planar_depth_and_stencil,console_floats_are_32_bits,copy_into_and_copy_from_round_trip,copy_from_3d_round_trip,copy_from_rejects_invalid_dst_span).xg_oracle: 6 passed, 0 failed, 12 ignored (oracle tests return early withoutXCL_SAMPLE_XG).xgcommits from D3D12.X / XG: async texture upload, detiling, VRAM, XG ABI, and PSO scheduling improvements #539 were also independently tested against a retail title by @ddm-j in D3D12.X / XG: async texture upload, detiling, VRAM, XG ABI, and PSO scheduling improvements #539 (comment) (confirmed validrow_pitch/slice_pitchand no access violation).Regression run
scripts/smoke.ps1runs (opened as draft until native Windowsscripts/test.ps1andmain+ PRxcl-smokeblocks are attached).Not tested
scripts/test.ps1(full workspace suite) andscripts/smoke.ps1regression runs (author builds on Linux/Wine).tests/xg_oracle.rswithXCL_SAMPLE_XGset against the consolexg_xs.dll.AI use
origin/main, refined the 2D/3D destination span check, wrote unit tests, ran cross-compile + Proton Wine checks, and drafted the PR description; reviewed by author).