Skip to content

kernelx: implement XMemIsToolsMemAvailable answering false on retail - #864

Open
n-romanovich wants to merge 1 commit into
xcl-dev:mainfrom
n-romanovich:kernelx/xmem-tools-mem
Open

n-romanovich wants to merge 1 commit into
xcl-dev:mainfrom
n-romanovich:kernelx/xmem-tools-mem

Conversation

@n-romanovich

@n-romanovich n-romanovich commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

On retail consoles, devkit / tooling memory is not available, and
XMemIsToolsMemAvailable answers FALSE (0). Retail game executables
import this from xmem.dll to verify memory status during startup;
without an HLE export, XCL fell back to an unresolved stub.

Unit test covers the return value.

What is in it

  • crates/xcl/src/hle/kernelx.rs: implement XMemIsToolsMemAvailable returning 0, export in KERNELX_EXPORTS, and unit test xmem_tools_mem_unavailable_on_retail

Tested

  • Windows 11 (26300), D3D12 SM 6.6, Rust 1.100.0 MSVC
  • cargo test -p xcl --lib xmem_tools_mem_unavailable_on_retail: 1 passed, 0 failed
  • xcl inspect game_scarlett_master.exe: 587 functions from 68 DLLs, 0 unimplemented stubs (xmem.dll: 12 HLE, 0 stubs)

Regression run
Main (5478c4a7c1ae5adba127c8d27018d7fdbf3a8725):

xcl-smoke v1
commit: 5478c4a7c1ae5adba127c8d27018d7fdbf3a8725
gpu: NVIDIA GeForce RTX 5060 Ti
title: FILES
seconds: 60
exit: 0x0
frames shown: 1541 (PresentX 1541)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15701 MB

PR (c371d6ec529be7423c8c0c5769655bc99e3fb674):

xcl-smoke v1
commit: c371d6ec529be7423c8c0c5769655bc99e3fb674
gpu: NVIDIA GeForce RTX 5060 Ti
title: FILES
seconds: 60
exit: 0x0
frames shown: 1516 (PresentX 1516)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15436 MB

Not tested

  • Actual devkit hardware with physical tooling memory enabled

AI use

  • Antigravity, Gemini 4 Carbon

gustavsi added a commit to gustavsi/xcl that referenced this pull request Nov 24, 2026
…cl-dev#851, xcl-dev#864, xcl-dev#875-xcl-dev#876 and Wine raw fences

Integrate clean upstream PRs on top of upstream/main (1ec4c98):
- xcl-dev#849: direct move_away for remapped physical pages (avoids 4x sparse tile-mapping round-trips)
- xcl-dev#838: FillMemoryWith*BitValueX uses list upload arena instead of leaked pattern buffers
- xcl-dev#840: merge released ranges of the shared descriptor heap
- xcl-dev#839: map queue-specific D3D12_BARRIER_LAYOUT values to legacy resource states
- xcl-dev#841: preserve due frame-clock events when schedule changes at deadline
- xcl-dev#851: split wrapped command lists before Wait64 GE after ordinary GPU work
- xcl-dev#864: export XMemIsToolsMemAvailable returning 0 on retail
- xcl-dev#875: tbuffer_load_format_* uses identity DST_SEL instead of V# DST_SEL
- xcl-dev#876: implement IDXGIDevice2::EnqueueSetEvent

Also add real::create_raw_fence for internal fences (late_release and EnqueueSetEvent) so Wine/vkd3d-proton never receives a FenceProxy on unadopted internal queues or SetEventOnMultipleFenceCompletion, and wrap list_x test exec with UnadoptGuard.

Assisted-by: Antigravity (Google DeepMind)
gustavsi added a commit to gustavsi/xcl that referenced this pull request Nov 24, 2026
… Linux PRs ivall#867/ivall#871/ivall#877

