runtime: decode the 261000 xmem attribute layout #3275

Manually merged
github merged 4 commits from github-bot/gh-3273 into gh-pr/3273/base 2026-11-28 05:27:52 +00:00 AGit
Owner

@⁠lambirou on GitHub · 2026-11-28 04:35 UTC · original
lambirou:gdk/xmem-attributes-261000 → main · +54 −39 · 5 files · 4 commits · merged 2026-11-28 05:22 UTC

Problem

The desktop xmem allocator decoded the attribute word as if it ended with 31 reserved bits. The GDK 261000 XALLOC_ATTRIBUTES layout has an address-below-4-GiB bit at bit 33 followed by 30 reserved bits (34-63), and page size 2 means 2 MiB, not 4 MiB.

Folding the address bit into the reserved field meant a valid request was rejected as an undefined attribute word. The page-size table also used the wrong size for value 2.

Change

  • Decode bit 33 as address_below_4gib and bits 34-63 as the 30-bit reserved field.
  • Refuse a below-4-GiB request explicitly until the allocator can provide such an address.
  • Change the page-size table entry for value 2 to 2 MiB.
  • Extend tests/era_heap_check.cpp with the address bit, the 30 reserved bits, the 2 MiB page and the observed words.
  • Update the layout comment in src/era_heap.h.
  • Move the 2 MiB page-size note in src/startup_stubs/d3d12_xs_device.cpp from #3274 to this XMem change.

Behavior for the observed Bink and AMD words is unchanged; the address-below-4-GiB request still returns null, but for a stated reason instead of being mistaken for reserved bits.

Evidence

The field order comes from the GDK 261000 xmem.h. A local compile-time probe using MAKE_XALLOC_ATTRIBUTES(0xAB, 0x1234, 5, 2, 0x11, 1) produced 0x00000002B1AB9234, which confirms the address bit at 33 and the 30 reserved bits above it. The SDK header is not copied into the repository.

Validation

.\tools\dev.ps1
cmake --preset dev
cmake --build --preset dev --target era_heap_check xmem_shim
ctest --preset dev --no-tests=error -R '^era_heap_'

Result: 10/10 era_heap tests passed; xmem.dll built successfully. The decode_fields_control test is the negative control (WILL_FAIL) and passes as expected.

  • era_heap_allocation: pass
  • era_heap_failure: pass
  • era_heap_concurrency: pass
  • era_heap_caller_layout: pass
  • era_heap_reuse: pass
  • era_heap_observed_words: pass
  • era_heap_large_alignment: pass
  • era_heap_graphics_types: pass
  • era_heap_decode_fields: pass
  • era_heap_decode_fields_control: pass (expected failure)

Notes

A real below-4-GiB allocator is a separate change. This PR only makes the decoding correct and the refusal explicit; it does not claim that such an address is currently served.

