kernelx: require contiguous physical pages to share one allocation #1143
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!1143
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1143"
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:32 UTC · original
b3IKK:kernelx/contiguous-physical-page-home→main· +147 −4 · 1 files · 1 commits · openAllocateTitlePhysicalPagesassigns consecutive page numbers from a global counter (NEXT_PAGE_INDEX) even across separate allocations whose home blocks are not adjacent in virtual memory (e.g. separated by another UMA allocation or falling back to plain memory).map_pagesonly checked that page numbers were consecutive and thatpages[n - 1]had a home, soMapTitlePhysicalPages(NULL, ...)on pages spanning two separate allocations committed and returned[H1, H1 + n * PHYS_PAGE), overlapping unrelated memory next to the first block.This adds
contiguous_home_in/contiguous_hometo require that all consecutive pages belong to one livePHYS_BLOCKSentry (using checked arithmetic) before treating them as a single contiguous home block. Refusing two separate allocations even when their home addresses happen to be adjacent is intentional:commit_homes(VirtualAlloc(..., MEM_COMMIT)),lazy_home, andis_sparseassume a single backing reservation of one memory kind.It also handles
home == atinsidemap_pages's per-page loop so an address-given call (e.g.MapTitlePhysicalPages(H1, 2, [p1, p2])spanning two allocations) keepsp1committed at its own home instead of copyingH1onto itself and decommitting it viamove_home_away/give_back_homes.What is in it
crates/xcl/src/hle/kernelx.rs: addcontiguous_home_in/contiguous_homeand use it inmap_pages; handlehome == atinsidemap_pages's per-page loop; addconsecutive_pages_from_separate_allocations_do_not_map_as_one_home,contiguous_home_requires_one_allocation, andmapping_page_at_its_own_home_in_mixed_call_keeps_it_committed.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): 754 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:consecutive_pages_from_separate_allocations_do_not_map_as_one_home,contiguous_home_requires_one_allocation, andmapping_page_at_its_own_home_in_mixed_call_keeps_it_committedall passRegression run
main:
PR:
Not tested
AI use
kernelx.rs, wrote the fix and regression tests, addressed @pvfreis's review finding onhome == atin the per-page loop, ran the test suite andscripts/smoke.ps1regression runs, and drafted this PR description.@DavidM1911 on GitHub · 2026-11-24 12:53 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: 34 passed, 0 failed, 1 ignored — the contiguous-physical-pages change is covered by the kernelx suite (scatter_matches_a_model_of_physical_pages,physical_pages_in_uma, etc.).AI use: test runs by Devin (Cognition, SWE-2); no code changes.
@b3IKK on GitHub · 2026-11-24 13:58 UTC · original
Thanks @pvfreis for the thorough review! Addressed in \
@pvfreis on GitHub · 2026-11-24 14:06 UTC · original
Follow-up at
076d027(rebased onto930e8b4). I read the diff only; nothing was built or run here.at(kernelx.rs:1280-1291) is brought back from wherever it was away, has its home committed again throughhome_againand is taken out ofaway.gone. It is not recorded inAWAY. So the page is no longer copied onto itself, and its home is not decommitted at the end of the call.mapping_page_at_its_own_home_in_mixed_call_keeps_it_committed(:2229) asserts that the page stays committed, keeps its data and is not inAWAY. Without the new branch, the assertion at:2252would fail.PHYS_BLOCKSvalue type thatcontiguous_home_in(:859) takes. #1055 and #1102 removeatfromaway.titleat the top of this loop and write it back on every path that leaves a page atat, so the newhome == atbranch will need that insert too when they meet.Reply by Claude Code (Claude Opus 5.5); checked by a person before posting.
@JoaoPauluu on GitHub · 2026-11-24 14:34 UTC · original
A run on Linux under Wine.
Tested
x86_64-pc-windows-gnu.076d027as it is (based on930e8b4), no uncommitted changes. The lib test binary runs under Wine, one test per process (--exact). The page and memory calls under kernelx are Wine's here.hle::kernelx::tests::consecutive_pages_from_separate_allocations_do_not_map_as_one_home: ok, no SKIPPED.hle::kernelx::tests::contiguous_home_requires_one_allocation: ok, no SKIPPED.hle::kernelx::tests::mapping_page_at_its_own_home_in_mixed_call_keeps_it_committed: ok, no SKIPPED.Not tested
AI use
@DavidM1911 on GitHub · 2026-11-26 03:41 UTC · original
Re-verification on RTX 3060 Ti (Windows 11): still a merge conflict with current
mainon the new head — needs another rebase before it can be tested.View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.