Repository navigation
kernelx: VirtualProtect commits lazy pages in its range first - #1191
emirduran707 wants to merge 1 commit into
Conversation
|
I checked the real-handle case listed under Not tested on A scratch test reserved a page, mapped a fresh physical page with In scratch, I used
AI-assisted. Codex (GPT-6, exact variant unavailable) wrote and ran the scratch checks and drafted this report. |
|
Independent verification on current Machine: Windows 11, Ryzen 9 7900X + RTX 3060 Ti; Rust stable MSVC, debug.
AI use: test runs by Devin (Cognition, SWE-2); no code changes. |
|
Full-suite run, to go with the Tested
Not tested
AI use
|
|
A run on Linux under Wine. Tested
Not tested
AI use
|
…vall#1142, ivall#1150, ivall#1156, ivall#1182, ivall#1191, ivall#1195, ivall#1221 Integrate 10 high-impact open upstream PRs on top of upstream/main (930e8b4): - ivall#1182: share video memory across render targets aliased onto one physical page (~1.85-2.1 GB VRAM saved) - ivall#1142: declare tiled texture pools texture-only (D3D12_HEAP_FLAG_DENY_BUFFERS) for vkd3d-proton - ivall#1097: report process memory under Wine via PagefileUsage fallback - ivall#1078: bound BCPack record scratch memory to 2 KiB stack batches - ivall#1150: convert console clear-value formats in CreatePlacedResource - ivall#1156: release the interface returned by QueryInterface in class_for - ivall#1139: check pointer alignment in is_adopted before dereferencing - ivall#1195: skip ExecuteIndirect dispatch of untranslated console compute pipelines - ivall#1191: VirtualProtect commits lazy pages in its range first - ivall#1221: unmark lazy away mappings in FreeTitlePhysicalPages Assisted-by: Antigravity (Google DeepMind)
…ll#1221, and updated Linux PRs Update fork README for upstream/main 930e8b4 (BCPack BC1-BC7, XCL_PSO_WAIT_MS, low-VA ASLR < 2^40, alloc_pool, sparse tile parking/pool reuse, direct page moves, write-watch merge), newly integrated PRs (ivall#1078, ivall#1097, ivall#1139, ivall#1142, ivall#1150, ivall#1156, ivall#1182, ivall#1191, ivall#1195, ivall#1221), and updated Linux PRs (ivall#867, ivall#871, ivall#877). Assisted-by: Antigravity (Google DeepMind)
|
AMD run on the exact head Tested
Not tested
AI use
|
|
Test report for head Tested
Not tested
AI use
|
|
Linux / AMD RDNA4 (RADV) test report for head Environment
Tested (debug test binary under Wine,
Not tested: full workspace suite, retail title run, native Windows. AI use: T3 Code / Antigravity (Gemini 4 Neon) merged, built, ran the tests on this machine, and drafted this report. |
Physical pages mapped into the title's own reservation are left reserved until first touched (lazy::mark in map_pages); the fault handler commits them on a CPU access, but kernel calls do not fault, they fail. Windows' VirtualProtect fails when any page of the range is not committed, so a title that maps pages and changes their protection before touching them got FALSE with ERROR_INVALID_ADDRESS (487), where the non-lazy path (and the console) succeeds. VirtualProtect now commits the lazy pages of the range first with lazy::ensure, as the file and DirectStorage paths already do; VirtualProtectEx does the same when the handle is the current process. The new test reserves two 64 KiB pages, marks them lazy and protects them read-only: before the fix it got (0, 487), now it succeeds, returns PAGE_READWRITE as the old protection and the pages read as zeros. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
d0211db to
c3ff67b
Compare
MapTitlePhysicalPages/XMemMapPhysicalPagesmap fresh pages into a title's own reservation lazily: the page stays reserved (lazy::mark) until it is first touched. A title that maps pages and callsVirtualProtecton them before touching them got FALSE withERROR_INVALID_ADDRESS(487). Windows'VirtualProtectfails when any page in the range is not committed. On the console the pages are mapped, and XCL's non-lazy path for the same call commits them, so there the call succeeds.lazy.rsitself notes that kernel calls fail on lazy pages and that buffers passed to them are committed first (ensure). TheVirtualProtectwrapper did not do that.VirtualProtect, andVirtualProtectExfor the current process, now calllazy::ensureon the range first.What is in it
crates/xcl/src/hle/kernelx.rs: the two calls; testvirtual_protect_commits_lazy_pages_first. It reserves two 64 KiB pages and marks them lazy, then callsVirtualProtect(PAGE_READONLY). It checks success, thatoldisPAGE_READWRITE, and that the memory reads zero.#1034 adds a different line at the top of
VirtualProtect; the two changes are independent (a rebase keeps both lines).Tested
cargo test --workspace --no-fail-fast -- --test-threads=4on c3ff67b: 1283 passed, 2 failed, 46 ignored; 8 SKIPPED (6 inlower_dxil::tests::{f16,f32}_programs_on_the_gpu;heap_window_out_of_memory_falls_back_to_the_switch_form;pso_measurement_compiles_an_exact_synthetic_record)gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1seed 722 andfuzz_validate_and_gpu_3seed 1599) fail identically on unmodifiedmainon this GPU.left: (0, 487),right: (1, 0); with ithle::kernelx::tests::virtual_protect_commits_lazy_pages_firstpassesRegression run
main:
this PR:
Not tested
VirtualProtectExwith a real handle to the own process (only the pseudo handle is treated as the current process, asVirtualFreeExdoes).AI use
main55d64c2(resolving thekernelx.rstest-block conflict by keeping both tests), reran the full workspace suite and smoke pair, and updated this description.