Skip to content

Memory: link xcl.exe without high-entropy ASLR so title memory stays under 2^40 - #631

Closed
13hourstilliland wants to merge 1 commit into
xcl-dev:mainfrom
13hourstilliland:memory-low-va
Closed

13hourstilliland wants to merge 1 commit into
xcl-dev:mainfrom
13hourstilliland:memory-low-va

Conversation

@13hourstilliland

Copy link
Copy Markdown
Contributor

Part of #585. A retail title's XboxBvhBuilder refuses any acceleration structure whose GPU address is at or above 2^40. @sub-north's addresses in #585 are about 2.06 TiB, in write-watched reservations that go through VirtualAlloc(NULL).

The reason they are that high: xcl.exe is linked with high-entropy VA (Rust's default), and with it Windows places a process's bottom-up allocations around 1 to 2.5 TiB. The title's memory lives in that process. Linking xcl.exe without it brings those allocations back near 2 GiB. That should also cover the fallbacks @sub-north found the VirtualAlloc2 ceiling could not catch, with no change in crates/xcl/src.

What is in it

  • crates/xcl/build.rs (new): /HIGHENTROPYVA:NO (MSVC) or -Wl,--disable-high-entropy-va (GNU) for the xcl binary only.
  • crates/xcl/tests/low_va.rs (new): reads xcl.exe's PE header and fails if the high-entropy VA flag is set.

Tested

  • RTX 3070 (driver 32.0.16.1088), i5-12600K, Windows 11 26200, rustc 1.100.0 x86_64-pc-windows-gnu (not MSVC), debug.
  • What the flag changes, measured with a small probe linked both ways (VirtualAlloc(NULL, 24 GiB, MEM_RESERVE) ×20, three runs each):
    • default: first reservation at 0x1e1cb8a0000, 0x1eda2c40000 and 0x23344380000; 20/20 above 2^40 in every run
    • --disable-high-entropy-va: from 0x7fff0000 up; 0/20 above 2^40
  • cargo test -p xcl --test low_va: fails on main with DllCharacteristics 0x160: high-entropy VA is on; passes with this change (0x140).
  • cargo test --workspace --no-fail-fast -- --test-threads=4 in an interactive session: 686 passed, 0 failed, 41 ignored, the e2e title test included. The same tree on main cb868b2 plus these two files.
  • SKIPPED printed: gpu_geometry_wave32_prefix_count_over_a_mask (no wave64). A Session 0 run of the same tree also printed gpu_wave32_program_in_wave64_hardware (no wave64).

Regression run
None. I do not have a retail title. scripts/pr_check.py does not ask for one here because nothing under crates/xcl/src changes, but the change affects where every allocation in the process lands, so a smoke run is the real check. @sub-north, you hit this wall: would you run smoke.ps1 on main and on this head?

Not tested

  • MSVC link (/HIGHENTROPYVA:NO is a standard link.exe switch, but I built with GNU only).
  • The retail title, and whether the BVH builder passes afterwards.
  • Allocations a title asks for with MEM_TOP_DOWN still go to the top of the address space. This change does not cover them.
  • On a target dir that had already built xcl.exe, one of my workspace runs kept a stale binary with the flag still set. cargo clean -p xcl fixed it, and every later run was consistent.

AI use
Claude Code (Claude Opus 5.5): found the cause, wrote the change and the test, ran the probe and the tests on the PC above, and wrote this description.

…under 2^40

A retail title's XboxBvhBuilder refuses an acceleration structure whose
GPU address has a bit at or above 40 set (xcl-dev#585: "DestAccelerationStructureData
can not have more than 40b of address set", then 0xe06d7363). The failing
addresses reported there are about 2.06 TiB, in write-watched title
reservations that go through VirtualAlloc(NULL).

Root cause: Rust links xcl.exe with high-entropy VA on, and with it Windows
puts a process's bottom-up allocations (heaps, stacks, VirtualAlloc(NULL))
around 1-2.5 TiB. Measured on Windows 11 26200 with a small probe linked
both ways: twenty 24 GiB reservations landed at 0x1e1cb8a0000 and up
(20/20 above 2^40, three runs); with --disable-high-entropy-va they landed
from 0x7fff0000 up (0/20 above 2^40). The title's memory follows, since it
lives in xcl.exe's process.

build.rs passes /HIGHENTROPYVA:NO (MSVC) or --disable-high-entropy-va
(GNU) to the xcl binary only; the library and test binaries are unchanged.
tests/low_va.rs checks the flag in xcl.exe's PE header.

Not covered: allocations the title asks for with MEM_TOP_DOWN still go to
the top of the address space.

Assisted-by: Claude Code (Claude Opus 5.5)
@LocranKing

Copy link
Copy Markdown

Tested the MSVC build (x86_64-pc-windows-msvc) and retail smoke run on NVIDIA RTX 3060 Ti.

Tested

  • Commit: 12be9306269772e1e24aa1e44219f2bce684c193 (pr-631, clean tree; cargo clean -p xcl before building)
  • Hardware / software: Windows 11 Home Build 26200, Ryzen 5 5500, 31.8 GB RAM, RTX 3060 Ti (8024 MiB VRAM, driver 32.0.16.2101), rustc 1.100.0 (x86_64-pc-windows-msvc, MSVC 14.44.35207), DXC 1.9.2602.17 (SDK 10.0.26100.0), --release
  • cargo test --release -p xcl --test low_va: 1 passed, 0 failed (xcl_exe_is_linked_without_high_entropy_va ... ok)
  • cargo test --workspace --release --no-fail-fast -- --test-threads=4: 686 passed, 0 failed, 41 ignored, exit 0; 2 (no wave64) skipped (gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware)
  • Relocation / VA check in xcl.log on the retail smoke run: all relocated console DLLs and UMA windows landed well below 2^40 (e.g. vcruntime140.dll @ 0x16d0000, xboxbvhbuilder.dll @ 0xa6a0000, libhttpclient.gdk.dll @ 0xa780000, window 0 buffer at VA 0x300000000, coherent window at 0x400000000, console buffers 0x700010000).

Regression run (scripts/smoke.ps1, 60 s, XCL_NETWORK=0, title folder name redacted)

main (dd2ae9a):

xcl-smoke v1
commit: dd2ae9a70af5eb5aad60f02d86e386b72abe1e95
gpu: NVIDIA GeForce RTX 3060 Ti
title: retail-1.0.2.1
seconds: 60
exit: 0x0
frames shown: 1525 (PresentX 1525)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14720 MB

PR #631 (12be930):

xcl-smoke v1
commit: 12be9306269772e1e24aa1e44219f2bce684c193
gpu: NVIDIA GeForce RTX 3060 Ti
title: retail-1.0.2.1
seconds: 60
exit: 0x0
frames shown: 815 (PresentX 816)
presents per 2 s (last 3): 25 26 25
device removals: 0
crashes: 0
peak commit: 15654 MB

(Note on the lower frame count: #631 is branched off an older main before #636/#602, and during this run free system commit was 17342 MB < 17408 MB, so XCL kept a 512 MB coherent window.)

Not tested: World streaming / live XboxBvhBuilder calls past the start screen, debug build, GNU target.

AI use: Antigravity (Gemini 4 Hydrogen) ran the builds, tests, and smoke run and drafted this report from the actual command outputs and logs.

@Chrysana

Copy link
Copy Markdown

Test report for 12be931 on AMD RDNA4 with the retail title, which is the card in #586: with this PR, the acceleration-structure addresses the title hands its BVH builder are under 2^40; on main they are all above it. The runs below didn't reach the builder's check itself (see the last point under Long runs).

Setup: AMD Radeon RX 9070 XT 16 GB, driver 32.0.32015.2008, Ryzen 7 9800X3D, 31 GB RAM, Windows 11 25H2 build 26200.9974, rustc 1.100.0 x86_64-pc-windows-msvc, DXC 1.9.2602.17. Retail title 1.0.2.1, XCL_NETWORK=0. Debug build for the tests, release builds for the runs.

The link flag (MSVC):

  • xcl.exe DllCharacteristics: main 63cdc25 = 0x8160 (high-entropy VA on); 12be931 = 0x8140 (off).
  • cargo test --workspace --no-fail-fast -- --test-threads=4 at 12be931: 686 passed, 0 failed, 41 ignored; xcl_exe_is_linked_without_high_entropy_va passes. SKIPPED: the two debug-layer tests (the D3D12 debug layer isn't installed here).
  • Negative control: this PR's tests/low_va.rs alone on main 63cdc25 (without build.rs) fails with DllCharacteristics 0x8160: high-entropy VA is on.

Where the title's memory lands (from xcl.log; 2^40 = 0x100_0000_0000):

main this PR
the 24 GiB reservation (kernelx: reservation … 0x600000000 bytes) a different place each run, ≥ 2^40 in all 4: 0x149e4010000, 0x1d97c850000, 0x285e2a60000, 0x2a6ffec0000 0xd20000000 in all 5 runs
kept-in-step texture sources all above 2^40 (14/14, 16/16) all below (0/14, 0/16)
CreateShaderResourceView(RAYTRACING_ACCELERATION_STRUCTURE) addresses 4/4 above, 0x1dfda360000–0x1dfdd946f00 4/4 below, 0x1947a0000–0x197d81d00

Long runs (240 s, XCL_PRESS_A_AT=20,25,30, main 63cdc25 and this PR's head):

Regression run: scripts/smoke.ps1 -Game <folder> -Seconds 60, XCL_PRESS_A_AT=14,17,21, same saved state, two rounds. This PR is 15 commits behind main, so it was also merged onto main 63cdc25 (clean, local merge 52de9e9, not pushed):

build frames peak commit
main 63cdc25 1183, 1176 17197, 17135 MB
12be931 merged onto 63cdc25 1174, 1189 17130, 17201 MB
12be931 (its own base cb868b2) 1566 17417 MB

All runs reached the intro video; no crash or device removal.

main:

xcl-smoke v1
commit: 63cdc25bc0d2b59cc2af85e6e23f619dfaf72866
gpu: AMD Radeon RX 9070 XT
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1183 (PresentX 1184)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 17197 MB

PR merged onto main:

xcl-smoke v1
commit: 52de9e99b37c0f6bb2b5d2766563b5bb43b2fee8
gpu: AMD Radeon RX 9070 XT
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1174 (PresentX 1174)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 17130 MB

PR head:

xcl-smoke v1
commit: 12be9306269772e1e24aa1e44219f2bce684c193
gpu: AMD Radeon RX 9070 XT
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1566 (PresentX 1566)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 17417 MB

Not tested: the BVH builder's check passing (the watchdog stops both runs first); MEM_TOP_DOWN allocations; the low-commit fallback from #586's log (UMA: … under 17408 MB), which this machine didn't hit in these runs.

AI use: Claude Code with Claude Opus 5.5 built the commits, ran the tests, the negative control and the title runs, read the logs, and wrote this report. The runs were made on my machine.

@wetlevel

Copy link
Copy Markdown

Test report for 12be930: the BVH builder's check passes with the retail title (1.0.2.1). That's the case the runs above list as not tested, since their runs didn't reach it. On this machine main reaches the check and throws on every run.

Setup: RTX 4070, Ryzen 7 7800X3D, 32 GB RAM, Windows 11, rustc 1.100.0 (MSVC), release build, XCL_NETWORK=0, XCL_PRESS_A_AT=20,25,30.

On main (3 runs): every run threw from XboxBvhBuilder.dll, with D3D12 XDXR Error: DestAccelerationStructureData can not have more than 40b of address set, right after index buffer at … (96 bytes) is outside unified memory … mirrored. The RAYTRACING_ACCELERATION_STRUCTURE addresses were above 2^40 (0x259919a0000, 0x2599375fb00, 0x1d294723500).

With this PR:

The RAYTRACING_ACCELERATION_STRUCTURE addresses are below 2^40: 0x1947a0000, 0x196562400, 0x1974fc000, 0x197d84800. Kept-in-step textures are also low (0x1128d06000, 0x12e222c000).
No XDXR Error. The same index buffer … (96 bytes) … mirrored line appears, then about 50 more translated compute PSOs, past the point where main threw.
The run then ends in the title's GPU watchdog (0xc0000005 in game_scarlett_master.exe+0x23cf683, write at 0x0), as in #505 / #534 and the RDNA4 runs above. Not related to this PR.

Not tested: smoke.ps1 regression runs, a debug build.

AI use: Claude helped read the logs and drafted this report. The builds and runs were done on my machine.

@anes66

anes66 commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Verified 12be9306269772e1e24aa1e44219f2bce684c193 with MSVC on Windows 10 Pro (build 19045), Ryzen 7 9800X3D and RTX 3060 12 GB (driver 32.0.16.2114).

Tested

  • Rust/Cargo 1.100.0, MSVC 14.52.37025, debug build, DXC 1.9.2602.17, Agility SDK 1.620.2.
  • cargo build --locked --workspace -j 4: passed.
  • cargo test --locked --workspace --no-fail-fast -j 4 -- --test-threads=4 --show-output: 686 passed, 0 failed, 41 ignored. The new low_va test and synthetic title e2e tests passed.
  • Two GPU tests reported SKIPPED for lack of native wave64: gpu_geometry_wave32_prefix_count_over_a_mask and gpu_wave32_program_in_wave64_hardware. These are included in the passed count. All XCL_SAMPLE_* variables were unset, so sample-gated early returns do not establish coverage of game data.
  • The PR's MSVC-built xcl.exe has DllCharacteristics 0x8140; main f4ce27ceb6d1b0576d0c659b713b674778bf1968 built here had 0x8160. HIGH_ENTROPY_VA is cleared; DYNAMIC_BASE and NX_COMPAT remain set.
  • An independent MSVC C probe reserved twenty 24 GiB regions using VirtualAlloc(NULL, ..., MEM_RESERVE, PAGE_NOACCESS). With /HIGHENTROPYVA: 20/20 addresses were above 2^40 (first 0x1f9b6fc0000). With /HIGHENTROPYVA:NO: 0/20 were above it (first 0x7fff0000). Reservations were released; no pages were committed.

Not tested
Retail title smoke runs, XboxBvhBuilder progression, MEM_TOP_DOWN, release builds or GNU. The workspace run used this exact PR head, not a merge with current main. The standalone probe supports the allocation-placement explanation; it does not prove all title allocations will stay below 2^40.

AI use
Codex (GPT-6; exact variant unavailable) inspected the patch, ran the MSVC build and tests, wrote and ran the independent allocation probe, and drafted this report.

mastrr9 added a commit to mastrr9/xcl that referenced this pull request Nov 24, 2026
@maephisto666

Copy link
Copy Markdown

Test report: MSVC toolchain, and a retail run of #585's crash with and without this change.

Rebase note. The PR no longer applies to main (09940bb): main gained its own crates/xcl/build.rs in #762 (translator source hash). I tested the PR's linker flag added to main's build.rs (inside its main(), after the XCL_TRANSLATOR_SOURCE_ID line), plus tests/low_va.rs unchanged:

    match std::env::var("CARGO_CFG_TARGET_ENV").as_deref() {
        Ok("msvc") => println!("cargo:rustc-link-arg-bin=xcl=/HIGHENTROPYVA:NO"),
        Ok("gnu") => println!("cargo:rustc-link-arg-bin=xcl=-Wl,--disable-high-entropy-va"),
        _ => {}
    }

Tested

  • RTX 5090 (driver 32.0.16.2124), Ryzen 9 9950X3D, Windows 11 build 26100, rustc 1.100.0 x86_64-pc-windows-msvc, MSVC 14.44 link.exe.
  • xcl.exe DllCharacteristics (release): main 0x8160 → with the change 0x8140 (HIGH_ENTROPY_VA off, DYNAMIC_BASE still on).
  • cargo build --workspace then cargo test --workspace -- --test-threads=4 on main + the change (debug): 717 passed, 0 failed, 41 ignored; low_va passes. SKIPPED: gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware (no wave64). Also cargo test --release -p xcl --test low_va: 1 passed.
  • Retail title 1.0.2.1 (the D3D12.X: GPU addresses above 2^40 make the title's BVH builder throw ("more than 40b of address set") #585 one), XCL_NETWORK=0, fresh title data each run, 600 s cap, release builds:
build runs "DestAccelerationStructureData can not have more than 40b of address set" addresses seen how the run ended
main 09940bb 3 2 of 3 (at 112 s and 122 s; the third reached the #505 watchdog first, at 168 s) xboxbvhbuilder.dll at 0x1fb2ff00000 / 0x2e4d9bc0000; AS SRVs above 2^40 0xe06d7363 (2), watchdog (1)
main + this change 3 0 of 3 xboxbvhbuilder.dll at 0x9e60000; AS SRVs at 0x1947a0000–0x197d82e00 #505 watchdog at 108–120 s (all 3; one of them also had a local switch turning off the #795 Wait64 GPU bridge)

With the change the BVH builder's 40-bit check no longer fires; the runs then stop at the #505 stall instead. The AS SRVs are still logged as "not in unified memory – writing empty BVH descriptor" (a separate gap, no crash).

Not tested: AMD GPUs, the GNU toolchain, other titles (Minecraft / XDefiant / Fortnite / Unicorn Overlord), scripts/smoke.ps1 blocks.

AI use: Claude Code (Claude Opus 5.5) ran the builds, tests and retail runs on the hardware above and wrote this report.

@Creaa

Creaa commented Nov 24, 2026

Copy link
Copy Markdown

MSVC test on RTX 4070

RTX 4070 (driver 617.14), Core i7-13700F, Windows build 26300, Rust 1.100.0 (MSVC). Compared the PR head with its direct parent to isolate the linker change.

  • cargo test --locked --release -p xcl --test low_va at the PR head: 1 passed, 0 failed, 0 ignored. PE DllCharacteristics was 0x8160 on the parent and 0x8140 on the PR head.
  • Same title, 60 seconds offline each with scripts/smoke.ps1: 643 frames on the parent and 580 on the PR head. Both exited normally with zero crashes and zero device removals in that window. One comparable DirectStorage destination (#4096) moved from 0x20b7465f6d4 to 0x18dfef6d4, below the 40-bit limit.
  • In a separate interactive run on the PR head, the earlier 40-bit BVH error did not recur. After loading and a black screen, a write to address zero at game image offset +0x23cf683 stopped the run at 218.382 s. That signature matches The retail title 1.0.2.1 (RTX 5070): reaches the end of the first-run setup, then deterministic 0xC0000005 write at 0x0 in game_scarlett_master.exe+0x23cf683 #846. Controllable gameplay was not reached. The parent was not run interactively for this comparison.

Smoke blocks below have the title field redacted.

xcl-smoke v1
commit: cb868b200517d7b11bbfcb0146bf0c787ce632b6
gpu: NVIDIA GeForce RTX 4070
title: [redacted]
seconds: 60
exit: 0x0
frames shown: 643 (PresentX 643)
presents per 2 s (last 3): 20 19 18
device removals: 0
crashes: 0
peak commit: 16050 MB
xcl-smoke v1
commit: 12be9306269772e1e24aa1e44219f2bce684c193
gpu: NVIDIA GeForce RTX 4070
title: [redacted]
seconds: 60
exit: 0x0
frames shown: 580 (PresentX 580)
presents per 2 s (last 3): 18 19 18
device removals: 0
crashes: 0
peak commit: 16040 MB

AI use: Codex (GPT-6) built the revisions, ran the tests and smoke trials, and drafted this report. The on-screen observations came from the user.

@AlexLopezDevelop

Copy link
Copy Markdown

Tested on RTX 2080 Ti (Turing, driver 621.24) + Intel i9-9900K, Windows 11, 32 GB, retail 1.0.2.1, merged onto #891 (8cada26, XCL_PSO_WAIT_MS=50), DXC 1.9.2609, walked through the first-run setup by hand: #585 is gone.

Merge note: crates/xcl/build.rs conflicts with main's translator-source hash main(); I kept both bodies in one main().

AI-assisted (Claude Code, Claude Opus 5.5).

ivall pushed a commit that referenced this pull request Nov 24, 2026
…under 2^40 (PR #631)

A retail title's XboxBvhBuilder refuses an acceleration structure whose GPU address is at or
above 2^40 (#585). xcl.exe was linked with high-entropy VA (Rust's default), and Windows then
places a process's bottom-up allocations around 1 to 2.5 TiB, where the title's memory lives.
build.rs links the xcl binary with /HIGHENTROPYVA:NO (MSVC) or --disable-high-entropy-va
(GNU); tests/low_va.rs fails if the flag is set. Ported onto main's build.rs (#762) as
maephisto666 described in the PR.
@ivall

ivall commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator

Merged as a port onto main's build.rs (from #762) in 02bfd1d, with the linker flag exactly as maephisto666 described and your tests/low_va.rs unchanged (authored as you) - GitHub will not show this PR as merged, so I am closing it by hand. Thanks! Checked on main 02bfd1d together with #891, #693, #551 and #631: cargo test --workspace -- --test-threads=4 green (685 lib tests), and a retail run through the menus and intro into the start of the world load with XCL_PSO_WAIT_MS=50: no crash, no device removal.

@ivall ivall closed this Nov 24, 2026
@13hourstilliland
13hourstilliland deleted the memory-low-va branch November 24, 2026 16:08
wondercrash added a commit to wondercrash/xcl that referenced this pull request Nov 24, 2026
…mory

gpu_va takes an address a title binds as a vertex or index buffer for the title's own
memory when it is outside the unified-memory windows and readable, and copies or
mirrors those bytes. Since xcl-dev#631 host memory lies in the number range of the driver's
GPU addresses (window buffer at 0x3e0000000, title heaps at 0x10f370000), so a PC
buffer bound by the address res_gpu_va_x handed out could be replaced by whatever
unrelated memory sits at that number. res_gpu_va_x now notes each PC buffer's
[address, address + width), the last release forgets it, and a newer buffer over an old
range drops that one; gpu_va passes addresses in these ranges on as they are before
the readable test.

Found in review (integ-review.md A1); not seen in a log so far. Not run.

Assisted-by: omp (Claude Opus 5.5)
wondercrash added a commit to wondercrash/xcl that referenced this pull request Nov 24, 2026
Conflicts:
- build.rs: upstream's per-lane source hash kept; integ's second copy of the
  /HIGHENTROPYVA:NO link argument dropped (upstream's xcl-dev#631 copy at the top of
  main() stays).
- gpu/recomp/mod.rs: integ's loop budget kept next to upstream's xcl-dev#1321
  fallback, then xcl-dev#1321 left out: integ's one skip variable (c70c9f0)
  removes the quadratic guards it bounds. With it, no retail program comes
  near 128 B per byte (95cc13288a27a96e: 18.9 MB structured), and the bound
  would only move memory-dense programs (S_BUFFER_LOAD / BUFFER_LOAD runs at
  4 windows: 250-300 B per byte, structured no larger than the pc form) to
  the pc form. Its test is left out with it; c70c9f0's
  crossing_forward_jumps_keep_the_guards_short covers that layout.
- hle/d3d12x/bind.rs: xcl-dev#1791 is upstream's copy of d2d8c93 / 923c3f8:
  integ's call sites (gpu_profile, breadcrumbs, XCL_SKIP_SHADERS) kept
  around upstream's identical fresh_indirect_arguments; the test that both
  sides added is kept once, at upstream's place.
- hle/d3d12x/vram.rs: xcl-dev#1747 as ported on try-1747 (11a9069): the PR's side
  of place_on_pages, with integ's pages() at its two PAGES.lock() sites so
  releases deferred while PAGES was held still run.

Assisted-by: omp (Claude Opus 5.5)
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.

9 participants