xmem: 32-bit blocks keep the alignment their attributes ask for #2268
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2270"
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 Marvisak/VIctory. Originally posted by Calvix2k on 2026-11-25T09:28:51Z.
Fixes #2183.
Problem
XMemAllocDefault's 32-bit branch calledXMemVirtualAlloc, whose address requirements take an alignment only from thePAGES_2Mkind; otherwiseMEM_ADDRESS_REQUIREMENTS::Alignmentis 0, i.e. the 64 KiB allocation granularity. A 32-bit block asked for at 128 KiB, 1 MiB or 2 MiB therefore came back 64 KiB-aligned, although the module's header promises that what constrains addresses — alignment included — is honoured.Change
The body of
XMemVirtualAllocis nowvirtual_alloc(..., alignment), with the public entry passing 0 (kind-derived, as before).XMemAllocDefault's 32-bit branch passes the attributes' alignment (log2 in 5 bits at 24, at least 16) when it is at least the 64 KiB granularity — below that the address requirements cannot express it and 0 already means the granularity. The 32-bit address range (ADDRESS_32BIT, below 4 GiB) and the write-watch/commit accounting are untouched.Verification
New
aligned_32_bit_blocks_get_their_alignmenton this machine (Windows 10 19045): blocks of 4096 bytes at 128 KiB, 1 MiB and 2 MiB come back aligned to their request and below 4 GiB, then free cleanly.On unmodified
mainthe same test fails at the 1 MiB request (the returned address was 128 KiB-aligned); the 128 KiB case passed there only because the allocator happened to satisfy it. With the change all three pass.cargo test -p victory-hle: 144 lib tests pass; clippy-D warningsclean;cargo xtask policy1 file ok.Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T09:35:39Z.
Review: COMMENTED
xmem: 32-bit blocks keep the alignment their attributes ask for (alignment parameter threaded through virtual_alloc). Static review only: victory-gpu/victory-hle are Windows-only (D3D12/windows-sys); not compiled or tested on this macOS arm64 host. rustc 1.98.1.
upstream-sync referenced this pull request2026-11-25 10:07:23 +00:00
Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-25T09:44:49Z.
Triage note: this is the same fix as #2184 for #2183 — both extract a
virtual_alloctaking an explicit alignment and forward the attributes' alignment field on theALLOC_32BITpath, zeroing it at/below the 64 KiB granularity (this PR uses.max(4)+>= 64*1024, #2184 uses the raw field +> PAGE; equivalent). Only real difference: hereXMemVirtualAllocpasses0sovirtual_allocstill owns thePAGES_2M→ 2 MiB rule, while #2184 hasXMemVirtualAlloccompute that alignment itself. Same behavior either way. I verified #2184's test suite passes (11/11 xmem tests); whichever lands, the other is redundant.Imported from Marvisak/VIctory. Originally posted by Calvix2k on 2026-11-25T10:20:56Z.
Closing as the duplicate of #2184 (@BastienRodz) that @kotekompotek spotted: same
virtual_alloc(..., alignment)extraction and the same 32-bit branch passing the attribute's alignment, and #2184 has its own regression test (alloc_32bit_honours_alignments_above_64k). Mine adds nothing beyond it; one PR is better.For the record, the check that made me keep mine this long was on hardware: on this Windows 10 19045 machine the new test passes at 128 KiB, 1 MiB and 2 MiB, and on unmodified
mainit fails at the 1 MiB request (the address comes back 128 KiB-aligned). #2184's test covers the same ground.upstream-sync referenced this pull request2026-11-25 15:04:25 +00:00
upstream-sync referenced this pull request2026-11-25 16:09:30 +00:00
upstream-sync referenced this pull request2026-11-26 02:06:47 +00:00
Pull request closed