Repository navigation
d3d12_xs: slot 14 takes the console layout only for committed, writable descriptor memory - #1387
Closed
JoshRob297 wants to merge 1 commit into
Closed
JoshRob297 wants to merge 1 commit into
JoshRob297 wants to merge 1 commit into
Conversation
4 tasks done
Author
|
Closing this as superseded: main already carries Two data points from running the retail title, in case they are useful for the tests behind it:
One difference worth keeping in mind: this PR accepted Nothing else here is needed. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
d3d12_xs: slot 14 takes the console layout only for committed, writable descriptor memory
Fixes #3.
The false positive reported here has a second shape after #4: a size-only guard accepts a plain PC
D3D12_DESCRIPTOR_HEAP_DESCwhose trailing caller words happen to be(1, 32), soGetCPUDescriptorHandleForHeapStart()returns address 1 (#1148). This replaces the shape test with acheck on the memory the console layout names.
What changes
runtime/shims/d3d12_xs_device.cppcommitted_writable_range(address, bytes): walks the range withVirtualQuery, requiring everypage to be
MEM_COMMITwithPAGE_READWRITEorPAGE_WRITECOPY.console_heap_range_plausible()now takes the heap's actual increment and accepts the console layoutonly when all of these hold:
addressis a user-mode address (>= 0x10000, below the canonical user limit);NumDescriptors != 0and does not overflow;size == 0(caller left it unset) orsize == NumDescriptors * increment, usingGetDescriptorHandleIncrementSize(desc->Type)(32 for CBV/SRV/UAV and RTV, as measured);[address, address + NumDescriptors * increment)is committed and writable.trailer: no address is applied, and an ordinary PC heap is created.
runtime/test/d3d12_console_descriptor_heap_test.cppVirtualAlloc, instead of using theunmapped constant
0x556677880000. A console heap is backed by title memory; after this change anunbacked address is no longer a console heap, so the test has to hand it real memory.
NumDescriptors = 1followed by the words(1, 32)must reach the PC path, and its CPU heap start must not be 1.Why this is a positive check, not a heuristic
The console layout is not identified by the bytes after the PC description; those bytes are the
caller's, and any readable non-zero word there is a coincidence. It is identified by what the pair
(address, size)claims: descriptor memory the title owns for this heap. That claim is checkable:VirtualQuery, not a readable probe of one word);A PC caller's trailing words are arbitrary. The only way they satisfy all three conditions is if the
caller really holds a committed, writable buffer of exactly
NumDescriptors * incrementbytes at theword after its descriptor, which is the console layout's contract. The shapes that produced the
reported crashes — address 1, or an unbacked synthetic address with a matching size — are rejected by
construction, not by a threshold.
Negative control, measured: with the previous size-only rule restored, the new
(1, 32)case takesthe console layout (
descriptor heap takes the console address 0x1 (size 32)) and the test fails withCPU start 0x1. With this change the same case reaches the PC path and both tests pass.Measurement on the retail title
The call that motivated the console path carries, after the 16-byte PC description:
0x1000039845888NumDescriptors124518432NumDescriptors * 3239845888[0x10000, 0x10000 + 39845888)is committed and writable in the title, so the validated check acceptsthe layout and the heap keeps the console address. The same numbers pass the size comparison alone,
which is why the size rule was necessary but not sufficient.
Build and test
Base:
upstream/mainat0f98d193c(the working mirror was 137 commits behind, so the branch was cutfrom upstream to keep the patch applicable).
Built with clang-cl 23.1.4 + xwin, run under Wine 11.22 (Staging) on an Intel Graphics (MTL) Vulkan
device.
d3d12_descriptor_test(ctestd3d12_descriptor)d3d12_console_descriptor_heap_test(1, 32)regression with the size-only guardCPU start 0x1(1, 32)regression with this changeThe SEGFAULT in the report is GPU/driver-specific and does not reproduce on this Intel MTL box:
upstream main already exits 0 here, matching the report from another machine on current main. The
regression is therefore demonstrated by the
(1, 32)case, which fails under the size-only guard andpasses here.
Not run: the full
ctestsuite (278+ tests), and the retail title on this machine. No game data isincluded.