shader: refuse executable xbox.* calls before a PSO submission #684
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/690"
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-22T20:29:49Z.
Change
Refs #584. This adds a submission gate for modules that still call
xbox.*intrinsics: check the module and refuse executable calls before a PSO is created, reporting the names. S3, routing these modules to a lowering, stays open, so this does not close the issue.tools/xbox_intrinsic_gate.pyreads the read-only inventory fromtools/probe_roots.pythat landed in #608 and keeps the three groups apart. What blocks submission is a call the module still executes; a symbol that is only declared, or one that only metadata mentions, does not.dxil_retarget.pygates the bytes it would submit with--pso-probe: the module after retargeting. A refused module returns the decision with the call names and the probe process is never started, so it produces zero submissions rather than a creation failure such asE_FAIL.The inventory is mandatory.
check_compute_pso()without one records{"verdict": "NOT_CHECKED", "reason": "module-not-disassembled"}and returns before the probe starts, so subprocess count is zero; the CLI always passes the final module's inventory, and a module that was never disassembled (no--probe) therefore submits nothing and says so on stderr.An adapter status is advisory. Every call the module still executes blocks, and an adapter's
LOWEREDanswer is recorded on that entry without changing the verdict: a lowering counts only when it is visible in the transformed module, as a call that is gone from the instructions.status_table()is a Python API for that reporting;dxil_retarget.pyexposes no lowering switch, andcheck-textno longer takes--lowered.Reporting stays read-only otherwise: each
--peentry carries the decision asgate, and the report countsgate_rejectedand, with a probe,pso_refused.Verification
Commits
d868476+5e56e6aon baseba329ec, Windows 11 build 26300.9711 (version string 10.0.26300.9711). 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 (without it the Python-driven tests are not registered at all).No skip anywhere in the run. The hardware case ran on a physical adapter and really submitted for both fixtures, which is the check that the inventory reaches the probe path:
root_device_probe.exepicks the adapter withEnumAdapterByGpuPreferenceandDXGI_GPU_PREFERENCE_HIGH_PERFORMANCEand reports its PCI ID asadapter_id, but the fixture line the test prints keeps only the PSO results, so this log does not record which adapter ran. This host has NVIDIA GeForce RTX 3080 (driver 32.0.16.1742) and AMD Radeon(TM) Graphics (driver 32.0.11024.2), listed fromWin32_VideoController; that preference should select the RTX 3080, so the adapter is inferred rather than observed by the test. The D3D12 debug layer was not enabled for this run: the probe creates its devices withCreateDXGIFactory2andD3D12CreateDeviceand never callsD3D12GetDebugInterface, so the results carry no debug-layer messages.The new comparisons are registered in
dxil_retarget_controls(#294). The same pure-Python block also runs inside #292 and #293, so its line appears three times in the verbose log:@xbox.V_ALIGNBYTE_B32dx.opcallsLOWEREDstatuscheck_compute_pso()with no inventoryNOT_CHECKED, probe started 0 timescheck_compute_psowith mockedsubprocess.run!0 = !{!"call void @xbox.text()"}(reported by @descent81 on #608)!0 = !{!"xbox.a;xbox.b"}--pso-probeand no--probegate.verdict = "NOT_CHECKED", nowarp_pso, nothing submitted, warning on stderrpython -B tests/docs_links_check.py(10 files, 133 links) andpython -B tests/bidi_controls_check.py(596 files) both pass.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.probe_roots.strip_comment()is the prerequisite fix for the gate: without it a;inside a quoted metadata string truncates a name, and the gate would miss that call or name.validate_pe_containers(), the CLI and the hardware wrapper all pass the final module's inventory, so no path can submit without a gate; a caller that has no inventory getsNOT_CHECKEDinstead of a submission.Checklist
docs/experiments.md).Drafted with AI assistance; the commands above were run on the author's Windows x64 host.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-22T21:12:02Z.
Review: CHANGES_REQUESTED
The read-only inventory and the CLI
NOT_CHECKEDresult are useful. Please make the actual Windows submission helper fail closed too.check_compute_pso()still starts the probe ifintrinsicsisNone, and itsstatus_ofadapter can mark anxbox.*declaration as lowered by name and allow submission even while that call remains in the final module. For #584, require the final module's inventory on the submission path and refuse any remaining executablexbox.*call. A lowering should be reflected in the transformed, validated module itself. Keep the status table for advisory reporting if useful. Add direct helper controls that record zero subprocess calls for missing inventory and for an executable call whose name an advisory adapter calls lowered, alongside the declarations-only and metadata-only controls.Imported from R0Y00/Xbox2Windows. Originally posted by MoonYueya on 2026-11-22T21:43:53Z.
Thanks — all three points are in, on top of the reviewed head. The branch is rebased onto
ba329ec; the changes are in5e56e6a, plus a one-line docs clarification inefc986b.1.
check_compute_pso()now fails closed. The inventory is mandatory: calling the helper without one records{"verdict": "NOT_CHECKED", "reason": "module-not-disassembled", "checked": false}and returns before the probe process starts, so subprocess count is zero. There is no optional-gate branch left.validate_pe_containers()and the CLI always pass the final module's inventory; the hardware wrapper intests/dxil_retarget_check.pynow threads it through too, sodxil_retarget_probeanddxil_retarget_probe_hardwarestill submit for real — the latter reportspso=(hardware:unsigned=0x80070057 signed=0x00000000 tampered=0x80070057 dispatch=ok)with no skip.2. An adapter status can no longer clear a call.
decide()puts every call the module still executes intoblockingand keeps the adapter's answer as an advisory field on that entry (advisory: "LOWERED"), which the verdict ignores. The message says what was claimed and that the module still calls the symbol, e.g.REJECT: 1 executable xbox.* call(s): xbox.V_ALIGNBYTE_B32 (advisory reports LOWERED for V_ALIGNBYTE_B32; the module still calls them). A lowering only counts when it is visible in the transformed module — the call is gone from the instructions, so the inventory no longer lists it.status_table()is now advisory only and thecheck-text --loweredswitch is gone.3. Two new comparisons sit next to the declaration-only and metadata-only ones. In
dxil_retarget_controls(pure Python): an executable call with an advisory LOWERED status produces zero submissions and stays REJECT, and a missing inventory produces zero probe processes. Both also cover the transition in the same case: the same module flips to ALLOW once the call is removed.ctest --preset dev --no-tests=error -R 'dxil_retarget|shader_metadata|dxcontainer_part_offsets' -Vpasses 7/7 with no skip, includingshader_metadata_censusfrom main;docs_links_check.pyandbidi_controls_check.pypass. The verbose log line for the new comparisons:docs/experiments.mdand the module docstring now describe that rule, and the PR body is updated to match.Drafted with AI assistance; the commands above were run on the author's Windows x64 host.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-22T21:55:31Z.
Reviewed
efc986ba40c1ced5473272fac6ca9d411982a74c. My requested changes are satisfied. The CLI and PE path inventory the final retargeted module, and the submission helper returnsNOT_CHECKEDwithout spawning the probe when that inventory is missing. The verdict uses actual call sites even when an adapter claimsLOWERED. Run45073727008confirms the zero-invocation controls for both scenarios and for a live call, the one-invocation controls after removal and for metadata/declaration-only modules, and greendxil_retarget_probeanddxil_retarget_controlsin both Windows presets. The scope is the retargeting tool's compute submission path.