Update fork README for upstream/main 1ec4c98 (fenced late_release and queue-wait diagnostics), newly integrated PRs (ivall#838-ivall#841, ivall#849, ivall#851, ivall#864, ivall#875, ivall#876), live gameplay audio progress, and our three open upstream Linux PRs (ivall#867, ivall#871, ivall#877).

Assisted-by: Antigravity (Google DeepMind)
@dcastell1

Copy link
Copy Markdown

Verified on Windows 11 10.0.26300, NVIDIA GeForce RTX 5090 (driver 621.24), Rust 1.100.0 MSVC 14.44.35207, debug build, on clean main@beaa245 (713 passed, 0 failed, 41 ignored on this box):

patch -p1 < this PR            # clean, no fuzz
cargo test --workspace -- --test-threads=4
714 passed; 0 failed; 41 ignored   (exit 0)

One more passing test than main: XMemIsToolsMemAvailable answering false is covered; nothing else changes verdict.

Tree restored afterwards (md5 and a full diff against a clean checkout), hardware adapter, no Wine, no game data. AI-assisted (opencode): applied the patch to a built tree, ran the suite, reverted it.

@n-romanovich

Copy link
Copy Markdown
Contributor Author

Thanks for the review!

@SlopTart

Copy link
Copy Markdown

Linux / AMD RDNA3 datapoint.

Merged state: head fa01b91 onto main 1ec4c98, clean merge.

Full suite, cargo test --workspace --release --no-fail-fast --target x86_64-pc-windows-gnu -- --test-threads=4: 706 passed, 10 failed, 41 ignored. Failures = the known Wine-lane set from my #42 rows plus #718 trio members and a hit of gpu_mirror_upload_follows_cpu_writes_and_later_mapping_changes (new flake, see #718 addendum). XMemIsToolsMemAvailable green.

Not tested: retail titles (none here), Windows, RDNA4.
Counts only, no game data.

Machine: RX 7900 XT (RADV NAVI31), Mesa 26.2.5, kernel 7.2 (Arch), Proton Experimental (wine-11.0), patched vkd3d-proton v3.1, Rust cross x86_64-pc-windows-gnu, XCL_NETWORK=0, release profile, --test-threads=4. My Linux rows: #42 / #718.

AI use: Hermes agent (local Qwen-class) ran the suite and drafted this; I checked it before posting.

@upipibi upipibi mentioned this pull request Nov 24, 2026
gustavsi added a commit to gustavsi/xcl that referenced this pull request Nov 24, 2026
…cl-dev#864, xcl-dev#875-xcl-dev#876

Re-apply the 8 non-merged upstream PRs from our previous fork main onto upstream/main (930e8b4): xcl-dev#838 (upload-arena fills), xcl-dev#839 (queue-specific barrier layouts), xcl-dev#840 (coalesced shared descriptor heap), xcl-dev#841 (frame clock deadline reschedule), xcl-dev#851 (split before Wait64 GE after ordinary work), xcl-dev#864 (XMemIsToolsMemAvailable), xcl-dev#875 (tbuffer_load_format identity DST_SEL), and xcl-dev#876 (IDXGIDevice2::EnqueueSetEvent with create_raw_fence).

Assisted-by: Antigravity (Google DeepMind)
@throny

throny commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator

Two contributors checked independently and found that this PR makes the same change as #563: #1607, group D60. They suggest keeping #563. If you agree, closing this PR or joining the other one would save the maintainers a review. If the two differ in a way the checks missed, a note in #1607 helps.

This is a hint from the community triage in #1607, not a maintainer decision.

AI use: Claude Code (Claude Opus 5.5), posted by a script from the #1607 table.

@JJAutoCompare

Copy link
Copy Markdown

Empirical test report (fa01b91)

Verified xcl-dev/xcl PR #864 at fa01b911183db09a92c5cdda669b1ec5fbdc8e09 in a clean detached worktree.

Hardware / environment

  • Windows x64 build 26200 on an AMD CPU (family 23, model 113, stepping 0) with 12 logical processors.
  • Rust 1.100.0 (0ef1bc386 2026-11-09) and DXC 1.9.2609.5 (01b62ad47). Cargo used the unoptimized test profile with debug info and incremental compilation disabled.
  • The focused run set XCL_ADAPTER=NONE_CPU_ONLY and RUST_TEST_NOCAPTURE=1. Both commands ran outside Invoke-ArcTest.ps1 without acquiring the Arc GPU mutex.

Commands and results

  • cargo test --workspace --no-run built the workspace test executables and exited with code 0.
  • cargo test -p xcl --lib xmem_tools_mem_unavailable_on_retail -- --nocapture exited with code 0. The captured harness summary reported 1 passed, 0 failed, 0 ignored, and 693 filtered out. A case-sensitive scan found 0 SKIPPED lines.
  • Both commands emitted a deprecation warning for AtomicU32::fetch_update in xgameruntime.

Observed behavior

The targeted test called XMemIsToolsMemAvailable() directly and verified that it returned 0 (FALSE). The function and test use no D3D12 or GPU calls.

Not tested

The full GPU workspace suite and game smoke runs were omitted. Title import resolution and startup were outside the scope of the direct unit test.

AI use

Verified with T3 Code / Codex (gpt-6.2-sol, reasoningEffort: high). Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified counts against pr864-focused.log and published.

On retail consoles, devkit / tooling memory is not available, and XMemIsToolsMemAvailable answers FALSE (0). Retail game executables import this from xmem.dll to verify memory status during startup; without an HLE export, XCL fell back to an unresolved stub.

Unit test covers the return value.
@n-romanovich
n-romanovich force-pushed the kernelx/xmem-tools-mem branch from fa01b91 to c371d6e Compare November 25, 2026 06:44
@DavidM1911

Copy link
Copy Markdown
Contributor

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

Thanks!

rootw0rm pushed a commit to rootw0rm/xcl that referenced this pull request Nov 26, 2026
…dev#1235, kernelx twin)

Windows hle/kernelx.rs hunks verbatim reference-only (cfg(windows)-only):
win_module_handle helper, module_handle_impl -> module_handle_in_ex,
module_handle_in cfg(test) shim, PIN/UNCHANGED_REFCOUNT consts,
unknown-bit + PIN|UNCHANGED combo guard, FROM_ADDRESS/null/name legs
via the helper, plus the refcount/flags test.

Linux twin hle/kernelx_linux.rs gets flag-validation only (win64 ABI
untouched, upstream guard order): unknown bits or PIN|UNCHANGED_REFCOUNT
-> *out=0 + ERROR_INVALID_PARAMETER. The refcount-bump half has no Linux
hook point (resolver_linux::system_module is a stub returning None), so
only validation ports. New Linux-shaped twin test covers the invalid
combo + unknown bit (FAILED pre-fix, green post-fix) plus a valid-name
control.

Triage-close xcl-dev#864 as already landed with citation, no code: export at
hle/kernelx.rs:61, impl at :876 returns 0, test at :3077, resolver pin
at resolver.rs:503.

Gates: both cargo checks 0 errors; lib 686/0/1 (+1); diff --check clean;
title fresh-root 12 GPU-only; retail SIGSEGV +0x2237320 HOLDS.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants