eh: harden is_writable for PAGE_GUARD, regions, and lazy pages (#626) #523
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!523
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-523"
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?
@Grimkaaah on GitHub · 2026-11-24 01:16 UTC · original
Grimkaaah:fix/278-is-writable-guards→main· +117 −7 · 1 files · 1 commits · openFixes #626 (item 3 of #278:
is_writableguards). Items 1–2 are already onmain; item 4 is #321. Complements #501 (sparse-window fast path) — this PR fixes the VirtualQuery fallback that #501 still uses.Emulated
CLZERO/ClzeroLoopasked whether the destination was writable with a singleVirtualQuery. That was wrong in four ways:PAGE_GUARD.PAGE_READWRITE | PAGE_GUARD(0x104) passed& (PAGE_READWRITE | PAGE_EXECUTE_READWRITE) != 0, so the VEH would write through a guard page instead of letting the real fault happen.ClzeroLoopcan cover adjacent committed runs with different protect; one query only sees the first.va + bytes. A wrapping end was undefined.MEM_RESERVE(lazy map) madeis_writablefalse →0xC000001D, instead of committing vialazy::ensureand zeroing.What is in it
eh::is_writablenow matches the shape ofdstorage::writable:checked_add→lazy::ensure→ UMA coherent-window fast path → walk everyVirtualQueryregion covering[va, end), requiring a writable protect (READWRITE/WRITECOPY/EXECUTE_*) and noPAGE_GUARD.VirtualProtect;PAGE_NOACCESSand wrapping end; span across two differently-protected committed pages; reserved hole fails; lazy page commits throughensure; CLZERO on a guard page returns 0 without clearing the guard.Tested
rust-toolchain.toml.cargo test -p xcl --lib eh::tests -- --nocapture: 8 passed, 0 failed.cargo test -p xcl --lib -- --test-threads=4: 648 passed, 0 failed, 21 ignored; 0 GPUSKIPPED.ed2f33c.Regression run
Same title and wall time on
mainand on this PR's head (clean tree):Not tested
sparse::known_writablefast path (not onmainyet); merge order should be fine — both can sit above the VirtualQuery walk.AI use
Implemented, tested, smoke runs, and PR description with Cursor (Composer). Plan posted on #626 / #278 before landing the complete PR.
@brothernog on GitHub · 2026-11-24 01:42 UTC · original
Tested
056cb61on an RTX 3050 (driver 610.88), Windows 11 Home 26300, Rust 1.100.0, debug:cargo test -p xcl --lib eh::tests: 8 passed.main'sis_writableand kept the new tests.is_writable_guards_regions_overflow_and_lazy_pagesfails at "PAGE_GUARD must not count as writable".clzero_refuses_a_guard_pagekills the test process with0x80000001(STATUS_GUARD_PAGE_VIOLATION): the old CLZERO wrote through the guard.cargo build --workspacethencargo test --workspace --no-fail-fast -- --test-threads=4: 679 passed, 0 failed, 41 ignored. SKIPPED (no wave64):gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware.The new
is_writablehas the same steps asdstorage::writable(checked end,lazy::ensure, coherent window, region walk withoutPAGE_GUARD), plus anext <= atguard.On the interaction with #501, which the description mentions: #501 puts
sparse::known_writablebefore this walk. On my machine its working-set check reports guarded, no-access and read-only pages as writable, details on #501. For a committed sparse-window page a title has guarded, CLZERO would then skip this PR'sPAGE_GUARDcheck. Whichever merges second may want to keep the guard check ahead of that fast path.This review was AI-assisted.
@eizispark on GitHub · 2026-11-24 02:30 UTC · original
Hardware check of
056cb61ac7506e423c307832c88e009720fd2091(verified clean merge withmaincb868b2): pass.Tested
rustc 1.100.0 (0ef1bc386 2026-11-09), release + test profilecargo test --workspace -- --test-threads=4:679 passed, 0 failed, 41 ignored(GPU tests skipped on this adapter:none)cargo test -p xcl --lib eh::tests:8 passed, 0 failedRegression run
main(9ce2070):PR (
056cb61):Not tested
AI use
scripts/smoke.ps1harness on this machine and formatted this report.@Grimkaaah on GitHub · 2026-11-24 02:44 UTC · original
Rebased onto current main (
3db536e), linked to dedicated issue #626, and filled Regression run with real xcl-smoke blocks (main + headed2f33c, GTA6 60s, RX 7900 XTX).@bunbeans2-arch on GitHub · 2026-11-24 04:43 UTC · original
Test report for
ed2f33c4180389ab3d926995aff111f5c987bae2on an Intel CPU without CLZERO (i9-9900K), where the emulated CLZERO path this PR changes is the one taken. The other runs here were on RDNA3 and on a Ryzen 7 9800X3D, which runs CLZERO itself.Tested
stable-x86_64-pc-windows-msvc, debug.3db536e):cargo build --workspace+cargo test --workspace -- --test-threads=4: 688 passed, 0 failed, 41 ignored, 0SKIPPED(D3D12 backend on the RX 9070 XT);eh::tests::clzero_refuses_a_guard_pageandeh::tests::is_writable_guards_regions_overflow_and_lazy_pagespass. Control,mainf4ce27c: 701 passed, 0 failed, 41 ignored.eh.rs, not part of this PR; its source is in my report on #321: https://github.com/ivall/xcl/pull/321#issuecomment-7122269978), on this PR's head merged ontomainf4ce27c(clean merge): the instructions run for real, the CPU raisesSTATUS_ILLEGAL_INSTRUCTIONandeh's handler takes it.clzeroat a line in a read-write buffer: 1 fault, that line zeroed and the bytes around it left as they were.clzero; add rax, 0x40; cmp rax, rdx; jb) over 0x400 bytes: 1 fault, the 0x400 bytes zeroed and the rest left as it was.main).Not tested
scripts/smoke.ps1run (no game files were used), a release build.main: that is the CLWB hot-patch race of #321, which this PR does not touch.AI use
@raylitebull on GitHub · 2026-11-24 10:40 UTC · original
Code/CI review only (not independently runtime-tested by me): clean merge and
PR descriptiongreen (just awaiting CI workflow approval). Hardenseh::is_writableforPAGE_GUARD, multi-region spans, and lazy pages (#626). Recommend approving CI and merging, @ivall.@DavidM1911 on GitHub · 2026-11-25 13:43 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)Thanks!
@upipibi on GitHub · 2026-11-25 20:25 UTC · original
NVIDIA test report for
ed2f33c(head as is, base3db536e), for #1607's "one more test report" list. RTX 3070 8 GB (Ampere, 32-lane waves), driver 616.56, Windows 11, debug, aftercargo build --workspace:cargo test --workspace --no-fail-fast -- --test-threads=4 --skip hle::xaudio2: 679 passed, 0 failed, 41 ignored. The end-to-end title tests pass.hle::xaudio2, because its tests fail or hang on this machine onmaintoo. The PR doesn't touch it.no wave64on this card.AI-assisted (Claude Code, Claude Opus 5.5). Synthetic tests only; no title run.
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.