KernelX: reject cross-allocation boundary overruns in map_pages (#1488) #1635
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!1635
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1635"
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?
@slopgobblercobbler on GitHub · 2026-11-24 18:27 UTC · original
slopgobblercobbler:fix/phys-pages-boundary→main· +88 −4 · 1 files · 1 commits · openSummary
Rejects cross-allocation boundary overruns in
kernelx::map_pagesincrates/xcl/src/hle/kernelx.rs(Issue #1488, findingXCL-BT-007):page_block(page: usize) -> Option<(usize, usize, usize, usize)>helper to safely retrieve(first_index, count, live, home)fromPHYS_BLOCKS.map_pages: for consecutive page requests (consecutive == true), validates that the requested range[first_idx..first_idx + n]does not cross or overrun the enclosingPHYS_BLOCKSallocation boundary (end_index <= block_end).ERROR_INVALID_PARAMETER(87) and returnsnull_mut(), preventingcommit_homesfrom committing unallocated memory past allocation bounds.map_pages_rejects_cross_allocation_overrun: verifies valid sub-allocations within boundaries succeed; verifies consecutive ranges extending past block boundaries fail withERROR_INVALID_PARAMETER; verifies cross-boundary ranges fail; and verifies overruns with explicit virtual addresses fail.Changes
crates/xcl/src/hle/kernelx.rs:page_blockhelper for allocation bounds queries.map_pages.Tested
cargo test -p xcl -- kernelx: 34 passed, 0 failed.upstream/main, GPL-2.0-only compliant, zero retail game data or keys.Not Tested
AI Use
Co-Authored-By: Claude Code (Claude Opus 5.5) / Gemini Antigravity
@Anon64 on GitHub · 2026-11-24 19:33 UTC · original
Regression run for this PR: head
52d87de, based onmain9e3831e. RTX 3060 12 GB (581.80, wave32), Windows 11 26200, release,XCL_NETWORK=0, A pressed every 4 s from 20 s,scripts/smoke.ps1on a retail title for 60 s, in one batch with themainrun.main
9e3831e:this PR:
No device removals or crashes; 99 % of main's frames, 99 % of its peak commit.
Peak commit on this machine is mostly the pipeline preload's DXC compiles (#1035) and varies from run to run, so it says little about this PR.
Not tested: the whole suite; whether the title reaches the changed code in these 60 s.
Written with Claude Code (Claude Opus 5.5) from runs on this machine.
@DavidM1911 on GitHub · 2026-11-24 20:56 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~22 ignored.Thanks!
@ -2116,0 +2144,4 @@#[test]fn map_pages_rejects_cross_allocation_overrun() {unsafe {let Some(_u) = crate::gpu::uma::get() else { return };@gut0to on GitHub · 2026-11-24 18:31 UTC · original
When UMA is unavailable this test returns normally, so the test harness counts it as passed rather than skipped. CONTRIBUTING.md asks GPU-dependent tests to call
gpu::recomp::runner::skip_test(...)before returning when the adapter cannot run them. Could this report an appropriate skip reason here so the workspace totals distinguish skipped coverage from a pass? AI-assisted review; I verified the test path and guide.@gut0to on GitHub · 2026-11-24 18:31 UTC · original · reviewed
AI-assisted review; I checked the unavailable-UMA path against the GPU test guidance.
@luckyteagirl on GitHub · 2026-11-26 09:40 UTC · original · reviewed
On
52d87de, the new same-allocation guard runs before the mapper chooses between its contiguous-home fast path and the per-page path. If two live allocations happen to receive adjacent page IDs,[A.last, B.first]is rejected even when the caller provides a separate reserved non-home destination. That destination already follows the per-page mapping path, which resolves each page's home independently; the same two allocations with nonconsecutive IDs still reach that path. The guard is needed forcommit_homes, but this location also blocks a valid explicit mapping. The new test's explicit-address case uses an overrun/nonexistent ID, which does not cover two live adjacent blocks.Could the same-allocation check apply only when selecting the home fast path, leaving explicit non-home VA to the per-page mapper? Open PR #1143 already has a
contiguous_homehelper that scopes this check and may be useful to coordinate with. A fixture with known adjacent live IDs should map both into a separate reserved VA and verify their contents/order, while a null/home request for the same pair and a genuinely nonexistent ID still fail. This is exact-head source review; I did not run a UMA fixture.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.