gpu: check the raw UAV window validation and touching windows #1541
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1548"
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 R0Y00/Xbox2Windows. Originally posted by Asimmimx on 2026-11-24T13:48:29Z.
Change
This adds a device-free check for
src/raw_buffer_uav.h. For a 4- or 16-byte store at a logical address,resolve_raw_uav_storefinds the one window that contains it. Before it does, it validates every window: size in whole dwords, element count withinUINT, a 16-byte-aligned resource offset inside the buffer, an extent within the buffer, no wrap past the last logical address, nonzero size and no overlap. It then returns the rawR32_TYPELESSUAV description for that window.The header's only test is
vm_raw_uav_warp. It uses two valid windows 4 GiB apart and refuses misaligned or out-of-window stores and four bad windows: too wide, unaligned, wrapping and overlapping. None of its windows is sized in partial dwords, has a misaligned or out-of-range resource offset, overruns its buffer, is empty, ends at the last logical address or touches another window. So 9 single-point mutants left it passing (table below).raw_buffer_uavincludes only the header. It resolves eight stores against a hand-worked window, offset,FirstElementandNumElements, and checks the format, dimension and raw flag. The stores cover:It also refuses six bad windows and checks that each refusal leaves the result unchanged.
raw_buffer_uav_adjacent_control(--mutate adjacent) expects the first byte of the upper window to resolve into the lower one, and must fail (WILL_FAIL).The change is test, CMake and
docs/experiments.mdonly. The CMake block follows thevm_raw_uav_${adapter}loop, and the doc sentence follows thevm_raw_uav_run line.Verification
Commit
309cfede(main) plus this change,devpreset (Debug), Windows 11 Pro build 26300.9974, MSVC 19.51.36260, Windows SDK 10.0.26100.0, WARP 10.0.26100.9818.tests/docs_links_check.py,tests/bidi_controls_check.pyandgit diff --checkpassed.Mutation probe
I applied each mutation to the header alone, rebuilt, ran the tests, then reverted. None of this is committed.
vm_raw_uav_warpraw_buffer_uavselected != countdroppedbytes % 4guard droppedbytes / 4 > UINT_MAXguard droppedresource_offset % 16guard droppedresource_offset > resource_widthguard droppedbytes > width - resource_offsetguard droppedbytes - 1 >→bytes >offset >= bytes→>!window.bytesguard dropped<→<=FirstElementin bytes instead of elementsThe last row is dead code under the alignment rules. Window bases are 16-aligned and the address is aligned to the store size, so the gap before a window is always at least the store size. Deleting the guard changes nothing.
No current caller builds two touching windows. The check treats them as accepted because the header requires only that a store fit inside one window. If you would rather treat touching windows as an error, I will change that case.
Checklist
AI-assisted (Claude Code).
Imported from R0Y00/Xbox2Windows. Originally posted by Makto94 on 2026-11-24T15:14:31Z.
Hardware check of this PR (head of pr-1548, clean worktree build).
ctest --preset dev --no-tests=error -R '^(raw_buffer_uav|raw_buffer_uav_adjacent_control|vm_raw_uav_(warp|hardware))$' -j1No capability skips. Code read: the hand-worked expectations for touching windows, the top-of-address-space window and the widest 32-bit element count match
resolve_raw_uav_store; each refusal also checks that the output is left unchanged.