Repository navigation
KernelX: reject cross-allocation boundary overruns in map_pages (#1488) - #1635
slopgobblercobbler wants to merge 1 commit into
Conversation
gut0to
left a comment
There was a problem hiding this comment.
AI-assisted review; I checked the unavailable-UMA path against the GPU test guidance.
| #[test] | ||
| fn map_pages_rejects_cross_allocation_overrun() { | ||
| unsafe { | ||
| let Some(_u) = crate::gpu::uma::get() else { return }; |
There was a problem hiding this comment.
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.
|
Regression run for this PR: head main 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. |
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Thanks! |
xcl-dev#1635; xcl-dev#1705/xcl-dev#1610 verify-landed) Port the remainder of upstream xcl-dev#1143 (live pr1143head=076d027b, still OPEN; cae046e already landed contiguous_home + NULL-VA fast path) and the xcl-dev#1635 companion (live pr1635head=52d87def, still OPEN) as Linux-adapted pin tests; xcl-dev#1705 (pr1705head=cf0cde26) and xcl-dev#1610 (pr1610head=d3e20531) verified already landed (f0f9ea3, 27d80db), no code. - xcl-dev#1635 gap half (matches upstream): map_pages_gap_overrun_is_refused — a range holding a never-allocated page number refuses with ERROR_INVALID_PARAMETER on both the NULL-address and the explicit-VA path. - xcl-dev#1635 live-span half (DELIBERATE divergence): upstream refuses any consecutive span crossing a block end, but the Linux fast path requires contiguous_home and the rest is per-page, so no cross-block home is ever returned over unrelated memory — cross_allocation_live_span_splits_... pins the split (NULL + explicit VA) with per-page contents. No page_block refactor: the split is the fix. - xcl-dev#1143 home == at arm: N/A on Linux (homes are private malloc, targets are always gfx-pool, gfx_contains gate) — remap_at_current_mapping_... (twin of upstream mapping_page_at_its_own_home...) pins contents preserved with the mapping AWAY-recorded by design. - Failing-first via graft worktree: verbatim upstream xcl-dev#1635 test FAILED (split returns non-null where refusal expected) and verbatim xcl-dev#1143 own-home test FAILED (on the !physical_page_at bookkeeping assert; contents/commit asserts passed) — proving split-wins and home==at N/A. Graft removed afterwards. - Test-only diff (+140/-0): no product change; title/retail behavior identical by construction. Gates: cargo check -p xcl --tests + cargo check --workspace 0 errors; cargo test -p xcl --lib 640/0/1 (637 + 3); e2e harness 11 D3D12.X GPU-only fails, 0 non-GPU (by-design M2 baseline); retail SIGSEGV +0x2237320 exit 139, stubs 20, xgr XAsync/XNetworking/XUser — HOLDS, M1-RE TERMINAL.
luckyteagirl
left a comment
There was a problem hiding this comment.
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 for commit_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_home helper 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.
Summary
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