startup: X2W_LOW_ADDRESSES keeps the title's own memory below 2^40 #2859
No reviewers
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows!2859
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2859"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@tedin7 on GitHub · 2026-11-26 14:39 UTC · original
tedin7:x2w-low-addresses→main· +110 −3 · 6 files · 2 commits · merged 2026-11-27 19:52 UTCPart of #1758
Fixes #2858
What this unblocks: a run can keep the title's own allocations below 2^40, so the package acceleration-structure builder no longer sees a destination address with bits set above bit 39.
What changed
tools/startup/launch.pyandtools/startup/debug_launch.pystart the title withPROC_THREAD_ATTRIBUTE_MITIGATION_POLICYset toPROCESS_CREATION_MITIGATION_POLICY_BOTTOM_UP_ASLR_ALWAYS_OFFwhenX2W_LOW_ADDRESSES=1, so the title's ownVirtualAllocblocks come from the low end of the address space instead of a random start (often above 2^40).tools/startup/run.ps1 -LowAddressessets the variable.tests/startup_launch_probe.cppgets anaddressesmode;tests/startup_launch_check.pyruns it four times with the switch (every block must end below 2^40) and eight times without (at least one block must end above 2^40, the control).docs/startup-runtime.md: a row next toX2W_XMEM_STARTUP_BELOW_40, which covers only the blocks the shim allocates.Why it is correct: the builder receives the title's CPU address of the block (docs/experiments.md, "Startup blocks below 2^40"), which the shim cannot move; the blocks the title allocates itself follow the process's bottom-up ASLR setting, so turning that off keeps them low.
Source: Microsoft documentation of
UpdateProcThreadAttribute,PROC_THREAD_ATTRIBUTE_MITIGATION_POLICYandPROCESS_CREATION_MITIGATION_POLICY_BOTTOM_UP_ASLR_ALWAYS_OFF; docs/experiments.md, "Startup blocks below 2^40".Verification:
python3 -I tests/startup_launch_check.py --unit: passed.python3 -I tests/docs_links_check.py: 29 files, 545 links, clean.git diff --cached --check: clean.x86_64-w64-mingw32-g++ -std=c++17 -fsyntax-only tests/startup_launch_probe.cpp: ok.python3 -I tests/startup_launch_cli_check.py: 1 error on Linux (ctypes.get_last_erroris Windows-only); the same single error on a plainorigin/maincheckout, so it is not caused by this change.314b097a9:startup_launch(built fromstartup_launch_probe) passed in Debug (1/1) and Release (1/1). Four launches withX2W_LOW_ADDRESSES=1keep every block below 2^40; the control without it gets a block above 2^40 in at least one of eight launches.0x2 << 16to0): the check fails ("a block ends at 0x16dd2b3ffff, above 2^40").Real-hardware testing: @Makto94 - thanks for the help.
AI-assisted; commands listed were executed locally.
@tedin7 on GitHub · 2026-11-26 14:42 UTC · original
Gate receipt for head
314b097a9(Windows Server 2025 build 26100, MSVC 14.44, WARP).The head reached Windows as the exact PR head (fetched from
pull/2859/head, no patch).Result: dev 2/2 and release 2/2 passed (
startup_launch,startup_launch_cli_check).Mutant (patch, applied):
startup_for_createalways returns the unchanged startup info, so the mitigation attribute is never set.startup_launchfails withwith X2W_LOW_ADDRESSES=1 a block ends at 0x1a46bc4ffff, above 2^40in both dev and release.Not covered by this gate: the policy-value-0 mutant (gated separately) and any run with a real title.
AI-assisted; commands listed were executed locally.
@chatgpt-codex-connector[bot] on GitHub · 2026-11-26 14:42 UTC · original · edited 2026-11-26 14:48 UTC
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
314b097ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.
@chatgpt-codex-connector[bot] on GitHub · 2026-11-26 14:48 UTC · original · reviewed
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit:
314b097a94ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
@ -225,0 +259,4 @@assert top < limit, f"with X2W_LOW_ADDRESSES=1 a block ends at 0x{top:x}, above 2^40"assert "bottom-up ASLR off" in out, out# Control: without the switch, the same child gets blocks above 2^40 on some runs (the default ASLR picks a random start).above = [highest({}, f"default-{attempt}")[0] >= limit for attempt in range(8)]@chatgpt-codex-connector[bot] on GitHub · 2026-11-26 14:48 UTC · original
When the Windows test is started from an environment that already has
X2W_LOW_ADDRESSES=1,highest({})preserves that value throughdict(os.environ, **env_extra). All eight “default” children therefore receive the low-address mitigation too, so a correctly working implementation makesany(above)false and failsstartup_launch. Remove the variable from the control environment, or explicitly override it with"0", so the negative control actually exercises the disabled case.AGENTS.md reference: AGENTS.md:L314-L314
Useful? React with 👍 / 👎.
@ -225,0 +259,4 @@assert top < limit, f"with X2W_LOW_ADDRESSES=1 a block ends at 0x{top:x}, above 2^40"assert "bottom-up ASLR off" in out, out# Control: without the switch, the same child gets blocks above 2^40 on some runs (the default ASLR picks a random start).above = [highest({}, f"default-{attempt}")[0] >= limit for attempt in range(8)]@tedin7 on GitHub · 2026-11-26 14:49 UTC · original
Fixed in
cbffed0ab: the control children now start from an environment without X2W_LOW_ADDRESSES (new child_env helper in tests/startup_launch_check.py); only the switch-on children get it, from the test. Added a Linux unit assertion (a caller with the variable set does not leak it into the control environment); a version of the helper that keeps the variable fails it. The Windows result of the earlier head is unchanged by this test-only edit; Stage-2 can re-run startup_launch on the new head.AI-assisted; commands listed were executed locally.
@KelboLive on GitHub · 2026-11-26 15:53 UTC · original · approved these changes
Reviewed PR for X2W_LOW_ADDRESSES: keeps the title's VirtualAlloc allocations below 2^40.
Summary
This PR enables bottom-up ASLR to be always off via PROC_THREAD_ATTRIBUTE_MITIGATION_POLICY when X2W_LOW_ADDRESSES=1. The result is that the title's own memory stays below 2^40, which is needed for the acceleration-structure builder that refuses destination addresses with bits above bit 39.
Changes
tools/startup/launch.py
tools/startup/debug_launch.py
tools/startup/run.ps1
tests/startup_launch_probe.cpp
tests/startup_launch_check.py
docs/startup-runtime.md
Review Assessment
Correctness:
Safety:
Testing:
This is a clean, targeted change with thorough testing. No issues to address.
Approved for merge.
@pigalot on GitHub · 2026-11-27 19:52 UTC · original · approved these changes
Independently reviewed
cbffed0aintegrated overmain968ddcdf(treeb52a33b2, clean merge).What I traced.
PROC_THREAD_ATTRIBUTE_MITIGATION_POLICYisProcThreadAttributeValue(7, FALSE, TRUE, FALSE)=0x20007...._BOTTOM_UP_ASLR_ALWAYS_OFFis0x2 << 16, inside the0x3 << 16mask, where0x1 << 16isALWAYS_ON.startup_for_create: it copies the caller'sSTARTUPINFOW, including the std handles, into aSTARTUPINFOEXW, and setscbto the extended size. It returns the attribute buffer and the policy word, so both stay alive acrossCreateProcessW. With the switch off, or when either call fails, it falls back to the unchangedsi.debug_launch.pyuses the same helper, but no test starts the title through it with the switch on.child_envdrops an inheritedX2W_LOW_ADDRESSESfor the control children.What I ran. I built
startup_launch_probeindevandrelease, then ranctest --test-dir out/build/<preset> --no-tests=error -j 1 --output-on-failure -R '^startup_launch$'3 times per preset: 6/6 passed.
python -B tests/startup_launch_check.py --unitpasses as well.How strong the control is. On this host,
startup_launch_probe.exe addresses, started directly 40 times, ended above 2^40 in 40 of 40 runs. So the "at least one of eight default runs above 2^40" control is not marginal here.Mutant. With
ALWAYS_ON(0x1 << 16) in place ofALWAYS_OFF,startup_launchfails atwith X2W_LOW_ADDRESSES=1 a block ends at 0x259ff21ffff, above 2^40. Restored, it passes.git diff --checkis clean.Verdict: approve on
cbffed0a.Environment: Windows 11 25H2 build 26200.9974; MSVC 19.52.37029; Python 3.12.10.
CI:
Build and test on Windowspasses oncbffed0a. The one review thread is resolved.This reply was AI-assisted.