Memory: reject sparse and cross-window spans in texture::uma_bytes #1520

Closed
OtavioTadeu wants to merge 1 commit from upstream-pr/1530 into main
OtavioTadeu commented 2026-11-24 17:18:39 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by OtavioTadeu on 2026-11-24T17:18:39Z.


Prevents texture::uma_bytes from reading uncommitted WindowKind::Sparse UMA reservations or cross-window spans, and returns an owned Vec<u8> instead of forging &'static [u8] over guest-mutable memory. Fixes #1393.

What is in it

  • crates/xcl/src/gpu/uma.rs: add Uma::contains_committed_span and unit tests covering sparse windows, cross-window spans, zero-length, and overflow
  • crates/xcl/src/gpu/texture.rs: validate spans via contains_committed_span, return Result<Vec<u8>, String> via uma_bytes_in, and add unit tests

Tested

  • NVIDIA GeForce GTX 1660 SUPER (driver 32.0.16.1088), AMD Ryzen 5 5600G, Windows 11 build 26200, DXC 1.9.2602.17 (Windows SDK 10.0.26100.0), rustc 1.100.0 (stable-x86_64-pc-windows-msvc), debug build
  • cargo test --workspace -- --test-threads=4: 778 passed, 0 failed, 41 ignored (SKIPPED GPU tests: gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask [no wave64], gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware [no wave64], heap_window_out_of_memory_falls_back_to_the_switch_form [no heap windows])
  • cargo test -p xcl --lib uma: 12 passed, 0 failed
  • cargo test -p xcl --lib texture: 31 passed, 0 failed

Regression run

  • scripts/smoke.ps1 -Game retail_title -Seconds 60 (main baseline vs PR head on NVIDIA GeForce GTX 1660 SUPER):

xcl-smoke v1

commit: 9e3831e1f570d3646e53ab753b19ec07eb8f1485

gpu: NVIDIA GeForce GTX 1660 SUPER

title: retail_title

seconds: 60

exit: 0x0

frames shown: 631 (PresentX 631)

presents per 2 s (last 3): 47 47 49

device removals: 0

crashes: 0

peak commit: 15199 MB


xcl-smoke v1

commit: 3cf8012435545c359e5806910f48f210abb9d716

gpu: NVIDIA GeForce GTX 1660 SUPER

title: retail_title

seconds: 60

exit: 0x0

frames shown: 637 (PresentX 638)

presents per 2 s (last 3): 41 40 40

device removals: 0

crashes: 0

peak commit: 15194 MB

Not tested

  • AMD / native wave64 GPUs, Linux/Wine, and extended gameplay past the 60 s smoke window

AI use

  • Antigravity with Gemini 4 Neon: analyzed the issue, wrote the fix, tests, and PR description; reviewed by author.
