Skip to content

[upstream #1143] kernelx: require contiguous physical pages to share one allocation - #19

Closed
ufoptg wants to merge 1 commit into
mainfrom
upstream-pr/1143
Closed

ufoptg wants to merge 1 commit into
mainfrom
upstream-pr/1143

Conversation

@ufoptg

@ufoptg ufoptg commented Nov 24, 2026

Copy link
Copy Markdown
Owner

AllocateTitlePhysicalPages assigns consecutive page numbers from a global counter (NEXT_PAGE_INDEX) even across separate allocations whose home blocks are not adjacent in virtual memory (e.g. separated by another UMA allocation or falling back to plain memory). map_pages only checked that page numbers were consecutive and that pages[n - 1] had a home, so MapTitlePhysicalPages(NULL, ...) on pages spanning two separate allocations committed and returned [H1, H1 + n * PHYS_PAGE), overlapping unrelated memory next to the first block.

This adds contiguous_home_in / contiguous_home to require that all consecutive pages belong to one live PHYS_BLOCKS entry (using checked arithmetic) before treating them as a single contiguous home block.

What is in it

  • crates/xcl/src/hle/kernelx.rs: add contiguous_home_in / contiguous_home and use it in map_pages; add consecutive_pages_from_separate_allocations_do_not_map_as_one_home (reproduces the bug before the fix and verifies NULL + ERROR_NOT_SUPPORTED after) and contiguous_home_requires_one_allocation.

Tested

  • hardware (GPU + driver, CPU), Windows build, Rust version, debug / release: NVIDIA GeForce RTX 5080 (driver 32.0.16.1088), AMD Ryzen 9 9950X3D, Windows 11 10.0.26300, Rust 1.100.0 (stable-x86_64-pc-windows-msvc), DXC 1.9.2609.5, debug (scripts/test.ps1) and release (scripts/smoke.ps1)
  • .\scripts\test.ps1 (cargo build --workspace + cargo test --workspace -- --test-threads=4): 743 passed, 0 failed, 41 ignored (SKIPPED GPU tests: 2 no wave64 — gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask, gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware)
  • cargo test -p xcl --lib consecutive_pages_from_separate_allocations_do_not_map_as_one_home and contiguous_home_requires_one_allocation: both pass (first verified failing before the fix)

Regression run

main:

xcl-smoke v1
commit: 47efa2ecea0a12934719ae69b81930cf02a4b1c3
gpu: NVIDIA GeForce RTX 5080
title: GTA6.Xbox.v1.0.2.1
seconds: 60
exit: 0x0
frames shown: 1226 (PresentX 1226)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15341 MB

PR:

xcl-smoke v1
commit: 81d047a0b1fda6a29333a8addcd863143dae6160
gpu: NVIDIA GeForce RTX 5080
title: GTA6.Xbox.v1.0.2.1
seconds: 60
exit: 0x0
frames shown: 1643 (PresentX 1643)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14576 MB

Not tested

  • AMD GPUs and native wave64 hardware
  • other titles (Minecraft Preview, Unicorn Overlord, Fortnite, XDefiant) and Linux / Wine

AI use

  • OpenCode, Gemini 4 Neon: audited kernelx.rs, wrote the fix and regression tests, ran the test suite and scripts/smoke.ps1 regression runs, and drafted this PR description.

Mirror of xcl-dev#1143 (auto-synced, do not edit).

AllocateTitlePhysicalPages assigns consecutive page numbers from a
global counter (NEXT_PAGE_INDEX) even across separate allocations whose
home blocks are not adjacent in virtual memory. map_pages only checked
that page numbers were consecutive and that the last page had a home,
so MapTitlePhysicalPages(NULL, ...) on pages from two separate
allocations committed and returned the first block's home over
unrelated memory next to it.

Check that all pages in the slice fall within one live PHYS_BLOCKS
entry (contiguous_home) with checked arithmetic before treating them as
a single contiguous home block.

Assisted-by: OpenCode (Gemini 4 Neon)
@ufoptg

ufoptg commented Nov 25, 2026

Copy link
Copy Markdown
Owner Author

Upstream PR xcl-dev#1143 was closed or merged.

@ufoptg ufoptg closed this Nov 25, 2026
@ufoptg
ufoptg deleted the upstream-pr/1143 branch November 25, 2026 00:14
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.

2 participants