Memory: enforce placeholder replacement and region bounds #2009
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2019"
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?
Imported from ivall/xcl. Originally posted by eizispark on 2026-11-25T00:55:35Z.
VirtualAlloccalls on placeholder reservations withoutMEM_REPLACE_PLACEHOLDERpreviously returnedNonefromplaceholders::allocand fell through tokernelx's sparse commit path. That allowedMEM_COMMITon an unreplaced placeholder (whichplaceholders::freenever decommits becauser.placeholderremainstrue, leaking RAM and D3D12 sparse tiles), allowedMEM_COMMIT | MEM_REPLACE_PLACEHOLDERwithoutMEM_RESERVE, and allowed commits on a replaced placeholder to straddle past its region end into adjacent placeholders or separate replacements.VirtualFreealso acceptedMEM_RELEASE | MEM_PRESERVE_PLACEHOLDERacross an entire unreplaced placeholder without splitting it and acceptedMEM_RELEASE | MEM_COALESCE_PLACEHOLDERSon a single placeholder.What is in it
crates/xcl/src/hle/kernelx/placeholders.rs: rejectMEM_RESERVE_PLACEHOLDER | MEM_REPLACE_PLACEHOLDER, rejectMEM_REPLACE_PLACEHOLDERwithoutMEM_RESERVEor with a null/zero-size range, intercept non-replacementVirtualAlloccalls inside tracked placeholder regions (rejecting unreplaced placeholders, re-reservations, zero-size calls, and out-of-region straddles with Windows'ERROR_INVALID_PARAMETER/ERROR_INVALID_ADDRESScodes, and aligning sub-page commits to their 4 KiB page base before notifyingsparse::committed), and reject degenerate single-placeholderMEM_PRESERVE_PLACEHOLDERsplits andMEM_COALESCE_PLACEHOLDERScoalesces inplaceholders::free.hle::kernelx::placeholders::testscovering unreplaced commit rejection, cross-region straddle rejection, sub-page commits inside a replaced slice, and degenerate single-placeholder split/coalesce rejection.Tested
rustc 1.100.0 (0ef1bc386 2026-11-09), debug and release.cargo test -p xcl --lib kernelx: 35 passed, 0 failed, 1 ignored.cargo test --workspace --no-fail-fast -- --test-threads=4: 861 passed, 0 failed, 42 ignored (SKIPPED GPU tests: 1 –heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows).Regression run
main:PR:
Not tested
MapViewOfFile3(..., MEM_REPLACE_PLACEHOLDER)over split placeholder slices beyondtesttitleand the 60 s retail smoke run above.AI use
kernelbase, wrote the regression tests andplaceholders.rsbounds checks, and ran the test suite and smoke verification.Imported from ivall/xcl. Originally posted by raylitebull on 2026-11-25T01:12:50Z.
Code review on
8c7adcd:region_end,contains_range, andplaceholders_for_commitincrates/xcl/src/hle/kernelx/placeholders.rscleanly enforce non-overflowingchecked_addbounds and placeholder/mapped coverage for commit, protect, and free operations, with unit coverage inreject_out_of_bounds_free_and_protectandreplace_rejects_partial_map_or_wrong_size.CIworkflow approved (currently running).Remaining before merge:
Build and test (Windows, no GPU)finishing green plus an NVIDIA verification pass on8c7adcd.Imported from ivall/xcl. Originally posted by JJAutoCompare on 2026-11-25T01:28:24Z.
PR #2019 empirical test report
Tested the clean live head
8c7adcdebe3eee539a19a7534fd727a13e145e5eof xcl-dev/xcl#2019. The remote PR head still matched after testing.git merge-tree --write-treeexited 0 against the initialorigin/mainat0e45b975235d6a46daf44076ee9bcd020ebef971and the newerorigin/mainat2bdf0477f84377d1b08e29424100c9bace4e530f.Tested
1.100.0 (0ef1bc386 2026-11-09)onx86_64-pc-windows-msvc. DXC1.9.2609.5 (01b62ad47). Unoptimized dev and test profiles withCARGO_INCREMENTAL=0,CARGO_PROFILE_DEV_DEBUG=0,CARGO_PROFILE_TEST_DEBUG=0, andXCL_ADAPTER=A770.cargo test --workspace --no-runsucceeded.cargo build --workspacesucceeded and produced both e2e fixture binaries.cargo test -p xcl --lib hle::kernelx::placeholders::tests:: -- --show-outputran outside the GPU lock. 3 passed, 0 failed, 0 ignored, 0 skipped. The log confirms UMA initialization, which the tests require to reach their assertions.hle::kernelx::placeholders::tests::replaced_placeholder_bounds_commits_to_its_own_regionhle::kernelx::placeholders::tests::split_and_coalesce_reject_degenerate_single_placeholder_operationshle::kernelx::placeholders::tests::unreplaced_placeholder_rejects_commit_and_keeps_pages_reservedcargo test --workspace --no-fail-fast -- --test-threads=4 --show-outputran once underInvoke-ArcTest.ps1. Cargo exited 101 after completing 20 test harness results. 843 passed, 18 failed, 42 ignored in the raw libtest totals. The six explicit skips below represent unexercised coverage even though libtest records the containing cases as passing. Sample-dependent paths also had no coverage because allXCL_SAMPLE_*variables were unset.Workspace failures
CreateComputePipelineStatereturned0x80070057in these 13 tests.gpu::dxil::ops_tests::doubles_match_cpugpu::dxil::ops_tests::groupshared_barrier_and_atomics_rungpu::recomp::tests::gpu_clamp_and_omod_per_instructiongpu::recomp::tests::gpu_f64_class_comparegpu::recomp::tests::gpu_f64_compares_with_nangpu::recomp::tests::gpu_f64_literal_high_wordgpu::recomp::tests::gpu_f64_rounding_and_conversionsgpu::recomp::tests::gpu_f64_rootsgpu::recomp::tests::gpu_f64_math_randomgpu::recomp::tests::gpu_frexp_f64_exp_and_mantgpu::recomp::tests::gpu_ldexp_f64gpu::recomp::tests::gpu_float_compares_randomgpu::recomp::tests::gpu_rndne_f64The remaining tests failed assertions.
gpu::recomp::tests::gpu_nonfused_mad_and_mac_prevent_fma_contraction— assertionleft == rightfailed: v_fma_f32 overflow control should stay fusedgpu::recomp::tests::gpu_ps_image_sample_offset_implicit_lod_between_mips— pixel (0,0) = 25.609375, expected 26gpu::recomp::tests::gpu_valu_16_and_64_bit— assertionleft == rightfailed: lane 0 v_add_f16 keeps the high halfgpu::recomp::tests::gpu_wave64_ps_whole_wave_reductions— assertionleft == rightfailed: pixel 0 (lane 0, wave of pixel 0): min / sum over the odd pixels, waterfall readtest_title_runs_and_game_folder_is_untouched— synthetic-title D3D12.X dynamic depth bias check #94 expected a green top-right pixel afterRSSetDepthBiasX(-1000.5)and read blue[0, 0, 255, 255].Explicit GPU skips (6)
SKIPPED gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask: no wave64SKIPPED gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware: no wave64SKIPPED placed_title_textures_share_vram_and_preserve_pixels: tiled tier < 2SKIPPED test_title_draws_with_a_root_signature_under_the_debug_layer: no d3d12SDKLayers.dllSKIPPED heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windowsSKIPPED uploads_start_from_each_subresources_state: no D3D12 debug layer (The application requested an operation that depends on an SDK component that is missing or mismatched. (0x887A002D))Not tested
origin/main, so the workspace failures have no same-host baseline comparison in this report.AI use
T3 Code / Codex (
gpt-6.2-sol) fetched and checked the revisions, built and ran the tests, and summarized the captured output. Coordinator #2 (T3 Code / Antigravity,gemini-4-neon) verified the counts against the saved log and published this report.upstream-sync referenced this pull request2026-11-25 04:08:41 +00:00
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T04:01:33Z.
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!
upstream-sync referenced this pull request2026-11-25 10:09:30 +00:00
Imported from ivall/xcl. Originally posted by ramon-victor on 2026-11-26T00:01:07Z.
Independent NVIDIA (wave32) full-suite + retail smoke test report on exact PR head
8c7adcdebe3eee539a19a7534fd727a13e145e5e(clean detached checkout, no local changes).Tested
x86_64-pc-windows-msvc), DXC/DXIL 1.8.2502.11 (Windows SDK 10.0.26100.0); debug tests, release smoke.cargo test -p xcl --lib hle::kernelx::placeholders::tests): 3 passed, 0 failed (with live UMA initialized:split_and_coalesce_reject_degenerate_single_placeholder_operations,unreplaced_placeholder_rejects_commit_and_keeps_pages_reserved,replaced_placeholder_bounds_commits_to_its_own_region)..\scripts\test.ps1): 861 passed, 0 failed, 42 ignored (3 GPU skips expected on this wave32 adapter: 2no wave64, 1no heap windows; lower total count reflects this PR's older base commit).cargo build --release -p xcl) and 60 s retail smoke run (XCL_NETWORK=0;title:hashed to3c290c16per#677since this PR's base predatessmoke.ps1hashing):Regression run
(Today's
main @ 08db802baseline on the same machine:1605frames,15009 MBpeak commit,0crashes,0device removals.)Not tested
XCL_SAMPLE_*tests (unset).AI use
Imported from ivall/xcl. Originally posted by throny on 2026-11-28T02:13:57Z.
merge-check claim
head:
8c7adcdebeImported from ivall/xcl. Originally posted by throny on 2026-11-28T02:30:29Z.
merge-check
base:
753e8b1ahead:
8c7adcdebemerge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 1515 passed, 0 failed, 47 ignored (26 SKIPPED lines); base alone: 1512 passed, 0 failed, 47 ignored
review: no blocking finding. The bounds arithmetic uses checked adds and the region lookup is right. Behaviour a title that relied on the old lax handling would now see: a commit into a placeholder that was not replaced fails with an invalid-address error, a commit past its region's end fails, a reserve at a tracked address fails, a split of a whole placeholder (a no-op before) fails, and so does a coalesce of a single region. Not verified: that Windows returns the same error codes in each case; the smoke runs in the PR are clean, but no retail run shows those paths are unused. One earlier review in the thread names functions that are not in this diff and can be disregarded.
performance: one more lock and map lookup per fixed-address VirtualAlloc (reasoned).
verdict: safe to merge
hardware / tool and model: RTX 4080 16 GB (621.40), i9-12900K (no SSE4a), Windows 11 26300, Rust 1.100.0, debug. Claude Code; merge, build and suite run by Claude Fable 5.2, diff review by Claude Opus 5.5 (every hunk read; nothing run on the GPU beyond the suite).
Imported from ivall/xcl. Originally posted by KOLESNiii on 2026-11-28T10:19:36Z.
merge-check claim
head:
8c7adcdebeImported from ivall/xcl. Originally posted by KOLESNiii on 2026-11-28T11:37:51Z.
merge-check
base:
e429936c10head:
8c7adcdebemerge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2129 passed, 9 failed, 48 ignored, 25 SKIPPED: 21 no wave64, 3 per-lane f16/f32 forms refused (#1426 semantics), 1 no heap windows; failing: gpu::dxil::module::split::tests::dispatch_chain_oversized_loop_matches_whole, gpu::dxil::module::split::tests::dispatch_chain_wave32_live_loops, gpu::dxil::module::split::tests::dispatch_chain_wave64_live_loops_and_exchange, gpu::recomp::heap_window_tests::gpu_heap_flat_reads_match_guarded_and_root_output, gpu::recomp::tests::gpu_compute_mode_dispatch_abi, gpu::recomp::tests::gpu_float_cas_uses_ieee_equality, test_title_draws_with_a_root_signature_under_the_debug_layer, test_title_runs_and_game_folder_is_untouched, test_title_runs_under_the_debug_layer_with_dred: these 9 fail on the base too (the base e429936c's suite, run alone on this PC with the same command: 2126 passed, 9 failed, 48 ignored, 25 SKIPPED, these same 9 failing), and each also failed when rerun alone on this merge (the two debug-layer e2e tests stop on the D3D12 debug layer rejecting a pixel shader as corrupt or unsigned, and test_title_runs_and_game_folder_is_untouched on the test title's console command list memory-methods check, "post-Wait32/64 write failed"); not caused by this PR. The suite ran on this PC at the same time as 3 other PRs' suites, in one queued job.
review: none. Whole diff read (placeholders.rs: RESERVE_PLACEHOLDER with REPLACE_PLACEHOLDER refused; a VirtualAlloc at an address inside a tracked region is handled here: a commit into an unreplaced placeholder, a reserve over a region, or a range past the region's end gives ERROR_INVALID_ADDRESS, size 0 or no alloc type ERROR_INVALID_PARAMETER, a commit inside a replaced region commits from the page base through commit_sparse as the kernelx sparse path did, other types go to VirtualAlloc; VirtualFree PRESERVE of a whole placeholder and COALESCE of fewer than two placeholders refused with ERROR_INVALID_ADDRESS; 3 tests). Addresses outside the tracked regions still return None and take the kernelx path unchanged.
performance: reasoned, not measured: one REGIONS map lookup under its lock per VirtualAlloc with a non-null address; commits take the same commit_sparse call as before.
verdict: safe to merge
hardware / tool and model: Windows 11 build 26300.9974, NVIDIA GeForce RTX 2070 SUPER 8 GB (driver 621.40, wave32 only), AMD Ryzen 5 3600XT; rustc 1.100.1 (20ddd0171 2026-11-25) x86_64-pc-windows-msvc, debug test profile; trial merge 681b0acd01760a2d2da9697c0fab03d3860ec0ad (local, not pushed). Claude Code: Claude Opus 5.5 (coordination, full-diff review, draft).
correction (2026-11-28): the base counts above were first given as 2128 passed: that base run reused this PC's merge test binary (one cargo target dir for both sides). The base was rerun with its own target dir; the same 9 tests fail on it, so the classification and the verdict stand.