kernelx: use checked size rounding in VirtualAlloc and Uma::sparse_reserve #1185
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!1185
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1185"
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?
@b3IKK on GitHub · 2026-11-24 12:57 UTC · original
b3IKK:kernelx/virtualalloc-size-overflow→main· +28 −13 · 2 files · 1 commits · openVirtualAllocroundedMEM_GRAPHICSsizes withdiv_ceil(align) * align, andUma::sparse_reserve/Uma::sparse_alloc_inrounded with(size.max(1) + GRAIN - 1) & !(GRAIN - 1). For sizes nearusize::MAX, these overflowed—aborting the process on panic insideextern "system" fnin debug builds and wrapping to0(returning a non-null allocation) in release builds.This switches them to
checked_next_multiple_of(matchingXMemAllocDefaultandUma::sparse_alloc) andchecked_next_power_of_twoinsparse_alloc_in.What is in it
crates/xcl/src/hle/kernelx.rs: usechecked_next_multiple_ofinVirtualAlloc'sMEM_GRAPHICScommit and 4 MiB reserve paths; addvirtual_alloc_and_sparse_reserve_overflows_fail_cleanly(aborted with0xc0000409before the fix).crates/xcl/src/gpu/uma.rs: usechecked_next_multiple_ofinsparse_reserveandsparse_alloc_in, andchecked_next_power_of_twofor alignment insparse_alloc_in.Tested
stable-x86_64-pc-windows-msvc), DXC 1.9.2609.5, debug (scripts/test.ps1) and release (scripts/smoke.ps1).\scripts\test.ps1(cargo build --workspace+cargo test --workspace -- --test-threads=4): 742 passed, 0 failed, 41 ignored (SKIPPED GPU tests: 2no wave64—gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask,gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware)cargo test -p xcl --lib virtual_alloc_and_sparse_reserve_overflows_fail_cleanly: 1 passed, 0 failed (panicked/aborted with0xc0000409before the fix)Regression run
main:
PR:
Not tested
AI use
kernelx.rsanduma.rs, wrote the fix and regression test, ran the test suite andscripts/smoke.ps1regression runs, and drafted this PR description.@DavidM1911 on GitHub · 2026-11-24 13:08 UTC · original
Independent verification on current
main384f7f7(branch already contains it — clean).Machine: Windows 11, Ryzen 9 7900X + RTX 3060 Ti; Rust stable MSVC, debug.
cargo test -p xcl --lib kernelx: 33 passed, 0 failed, 1 ignored.cargo test -p xcl --lib uma: 10 passed, 0 failed — the checked size rounding inVirtualAlloc/Uma::sparse_reservekeeps both suites green.AI use: test runs by Devin (Cognition, SWE-2); no code changes.
@JoaoPauluu on GitHub · 2026-11-24 14:34 UTC · original
A run on Linux under Wine.
Tested
x86_64-pc-windows-gnu.1ba5518as it is (based on47efa2e), no uncommitted changes. The lib test binary runs under Wine, one test per process (--exact).VirtualAllocis Wine's here.hle::kernelx::tests::virtual_alloc_and_sparse_reserve_overflows_fail_cleanly: ok, no SKIPPED.Not tested
AI use
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.