hle,eh: reclaim partial physical frees, shard lazy VEH, harden dstorage/input/audio #1994
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2004"
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 raylitebull on 2026-11-25T00:37:46Z.
Hardens HLE world streaming, physical-page reclamation, lazy VEH sharding, monitor/mwait patching, audio buffer reuse, and GameInput/KBM playability:
kernelx/lazy.rs:XMemVirtualAlloc/ overflowalloc_physical_homeMEM_RESERVEfallbacks below the 40-bit VA ceiling viaalloc_below_40bit(VirtualAlloc2, preserving#2157's sparse-layout coherent UMA opt-out); stops largeAllocateTitlePhysicalPagespools from stealing pre-committed coherent UMA; skips committing lazy pages on reads while ensuring lazy pages before writes (uses existing upstreamXMemIsToolsMemAvailableinkernelx.rs).PHYS_BLOCKScounters with a per-page live bitmap (PhysBlock) for exact per-page liveness (physical_pages_live+is_live_physical_page), double-free immunity, and immediate coalescedMEM_DECOMMIT+sparse::decommittedon partialFreeTitlePhysicalPagescalls.4 MiBstripes (kernelx/lazy.rs) with atomicLAZY_COUNT/LAZY_COMMITTED_ANYfast paths and batchedlazy::mark/unmark.dstorage.rs,dstorage/parallel.rs,dstorage/parallel_tests.rs):#1405execution-time physical page-list resolution (!dest_on_stack+read_own+kernelx::physical_pages_live+ zero-entry reread) insidedstorage.rs::write_dest_physical_pagesacross sequentialexecute()anddstorage/parallel.rs(InFlightTask::dest_on_stack), refreshing stale/freed entries on write/read retry (0x89240009prevention) and extending parallel decompression to physical-page destinations and supported BCPack requests.Monitorx/Mwaitx& EH (eh.rs):SEENmutex inemulate_console_onlywith a lock-freeAtomicU16bitmask and live-patchesMonitorx->nop;nop;nopandMwaitx->pause;nopvia atomic alignedu64CAS +FlushInstructionCache(opt-out viaXCL_NO_PATCH_MONITORX=1).opus.rs,acphal.rs):IMFSample/IMFMediaBufferpairs acrossMftDecoderpackets; splitsXApustream locks to per-stream mutexes with reusable PCM/float scratch buffers and atomic progress throttling (preserving#471'sChannel::connectclear).gameinput.rs,kbm.rs):GetNextReading/GetPreviousReadinghistory; extendsXCL_PRESS_ATfor triggers/sticks/durations; addsZ/Cbumper keys; gates mouse buttons on capture/non-sizing and guards zero-delta poll velocity decay (preserving#552's PlayStation HID fallback).Part of #1833.
What is in it
crates/xcl/src/eh.rs,crates/xcl/src/hle/{acphal.rs, dstorage.rs, dstorage/parallel.rs, dstorage/parallel_tests.rs, gameinput.rs, kbm.rs, kernelx.rs, kernelx/lazy.rs, opus.rs}(10files).Tested
rustc 1.99.1 (58cf8f9c3 2026-10-13), rebased cleanly onto73e3aba6(57560bf5).cargo check --workspace --tests: passed (0warnings in touched files).cargo test -p xcl --lib -- --test-threads=4 hle::kernelx:: hle::dstorage:: hle::gameinput:: hle::kbm:: hle::acphal:: hle::opus:: eh::tests::: 128 passed, 0 failed, 1 ignored (0.61s, including#1405,#495,#2157,#509,#563,#2048, and all 13#2004tests).Regression run
scripts/smoke.ps1pair on57560bf5vs73e3aba6has not been run yet. AMD and NVIDIA reviewers are invited to verify57560bf5vs73e3aba6(includingscripts/smoke.ps1, DirectStorage streaming, and GameInput/KBM paths) and post results in the comments.Not tested
scripts/smoke.ps1pair on57560bf5, fullcargo test --workspacesuite on57560bf5, runtime GPU execution across AMD / NVIDIA / Intel hardware, and Linux/Wine/vkd3d-proton.AI use
73e3aba6, and unit tests; the author reviewed the diff and test output.Imported from ivall/xcl. Originally posted by raylitebull on 2026-11-25T00:47:42Z.
Overlap note: full credit to #565 (@ZekkJJ) for retaining recent
GameInputreadings forGetNextReading/GetPreviousReadingingameinput.rs.If #565 lands first, we will drop the reading-history hunks from #2004 and keep #2004 focused on its independent
eh,acphal,dstorage,kbm,kernelx,lazy,opus, andXCL_PRESS_AT/ rumble changes.Imported from ivall/xcl. Originally posted by futurepro62 on 2026-11-25T01:03:50Z.
Full-suite run, since this PR has no test report yet. Tested exact head
462a456(on its base6567c5f).Tested
cargo build --workspace, thenXCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4 --skip heap_window_out_of_memory_falls_back_to_the_switch_form --skip gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f64_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::const_and_null_mask_operands_agree_with_hlsl_on_the_gpu --skip gpu::dxil::fuzz_tests: 999 passed, 0 failed, 43 ignored. SKIPPED (no wave64):a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu,a_per_lane_2d_or_3d_group_runs_on_the_gpu,coalesced_guarded_runs_agree_with_the_hlsl_path_on_the_gpu,cross_lane_reads_agree_with_the_hlsl_path_on_the_gpu,gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware,the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu.monitorx_and_mwaitx_patch_to_nop_and_pause_safely,xapu_reuses_stream_scratch_and_supports_concurrent_streams,parallel_decode_supports_physical_page_destinations_and_late_refresh,rumble_skips_disconnected_pad_and_deduplicates_unchanged_speeds,next_and_previous_reading_walk_state_changes_and_terminate,extended_scripted_actions_drive_triggers_sticks_and_durations,mouse_buttons_require_capture_and_not_sizing,high_frequency_zero_polls_do_not_prematurely_decay_velocity,xmem_tools_mem_and_40bit_virtual_alloc,physical_page_reads_skip_commit_writes_ensure_lazy_and_free_unmarks,partial_free_tracks_exact_liveness_decommits_homes_and_ignores_double_free,sharded_lazy_batch_spans_stripes_and_unmarks_cleanly,mft_decoder_reuses_cached_samples_across_packets.XCL_ADAPTER=radeon),cargo test --workspace -- --test-threads=4 --skip gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1: 1009 passed, 0 failed, 45 ignored. SKIPPED:f16_programs_on_the_gpu(f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))),f16_programs_on_the_gpu(f16 arithmetic, wave64, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))),f16_programs_on_the_gpu(f16 packed, wave32, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))),f16_programs_on_the_gpu(f16 packed, wave64, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))),f32_programs_on_the_gpu(f32 conversions, wave32, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))),f32_programs_on_the_gpu(f32 conversions, wave64, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))),heap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows).--skipleaves out tests that fail on main7994cd1too, not because of this PR. On NVIDIA:heap_window_out_of_memory_falls_back_to_the_switch_form(#1651), the fourgpu::recomp::lower_dxil::tests::*_programs_on_the_gputests andconst_and_null_mask_operands_agree_with_hlsl_on_the_gpu(follow-up on #1651) fail becauserunner::skip_testturns their skips into failures underXCL_REQUIRE_GPU=mesh, andgpu::dxil::fuzz_testsseeds 70, 545, 1019 and 1507 failCreateComputePipelineStatewithE_OUTOFMEMORYon this card (drivers 616.64 and 621.40). On AMD:fuzz_validate_and_gpu_1fails on seed 540 (res[833]0x7 vs CPU 0x6). The AMD run does not setXCL_REQUIRE_GPU.Not tested
AI use
Imported from ivall/xcl. Originally posted by Anon64 on 2026-11-25T01:47:29Z.
Regression run for this PR: head
462a456, based onmain80f4819. RTX 3060 12 GB (581.80, wave32), Windows 11 26200, release,XCL_NETWORK=0, A pressed every 4 s from 20 s,scripts/smoke.ps1on a retail title for 60 s, in one batch with themainrun.main
80f4819:this PR:
No device removals or crashes; 98 % of main's frames, 105 % of its peak commit.
Not tested: the whole suite; world loading; whether the title reaches all of the changed code in these 60 s (default settings:
XCL_DIRECT_DXILandXCL_HEAP_WINDOWSunset).Written with Claude Code (Claude Opus 5.5) from runs on this machine.
Imported from ivall/xcl. Originally posted by raylitebull on 2026-11-25T01:54:23Z.
Rebased and trimmed
#2004cleanly ontod63071a(4d7d3bb+c57227f):#563duplicate: removed our duplicateXMemIsToolsMemAvailable()definition fromcrates/xcl/src/hle/kernelx.rs(using#563's implementation onmain).#509(#476): updateddstorage.rs::refresh_stale_pagesto useread_own(ReadProcessMemory) so unmapped page arrays never fault while still refreshing stale/freed page entries.#552Ǘ: cleanly kept the PlayStation HID fallback ingameinput.rsandChannel::connectclear inacphal.rs.Pushed
c57227ffor GitHub ActionsBuild and testand fresh verification.Imported from ivall/xcl. Originally posted by Toons29 on 2026-11-25T03:42:02Z.
Regression run of
6bdf9b99on the retail title, for this PR's Regression run section. Both blocks are fromscripts/smoke.ps1as printed, not edited:mainon568e7db7, this PR on its head commit with no uncommitted changes, same title and time.Against the limits in CONTRIBUTING.md: 104 % of
main's frames, 100 % of its peak commit, no crash, no device removal.AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0,
cargo build --release -p xcl, 60 s,XCL_NETWORK=0. This is a regression check only: it does not show whether the run reaches the code this PR changes.AI use: Claude Code (Claude Opus 5.5) built both trees and ran
scripts/smoke.ps1; both blocks are exactly as printed, and I approved posting this.Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T03:51:32Z.
Verification on RTX 3060 Ti (Windows 11): merge conflict with current
main— needs a rebase before it can be tested.Imported from ivall/xcl. Originally posted by raylitebull on 2026-11-25T10:57:52Z.
Rebased
#2004cleanly onto5478c4a7(52e01595+6bdf9b99), integrating#2157(3e1eab29, keepingalloc_physical_homesparse-layout coherent UMA skip and wiringalloc_below_40bitinto its plainMEM_RESERVEfallback).Verified locally (
cargo check --workspace --tests+126 passed, 0 failed, 1 ignoredacrosskernelx,dstorage,gameinput,kbm,acphal,opus, andehtests, including both#2157tests) and pushed6bdf9b99— ready for re-testing (ping@DavidM1911)!Imported from ivall/xcl. Originally posted by raylitebull on 2026-11-25T18:16:47Z.
Rebased
#2004cleanly onto73e3aba6(9b81c214+57560bf5), integrating#1405(bb27ed6dexecution-time DirectStorage physical page-list resolution):#1405's execution-time physical page-list resolution (!dest_on_stack+read_own+kernelx::physical_pages_live+ zero-entry reread) insidedstorage.rs::write_dest_physical_pagesso sequentialexecute()anddstorage/parallel.rs(InFlightTask::dest_on_stack) share identical#1405/#476semantics.kernelx::physical_pages_liveandkernelx::is_live_physical_pagebacked byPhysBlock's exact per-page bitmap, and updatedparallel_decode_supports_physical_page_destinations_and_late_refreshto use a heap-allocatedvec![stale_page[0]]matching#1405.cargo check --workspace --tests+128 passed, 0 failed, 1 ignoredacrosskernelx,dstorage,gameinput,kbm,acphal,opus, andehtests, including#1405,#495,#2157,#509,#563,#2048) and pushed57560bf5.Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-26T00:49:42Z.
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
Imported from ivall/xcl. Originally posted by Prime1997 on 2026-11-28T09:34:02Z.
The physical-page release portion of this PR is adapted on our NVIDIA integration branch in 6198b180, with release-notification ordering in ba3036af. Credit to @raylitebull for the partial-home reclamation work, alongside @Babyhamsta's per-page liveness repair and @b3IKK's lazy-mark cleanup.
The adaptation frees only released page homes, rejects stale page IDs and repeated-free sibling retirement, and keeps the mapping lock through decommit. A home or empty reservation occupied by another live page remains held until that occupant leaves. The whole-block notification still runs before its bytes disappear. It preserves NVIDIA's current sparse/source-release paths; the unrelated DirectStorage, audio, input and exception-handler changes from this PR are not imported.
These links are for review and reuse through the existing owner PRs, not a replacement omnibus PR.
Compilation:
cargo build --locked --release -p xcl --target-dir <isolated-target>completed on integrated commit04722e9a71d22e2e23cbbeb859161246023adea4(exit 0, 229.969 seconds, 8 compiler warnings). This is compilation evidence only.Interactive follow-up on the combined NVIDIA candidate
An RTX 3060 Ti (8 GiB) run of the same clean integration head
04722e9a71d22e2e23cbbeb859161246023adea4ended after 3,266 seconds with D3D12 device removal0x887A0005; 1,060 read-only monitor samples were recorded. Peak logged process commitment was 25,311 MiB and local DXGI usage 9,218 MiB, with a maximum 2,002 MiB overrun of its contemporaneous budget. Immediately before removal, a two-second interval recorded 1,703 draws and 7,023 dispatches with no new presents. DRED state was UNKNOWN and breadcrumbs were unavailable. Budget pressure coincided with failure; the exact GPU fault and causal contribution of any individual patch are not established.The physical-alias counter reported 1,006 MiB of duplicate address backing avoided; this is allocator accounting, not an isolated measured DXGI reduction. At least 2,048 earlier-run driver blobs were successfully reused. Three matched cached creations took 135–147 ms versus 16,672–31,259 ms previously uncached. These narrow observations do not make the combined candidate gameplay-validated. No unit/GPU test batch or matched main/head smoke comparison was run for this revision, and this report is not an approval to merge the integration or evidence that this individual PR caused the failure.
AI use: Codex (GPT-6), adaptation and source review.
An optional temporary Discord is available to coordinate contributor work, help test and compare results.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T06:26:09Z.
Review (head
57560bf5, diff read, not a merge-check; it conflicts with main and CI /PR descriptionare red, so not built or run):About 1,670 lines across ten unrelated areas with no reason given for not splitting. Some parts are on main in another form (Monitorx/Mwaitx patching
d634138c, GetNext/GetPreviousReadingf9e6ac5f, and the hard-coded KBM keys replaced by per-title input profilesb8005022); several useful parts aren't.kernelx.rs~2409-2431) decrements the block's live count once per page in the array with no per-page record, so freeing the same page twice can release a block whose other pages are still in use. The per-page bitmap here prevents that.read_src_physical_pages(dstorage.rs~955) rereads the source page list fromr.sourcewithout the on-stack check the destination path has (dest_on_stack), so a list that was on the enqueuing thread's stack can be reread as reused stack bytes.lazy::unmark_batch(kernelx.rs~1458) runs after theAWAYlock is released; a concurrent MapTitlePhysicalPages at the same address can mark a new lazy page that then gets unmarked and is never committed.gameinput.rs~497 changesDEVICE_IDpadding from spaces to NULs, which changes the id the title sees and isn't in the description.kernelx.rs~731 sends plainXMemVirtualAllocreserves toVirtualAlloc2, skipping the kernelx VirtualAlloc hook (placeholders, GPU-view reservations); no title needing 40-bit addresses is cited. The description also claims large physical-page pools stop taking pre-committed coherent UMA, which isn't in the diff. A narrow window inlazy.rs~70 can pass on the very first lazy commit fault.Fine: reads of physical pages no longer commit untouched pages, and the parallel DirectStorage path for physical pages / BCPack and the XApu per-stream locks look reasonable. Recommendation: close and re-split against current main, one PR each: (a) per-page bitmap / double-free fix with a test; (b) partial-free decommit through main's
source_going/mirrors::page_freed; (c) reads that don't commit; (d) DirectStorage parallel physical-page and BCPack requests; (e) source-page reread with the on-stack rule; (f) XApu locks and buffers; (g) Opus sample reuse; (h) rumble skip and dedup; (i)XCL_PRESS_ATextensions; (j) mouse decay on main's input profiles. Lazy sharding and 40-bit placement only with measurements and a named title.AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.
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.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.