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 |
A retail title's XboxBvhBuilder refuses an acceleration structure whose GPU address is at or above 2^40 (xcl-dev#585). xcl.exe is now linked without high-entropy ASLR so title memory stays below it (PR xcl-dev#631); this adds the always-compiled runtime guard that catches that link flag regressing in a release build. - gpu::uma::gpu_address_refusal (uma.rs) is the one boundary test: a range is inside the console's 40-bit GPU address space when addr + bytes <= 2^40. Its message names the address, the end, the limit and the source that formed it. - uma.rs: every aperture slot - the 4-window legacy layout included - now ends at or below 2^40 (slot_limit), and reserve_runtime/with_windows re-check each candidate aperture and log an error instead of reserving above the limit. - kernelx.rs: the title's fresh Windows allocations (VirtualAlloc, the graphics reserve and GPU-visible write-watched fallbacks, XMemAlloc graphics and heap, physical-page homes) are refused with a loud kernelx error when Windows places them at or above 2^40, so the failure is XCL's to report, not the title's. - d3d12x::real: a raytracing acceleration-structure SRV whose console VA is at or above 2^40 is refused with the descriptor named and an empty BVH descriptor written, instead of encoding the out-of-range base. Test: gpu::uma::tests::gpu_addresses_at_or_above_2_40_are_refused asserts 2^40 is refused (the message names 0x1000000000 and its source), 2^40-1 is accepted, a range ending at the limit fits and one crossing it does not, and every slot a 4/8/16-window layout may choose keeps its aperture below the limit. Verified under Wine: gpu::uma::tests 20/20 and hle::kernelx::tests 43 passed, 1 ignored; the parallel run of kernelx has a pre-existing flake in a_page_whose_move_fails_stays_mapped_where_it_was (passes serially). 30-minute measurement for the next session (not run here - a preparation proof owns the title prefix): build the release exe, then XCL_EXE=<target>/x86_64-pc-windows-gnu/release/xcl.exe \ XCL_DXC_DIR='Z:\opt\Games\XboxGameTest\xcl\target\x86_64-pc-windows-gnu\release' \ XCL_RUN_SECONDS=1800 /opt/Games/XboxGameTest/run-xcl.sh 2>&1 | tee logs/t061-40bit.log grep -c '40-bit GPU address limit' logs/t061-40bit.log # must print 0
`crates/xcl/build.rs` previously emitted `cargo:rustc-link-arg-bin=xcl=...` only, leaving the crate's integration test binaries linked with Windows high-entropy ASLR (where `VirtualAlloc(NULL)` lands above 2^40 instead of matching `xcl.exe`'s low-VA layout from xcl-dev#631). Also emit `cargo:rustc-link-arg-tests=/HIGHENTROPYVA:NO` (MSVC) and `cargo:rustc-link-arg-tests=-Wl,--disable-high-entropy-va` (GNU) in `crates/xcl/build.rs`, and extend `crates/xcl/tests/low_va.rs` to verify both `xcl.exe` and the integration-test executable clear `IMAGE_DLLCHARACTERISTICS_HIGH_ENTROPY_VA` and reserve `VirtualAlloc(NULL)` strictly below 2^40. Fixes xcl-dev#2263 Assisted-by: Google Antigravity (Gemini 4 Neon)
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.