Recompiler: treat raw buffer offsets that wrap past 2^32 as out of range #1923
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1933"
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 ivall/xcl. Originally posted by PracticalStudios on 2026-11-24T23:42:45Z.
Direct-DXIL raw buffer loads, stores and atomics now treat an offset that wraps past 2^32 as out of range. Part of #1893 (the raw-buffer part; the
s_buffer_loadpart is not changed).Why:
voff + OFFSETandoff + byteswere added in 32 bits, so a wrapped sum passed the bounds check. Onmain, abuffer_load_dwordat voff0xFFFF_FFF0+ OFFSET0x20on a 0x100-byte buffer returned another dword of the buffer (4116) instead of 0.What is in it
lower_mem.rs:mubuf'sin_rangeandbuffer_atomicalso require the sums not to wrap.gpu_direct_raw_buffer_offsets_that_wrap_are_out_of_range: wrapped loads read 0, a wrapped store and wrapped atomics (also with a non-zero OFFSET) are dropped; an in-range lane is the control.Tested
main(left: 4116, right: 0) and passes here; removing each of the two checks fails it.cargo test --workspace --no-fail-fast -- --test-threads=2onaa16bda: 1154 passed, 1 failed, 46 ignored. The failure (kernelx::tests::xmem_virtual_query_marks_cpu_readable_memory) fails the same way onmain(fixed by #650).Regression run
.\scripts\smoke.ps1 -Game <retail title> -Seconds 60, no input,main(this PR's base) first, same machine:Not tested
index < num_records).AI use
Imported from ivall/xcl. Originally posted by upipibi on 2026-11-24T23:45:27Z.
The HLSL path has the same wrap in one of its two forms, from reading
recomp/emit.rsonmain(not run). In MUBUF's range check:mem_windows > 1),_off = (uint64_t)voff + OFFSETand_off + bytes <= num_recordsare 64-bit, so a wrapped sum stays out of range (fine);uint _off = voff + OFFSET;andin_range=_off + bytes <= num_recordsare 32-bit.voff = 0xFFFF_FFF0withOFFSET = 0x20gives_off = 0x10, which passes on a 0x100-byte buffer, as on the direct path before this PR.Measured (edited; this replaces my earlier "should"). I ran this PR's program through the HLSL path on
main20cf130with one window (runner::run_code,XCL_DIRECT_DXILunset), on an RTX 3070, driver 616.56:0xFFFF_FFF0+ OFFSET0x20:0x1014(4116), want 0;0xFFFF_FFFC, no OFFSET:0x100f, want 0. So_off + byteswraps as well, not onlyvoff + OFFSET;0xFFFF_FFF0+0x20wrotemem[0x50 / 4](0xC0DE0000), which should be untouched.Widening the one-window
_offand thein_rangesum to 64 bits, as the multi-window branch already does, would cover both.AI-assisted (Claude Code).
Imported from ivall/xcl. Originally posted by PracticalStudios on 2026-11-25T00:06:49Z.
@upipibi thanks, confirmed: the same wrap shows on the HLSL path's one-window form here too. #1146 (b3IKK) already widens those
mubuf/buffer_atomic/mubuf_d16checks to 64 bits, so I've left that path to it and kept this PR to direct DXIL.AI use: Claude Code (Claude Opus 5.5) wrote this reply.
Imported from ivall/xcl. Originally posted by futurepro62 on 2026-11-25T00:56:00Z.
Full-suite run, since this PR has no test report yet. Tested exact head
bb5e0b7(on its base689f2db).Tested
cargo build --workspace, thenXCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4 --skip heap_window_out_of_memory_falls_back_to_the_switch_form --skip gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f64_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::const_and_null_mask_operands_agree_with_hlsl_on_the_gpu --skip gpu::dxil::fuzz_tests: 966 passed, 0 failed, 43 ignored. SKIPPED (no wave64):a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu,a_per_lane_2d_or_3d_group_runs_on_the_gpu,coalesced_guarded_runs_agree_with_the_hlsl_path_on_the_gpu,cross_lane_reads_agree_with_the_hlsl_path_on_the_gpu,gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware,the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu.gpu_direct_raw_buffer_offsets_that_wrap_are_out_of_range.XCL_ADAPTER=radeon),cargo test --workspace -- --test-threads=4 --skip gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1: 975 passed, 0 failed, 45 ignored. SKIPPED:f16_programs_on_the_gpu(f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))),f16_programs_on_the_gpu(f16 arithmetic, wave64, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))),f16_programs_on_the_gpu(f16 packed, wave32, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))),f16_programs_on_the_gpu(f16 packed, wave64, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))),f32_programs_on_the_gpu(f32 conversions, wave32, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))),f32_programs_on_the_gpu(f32 conversions, wave64, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))),heap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows).--skipleaves out tests that fail on main7994cd1too, not because of this PR. On NVIDIA:heap_window_out_of_memory_falls_back_to_the_switch_form(#1651), the fourgpu::recomp::lower_dxil::tests::*_programs_on_the_gputests andconst_and_null_mask_operands_agree_with_hlsl_on_the_gpu(follow-up on #1651) fail becauserunner::skip_testturns their skips into failures underXCL_REQUIRE_GPU=mesh, andgpu::dxil::fuzz_testsseeds 70, 545, 1019 and 1507 failCreateComputePipelineStatewithE_OUTOFMEMORYon this card (drivers 616.64 and 621.40). On AMD:fuzz_validate_and_gpu_1fails on seed 540 (res[833]0x7 vs CPU 0x6). The AMD run does not setXCL_REQUIRE_GPU.Not tested
AI use
Imported from ivall/xcl. Originally posted by raylitebull on 2026-11-25T01:08:18Z.
Diff audit passed (
lower_mem.rs32-bit wrap checksoff >= voffande >= offinmubufandbuffer_atomic, plus GPU testgpu_direct_raw_buffer_offsets_that_wrap_are_out_of_range),Build and test+PR descriptionare green onbb5e0b7, and NVIDIA (RTX 3090, RTX 5070 Ti) verified it.Remaining before merge: one independent AMD GPU pass on
bb5e0b7.Imported from ivall/xcl. Originally posted by PracticalStudios on 2026-11-25T01:29:37Z.
Rebased onto
main8f5fca5to resolve a conflict at the end ofrecomp/tests.rs(#1990's test landed in the same spot). Thelower_mem.rschange and the test are unchanged, so the runs onbb5e0b7above still apply; the regression blocks for the new head follow.Rebased again onto
cbc296a(sametests.rsend-of-file conflict): the test now sits next to the other raw-buffer bounds tests instead of at the end of the file, so later appends don't collide with it. Code and test unchanged; new headaa16bda, its blocks are in the description.AI use: Claude Code (Claude Opus 5.5) wrote this note.
Imported from ivall/xcl. Originally posted by raylitebull on 2026-11-25T01:36:11Z.
Build and test (Windows, no GPU)just passed on7946c96! Two small items remain before merge:PRxcl-smoke v1block in the PR description (commit:still points tobb5e0b7instead of7946c96, causing thePR descriptioncheck to fail).gpu_direct_raw_buffer_offsets_that_wrap_are_out_of_rangeon7946c96.Imported from ivall/xcl. Originally posted by upipibi on 2026-11-25T02:37:01Z.
Re-checked
7946c96on the RTX 3070 (driver 616.56): the newgpu_direct_raw_buffer_offsets_that_wrap_are_out_of_rangepasses withXCL_DIRECT_DXIL=0and1.AI-assisted (Claude Code).
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T02:41:02Z.
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)Thanks!
Imported from ivall/xcl. Originally posted by PracticalStudios on 2026-11-25T02:21:31Z.
@philip-roy-jones would you have a few minutes for this PR's remaining check, an AMD run? Your RX 580 (native 64-lane waves) would cover what the NVIDIA runs couldn't. On head
7946c96:(and the full
cargo test --workspaceif you have the time). No worries if not.As additional verification (my own run, so not the independent one): on this machine's AMD Radeon iGPU (Ryzen 7 9800X3D, RDNA2, driver 32.0.21042.62,
XCL_ADAPTER=radeon), head7946c96:gpu_direct_raw_buffer_offsets_that_wrap_are_out_of_range1 passed;gpu::dxil108 passed, 1 failed —fuzz_validate_and_gpu_1seed 540 (res[833] = 0x7, CPU 0x6), the AMD failure already seen onmain.AI use: Claude Code (Claude Opus 5.5) wrote this request.
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-26T06:41:22Z.
Re-verification on RTX 3060 Ti (Windows 11), new head merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved.Thanks!
— Devin
Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-11-30T08:43:33Z.
Nothing has happened on this PR for 3 days, so it is marked
staleand will be closed in 4 days. A push or a comment takes the mark off: rebase it ontomainif it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T07:06:49Z.
Triage (#1607) – head
aa16bdaMain already has this fix. #3265 (
cb7fe9bd,Recompiler: guard 32-bit raw-buffer OOB wraparound in Direct DXIL) adds the same two checks to the stride-0 bounds of both the MUBUF access andbuffer_atomicingpu/dxil/lower_mem.rs:off >= voffforvoff + OFFSETande >= offforoff + bytes. The only difference is that main skips the first check when OFFSET is 0, where it is always true.This PR's GPU test
gpu_direct_raw_buffer_offsets_that_wrap_are_out_of_rangechecks loaded values and memory. Main's test (raw_buffer_oob_check_guards_32bit_wraparound) only countsicmp ugein the disassembly. The GPU test could still be offered as a test-only PR.Recommendation: close (superseded by #3265 / main commit
cb7fe9b).AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
Imported from ivall/xcl. Originally posted by throny on 2026-12-01T12:49:55Z.
Closing as superseded: this change is already on
main(cb7fe9bd). main lower_mem.rs adds off_no_wrap (voff + OFFSET) and e_no_wrap checks to raw mubuf and buffer_atomic bounds, plus a core_tests test; equivalent to the PRTwo independent checks found this: Foniass's close list on #1607 and ours against current
main. If something here is still missing onmain, say so and reopen it, or ask and I will.AI use: Claude Code (Claude Opus 5.5); the per-PR comparison was done by Claude Sonnet 5.5 sub-agents.
Pull request closed