shader: block every form that reaches an xbox.* builtin, not only a direct call #728
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/734"
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 MoonYueya on 2026-11-22T23:51:59Z.
Change
Closes the gap left by #690, which refuses a module while it still executes an
xbox.*call: six forms reached the same builtin without being counted, so the gate admitted them.tools/probe_roots.pyadds areferencesgroup toxbox_intrinsic_inventory(): everyxbox.*symbol the module keeps reachable outside a call, with its kind —alias,store,bitcast,global-initializerorcall-operand— anddebug-onlywhen the only use is a debug intrinsic's metadata. The call-site scan takes the first@symbol before the call's operand list, so a direct call spelled with an inline bitcast is a call again. The debug exception is decided from the callee alone: a line that merely mentionsllvm.dbg.*somewhere in an argument is still an executable call. A leading block label needs no handling, becausedxc -dumpbinprints a basic block as a; <label>:Ncomment line.tools/xbox_intrinsic_gate.pyblocks oncalls ∪ referencesand lists calls and other executable references apart:REJECT: 1 executable xbox.* call(s): xbox.BFI (call); 1 executable xbox.* reference(s): xbox.foo (alias). A module whose only use is debug metadata passes and reportsdebug-only;llvm.dbg.declareandllvm.dbg.assignbehave the same.referencescounts executablesitesapart fromdebug_sites, so a debug-only symbol reports 0 executable sites.reaches_xbox()gives the archive filter one meaning:--only-without-xbox-callsselects modules where nothing is reachable, debug-only uses included, and the report counts them asskipped_xbox_intrinsics. The filter therefore counts reachable uses while the gate counts executable ones, which errs on skipping.docs/experiments.mddescribes all of that, including that the scanner reads the LLVM 3.x textdxc -dumpbinprints and that the newer#dbg_valuerecord form would be over-blocked rather than missed.Verification
Commit
2bf2161on base761e323, Windows 11 build 26300.9711, from a clean build (the build directory was removed first). Configured with thedevpreset (Ninja) insidevcvars64.batfrom Visual Studio Build Tools 18.11.0: MSVC 19.51.36260.0 (cl 14.51.36231), Windows SDK 10.0.26100.0,dxc/dxil.dll1.8.2502.11, Python 3.15.0 with-DINTAKE_PYTHONpointing at it.The verbose log of this run is
out/ctest-734-r3.login the working tree (not in the patch). No skip in it: the hardware case really submitted for both fixtures —330: fixture compute_root.cso: … pso=(hardware:unsigned=0x80070057 signed=0x00000000 tampered=0x80070057 dispatch=ok)and the same forCopyBlocksSM65.cso.The new cases live in
dxil_retarget_controls(#331), the pure-Python entries:@xbox.V_ALIGNBYTE_B32call, 0 submissions@a = alias i32 (i32), ptr @xbox.BFIalias, 0 submissionsstore ptr @xbox.global_store_dword_with_cache, ptr %slotstore, 0 submissions%fp = bitcast ptr @xbox.foo to ptr+call void %fp(i32 1)bitcast, 0 submissions@table = global ptr @xbox.Med3_F32global-initializer, 0 submissions@slot = global ptr null+store ptr @xbox.foo, ptr @slot+call void %fp(i32 1)store, 0 submissionsdeclare void @consume(ptr)+call void @consume(ptr @xbox.foo)call-operand, 0 submissionscall void @consume(ptr @xbox.foo, ptr bitcast (void()* @llvm.dbg.value to i8*))call-operand, 0 submissionscall void bitcast (void (i32)* @xbox.foo to void (i64)*)(i64 5)llvm.dbg.value/llvm.dbg.declare/llvm.dbg.assigncarrying the symbol as metadatadebug-only, 0 executable sitesLOWEREDstatuscheck_compute_pso()with no inventoryNOT_CHECKED, probe started 0 times--pso-probeand no--probegate.verdict = "NOT_CHECKED", nothing submitted, warning on stderrpython -B tests/docs_links_check.py(13 files, 143 links),python -B tests/bidi_controls_check.py(626 files) andpython -B tests/hardware_reports_check.py(11 tests) all pass; their output is kept locally asout/docs-checks-734.log.Evidence and follow-up
tests/dxil_retarget_check.pyis original, and the synthetic DXBC containers are assembled in the same file from that text and the repository's own bitstream helpers. No game data, dumps or external samples are involved, and the contribution is under this repository's MIT license.callsandreferencesare both executable;debug-onlyis not. The refusal names the form, so a diagnostic says how the module still reaches the builtin.skipped_xbox_callsbecameskipped_xbox_intrinsics, because the filter now covers every reachable form.Checklist
docs/experiments.md).Drafted with AI assistance; the commands above were run on the author's Windows x64 host.
Refs #733
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T00:12:06Z.
The wide reference inventory is a good direction, but one new test uses
llvm.dbg.value(metadata ...)as the positive blocking example for a call operand. That is debug metadata and the runtime does not use it. Please use an ordinary executable callee with a function pointer for the blocking case, add the valid debug-only use as an allowed control, and make the classifier distinguish those cases. Keep the zero-invocation assertions at the final submission boundary.Imported from R0Y00/Xbox2Windows. Originally posted by MoonYueya on 2026-11-23T02:28:22Z.
All of the changes are in commits on top of current main: the branch is rebased onto
761e323and force-pushed, so the difference since your review is exactly these commits — final2bf2161,git diff --stat 761e323 2bf2161= 5 files, +314/−45 (tools/probe_roots.py,tools/xbox_intrinsic_gate.py,tools/dxil_retarget.py,tests/dxil_retarget_check.py,docs/experiments.md, all modified).1. A debug intrinsic is no longer a blocking example, and the exception is decided from the callee.
classify_line()takes the first@symbol before the call's operand list and tests that callee againstllvm\.dbg\.(value|declare|assign|label); only then is anxbox.*symbol on the linedebug-only. Everything else stays executable. The blocking example is now an ordinary executable callee receiving the symbol as an argument, plus a function pointer held in a slot and called through it:Your boundary case is a control:
call void @consume(ptr @xbox.foo, ptr bitcast (void()* @llvm.dbg.value to i8*))is refused ascall-operandwith 0 submissions, because the callee is@consumeand the debug mention is only an argument. The valid debug-only uses are the allowed controls —llvm.dbg.value,llvm.dbg.declareandllvm.dbg.assigneach submit once, reportdebug_only == ["xbox.foo"], and record 0 executable sites.2. Calls and other executable references are reported apart.
decide()returnsblocking_calls,blocking_referencesanddebug_only, and the refusal lists calls first:3. Zero invocations stay at the final submission boundary, and an advisory status clears nothing. Every executable form is asserted through the recording submission stub (0 submissions), a reference-only inventory is also refused at the backend boundary with
subprocess.runcalled 0 times, declarations and metadata-only names still submit once, and an alias withstatus_table(["BFI"])staysREJECTwith the advisory recorded.Two boundary notes now in
docs/experiments.md: the scanner reads the LLVM 3.x textdxc -dumpbinprints, so the newer#dbg_valuerecord form would be over-blocked rather than missed (still fail-closed); and the archive filter counts reachable uses while the gate counts executable ones, so--only-without-xbox-callsalso skips a module whose only reference is debug metadata — the conservative direction.From a clean build (
vcvars64+ Ninja,devpreset, MSVC 19.51, SDK 10.0.26100.0,dxc/dxil.dll1.8.2502.11, Python 3.15):No skip in that run; the hardware case still submitted for both fixtures (
pso=(hardware:unsigned=0x80070057 signed=0x00000000 tampered=0x80070057 dispatch=ok)). The verbose log is kept locally asout/ctest-734-r3.log.docs_links_check.py(13 files, 143 links),bidi_controls_check.py(626 files) andhardware_reports_check.py(11 tests) pass; their output isout/docs-checks-734.log.Drafted with AI assistance; the commands above were run on the author's Windows x64 host.