Repository navigation
Conversation
…nt wrap In mubuf, buffer_atomic, and mubuf_d16, the mem_windows == 1 path computed t_off = voff + OFFSET and checked t_off + bytes <= d2 in 32-bit uint, unlike the multi-window path which already uses uint64_t. A large/negative voff (e.g. 0xFFFFFFFC with bytes=4, or 0xFFFFFFF0 with OFFSET=16) wrapped past 2^32 to 0 <= d2 and performed an out-of-bounds load, store, or atomic instead of treating the access as out of bounds. Compute t_off and the raw bounds comparison in uint64_t for both single- and multi-window modes, with a GPU regression test covering BUFFER_LOAD_DWORD, BUFFER_STORE_DWORD, BUFFER_ATOMIC_ADD, and BUFFER_LOAD_SHORT_D16. Assisted-by: OpenCode (Gemini 4 Neon)
Owner
Author
|
Upstream PR xcl-dev#1146 was closed or merged. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In
mubuf,buffer_atomic, andmubuf_d16, the single-window (mem_windows == 1) path computedt_off = voff + OFFSETand checkedt_off + bytes <= d2in 32-bituint, unlike the multi-window path which already usesuint64_t. A large/negativevoff(e.g.0xFFFFFFFCwithbytes = 4, or0xFFFFFFF0withOFFSET = 16) wrapped past2^32to0 <= d2, reading or writing out of bounds instead of treating the access as out of bounds.This hoists
uint64_t t_offand uses the 64-bit raw bounds check in both single- and multi-window modes acrossmubuf,buffer_atomic, andmubuf_d16.What is in it
crates/xcl/src/gpu/recomp/emit.rs: computet_offand rawSTRIDE == 0bounds comparisons inuint64_tformubuf,buffer_atomic, andmubuf_d16regardless ofmem_windows.crates/xcl/src/gpu/recomp/tests.rs: add GPU testgpu_mubuf_raw_bounds_do_not_wrap_32bitcoveringBUFFER_LOAD_DWORD,BUFFER_STORE_DWORD,BUFFER_ATOMIC_ADD, andBUFFER_LOAD_SHORT_D16(verified failing before the fix); update the HLSL text check inatomic_fcmpswap_x2_is_a_bitwise_64_bit_casfor the widened comparison.Tested
stable-x86_64-pc-windows-msvc), DXC 1.9.2609.5, debug (scripts/test.ps1) and release (scripts/smoke.ps1).\scripts\test.ps1(cargo build --workspace+cargo test --workspace -- --test-threads=4): 742 passed, 0 failed, 41 ignored (SKIPPED GPU tests: 2no wave64—gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask,gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware)cargo test -p xcl --lib gpu_mubuf_raw_bounds_do_not_wrap_32bit: 1 passed, 0 failed (failed on the GPU before the fix, reading0xDEAD_BEEFfrombase - 4)Regression run
main:
PR:
Not tested
AI use
emit.rs, wrote the fix and GPU test, ran the test suite andscripts/smoke.ps1regression runs, and drafted this PR description.Mirror of xcl-dev#1146 (auto-synced, do not edit).