GPU/BVH: truncated preparation keys alias distinct guest addresses every 8 GiB #202
Labels
No labels
accessibility
already-solved
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
merged
needs-decision
needs-game-run
needs-rebase
not-merged
nvidia
obsolete
question
security
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/avatarmanz--VIctory-7900XTX#202
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
@FunWithFlagsDev on GitHub · 2026-11-26 11:26 UTC · original
<html>Summary
While reviewing the memory preparation path in the AvatarManz fork, I identified two per-recording deduplication keys that discard significant bits of guest addresses.
Distinct guest addresses separated by multiples of 8 GiB produce identical keys. Consequently, preparing one address may suppress necessary preparation or copy-back registration for another address within the same command list.
The arithmetic collision is reproducible without title files, GPU execution or proprietary data.
A narrowly scoped candidate correction and regression tests are included in the attached archive.
1. Affected revision
Repository:
avatarmanz/VIctory-7900XTXCommit:
0dec5dcc228b6e0b7540d170c2dcd7d52e6d0b99Affected files:
crates/victory-gpu/src/memory.rscrates/victory-gpu/src/host.rs2. Source-level evidence
In
memory.rs:989–1006, the builder's write preparation is deduplicated using:The corresponding small-buffer copy-back registration uses:
Both expressions retain only 31 bits of the shifted address.
The resulting collision period in byte addresses is:
This is not a hash collision resolved by the collection's equality check. The original addresses are converted into identical integer keys before insertion.
HostList::first_useinserts these keys into the same per-recording set:The second insertion returns false even when the original guest addresses are distinct.
3. Minimal arithmetic counterexample
Consider four synthetic guest addresses:
Guest address | Location | Masked address -- | -- | -- 0x1_0001_0000 | 4 GiB + 64 KiB | 0x40004000 0x3_0001_0000 | 12 GiB + 64 KiB | 0x40004000 0x5_0001_0000 | 20 GiB + 64 KiB | 0x40004000 0x7_0001_0000 | 28 GiB + 64 KiB | 0x40004000All 13 Python unit tests passed.
The tests cover:
The 8 GiB collision period.
Distinct high address bits.
Repeated-address deduplication.
Separation of operation kinds.
Recording reset.
Reversed insertion order.
Address identity across the representable 40-bit domain.
Conditional page-coverage arithmetic.
Source transformation and patch-staging safeguards.
The test inputs were deliberately constructed to exercise collisions. These results do not estimate their frequency in the title.
7. Proposed Rust regression
The archive includes a candidate test-only addition alongside the
Deferredimplementation inhost.rs.Test name:
builder_memory_keys_keep_full_addresses_and_operation_kindThe test checks the original arithmetic collision as a negative control, then verifies that the proposed per-recording set:
Admits distinct addresses separated by 8 GiB.
Deduplicates exact repetitions.
Distinguishes
WritefromBack.Keeps independent recordings separate.
Admits the same addresses again after reset.
The proposed test does not require a GPU adapter or title assets.
The Rust implementation and regression have not yet been compiled or executed.
8. Reproduction and candidate integration
Python validation:
The included
prepare_patch.pyscript checks the exact upstream revision and normalized Git blob hashes before staging modifications to both affected source files.On a dedicated checkout of the pinned revision:
The script generates:
Review the generated changes before applying them.
Suggested native validation:
The staging helper was tested on synthetic source-anchor fixtures. Full-checkout staging and native compilation remain pending.
9. Suggested end-to-end validation
An independent native test could allocate or register two eligible synthetic memory regions separated by 8 GiB.
Using the production
memory::readypath within one recording:
</html>## SummaryRequest builder write preparation for both addresses.
Inspect directory entries, prepared page
While reviewing the memory preparation path in the AvatarManz fork, I identified two per-recording deduplication keys that discard significant bits of guest addresses.
Distinct guest addresses separated by multiples of 8 GiB produce identical keys. Consequently, preparing one address may suppress necessary preparation or copy-back registration for another address within the same command list.
The arithmetic collision is reproducible without title files, GPU execution or proprietary data.
A narrowly scoped candidate correction and regression tests are included in the attached archive.
1. Affected revision
Repository:
avatarmanz/VIctory-7900XTXCommit:
0dec5dcc228b6e0b7540d170c2dcd7d52e6d0b99Affected files:
crates/victory-gpu/src/memory.rscrates/victory-gpu/src/host.rs2. Source-level evidence
In
[memory.rs:989–1006](https://github.com/avatarmanz/VIctory-7900XTX/blob/0dec5dcc/crates/victory-gpu/src/memory.rs#L989-L1006), the builder's write preparation is deduplicated using:The corresponding small-buffer copy-back registration uses:
Both expressions retain only 31 bits of the shifted address.
The resulting collision period in byte addresses is:
This is not a hash collision resolved by the collection's equality check. The original addresses are converted into identical integer keys before insertion.
[HostList::first_use](https://github.com/avatarmanz/VIctory-7900XTX/blob/0dec5dcc/crates/victory-gpu/src/host.rs#L7448-L7450)inserts these keys into the same per-recording set:The second insertion returns false even when the original guest addresses are distinct.
3. Minimal arithmetic counterexample
Consider four synthetic guest addresses:
0x1_0001_00000x400040000x3_0001_00000x400040000x5_0001_00000x400040000x7_0001_00000x40004000For each operation kind, all four addresses produce the same deduplication key.
Expected admission:
Current key-based admission:
The same collision can occur in reverse recording order. Whichever address is prepared first suppresses the subsequent colliding addresses.
These are invented addresses demonstrating the arithmetic defect, not addresses captured from the title.
4. Potential consequences
The affected write-preparation branch controls several operations:
m.opens(at)m.small(list, start, len)m.ready(at, BUILT)Their suppression may affect:
A. Write permissions
A distinct registered buffer may not receive its own
opensoperation.Its pages could therefore remain read-only through the by-address memory path when the builder attempts to store into them.
B. Small-buffer copy-back
The second truncated key independently deduplicates the registration of small buffers whose builder-generated results must return to title memory.
Two distinct buffer starts separated by 8 GiB may suppress one another's copy-back registration.
C. Incomplete preparation of loose memory
The normal builder preparation requests
BUILT, which is 4 MiB.If the write-preparation branch is incorrectly skipped, the subsequent ordinary address preparation may request only
VIEW, which is 256 KiB.For two aligned, independent, nonpacked and previously unmapped loose-memory destinations, assuming successful mapping and no other preparation:
This 60-page difference is a conditional source-level consequence, not an observed GPU fault.
Existing mappings, packed structures or other preparation requests may prevent the coverage gap in a particular recording.
5. Proposed correction
Instead of encoding the operation kind and a truncated address into a shared integer key, use a dedicated typed key containing the complete guest byte address.
Maintain a separate per-recording set:
Replace the affected calls with:
and:
This preserves:
The set is cleared by the existing reset mechanism:
See
[host.rs:6527–6535](https://github.com/avatarmanz/VIctory-7900XTX/blob/0dec5dcc/crates/victory-gpu/src/host.rs#L6527-L6535).A separate typed set also avoids accidental overlap with unrelated texture and sentinel keys.
The candidate deliberately uses exact byte addresses rather than retaining the previous dword rounding. This could admit additional preparations for addresses within the same dword and should be considered during review.
6. Asset-free validation
The attached Python model covers 256 distinct synthetic addresses arranged into 16 independent deliberately colliding sequences.
All 13 Python unit tests passed.
The tests cover:
The test inputs were deliberately constructed to exercise collisions. These results do not estimate their frequency in the title.
7. Proposed Rust regression
The archive includes a candidate test-only addition alongside the
Deferredimplementation inhost.rs.Test name:
builder_memory_keys_keep_full_addresses_and_operation_kindThe test checks the original arithmetic collision as a negative control, then verifies that the proposed per-recording set:
WritefromBack.The proposed test does not require a GPU adapter or title assets.
The Rust implementation and regression have not yet been compiled or executed.
8. Reproduction and candidate integration
Python validation:
The included
prepare_patch.pyscript checks the exact upstream revision and normalized Git blob hashes before staging modifications to both affected source files.On a dedicated checkout of the pinned revision:
The script generates:
Review the generated changes before applying them.
Suggested native validation:
The staging helper was tested on synthetic source-anchor fixtures. Full-checkout staging and native compilation remain pending.
9. Suggested end-to-end validation
An independent native test could allocate or register two eligible synthetic memory regions separated by 8 GiB.
Using the production
memory::readypath within one recording:avatar_bvh_keys_audit.zip
github-bot referenced this issue2026-11-26 12:16:01 +00:00