Skip to content

Runtime: CPU check at start, bounded reads in the exception logger, t… - #127

Merged
ivall merged 1 commit into
xcl-dev:mainfrom
gbuyssens:pr/eh-pe-cpu-check
Nov 23, 2026
Merged

ivall merged 1 commit into
xcl-dev:mainfrom
gbuyssens:pr/eh-pe-cpu-check

Conversation

@gbuyssens

Copy link
Copy Markdown
Contributor

…hread dump and probes guarded, PE directory bounds (#106)

  • The launcher refuses to start on a CPU without the console Zen 2's extensions (AVX2, FMA, F16C, BMI1 / BMI2, LZCNT, POPCNT, MOVBE, SSE4.2) with a message naming them instead of the title's illegal-instruction crash; XCL_SKIP_CPU_CHECK=1 runs anyway.
  • cpp_exception_logger: null checks on the exception pointers, strings read only as far as the memory is readable (a fault in the vectored handler would have made the exception fatal).
  • dump_threads takes only the context while a thread is suspended; the unwinding, module lookup and formatting (loader and heap locks the thread may hold) run after ResumeThread.
  • watch_writes / start_probes: an invalid snapshot and a failed SuspendThread are checked.
  • PE: offsets into the import / delay-import / relocation directories are checked (a table at the top of the address space overflowed u32: a panic in debug builds), and a relocation block claiming more than the directory holds is an error instead of a walk over up to 2^31 entries. Test on kernel32 with the block size and the import directory corrupted.

…hread dump and probes guarded, PE directory bounds (xcl-dev#106)

- The launcher refuses to start on a CPU without the console Zen 2's extensions (AVX2, FMA,
  F16C, BMI1 / BMI2, LZCNT, POPCNT, MOVBE, SSE4.2) with a message naming them instead of the
  title's illegal-instruction crash; XCL_SKIP_CPU_CHECK=1 runs anyway.
- cpp_exception_logger: null checks on the exception pointers, strings read only as far as the
  memory is readable (a fault in the vectored handler would have made the exception fatal).
- dump_threads takes only the context while a thread is suspended; the unwinding, module
  lookup and formatting (loader and heap locks the thread may hold) run after ResumeThread.
- watch_writes / start_probes: an invalid snapshot and a failed SuspendThread are checked.
- PE: offsets into the import / delay-import / relocation directories are checked (a table at
  the top of the address space overflowed u32: a panic in debug builds), and a relocation block
  claiming more than the directory holds is an error instead of a walk over up to 2^31 entries.
  Test on kernel32 with the block size and the import directory corrupted.
@ivall
ivall merged commit ac18a27 into xcl-dev:main Nov 23, 2026
@ivall

ivall commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator

Merged. Checked on Windows 11 with an RX 9070 (RDNA4), merged together with the rest of #110–#129: cargo test --workspace green with the retail samples (shader pack, console DLLs, texture archive), lib tests also with XCL_SPLIT_WAVE64=1; the retail pack still translates 26 698 / 26 698; the FSR4 GPU probe passes; Unicorn Overlord and XDefiant run. Thanks!

mastrr9 added a commit to mastrr9/xcl that referenced this pull request Nov 24, 2026
CreateCommittedResource (xcl-dev#127) and CreatePlacedResourceX (xcl-dev#133) of the
newer device layout take a D3D12_BARRIER_LAYOUT for the initial state,
which layout_state() turns into a legacy resource state. It knew layouts
0 to 10 only, so the DIRECT_QUEUE_* and COMPUTE_QUEUE_* layouts (18 to 29)
and SHADING_RATE_SOURCE (11) all became COMMON: a texture made in
DIRECT_QUEUE_SHADER_RESOURCE or COMPUTE_QUEUE_UNORDERED_ACCESS started in
COMMON on the PC while the title treats it as already in that layout.

Assisted-by: Claude Code (Claude Opus 5.5)
theaustinayers pushed a commit that referenced this pull request Nov 24, 2026
…ites

`pc_resource_desc` takes ALLOW_UNORDERED_ACCESS from a depth buffer the
console also lets shaders write (the PC refuses ALLOW_DEPTH_STENCIL with
ALLOW_UNORDERED_ACCESS). Only CreatePlacedResourceX (#44) moved such a
resource's initial state off UNORDERED_ACCESS as well (to DEPTH_WRITE).
The other paths that create a resource of the converted description
only masked the state with PC_RESOURCE_STATES: the committed fallback of
CreateCommittedResource (#27 / #76 / #127, reached without unified
memory or when its coherent window is full), the PC-way retry and the
committed fallback of CreatePlacedResource (#29), and its memory-of-its-
own path for textures larger on the PC. A console texture with flags
DEPTH_STENCIL | UNORDERED_ACCESS created in UNORDERED_ACCESS was then
asked for in a state D3D12 refuses for a resource without the UAV flag
(E_INVALIDARG; the #29 own-memory path fell back to COMMON).

`device_x::pc_initial_state` does both steps; #44 uses it with no change
in behaviour, and the four other sites use it with the console flags
(or the PC description's, which keep ALLOW_DEPTH_STENCIL).

Tests: a unit test of the helper; a GPU test placing a 256x256 D16
depth+UAV texture in UNORDERED_ACCESS as XCL now does (not run here).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
IvyNotFound pushed a commit to IvyNotFound/xcl that referenced this pull request Nov 25, 2026
…rceBarrier

Console command list slot xcl-dev#146 is ID3D12GraphicsCommandList7::Barrier(NumBarrierGroups, pBarrierGroups) on both older and newer layouts; previously it emitted only a wildcard UAV barrier, dropping every texture layout transition.

- Parse D3D12_BARRIER_GROUP (GLOBAL, TEXTURE, BUFFER) safely with readable() checks; unparseable calls fall back to the legacy global UAV barrier.
- Map D3D12_BARRIER_LAYOUT 0..=31 including 0x1F (DIRECT_QUEUE_GENERIC_READ_COMPUTE_QUEUE_ACCESSIBLE) and fall back to access bits for console-only layouts > 0x1F; align device xcl-dev#127/xcl-dev#133 initial layout states with texture-vs-buffer awareness.
- Track whole-resource states across xcl-dev#127/xcl-dev#133 creation, legacy xcl-dev#26, and enhanced xcl-dev#146 (cleared on res_release) for UNDEFINED Before layouts, forward emitted transitions to title_textures::note_transitions, emit wildcard aliasing barriers for UNDEFINED placed textures, keep non-UAV textures out of UNORDERED_ACCESS, and skip states disallowed on compute/copy lists.
ivall added a commit that referenced this pull request Nov 25, 2026
Every other method of the newer command list sits two slots after the older one, so #129 is the
older #127, not #126. A retail title's own calls through its list agree with the slots before it:
#126 takes a value and a pointer (RSSetShadingRate), #127 one resource (RSSetShadingRateImage), #128
one pointer. Nothing handles either slot yet; #2092's DispatchMesh is at #127.
JR-Wiederkehr pushed a commit to JR-Wiederkehr/xcl that referenced this pull request Nov 25, 2026
…ecuteIndirect)

Supersedes xcl-dev#724; its commits are kept with their authors.

Conflicts:
- bind.rs State keeps the tree's heap_bound and xcl-dev#1803's heaps next to
  the record buffers and scratch; reset clears the heaps and holds the
  record buffers for the old allocator; forget takes the state out of
  the sharded map (bind::STATES) and holds its buffers. HashMap is
  imported again for the PR's maps.
- console_list.rs Layout keeps xcl-dev#1803's heaps and the PR's inline_ms;
  with_heaps and user_data_ms both stay.
- device_x.rs keeps xcl-dev#1887's log of a refused signature and the PR's
  companion Dispatch signature; the CreateCommandSignature doc is back
  above its function (the merge had put it above indirect_arg_bytes).
- real.rs console slots keep the tree's #131 / xcl-dev#132 FlushCacheRange and
  the PR's DispatchMesh at xcl-dev#127.
- list_x.rs: the PR's bound_heaps test helper removes the list from
  its own part of the sharded recording map.

DispatchMesh slot: xcl-dev#1984 mapped the newer layout's xcl-dev#129 to the older
xcl-dev#126, this PR to xcl-dev#127, where it hooks DispatchMesh. Kept xcl-dev#127: it is
the shift of two slots the other methods have, and xcl-dev#1984's own reading
of the newer layout (xcl-dev#126 / xcl-dev#127 the shading-rate methods, the older
xcl-dev#124 / xcl-dev#125) puts its xcl-dev#128 at the older xcl-dev#126. xcl-dev#1984's test is rewritten
for (129, 127) and checks that the older slot runs bind::dispatch_mesh.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.

2 participants