startup: X2W_LOW_ADDRESSES keeps the title's own memory below 2^40 #2851
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/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?
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T14:39:42Z.
Part 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.
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-26T14:48:13Z.
Review: COMMENTED
💡 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".
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T14:49:26Z.
Review: COMMENTED
No description provided.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T14:42:55Z.
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.
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-26T14:42:58Z.
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.
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-26T14:48:13Z.
Code review location:
tests/startup_launch_check.py; line 242When 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 👍 / 👎.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T14:49:26Z.
Code review location:
tests/startup_launch_check.py; line 242Fixed 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.
Imported from R0Y00/Xbox2Windows. Originally posted by KelboLive on 2026-11-26T15:53:31Z.
Review: APPROVED
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.
Imported from R0Y00/Xbox2Windows. Originally posted by pigalot on 2026-11-27T19:52:17Z.
Review: APPROVED
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.