**@⁠lambirou** on GitHub · 2026-11-28 04:35 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3273) `lambirou:gdk/xmem-attributes-261000` → `main` · +54 −39 · 5 files · 4 commits · merged 2026-11-28 05:22 UTC ## Problem The desktop xmem allocator decoded the attribute word as if it ended with 31 reserved bits. The GDK 261000 XALLOC_ATTRIBUTES layout has an address-below-4-GiB bit at bit 33 followed by 30 reserved bits (34-63), and page size 2 means 2 MiB, not 4 MiB. Folding the address bit into the reserved field meant a valid request was rejected as an undefined attribute word. The page-size table also used the wrong size for value 2. ## Change - Decode bit 33 as address_below_4gib and bits 34-63 as the 30-bit reserved field. - Refuse a below-4-GiB request explicitly until the allocator can provide such an address. - Change the page-size table entry for value 2 to 2 MiB. - Extend tests/era_heap_check.cpp with the address bit, the 30 reserved bits, the 2 MiB page and the observed words. - Update the layout comment in src/era_heap.h. - Move the 2 MiB page-size note in src/startup_stubs/d3d12_xs_device.cpp from #3274 to this XMem change. Behavior for the observed Bink and AMD words is unchanged; the address-below-4-GiB request still returns null, but for a stated reason instead of being mistaken for reserved bits. ## Evidence The field order comes from the GDK 261000 xmem.h. A local compile-time probe using MAKE_XALLOC_ATTRIBUTES(0xAB, 0x1234, 5, 2, 0x11, 1) produced 0x00000002B1AB9234, which confirms the address bit at 33 and the 30 reserved bits above it. The SDK header is not copied into the repository. ## Validation ~~~powershell .\tools\dev.ps1 cmake --preset dev cmake --build --preset dev --target era_heap_check xmem_shim ctest --preset dev --no-tests=error -R '^era_heap_' ~~~ Result: 10/10 era_heap tests passed; xmem.dll built successfully. The decode_fields_control test is the negative control (WILL_FAIL) and passes as expected. - era_heap_allocation: pass - era_heap_failure: pass - era_heap_concurrency: pass - era_heap_caller_layout: pass - era_heap_reuse: pass - era_heap_observed_words: pass - era_heap_large_alignment: pass - era_heap_graphics_types: pass - era_heap_decode_fields: pass - era_heap_decode_fields_control: pass (expected failure) ## Notes A real below-4-GiB allocator is a separate change. This PR only makes the decoding correct and the refusal explicit; it does not claim that such an address is currently served.
The GDK 261000 XALLOC_ATTRIBUTES layout has objectType:14, pageSize:2, allocatorId:8, alignment:5, memoryType:4, an address-below-4-GiB bit at 33 and 30 reserved bits above it. Page size 2 is 2 MiB, not 4 MiB.

Separate the address bit from the reserved field and refuse a below-4-GiB request explicitly until the allocator can honor it. Tests: era_heap_decode_fields, era_heap_failure and the other era_heap scenarios (10/10).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-28 04:35:50 +00:00
Author
Owner

@⁠R0Y00 on GitHub · 2026-11-28 04:42 UTC · original · requested changes

Independent check of a2698792: built era_heap_check and xmem_shim in Debug and Release, then ran ctest --preset <preset> --no-tests=error --output-on-failure -R '^era_heap_'. Both configurations passed all 10 checks, including the expected-failure control. Windows 11 build 26200, MSVC 19.51.

Please update the Era heap section of docs/experiments.md before merge. The era_heap_graphics_types row still describes the rejected page size as 4 MB, and era_heap_decode_fields still describes 31 reserved bits. Those rows should reflect the two-MiB page, bit 33 and bits 34–63, and say that a below-4-GiB request still returns null. Keep the older desktop test observations scoped to the layout they measured.

**@⁠R0Y00** on GitHub · 2026-11-28 04:42 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3273#pullrequestreview-6095854644) · **requested changes** Independent check of `a2698792`: built `era_heap_check` and `xmem_shim` in Debug and Release, then ran `ctest --preset <preset> --no-tests=error --output-on-failure -R '^era_heap_'`. Both configurations passed all 10 checks, including the expected-failure control. Windows 11 build 26200, MSVC 19.51. Please update the Era heap section of `docs/experiments.md` before merge. The `era_heap_graphics_types` row still describes the rejected page size as 4 MB, and `era_heap_decode_fields` still describes 31 reserved bits. Those rows should reflect the two-MiB page, bit 33 and bits 34–63, and say that a below-4-GiB request still returns null. Keep the older desktop test observations scoped to the layout they measured.
Record the 2 MiB page-size value, the address-below-4-GiB bit at 33 and the 30 reserved bits at 34-63. Scope the older observed words to the zeros they measured and note that a below-4-GiB request still returns null.
Page size 2 is 2 MiB. This comment belongs with the XALLOC_ATTRIBUTES change rather than the command-list slot names.
Author
Owner

@⁠R0Y00 on GitHub · 2026-11-28 05:02 UTC · original · requested changes

