startup: allocations the title makes itself can land above 2^40; add an opt-in launcher mode that keeps them low (#1758) #2850

Closed
opened 2026-11-26 14:38:48 +00:00 by tedin7 · 1 comment
tedin7 commented 2026-11-26 14:38:48 +00:00 (Migrated from github.com)
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T14:38:48Z.


Part of #1758 (under #874)

Problem

The package acceleration-structure builder refuses a destination address that has bits set above bit 39 (documented in docs/experiments.md, "Startup blocks below 2^40"). It receives the title's CPU address of the block, not a desktop GPU virtual address, so the shim cannot move it.

X2W_XMEM_STARTUP_BELOW_40=1 already places the large-page startup blocks (XMemVirtualAlloc, attribute 0x283) below 2^40. That covers only blocks the shim allocates. The title also allocates memory itself with VirtualAlloc. By default a 64-bit Windows process gets bottom-up allocations from a random start (bottom-up ASLR), which is often far above 2^40, so a placed buffer inside such a block hands the builder an address with high bits set. The shim never sees that allocation, so it cannot place it.

What would fix it

tools/startup/launch.py and tools/startup/debug_launch.py start the title with PROC_THREAD_ATTRIBUTE_MITIGATION_POLICY set to PROCESS_CREATION_MITIGATION_POLICY_BOTTOM_UP_ASLR_ALWAYS_OFF, so the title's own VirtualAlloc blocks come from the low end of the address space. Opt in with X2W_LOW_ADDRESSES=1 (run.ps1 -LowAddresses). If the attribute list cannot be built the launcher says so and starts the title as before.

Acceptance

  • startup_launch runs a source-built probe that reserves blocks of several sizes. With X2W_LOW_ADDRESSES=1 every block ends below 2^40. Without it, at least one of eight runs gets a block above 2^40 (the control).
  • With the policy value changed to 0 the check fails (mutant).
  • Documented in docs/startup-runtime.md next to X2W_XMEM_STARTUP_BELOW_40.

Source: Microsoft documentation of UpdateProcThreadAttribute, PROC_THREAD_ATTRIBUTE_MITIGATION_POLICY and PROCESS_CREATION_MITIGATION_POLICY_BOTTOM_UP_ASLR_ALWAYS_OFF; docs/experiments.md "Startup blocks below 2^40".

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6628980105 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/2858). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T14:38:48Z. --- Part of #1758 (under #874) Problem The package acceleration-structure builder refuses a destination address that has bits set above bit 39 (documented in docs/experiments.md, "Startup blocks below 2^40"). It receives the title's CPU address of the block, not a desktop GPU virtual address, so the shim cannot move it. `X2W_XMEM_STARTUP_BELOW_40=1` already places the large-page startup blocks (`XMemVirtualAlloc`, attribute `0x283`) below 2^40. That covers only blocks the shim allocates. The title also allocates memory itself with `VirtualAlloc`. By default a 64-bit Windows process gets bottom-up allocations from a random start (bottom-up ASLR), which is often far above 2^40, so a placed buffer inside such a block hands the builder an address with high bits set. The shim never sees that allocation, so it cannot place it. What would fix it `tools/startup/launch.py` and `tools/startup/debug_launch.py` start the title with `PROC_THREAD_ATTRIBUTE_MITIGATION_POLICY` set to `PROCESS_CREATION_MITIGATION_POLICY_BOTTOM_UP_ASLR_ALWAYS_OFF`, so the title's own `VirtualAlloc` blocks come from the low end of the address space. Opt in with `X2W_LOW_ADDRESSES=1` (`run.ps1 -LowAddresses`). If the attribute list cannot be built the launcher says so and starts the title as before. Acceptance - `startup_launch` runs a source-built probe that reserves blocks of several sizes. With `X2W_LOW_ADDRESSES=1` every block ends below 2^40. Without it, at least one of eight runs gets a block above 2^40 (the control). - With the policy value changed to 0 the check fails (mutant). - Documented in docs/startup-runtime.md next to `X2W_XMEM_STARTUP_BELOW_40`. Source: Microsoft documentation of `UpdateProcThreadAttribute`, `PROC_THREAD_ATTRIBUTE_MITIGATION_POLICY` and `PROCESS_CREATION_MITIGATION_POLICY_BOTTOM_UP_ASLR_ALWAYS_OFF`; docs/experiments.md "Startup blocks below 2^40".
tedin7 commented 2026-11-26 15:00:59 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T14:38:49Z.


Claiming this; a Draft PR follows shortly.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7195119037 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/2858#issuecomment-7195119037). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T14:38:49Z. --- Claiming this; a Draft PR follows shortly.
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows#2850
No description provided.