Skip to content

Tools: native RDNA1 MUBUF OOB_SELECT bounds probe (SHADER-341) - #3349

Open
bobcatchris wants to merge 2 commits into
ItsNotRexed:mainfrom
bobcatchris:shaders/buf-bounds-rdna1
Open

bobcatchris wants to merge 2 commits into
ItsNotRexed:mainfrom
bobcatchris:shaders/buf-bounds-rdna1

Conversation

@bobcatchris

Copy link
Copy Markdown
Contributor

SHADER-341 — native RDNA1 measurement of MUBUF OOB_SELECT bounds, with a reusable synthetic probe.

What and why

docs/buffer_bounds.md measured the four bounds modes on RDNA2 (gfx1036) and found the hardware follows Mesa's GFX11 column, not the GFX10 column used for the console's gfx1013/GFX10.1. The RDNA1 case was open. This PR measures it on an AMD Radeon Pro V540 (Navi 12, gfx1011, RDNA1, PCI 1002:7360, bare metal, RADV Mesa 25.2.8, Ubuntu 24.04, kernel 7.0.0-31-generic) through tools/hw_oracle's Linux libdrm launcher with AMD clang 18.

  • 12 one-lane cases x wave32 and wave64 = 24 groups, 0 launcher errors, 0 wave32/wave64 differences.
  • All 24 cases follow the RDNA2 / Mesa GFX11 column; 8/24 disagree with Mesa's GFX10 column. Witnesses: mode 0 stride 16 at offset 13, mode 3 NR 18 at offset 16, mode 3 NR 3 at offset 0, and mode 3 offset 8 with soffset 8 and NR 18 (soffset is included in the RAW check).
  • This is gfx1011, not gfx1013; the console part itself remains unmeasured. Swizzled V#s and unaligned addresses are out of scope and stated as such in the doc.

Changes

  • tools/buffer_bounds_probe.py: stdlib-only, --self-test models, --waves, --json, exits 77 when the oracle is unavailable or not GFX10.
  • tests/test_buffer_bounds_probe.py: self-test, bad arguments, missing-oracle exit 77.
  • docs/buffer_bounds.md: replaces the 'needs an RDNA1 card' open item with the measurement and leaves gfx1013 explicitly open.
  • docs/design.md: updates the 'Buffer bounds checking' contract row.

Tested

python -I tools/buffer_bounds_probe.py --self-test                  # self-test OK
pytest tests/test_buffer_bounds_probe.py -q                         # 3 passed
python -I tests/test_docs_links.py                                  # 5 tests OK
python -m compileall -q tools/buffer_bounds_probe.py tests/test_buffer_bounds_probe.py
LEONIDA_HW_DRM_NODE=/dev/dri/renderD129 python -I tools/buffer_bounds_probe.py
# gfx1011: 24 cases, 0 disagree with the measured RDNA2/GFX11 column,
#          8 disagree with Mesa's GFX10 column, 0 wave32/wave64 differences

Earlier one-off run of the same cases was also posted as the SHADER-341 result in the coordination issue. No game data, shader corpus, keys or private paths were used; every descriptor, buffer and pattern is synthetic.

AI-assisted.

@bobcatchris

Copy link
Copy Markdown
Contributor Author

Rebased onto main f847748c (this PR had gone CONFLICTING after the round-41 merges).

The only conflict was docs/design.md: the row this PR edits, "Buffer bounds checking", was rewritten by one of those merges. I took main's row and re-applied only this PR's sentence, keyed on the one anchor that survived — **Unmeasured**: gfx1013/GFX10.1 itself (see docs/buffer_bounds.md), — so the row now reads the merged text plus the RDNA1 result, with the Unmeasured clause kept and gfx1013 still listed. Nothing else in this PR changed; docs/buffer_bounds.md, the probe and its test are byte-identical to before.

Re-checked after the rebase: python -IB tests/test_buffer_bounds_probe.py → 3 tests, OK, compileall clean, and the PR is MERGEABLE again (checks still queued).

@bobcatchris

Copy link
Copy Markdown
Contributor Author

Rebased onto current main f847748c (head a94ff234); the docs/design.md row conflict was resolved by keeping the current row and re-applying only the RDNA1 measurement note. Re-ran: probe self-test OK, probe tests 3 passed, docs links 5 OK, git diff --check clean.
AI-assisted.

@Dom-in

Dom-in commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Code check of 588c368 merged onto main f847748 (clean merge), Windows 11, Python 3.13: pytest tests/test_buffer_bounds_probe.py: 3 passed. There's no negative control: tools/buffer_bounds_probe.py is new, so main has no version to compare against. I can't repeat the RDNA1 measurement itself (no gfx101x part here; RX 9070 only), so this covers the synthetic tests only.

AI-assisted (Claude Code); runs on my machine.

@Kam471

Kam471 commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Reproduced on PR head 588c368c with Python 3.13.15 (-I) and synthetic hw_oracle/asm stubs returning valid rows: run main() with --json <temp>/missing/report.json.
After report generation, the unguarded JSON open() raises FileNotFoundError, producing a traceback instead of the documented exit code 2 for a harness error. Please report this write failure cleanly and add a CPU-only regression for a missing output parent.

@bobcatchris
bobcatchris force-pushed the shaders/buf-bounds-rdna1 branch from 588c368 to aee0054 Compare November 22, 2026 23:34
@bobcatchris

Copy link
Copy Markdown
Contributor Author

Rebased onto main aa2988cc. Note for review: today's main rewrite of the contract table already carries the **Unmeasured**: gfx1013/GFX10.1 itself (see docs/buffer_bounds.md) sentence, so docs/design.md no longer appears in the diff — this PR is now the probe, its page and the test only (tools/buffer_bounds_probe.py +244, docs/buffer_bounds.md 17, tests/test_buffer_bounds_probe.py 33). Re-ran tests/test_buffer_bounds_probe.py after the rebase: 3 tests OK.

@thirteenhustler

Copy link
Copy Markdown

Tested aee0054 on Linux 6.12.113+, Python 3.12.3 (no GPU, no game data): pass.

Ran python -I tools/buffer_bounds_probe.py --self-test (self-test OK), python -I tests/test_buffer_bounds_probe.py (3 OK), python -I tests/test_docs_links.py (6 OK) and python -I tests/test_docs_list_items.py (2 OK). No GFX10 device on this machine, so the 24 hardware cases were not re-run.

The two columns in tools/buffer_bounds_probe.py match the table in docs/buffer_bounds.md: mode 0 checks offset + 4 > stride, raw mode checks offset + soffset + 4 > NUM_RECORDS and does not put index * stride in the check. The four witnesses in the new paragraph (mode 0 offset 13, mode 3 offset 16 with N=18, mode 3 N=3 at offset 0, mode 3 soffset 8) are exactly the cases where those two columns disagree, and case 10 is the soffset one (buffer_bounds_probe.py:171). A zero result is a safe out-of-range signal: the seeded dwords start at 0xA0000000. Word 3 for mode 3 comes out as 0x31016FAC, the same descriptor the contract row already quotes. Exit 77 when the oracle is missing is covered.

The description says docs/design.md was updated. The diff does not touch it. The measurement is in docs/buffer_bounds.md, which that contract row already points at. A short gfx1011 clause on the "Buffer bounds checking" row would record it there too.

@sds-228 sds-228 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review of aee0054: no issues found. The new probe has CPU-only self-tests for its case model and argument validation; the hardware measurement itself was not rerun here. Targeted suite: 3 tests OK; compileall clean.

AI-assisted (OpenCode).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants