Repository navigation
XG: CopyFromSubresource refuses a destination span it cannot write - #3738
Open
Royalflamejlh wants to merge 1 commit into
Open
Royalflamejlh wants to merge 1 commit into
Royalflamejlh wants to merge 1 commit into
Conversation
CopyFromSubresource wrote its rows to `dst` at the title's row and slice pitches without checking them. A wrong pitch (on main before adccb7d, the low half of the source pointer) sent the rows gigabytes past the destination and the title died in `copy_from` (xcl-dev#662). adccb7d reads the arguments right; this keeps a bad span from becoming an access violation: a row pitch under one row, a slice pitch under one slice, or a span that is not writable memory returns E_INVALIDARG and logs the call (8 at most). The span is checked with DirectStorage's `writable`, not `gpu::shader::readable` as first written: `readable` refused a destination in the title's lazy pages (mapped, committed on first use, which the copy itself would commit) and spans over 256 MiB, and let a read-only one through to fault. The guard is from xcl-dev#684; the writable check is the one xcl-dev#976 proposed. Co-authored-by: Marco Luzzaro <marcoluzzaro99@gmail.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Dec 2, 2026
Collaborator
|
Review of In short: The PR takes over #684's destination-span guard for Nit
Checked and fine
Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point. |
Royalflamejlh
marked this pull request as ready for review
December 2, 2026 23:58
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.
Takes over #684 (its author has been inactive since 2026-11-24); keeps only its destination-span guard, since the ABI half landed in adccb7d.
The guard and its first tests are @JGonzalezRodriguez's, and the commit keeps him as its author; the writable check is the one @Marukooh proposed in #976. Thanks to both, and to everyone who tested #684.
CopyFromSubresourcewrites rows todstat the title's row and slice pitches without checking them. With a wrong pitch the rows land far past the destination and the process dies incopy_from(the first crash of #662, from the misread argument that adccb7d fixed). With this change a row pitch under one row, a slice pitch under one slice (3D), or a span that is not writable memory returnsE_INVALIDARGand logs the call (8 at most), as #684 did.One change from #684: the span is checked with
dstorage::writable, notgpu::shader::readable. On today'smain,readableis wrong in both directions here: it refuses a destination in the title's lazy pages (mapped, committed on first use, which the copy itself would commit), and spans over 256 MiB; and it lets a committed read-only destination through, which then faults. Both cases fail underreadablein the tests below. That is #976's switch, so #976 has nothing left once this is in; #992 (the source check) can rebase onto it.Part of #662
What is in it
crates/xcl/src/hle/xg.rs: the span check incopy_from, aftercopy_args; testscopy_from_refuses_a_destination_span_it_cannot_writeandcopy_from_writes_a_padded_volume_into_lazy_pages.crates/xcl/src/hle/dstorage.rs:writableispub(super).copy_fromsignature, the doc-comment change and thexg_oracle.rschange (main'scopy_argstakes both forms), and its two round-trip tests (subresource_copies_take_both_argument_formsonmaincovers the 2D one; the 3D one is now the lazy-pages test).Tested
45a8d7b1bonmain078358a05.x86_64-pc-windows-gnu(debug), tests under Wine:cargo check --workspacewith and without--tests: no errors, no warnings in the two files.cargo test -p xcl --lib -- hle::xg::tests: 6 passed, 0 failed, 0 ignored.cargo test -p xcl --test xg_oracle: 6 passed, 0 failed, 12 ignored (XCL_SAMPLE_XGunset).copy_from_refuses_a_destination_span_it_cannot_writefails (row pitch under a row returnsS_OK). Withreadablein place ofwritable,copy_from_writes_a_padded_volume_into_lazy_pagesfails (the lazy destination refused) and the read-only case faults the test process.cargo test --workspace -- --test-threads=4: 3,008 passed, 0 failed, 52 ignored; 29SKIPPEDlines (22gpu_tests, 7 others),hle::xg::testsamong the passed.Regression run
RTX 2070 SUPER 8 GB (driver 621.01), Ryzen 7 5700X3D, Windows 11 Pro 26200, release builds by
scripts/smoke.ps1, the same retail title for 60 s each.main:this PR's head:
Not tested
xg_oracleagainst the console's library; a retail run that reaches a refused call (no run of XG: fix CopyFromSubresource 7-argument ABI and guard destination span #684 logged one).AI use
main, switched it towritable, wrote the tests, ran the builds and tests and wrote this description.