<!-- greyfinch-sync:ivall/xcl:issue:5476959953 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1530). Originally posted by [OtavioTadeu](https://github.com/OtavioTadeu) on 2026-11-24T17:18:39Z. --- Prevents `texture::uma_bytes` from reading uncommitted `WindowKind::Sparse` UMA reservations or cross-window spans, and returns an owned `Vec<u8>` instead of forging `&'static [u8]` over guest-mutable memory. Fixes #1393. **What is in it** - `crates/xcl/src/gpu/uma.rs`: add `Uma::contains_committed_span` and unit tests covering sparse windows, cross-window spans, zero-length, and overflow - `crates/xcl/src/gpu/texture.rs`: validate spans via `contains_committed_span`, return `Result<Vec<u8>, String>` via `uma_bytes_in`, and add unit tests **Tested** - NVIDIA GeForce GTX 1660 SUPER (driver 32.0.16.1088), AMD Ryzen 5 5600G, Windows 11 build 26200, DXC 1.9.2602.17 (Windows SDK 10.0.26100.0), rustc 1.100.0 (`stable-x86_64-pc-windows-msvc`), debug build - `cargo test --workspace -- --test-threads=4`: 778 passed, 0 failed, 41 ignored (SKIPPED GPU tests: `gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask` [no wave64], `gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware` [no wave64], `heap_window_out_of_memory_falls_back_to_the_switch_form` [no heap windows]) - `cargo test -p xcl --lib uma`: 12 passed, 0 failed - `cargo test -p xcl --lib texture`: 31 passed, 0 failed **Regression run** - `scripts/smoke.ps1 -Game retail_title -Seconds 60` (`main` baseline vs PR head on NVIDIA GeForce GTX 1660 SUPER): ``` xcl-smoke v1 commit: 9e3831e1f570d3646e53ab753b19ec07eb8f1485 gpu: NVIDIA GeForce GTX 1660 SUPER title: retail_title seconds: 60 exit: 0x0 frames shown: 631 (PresentX 631) presents per 2 s (last 3): 47 47 49 device removals: 0 crashes: 0 peak commit: 15199 MB ``` ``` xcl-smoke v1 commit: 3cf8012435545c359e5806910f48f210abb9d716 gpu: NVIDIA GeForce GTX 1660 SUPER title: retail_title seconds: 60 exit: 0x0 frames shown: 637 (PresentX 638) presents per 2 s (last 3): 41 40 40 device removals: 0 crashes: 0 peak commit: 15194 MB ``` **Not tested** - AMD / native wave64 GPUs, Linux/Wine, and extended gameplay past the 60 s smoke window **AI use** - Antigravity with Gemini 4 Neon: analyzed the issue, wrote the fix, tests, and PR description; reviewed by author.
GonZiin commented 2026-11-24 18:04:23 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by GonZiin on 2026-11-24T18:04:23Z.

Review: COMMENTED


Please reuse Uma::in_committed_window for the new texture copy. The existing method checks the same committed-window condition, and checked_span already checks the exclusive end for overflow before the texture code calls it. Keeping one predicate lets future UMA changes update the DirectStorage and texture paths together.

Tested

  • Windows 11 Pro 26300, Ryzen 7 7800X3D, Rust 1.100.0 MSVC, debug, head 3cf8012435545c359e5806910f48f210abb9d716.
  • cargo test -p xcl --lib <filter> -- --test-threads=1 with contains_committed_span_rejects_sparse_and_cross_window_spans and uma_bytes_rejects_sparse_and_out_of_bounds_spans_and_copies_committed_data. Each reported 1 passed, 0 failed and 0 ignored on the clean head.
  • In an isolated checkout I removed only the duplicate method and redirected the new validation and assertions to in_committed_window. The same commands passed with the same counts, covering rejection of sparse, overflowing and cross-window spans and copying of committed bytes.

Not tested

Full workspace, concurrent guest writes, and retail smoke.

AI use

Codex (gpt-6.2-sol) compared the predicates, ran the targeted tests and drafted this review.

<!-- greyfinch-sync:ivall/xcl:review:6044699922 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1530#pullrequestreview-6044699922). Originally posted by [GonZiin](https://github.com/GonZiin) on 2026-11-24T18:04:23Z. **Review:** COMMENTED --- Please reuse `Uma::in_committed_window` for the new texture copy. The existing method checks the same committed-window condition, and `checked_span` already checks the exclusive end for overflow before the texture code calls it. Keeping one predicate lets future UMA changes update the DirectStorage and texture paths together. **Tested** - Windows 11 Pro 26300, Ryzen 7 7800X3D, Rust 1.100.0 MSVC, debug, head `3cf8012435545c359e5806910f48f210abb9d716`. - `cargo test -p xcl --lib <filter> -- --test-threads=1` with `contains_committed_span_rejects_sparse_and_cross_window_spans` and `uma_bytes_rejects_sparse_and_out_of_bounds_spans_and_copies_committed_data`. Each reported 1 passed, 0 failed and 0 ignored on the clean head. - In an isolated checkout I removed only the duplicate method and redirected the new validation and assertions to `in_committed_window`. The same commands passed with the same counts, covering rejection of sparse, overflowing and cross-window spans and copying of committed bytes. **Not tested** Full workspace, concurrent guest writes, and retail smoke. **AI use** Codex (`gpt-6.2-sol`) compared the predicates, ran the targeted tests and drafted this review.
DavidM1911 commented 2026-11-24 19:07:56 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T19:05:49Z.


Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, ~21 ignored.

Thanks!

<!-- greyfinch-sync:ivall/xcl:comment:7141591896 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1530#issuecomment-7141591896). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-24T19:05:49Z. --- Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~21 ignored. Thanks!
Foniass commented 2026-12-01 06:00:30 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T06:00:30Z.


Triage (#1607) – head 3cf8012

No open or merged PR makes the same change (#1393). texture::uma_bytes has no callers on main, so the change has no runtime effect today; it removes a safe function that returned &'static [u8] over possibly uncommitted sparse windows and returns a copy instead. The contains_committed_span check rejects every sparse window, including committed reservations in them, which is fine for an unused helper but worth saying in the description.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

<!-- greyfinch-sync:ivall/xcl:comment:7302373501 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1530#issuecomment-7302373501). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T06:00:30Z. --- **Triage (#1607)** – head 3cf8012 No open or merged PR makes the same change (#1393). `texture::uma_bytes` has no callers on main, so the change has no runtime effect today; it removes a safe function that returned `&'static [u8]` over possibly uncommitted sparse windows and returns a copy instead. The `contains_committed_span` check rejects every sparse window, including committed reservations in them, which is fine for an unused helper but worth saying in the description. Recommendation: keep open. AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
throny commented 2026-12-02 08:58:52 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by throny on 2026-12-02T08:58:52Z.


Two contributors checked independently and found that this PR makes the same change as #1400: #1607, group D222. They suggest keeping #1400. If you agree, closing this PR or joining the other one would save the maintainers a review. If the two differ in a way the checks missed, a note in #1607 helps.

This is a hint from the community triage in #1607, not a maintainer decision.

AI use: Claude Code (Claude Opus 5.5), posted by a script from the #1607 table.

<!-- greyfinch-sync:ivall/xcl:comment:7340194148 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1530#issuecomment-7340194148). Originally posted by [throny](https://github.com/throny) on 2026-12-02T08:58:52Z. --- <!-- xcl-1607-hint:D222 --> Two contributors checked independently and found that this PR makes the same change as #1400: #1607, group D222. They suggest keeping #1400. If you agree, closing this PR or joining the other one would save the maintainers a review. If the two differ in a way the checks missed, a note in #1607 helps. This is a hint from the community triage in #1607, not a maintainer decision. AI use: Claude Code (Claude Opus 5.5), posted by a script from the #1607 table.
throny commented 2026-12-02 10:18:35 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by throny on 2026-12-02T10:18:35Z.


Closing as a duplicate of #1400: #1607 group D222, checked by Foniass and Decodere, who both read the diffs and suggest keeping #1400. If something here is not in #1400, say so and reopen it, or ask and I will.

AI use: Claude Code (Claude Opus 5.5) ran the closing script.

<!-- greyfinch-sync:ivall/xcl:comment:7342278693 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1530#issuecomment-7342278693). Originally posted by [throny](https://github.com/throny) on 2026-12-02T10:18:35Z. --- Closing as a duplicate of #1400: #1607 group D222, checked by Foniass and Decodere, who both read the diffs and suggest keeping #1400. If something here is not in #1400, say so and reopen it, or ask and I will. AI use: Claude Code (Claude Opus 5.5) ran the closing script.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl!1520
No description provided.