Rechecked c8716216; Release again passed 10/10, and the docs-link check passed. The new test rows describe the corrected constants. One contradiction remains in the same section: the overview still presents the old ERA layout as the desktop implementation and omits the below-4-GiB refusal, while era_heap_decode_fields describes a reserved field starting at bit 34 as a mutation, even though 34 is the correct start. Please distinguish the historical SlimEra comparison from the current 261000 decoder, update the rejection summary, and remove or correct the mutation sentence.

**@⁠R0Y00** on GitHub · 2026-11-28 05:02 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3273#pullrequestreview-6095925657) · **requested changes** Rechecked `c8716216`; Release again passed 10/10, and the docs-link check passed. The new test rows describe the corrected constants. One contradiction remains in the same section: the overview still presents the old ERA layout as the desktop implementation and omits the below-4-GiB refusal, while `era_heap_decode_fields` describes a reserved field starting at bit 34 as a mutation, even though 34 is the correct start. Please distinguish the historical SlimEra comparison from the current 261000 decoder, update the rejection summary, and remove or correct the mutation sentence.
Author
Owner

@⁠lambirou on GitHub · 2026-11-28 05:02 UTC · original

Merci pour la vérification. Le tableau Era heap est corrigé sur la branche (commit c8716216) :\n\n- ra_heap_graphics_types décrit la page de 2 MiB refusée, plus la valeur de page 3 et l'exposant 17 ;\n- ra_heap_decode_fields décrit le bit 33 « adresse sous 4 GiB » et les 30 bits réservés 34–63 ;\n- la ligne précise qu'une requête sous 4 GiB reste refusée par l'allocateur, et les anciennes observations desktop restent rattachées au layout qu'elles ont mesuré.\n\nHead : c8716216.

**@⁠lambirou** on GitHub · 2026-11-28 05:02 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3273#issuecomment-7234419319) Merci pour la vérification. Le tableau Era heap est corrigé sur la branche (commit c8716216) :\n\n- ra_heap_graphics_types décrit la page de 2 MiB refusée, plus la valeur de page 3 et l'exposant 17 ;\n- ra_heap_decode_fields décrit le bit 33 « adresse sous 4 GiB » et les 30 bits réservés 34–63 ;\n- la ligne précise qu'une requête sous 4 GiB reste refusée par l'allocateur, et les anciennes observations desktop restent rattachées au layout qu'elles ont mesuré.\n\nHead : c8716216.
Describe the current 261000 decoder, keep the older SlimEra observations scoped to their historical layout, include the below-4-GiB refusal, and replace the incorrect bit-34 mutation sentence.
github-bot changed target branch from main to gh-pr/3273/base 2026-11-28 05:27:50 +00:00
github manually merged commit d77efc7d0b into gh-pr/3273/base 2026-11-28 05:27:52 +00:00
Author
Owner

@⁠R0Y00 on GitHub · 2026-11-28 05:22 UTC · original · approved these changes

Rechecked d77efc7d. The overview now distinguishes the 261000 decoder and the historical SlimEra observations, documents the below-4-GiB refusal, and identifies bit 34 as the correct start of the reserved field. The docs-link check passed and all 10 Release era_heap_* checks passed again. One nonblocking wording correction for the experiment note: the 12-bit mask would leave the two recorded zero-valued object types unchanged, while it would truncate the widest value 0x3fff.

**@⁠R0Y00** on GitHub · 2026-11-28 05:22 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3273#pullrequestreview-6095990446) · **approved these changes** Rechecked `d77efc7d`. The overview now distinguishes the 261000 decoder and the historical SlimEra observations, documents the below-4-GiB refusal, and identifies bit 34 as the correct start of the reserved field. The docs-link check passed and all 10 Release `era_heap_*` checks passed again. One nonblocking wording correction for the experiment note: the 12-bit mask would leave the two recorded zero-valued object types unchanged, while it would truncate the widest value `0x3fff`.
This discussion has been locked. Commenting is limited to contributors.
No description provided.