xmem: 32-bit blocks keep the alignment their attributes ask for #2270
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!2270
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2270/head"
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?
@Calvix2k on GitHub · 2026-11-25 09:28 UTC · original
Calvix2k:codex/hle-xmem-32bit-align-2183→main· +37 −2 · 1 files · 1 commits · closed without mergingFixes #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.@kotekompotek on GitHub · 2026-11-25 09:44 UTC · original
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.@Calvix2k on GitHub · 2026-11-25 10:20 UTC · original
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.Pull request closed