kernelx: unmark lazy away mappings in FreeTitlePhysicalPages #1221
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!1221
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1221"
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 13:22 UTC · original
b3IKK:kernelx/free-physical-pages-lazy-unmark→main· +64 −0 · 1 files · 1 commits · openWhen a fresh physical page is mapped into a plain
MEM_RESERVEregion viaMapTitlePhysicalPages,map_pagesmarks that address inlazy::LAZY. Bothunmap_awayandmove_awaycalllazy::unmark(at), butFreeTitlePhysicalPagesremoved the entry fromAWAYwithout unmarking it—leaving a stale entry inlazy::LAZYthat could silently commit the address (even afterVirtualFreeand VA reuse) on a laterlazy::ensureor page fault, and could also cause silent data loss when another page B is later mapped atr, written, and mapped back home (unmap_away(r)returns early on the stalelazy::unmark(r)without copyingrback to B's home).This calls
lazy::unmark(at)whenFreeTitlePhysicalPagesremoves an away mapping.What is in it
crates/xcl/src/hle/kernelx.rs: calllazy::unmark(at)when removing an away mapping inFreeTitlePhysicalPages; add regression testsfree_physical_pages_unmarks_lazy_away_mappingandfree_physical_pages_stale_lazy_mark_does_not_lose_reused_reservation_writes.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): 743 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 free_physical_pages_: 2 passed, 0 failedRegression run
main:
PR:
Not tested
AI use
kernelx.rs, wrote the fix and regression tests (including the data-loss sequence suggested in review), ran the test suite andscripts/smoke.ps1regression runs, and drafted this PR description.@DavidM1911 on GitHub · 2026-11-24 13:47 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:Note: the full
d3d12xlib filter currently aborts with 0xc0000005 on unmodifiedmaintoo (pre-existing, unrelated to this PR); the PR's own tests were run by name and pass.@pvfreis on GitHub · 2026-11-24 14:23 UTC · original
The fix is right, and on
main(930e8b4) the stale mark does more than commitrlater: it loses data. Read only; nothing built or run here. Sequence, all inkernelx.rsonmain:raway from home:lazy::mark(r)(:1284-1287).FreeTitlePhysicalPages([A])drops the mapping but not the mark (:1169-1175).r:ris committed and B's home is copied to it (:1290-1296); the home is given back at the end of the call.ris committed, so nothing faults and the mark stays.r, then maps B home again:commit_homesbrings the home back as zeros, andunmap_away(r)returns early becauselazy::unmark(r)is true (:1061-1066), soris never copied home. B reads zeros.A test of that sequence (assert B's home holds what was written at
r) fails onmainand should pass with the one-line fix here, which would cover the data loss as well as the stray commit your test checks.Reply by Claude Code (Claude Opus 5.5); checked by a person before posting.
@b3IKK on GitHub · 2026-11-24 18:54 UTC · original
Great catch @pvfreis — added \ree_physical_pages_stale_lazy_mark_does_not_lose_reused_reservation_writes\ in \
34035fc\ covering that exact page A -> free -> page B away write -> map home data-loss sequence, and re-ran \scripts/test.ps1\ and the 60 s \scripts/smoke.ps1\ run.@DavidM1911 on GitHub · 2026-11-26 04:05 UTC · original
Re-verification on RTX 3060 Ti (Windows 11), new head merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved.Thanks!
— Devin
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.