gpu: check the raw SRV bounds and 64-bit offsets without a device #1706
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1713"
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-24T17:37:32Z.
Refs #1149.
What the header does
src/raw_buffer_srv.hdefinesmake_raw_buffer_srv, which turns a GPU byte address and a first element inside an already-owned buffer into a raw (R32_TYPELESS,D3D12_BUFFER_SRV_FLAG_RAW) buffer SRV description. It refuses (E_INVALIDARG) a null base, an address outside the buffer, a zero count, an address that is not DWORD-aligned, a first element or count that does not fit the remaining whole DWORDs, and a view start that is not 16-byte aligned.Tests that reach it
Only
vm_raw_srv_warpandvm_raw_srv_hardware(tests/vm_copy_queue_check.cpp). They resolve two views inside one 128 KiB buffer (a cross-page view and the same view shifted by four elements) and refuse a misaligned address, the address one past the buffer and a count one element too long. Nothing checks the header without a device, and nothing exercises widths or offsets above 4 GiB.Mutation probe
28 single-point mutants of the header, one at a time, rebuilding
vm_copy_queue_checkandraw_buffer_srv_checkand running^(vm_raw_srv_warp|raw_buffer_srv)$. Killed means at least one of the selected tests failed.vm_raw_srv_warpraw_buffer_srv!baseguardaddress < baseaddress - base >= widthto>address - base >= width!count(width - offset + 3) / 4)offset % element_bytesfirst_element > availableto>=first_element > availablecount > available - firstto>=(exact fit refused)offsetinstead ofstartE_FAIL% 16to% 4E_FAILE_FAILFormat=R32_UINTFirstElement=start(bytes)FirstElementignoresfirst_elementNumElements=count - 1Flags=NONEresult = {}(earlierStructureByteStridekept)first_elementtruncated to 32 bits instartFirstElementtruncated to 32 bitsExisting check: 11 of 28 killed. With the new check: 24 of 28 killed. The 4 survivors are equivalent mutants:
address - baseto a value that is never below a real buffer width.address - base == widththere are 0 available elements, and the nonzero count is refused anyway.start = offset + 4 * first_element, so an offset that is not a multiple of 4 always gives a start that is not 16-aligned.first_element == availableleaves 0 elements, and the nonzero count is refused anyway.New cases
tests/raw_buffer_srv_check.cppis a device-free check next toraw_buffer_uav_check. It needs only the D3D12 headers. Expected values are worked by hand in the comments. Each accepted view starts from a description filled with0xcdand must come back withR32_TYPELESS,BUFFER, the default component mapping, the expectedFirstElementandNumElements, a zeroStructureByteStrideand theRAWflag.Resolved (7):
Refused with
E_INVALIDARG(9): a null base, an address below the base, an address past the buffer end, zero elements, one element past the buffer end, one element too many for the 0x102-byte width, a first element past the available elements, an aligned address with an unaligned first element, and one element past what remains in a 0x1'0000'0010-byte buffer.Negative control
raw_buffer_srv_first_32_controlrunsraw_buffer_srv_check --mutate first-32withWILL_FAIL TRUE. The mutation expects the 32-bit truncation (0x4000'0000) of the first element above 4 GiB, so the check must fail:Not pinned
src/raw_buffer_uav.h, this header does not document it, so the check does not depend on it.Commands and results
raw_buffer_srv_checkprintsraw_buffer_srv: PASS (7 resolved, 9 refused).python -B tests/docs_links_check.pypasses (17 Markdown files, 364 links). No_hardwaretest was run for this change, and no capability skips occurred.Environment
Windows 11 Pro 26300.9974, MSVC from Visual Studio, Windows SDK 10.0.26100.0,
devpreset (Debug).vm_raw_srv_warpuses Microsoft WARP. The new check uses no device.Commit:
99e2e324AI-assisted (Claude Code).