Repository navigation
Memory: link xcl.exe without high-entropy ASLR so title memory stays under 2^40 - #631
13hourstilliland wants to merge 1 commit into
Conversation
…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)
|
Tested the MSVC build ( Tested
Regression run ( main ( PR #631 ( (Note on the lower frame count: Not tested: World streaming / live AI use: Antigravity ( |
|
Test report for 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 The link flag (MSVC):
Where the title's memory lands (from
Long runs (240 s,
Regression run:
All runs reached the intro video; no crash or device removal.
PR merged onto PR head: Not tested: the BVH builder's check passing (the watchdog stops both runs first); 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. |
|
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). 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. |
|
Verified Tested
Not tested AI use |
…hardened 40-bit fallback
|
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 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
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), AI use: Claude Code (Claude Opus 5.5) ran the builds, tests and retail runs on the hardware above and wrote this report. |
MSVC test on RTX 4070RTX 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.
Smoke blocks below have the title field redacted. 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. |
|
Tested on RTX 2080 Ti (Turing, driver 621.24) + Intel i9-9900K, Windows 11, 32 GB, retail 1.0.2.1, merged onto #891 (
Merge note: AI-assisted (Claude Code, Claude Opus 5.5). |
…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.
|
Merged as a port onto main's |
…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)
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)
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.exeis 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. Linkingxcl.exewithout it brings those allocations back near 2 GiB. That should also cover the fallbacks @sub-north found theVirtualAlloc2ceiling could not catch, with no change incrates/xcl/src.What is in it
crates/xcl/build.rs(new):/HIGHENTROPYVA:NO(MSVC) or-Wl,--disable-high-entropy-va(GNU) for thexclbinary only.crates/xcl/tests/low_va.rs(new): readsxcl.exe's PE header and fails if the high-entropy VA flag is set.Tested
x86_64-pc-windows-gnu(not MSVC), debug.VirtualAlloc(NULL, 24 GiB, MEM_RESERVE)×20, three runs each):0x1e1cb8a0000,0x1eda2c40000and0x23344380000; 20/20 above 2^40 in every run--disable-high-entropy-va: from0x7fff0000up; 0/20 above 2^40cargo test -p xcl --test low_va: fails onmainwithDllCharacteristics 0x160: high-entropy VA is on; passes with this change (0x140).cargo test --workspace --no-fail-fast -- --test-threads=4in an interactive session: 686 passed, 0 failed, 41 ignored, the e2e title test included. The same tree onmaincb868b2plus these two files.gpu_geometry_wave32_prefix_count_over_a_mask(no wave64). A Session 0 run of the same tree also printedgpu_wave32_program_in_wave64_hardware(no wave64).Regression run
None. I do not have a retail title.
scripts/pr_check.pydoes not ask for one here because nothing undercrates/xcl/srcchanges, 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 runsmoke.ps1onmainand on this head?Not tested
/HIGHENTROPYVA:NOis a standard link.exe switch, but I built with GNU only).MEM_TOP_DOWNstill go to the top of the address space. This change does not cover them.xcl.exe, one of my workspace runs kept a stale binary with the flag still set.cargo clean -p xclfixed 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.