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

Open
Pipodi wants to merge 1 commit into
ItsNotRexed:mainfrom
Pipodi:xs-slot-table
Open

Pipodi wants to merge 1 commit into
ItsNotRexed: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
Contributor

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)

@dandasma

Copy link
Copy Markdown
Contributor

Retail on AMD (own 1.0.2.1 copy, Windows 11, RX 9070 / AMD 26.10.1, Ryzen 9 9900X, LEONIDA_D3D12=vulkan, MSVC RelWithDebInfo): with this PR the jump to address 0 after slot 15 is gone (3/3): slot 133 is reached and returns E_NOTIMPL, the stop #7075/#7218 then clear. Base: main 042c5f3 + #4313 #6582 #4348 #6964 #6954 #7076.

AI-assisted (Claude Code).

zneel pushed a commit to zneel/Leonida that referenced this pull request Nov 23, 2026
…he title's own pages

Xbox device slot 133 is (va, desc, state, clear, riid, out): the title places a buffer at the VA of a
physical-page range it has just mapped (docs/retail_boot_chain.md 3.4, ItsNotRexed#6915). The proxy now hands it to
a handler the Vulkan layer registers (set_placed_at_va_handler), which imports [va, va + width) with
VK_EXT_external_memory_host and binds a VkBuffer to it: the CPU's writes there are the GPU's reads with no
copy, and the resource's console VA is the title's VA, so views and immediate writes the title names by
that VA resolve to it through the buffer VA index. The Xbox flag bits above the PC ones are dropped and
the layout made ROW_MAJOR, as slot 76 does; textures are E_NOTIMPL, a misaligned VA E_INVALIDARG, and
with no handler (a PC device) the slot refuses with E_NOTIMPL as ItsNotRexed#6953's table does.

Not decided here: a shader that adds heap_base to the title's VA (its own V#s) does not reach these
pages; that needs the single address space of docs/d3d12_vulkan.md 3.3.

d3d12_existing_heap_test: on a VirtualAlloc range and on a view of a pagefile-backed section (the form
xmem's physical pages take), the buffer's GPU VA is the address and a GPU copy to a READBACK buffer reads
a pattern the CPU wrote after creation; Vulkan validation clean on an RTX 4090.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
zneel added a commit to zneel/Leonida that referenced this pull request Nov 23, 2026
@Silliana

Copy link
Copy Markdown

Validation signal on main 9f53c50 + #7218 (Windows 11 26200, RTX 3070 Ti, Vulkan): both merged cleanly (this PR's kMaxSlots=192 hunk was already carried by #7218, so it auto-resolved). device_proxy_test 99 PASS / 0 FAIL, loader_test 88 ok / 0 failed, xs_proxy_mock_test PASS including the 133-no-handler case (E_NOTIMPL, no vtable call) and the handler mask/layout checks. The live boot that previously executed address 0 at slot 133 now gets a clean result. Good to carry.

@KevinPratap

Copy link
Copy Markdown

Tested 4b76715cf together with #7075 (e0b300f02) on RTX 4050 Laptop (NVIDIA 592.82), Windows 11, MSVC 14.44 RelWithDebInfo, LEONIDA_D3D12=vulkan, own 1.0.2.1 copy, gta6rt --run with outbound network blocked: pass. I did not run this PR on its own.

Merged onto main dde82f27e with #4313, #6582, #4348, #2490, #4531, #6964 and #6954; this PR merged cleanly. Before these two, the run ended with an execute fault at 0x0 right after device slot 15, consistent with the null slot-133 entry #6953 describes. With both, slot 133 places a committed buffer and the run reaches the first CreateDescriptorHeap. It then stops at the title's assert after heap slot 9, which is stop 13 in docs/retail_boot_chain.md. The D3D12 trace there has 1,183 calls, 1,182 ok.

Traces stay local; no addresses or game data here. AI-assisted (Claude Code).

@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.

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.