Skip to content

kernelx: preserve explicitly committed physical pages on unmap - #934

Open
Babyhamsta wants to merge 1 commit into
xcl-dev:mainfrom
Babyhamsta:kernelx/physical-unmap-content
Open

Babyhamsta wants to merge 1 commit into
xcl-dev:mainfrom
Babyhamsta:kernelx/physical-unmap-content

Conversation

@Babyhamsta

Copy link
Copy Markdown

A Windows VirtualAlloc commit can populate a lazy physical-page mapping without invoking XCL's lazy fault handler. Unmapping then discards the bytes as if the page were untouched.

What is in it

  • Preserve committed spans on unmap and leave reserved spans zero. If a committed span cannot be read, keep the mapping so the caller can restore access and retry. Added regressions for a full commit and disjoint 4 KiB commits.

Tested

  • Windows 11 build 26300, RTX 4070 driver 621.35, Intel i7-13700K, rustc 1.94.1. Debug tests and release smokes.
  • cargo test --workspace --offline --locked -- --test-threads=4 reported 718 passed, 0 failed, 41 ignored. Two of the reported passes printed SKIPPED for no wave64: gpu_geometry_wave32_prefix_count_over_a_mask and gpu_wave32_program_in_wave64_hardware.
  • Both preservation regressions failed with the runtime from main and passed on this head. The focused kernelx suite reported 27 passed, 0 failed, 1 ignored.

Regression run
Both clean builds ran the upstream smoke script offline for 60 seconds with fresh private data and separate cold DXIL caches. An earlier pair with copied saves hit the same startup breakpoint on both builds, so the fresh-profile pair below is the gate.

Main

xcl-smoke v1
commit: 09940bb87fa11bc394fd9e5de570c2b7cfd16323
gpu: NVIDIA GeForce RTX 4070
title: RetailTitle
seconds: 60
exit: 0x0
frames shown: 459 (PresentX 459)
presents per 2 s (last 3): 11 11 14
device removals: 0
crashes: 0
peak commit: 15345 MB

This PR

xcl-smoke v1
commit: 54ba01423ba0c19a24046c370841d31c0635b4f4
gpu: NVIDIA GeForce RTX 4070
title: RetailTitle
seconds: 60
exit: 0x0
frames shown: 546 (PresentX 546)
presents per 2 s (last 3): 27 24 25
device removals: 0
crashes: 0
peak commit: 15339 MB

Not tested

  • The retail smoke does not show whether the title exercised the specific external-commit path. AMD and Intel GPU runs were not performed.

AI use

  • Codex, GPT-6 (exact deployment identifier unavailable), implemented the fix and regression tests and assembled the report from the retained test and smoke outputs.

VirtualAlloc can populate a lazy mapping without entering the fault handler. Save the committed spans before releasing the mapping and keep reserved spans zero. Keep unreadable mappings intact so the caller can restore access and retry.
@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
715 passed; 0 failed; 41 ignored   (exit 0)

Two more passing tests than main: preserving explicitly committed physical pages on unmap is exercised and green.

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.

@SlopTart

Copy link
Copy Markdown

Heads-up: this branch no longer merges cleanly.

Rebuild today: pull/934/head onto current main hits a merge conflict (kernelx page-table code; main moved through the sparse/mapping work since the branch was cut). CI is Windows-only and stopped at the conflict, so nothing else covers it here. Untested until rebased; I can run it on RDNA3/Wine after that.

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.

@DavidM1911

Copy link
Copy Markdown
Contributor

Verification on RTX 3060 Ti (Windows 11): merge conflict with current main (crates/xcl/src/hle/kernelx.rs) — needs a rebase before it can be tested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

goal:world-load Bears on the retail title getting past world loading

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants