Skip to content

d3d12_xs: the device proxy table covers slot 133, so slots past the PC vtable refuse instead of jumping to 0 - #6953

Merged
ItsNotRexed merged 1 commit into
ProjectLeonida:mainfrom
Pipodi:xs-slot-table
Nov 23, 2026
Merged

ItsNotRexed merged 1 commit into
ProjectLeonida:mainfrom
Pipodi:xs-slot-table

Conversation

@Pipodi

@Pipodi Pipodi commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: #6750 (comment) (item 1, from the RT-5 boot measurement in #6915)

What and why

The retail executable calls Xbox device slot 133. The d3d12_xs device proxy's vtable had 128 entries, so that call read past the table and jumped to address 0 (an access violation at rip 0) instead of reaching the generic thunk that refuses unknown slots. kMaxSlots is now 192, with a static_assert that it covers 133. Every slot past the PC device's vtable is now refused with E_NOTIMPL and logged once, as the file already intends.

The queue, fence and allocator proxies (kQueueSlots, kFenceSlots, kAllocatorSlots) and the 11-slot heap proxy have the same fixed-size shape. Their tables refuse slots past the real object's count, but a call past the table itself would still go through an empty entry. I haven't seen the title do that yet, so they're left as they are.

Tested

AI-assisted: yes (Claude Code)

Checklist

  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a: runtime only)

🤖 Generated with Claude Code

…e PC vtable refuse with E_NOTIMPL

The retail title calls device slot 133, past the 128-entry table; the call read an empty entry and jumped to 0.
Every slot beyond the PC device's vtable now reaches the generic thunk. Mock test covers slot 133.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dadsmallbuk1

Copy link
Copy Markdown

Tested 4b76715 on NVIDIA GeForce RTX 5090, driver 617.42, Windows 11 (26200), MSVC 2022 RelWithDebInfo: pass.

  • ctest -R ^xs_proxy_mock: 4/4 pass (xs_proxy_mock, _no_reserve, _no_protect, _no_handler), at the PR head and merged locally onto current main (no conflicts).
  • Code read: the vtable is still filled with make_index_sequence<kMaxSlots>, so slots 128–191 get the generic thunk; g_hits/g_first/g_beyond_warned are sized by the same constant and the slot >= kMaxSlots guards are unchanged. Nothing else is touched.
  • Small note: the new check asserts mock->calls[127] == 0 after calling slot 133. I read that as "the call didn't reach a real slot", but a check on slot 133's own refusal count (the g_hits side) would pin the exact slot, if the mock exposes it.
  • Not checked: the retail title reaching slot 133 under gta6rt --run (I don't have the earlier stops' local stand-ins in place).

AI-assisted (Claude Code).

@Raavve

Raavve commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Tested 4b76715c on Windows 11, RTX 4060, driver 610.88, own 1.0.2.1 copy (exe SHA-256 matches the published one), stacked on main 1cc6e3c12 + #6792 + #6582 + #4313 + #4348 + #6919 (c9c90632) + #6964 (86b8e04e) (MSVC, RelWithDebInfo, LEONIDA_D3D12=vulkan, LEONIDA_UNIMPLEMENTED=stop):

AI-assisted, outcomes only.


Generated by Claude Code

@pvfreis

pvfreis commented Nov 23, 2026

Copy link
Copy Markdown

Tested 4b76715 on NVIDIA GeForce RTX 3060 (driver 617.14), Windows 11 (26300), MSVC 19.44.35229 (v143) + Ninja, RelWithDebInfo: pass.

  • ctest -R ^xs_proxy_mock: 4/4 pass (xs_proxy_mock, _no_reserve, _no_protect, _no_handler) at the PR head.
  • Negative control: with kMaxSlots set back to 128 (and the new static_assert removed), the new slot-133 check makes xs_proxy_mock fail with SEGFAULT. With 192 it returns E_NOTIMPL. So the test catches the regression the PR describes.
  • On the earlier note about mock->calls[127]: the mock has kMockSlots = 128, so it has no slot 133 to count. Index 127 is its last slot, and the E_NOTIMPL result plus the no-crash path is the meaningful part of the check.
  • Not checked: the merge onto current main, or the retail title under gta6rt --run.

AI-assisted (Claude Code).

@kapitche

Copy link
Copy Markdown
Collaborator

Tested 4b76715 merged with main e6190e7 (which already has #6935) on Windows 11 / RTX 4080 SUPER against own copy of the retail exe: pass

  • Build: MSVC 14.51 (VS 18), Ninja, RelWithDebInfo, gta6rt + device_proxy_test + xs_proxy_mock_test. The merge is clean.
  • ctest -R "device_proxy|xs_proxy_mock": 8/8 passed.
  • Negative control: main's runtime/shims/d3d12_xs_device.cpp with the PR's tests makes xs_proxy_mock crash (SegFault, the jump through the empty slot) and leaves the other 7 passing. With the PR's file restored, all 8 pass again.
  • gta6rt --dry-run (LEONIDA_D3D12=vulkan, fresh --trace, --trace-d3d12, --overlay to a scratch folder): main and the PR both have 30 unimplemented imports, with the same list (expected, since the change is in the proxy).
  • gta6rt --run with LEONIDA_UNIMPLEMENTED=stop: same as main, exit 3 at the first unimplemented import (D3D12ConfigureVirtualMemoryX) before D3D12XboxCreateDevice. Slot 133 is not reached in a main-only stop-mode run. On a newer main (b66e184, with d3d12_xs: D3D12ConfigureVirtualMemoryX shim (first unimplemented call of the title) #6792), --run now stops at an int3 in the title after 3 xmem_attributes events, which is still before device creation.

@kormocicsaba

Copy link
Copy Markdown

Tested 4b76715cf, merged alone into main 8575d36: pass. 257/259, baseline only.

Setup: RTX 4070 (driver 621.01), Windows 11 Pro 26300, MSVC (VS 18) RelWithDebInfo with Ninja, Vulkan SDK 1.4.363.0. The PR head was merged alone into main 8575d36 and runtime/ was built. I ran the full ctest -j8 --timeout 300; no game files were used.
Baseline on main: d3d12_vulkan_device and d3d12_indirect_dispatch_count fail on main 8575d36 as well. d3d12_bindless_churn fails now and then under -j8 on main too: it failed in main's -j8 run and passed 3 of 3 times run alone there.

AI-assisted review (Claude Code). How this compares with the other boot-chain PRs: #7333 (comment)

@dcastell1

Copy link
Copy Markdown
Contributor

Tested on RTX 5090, 621.24, Windows 11: pass, and with the retail image it is the difference between a silent crash and a named slot.

  • device_proxy, device_proxy_trace and the five xs_proxy_mock variants → 8/8 passed from this tree (plus a local copy with my extra assertion, see below).
  • Before: main@dde82f27 + the boot stack of Boot log for coding agents: where the executable stops and which PRs get past it #7154 dies with an access violation at 0, no stack, nothing logged, right after slot 15. At 128 slots the slot-133 vtable read lands in the zeroed tail of the allocation and the call goes to address 0.
  • After: the same run logs device slot 133 (forwarded) first call and is beyond the PC device vtable (80 slots); returning E_NOTIMPL, and the title's own int3 takes over.

One addition worth taking, three lines in xs_proxy_mock's check_xbox_slots:

EXPECT(hr_of(raw(device, 133, 0, 0, 0, 0)) == E_NOTIMPL);
EXPECT(xs::device_slot_hits(133) == 1);

That is the check that fails if the table shrinks back under the slot, so the fix is pinned by a test rather than by the comment. Verified green here with it applied.

@tedin7

tedin7 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

checked: #6953 at 4b76715, merged onto main 867d922 (clean merge, 2 files, +7/-1) | on: Wine 11 on RunPod RTX 4090 (Linux), clang-cl cross-build; not native Windows, host D3D12/WARP comparisons do not run | ran: xs_proxy_mock_test EXIT 0 (xs_proxy_mock_test: PASS) and its five ctest modes by hand (--fail-virtualalloc, --fail-virtualprotect, --fail-veh, --env-slots, --env-slots-invalid), all EXIT 0; device_proxy_test builds, EXIT 77 SKIP: no WARP adapter (not exercised under Wine). Negative control: with only d3d12_xs_device.cpp reverted to main (the PR's test kept), xs_proxy_mock_test does not finish and is killed by my 90 s timeout (EXIT 124) instead of passing; with the PR it passes. So the new raw(device, 133) == E_NOTIMPL check does fail without the change.

diff review: kMaxSlots 128 to 192, so the table of generic thunks, the hit counters and the beyond-vtable warning flags all cover slot 133; those arrays are all sized from the same constant, and the existing slot < kMaxSlots guards stay. The new static_assert pins 133. Cost is 64 more tiny thunks. One small weakness in the test: its second condition checks mock->calls[127] == 0, which says nothing about slot 133 (the real proof is the E_NOTIMPL return, which the negative control confirms). Another tester noted that #7218 carries the same kMaxSlots = 192 line, so whichever lands second has a trivial rebase. I found no defect.

Not verified: retail boot (this PR claims the title calls slot 133), native Windows.

agent: yes
AI-assisted.

@Cryptoteep

Copy link
Copy Markdown
Contributor

checked: #695322c09b3 | with: git merge-tree $(git merge-base main pr-6953) main pr-6953 + check_no_game_data | on: Windows 11, Intel CC150, RTX 5060 | result: clean merge onto main 867d922, 0 conflicts, 0 game data

Audited diff:

  • kMaxSlots raised from 128 to 192 with static_assert(kMaxSlots > 133) in runtime/shims/d3d12_xs_device.cpp, ensuring calls to device slot 133 (called by the retail title) hit the generic thunk returning E_NOTIMPL rather than reading past the vtable array and jumping to null (rip 0).
  • Synthetic test check in runtime/test/xs_proxy_mock_test.cpp explicitly calls slot 133 through the proxy vtable and asserts E_NOTIMPL with uncalled underlying mock device.
  • Tested clean merge against current main (867d922f0) without conflicts.
  • Verified python -I scripts/check_no_game_data.py runtime/shims/d3d12_xs_device.cpp runtime/test/xs_proxy_mock_test.cpp -> clean, exit 0.

@byPreaZy

Copy link
Copy Markdown

checked: #6953 | with: applied the diff on main 867d922, built xs_proxy_mock_test (MSVC, Ninja RelWithDebInfo) | on: Windows 11, RX 9060 XT (mock test, no GPU path) | result: PASS

Code read: kMaxSlots 128 -> 192 with static_assert > 133 is required for the retail title's slot 133 call to land on the generic thunk (E_NOTIMPL) instead of indexing past the vtable; the new EXPECT in check_levels verifies that refusal. Minimal and correct. Complements #7075, which implements slot 133 itself.

AI-assisted check.

@SirKingg

Copy link
Copy Markdown
Contributor

Independent Windows Sandbox integration check of 4b76715cf with #8379, #2490, #6582, #8461, #6964, #8258 and #7189 code/test hunks in a temporary checkout. Slot-26 and queue mock hunks required local reconciliation. Networking was disabled, game inputs were read-only and overlays were fresh.

  • Before this patch: 2/2 runs recorded 1,181 D3D12 calls then an execute access violation at null; startup trace: a call through a null pointer names its caller (null_call_from) #7189's diagnostic identified a slot-133 call.
  • With this patch: 2/2 runs recorded the same 1,181 D3D12 calls, logged the slot-133 E_NOTIMPL refusal and reached a guest breakpoint (0x80000003) instead of executing a null pointer. This confirms the explicit refusal, not a working slot-133 resource implementation.
  • startup_trace, device_proxy, xs_proxy_mock and gameinput CTests passed (4/4) on Windows 11 / MSVC 2022 RelWithDebInfo.

Only counts, error classes and public slot names are shared; traces stay local. AI-assisted.

Raxstreams added a commit to Raxstreams/Leonida that referenced this pull request Nov 23, 2026
d3d12_xs: the device proxy table covers slot 133, so slots past the PC vtable refuse instead of jumping to 0

Fork integration. AI-assisted (Codex).
@isfcrctfs

Copy link
Copy Markdown

checked: #69534b76715 | with: git merge origin/main (clean, 0 conflicts) then cmake -S runtime -B build --toolchain runtime/cmake/clang-cl-xwin.cmake -DXWIN_DIR=/mnt/disk-10tb/dsh/toolchain/xwin-sdk -DVulkan_INCLUDE_DIR=/mnt/disk-10tb/dsh/toolchain/vulkan-headers-1.4.363/include -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_TESTING=ON -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="-O2 -g -DNDEBUG /Zc:threadSafeInit-" -DLEONIDA_SDL3=ON -DLEONIDA_SDL3_FETCH=ON -DSDL_HIDAPI_LIBUSB=OFF + cmake --build build -j16, then xs_proxy_mock_test.exe under Wine | on: Linux x86_64 cross build — clang-cl 23.1.5 + lld-link against xwin SDK 10.0.26100, Wine 11.22-staging; no GPU (llvmpipe only) | result: pass — build rc=0; xs_proxy_mock_test 4/4 modes PASS (plain + --fail-virtualalloc + --fail-virtualprotect + --fail-veh), including device slot 133 ... is beyond the PC device vtable (44 slots); returning E_NOTIMPL; negative control with kMaxSlots back at 128 exits 5 instead of PASS

What I ran and saw:

  • Merge: 4b76715cf merges cleanly into current main@867d922f0 (2 files, +7/−1; no conflicts). origin/main still has kMaxSlots = 128, so this is not already merged.
  • Build: configure rc=0, build rc=0 (full tree with BUILD_TESTING=ON, SDL3 3.4.20 fetched and built).
  • Wine: xs_proxy_mock_test: PASS (9 allocations refused on purpose) and the three fault-injection modes exit 0. The new check is exercised: the log has device slot 133 (forwarded) first call and is beyond the PC device vtable (44 slots); returning E_NOTIMPL.
  • Negative control: with only kMaxSlots set back to 128 (and the >133 static_assert removed, test kept), xs_proxy_mock_test.exe exits 5 with no PASS line; restoring the PR's file brings it back to PASS.
  • python3 -I scripts/check_no_game_data.py on both changed files: clean.

Not run / limits:

  • Native Windows: not run. This is a cross-build + Wine data point, not a Windows check.
  • device_proxy / device_proxy_trace: not run — this Wine prefix has no usable D3D12 runtime (DXGI factory OK under Xvfb, but D3D12CreateDevice returns 0x80070057 E_INVALIDARG), so no WARP reference device; not a GPU or Windows result.
  • Retail boot / the title's real slot-133 call: not run (no game copy used).

@bobczan

bobczan commented Nov 23, 2026

Copy link
Copy Markdown

Independently verified on a retail run (Windows 11, RTX 5070, LEONIDA_D3D12=vulkan)

I found this crash from the other end — filed #9414 blaming slot 15, then ran the title under cdb and got the real site. It is exactly what this PR says, so this is a confirmation rather than a new finding.

The call, from the debugger:

00000001`41e8684c  41ff9228040000  call qword ptr [r10+428h]      RIP = 0 at the fault
r10 = our device proxy vtable (the qwords there symbolise to proxy_slot<0>, proxy_slot<1>)
+0x428 = entry 133 = 00000000`00000000

0x428 / 8 = 133, and the table had 128 entries, so the entry the title called was six pointers past the end of the array.

Before, on main 6312c057f + #8461 + #6964 + #8258 + #7076 — the last PR only to carry the title to this call:

rc=139  (2/2)   access violation, rip 0

After — I built the same change locally (kMaxSlots 256 rather than this PR's 192; same mechanism, same static_assert shape):

rc=3  (2/2)  d3d12_xs: device slot 133 (forwarded) is beyond the PC device vtable (80 slots); returning E_NOTIMPL

No fault, the refusal is logged once, and the run stops cleanly instead of dying. Same on both runs, so it is not flaky.

I am not submitting my version: this PR is the same fix, it is mergeable, and it was claimed first. Dropping mine so there is only one patch for the maintainers to take.

Slot numbers and outcome only; no game data.

dadnotdaddy pushed a commit to dadnotdaddy/Leonida that referenced this pull request Nov 23, 2026
… slot 133, so slots past the PC vtable refuse instead of jumping to 0

Squashed from ItsNotRexed#6953 by Pipodi, head 4b76715 (security scan PASS).
dadnotdaddy pushed a commit to dadnotdaddy/Leonida that referenced this pull request Nov 23, 2026
…ResourceX) makes a buffer on the title's own pages (VK_EXT_external_memory_host)

Squashed from ItsNotRexed#7218 by tibzejoker, head 4fb24d2 (security scan PASS).

Head moved from the scanned c3fe825 to 4fb24d2 (two commits: page-base import with bind offset, committed texture fallback); the new commits were re-scanned (prescan: no flags; Haiku read: PASS). Contains ItsNotRexed#6953. Conflicts with ItsNotRexed#6964/ItsNotRexed#7078: the slot-26 handler and the slot-133 handler both kept; device_slot_overridden lists 25/26/56 and 133.
Impre-visible pushed a commit to Impre-visible/Leonida that referenced this pull request Nov 23, 2026
…e resource of a slot 70 view of that address

Device slot 70 makes a shader-resource view from a description and a console
address, with no resource object. It asked only the device behind the proxy
for a buffer at that address, and that device knows the buffer by the title's
address only when it could put the buffer on the title's own pages. When it
could not (the import is refused, or the device is a PC one), the slot 133
buffer has an address of its own, nothing was found, and the title's
descriptor got the null view.

The proxy now remembers every buffer a slot 133 call made by the range the
title placed it at, whichever way it was made (the placed-at-VA handler, PC
CreateCommittedResource3 or CreateCommittedResource), and slot 70 asks there
first, then the device's provider. An entry holds no reference. An object
attached to the resource as private data removes the entry when the resource
dies, and a device proxy's entries go with it. The newest buffer over an
address answers, so a range the title places again is the new buffer's.

xs_proxy_mock_test: check_slot70_placed_buffer covers both creation paths
and the handler path, the element range, the cut at the buffer's end, the
addresses around two buffers, a texture, the provider fallback and its
order, a range placed twice, a released buffer and a released device. The
check of the placed-at-VA handler in check_levels hands out a mock resource
instead of a made-up pointer, since the proxy now asks the object for
ID3D12Resource.

Depends on: ItsNotRexed#7066 (slot 70), ItsNotRexed#7218 or ItsNotRexed#7075 (slot 133), ItsNotRexed#6953 (the table
reaches slot 133), and ItsNotRexed#7235 for the mock's SetPrivateDataInterface.

(cherry picked from commit 7387445)
Signed-off-by: local <local@localhost>
@ItsNotRexed
ItsNotRexed merged commit a4551a1 into ProjectLeonida:main Nov 23, 2026
0 of 5 checks passed
h1bru added a commit to h1bru/Leonida that referenced this pull request Nov 23, 2026
Implements Xbox console device slot 133 (CreatePlacedResourceX), clearing
Stop 12 in docs/retail_boot_chain.md (§1 row 12) where the title places
a committed resource at a reserved virtual address.

Changes:
- runtime/shims/d3d12_xs_device.cpp:
  - Extends kMaxSlots to 192 so slot 133 is covered.
  - Implements proxy_create_placed_resource_x forwarding to PC
    CreateCommittedResource on DEFAULT heap.
  - Normalizes buffer descriptors to ROW_MAJOR layout, 1D dimensions,
    DXGI_FORMAT_UNKNOWN, sample count 1, and masks out Xbox-specific flags.
  - Normalizes texture descriptors to UNKNOWN layout, standard alignments,
    and ensures sample count is at least 1.
  - Sanitizes initial state 0xFFFFFFFF to D3D12_RESOURCE_STATE_COMMON.
  - Strips clear-value on buffers and non-RT/DS textures, and retries texture
    creation without clear-value if initially rejected.
  - Updates slot_name(133) and device_slot_overridden(133).
- runtime/test/xs_proxy_mock_test.cpp:
  - Adds mock_create_committed_resource handler for slot 27.
  - Verifies slot 133 buffer normalization, clear-value stripping,
    2D/3D texture layout mapping, state preservation, and parameter validation.
  - Moves beyond-table refusal test to slot 134.
- runtime/test/device_proxy_test.cpp:
  - Adds WARP integration tests for placed buffer and texture creation via
    slot 133, verifying layout normalization, sample count, and hit counters.

Depends on: ProjectLeonida#6953
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.