kernelx: report the physical memory layout (XMemGetPhysicalMemoryLayout) #3352
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3352"
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 illu0x on 2026-11-29T10:05:45Z.
Export
XMemGetPhysicalMemoryLayout, which was auto-stubbed. A title that queries the split between standard- and GPU-optimal-bandwidth physical memory (XMEM_PHYSICAL_MEMORY_LAYOUT) now gets an answer instead of a stub. XCL has one memory pool with no bandwidth split on the PC, so both page numbers are 0 — all title memory counts as GPU-optimal from page 0, matching the single fast-memory poolXMemGetWorkingSetStatisticsalready reports. A null layout returns FALSE withERROR_INVALID_PARAMETER.Part of #1833.
What is in it
kernelx: report the physical memory layout (XMemGetPhysicalMemoryLayout)— new export, implementation and unit test, incrates/xcl/src/hle/kernelx.rsTested
stable-x86_64-pc-windows-msvc, debug; GPU AMD Radeon RX 6600cargo test --workspace -- --test-threads=4: 2469 passed, 1 failed, 29 ignored, 0 SKIPPEDhle::kernelx::tests::physical_memory_layout_writes_both_page_numberspasses.gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1, is a pre-existing RDNA2-only wave32WaveReadLaneAtGPU/CPU mismatch (the documentedamd_reduced_seedsfamily, HANDOFF.md). It fails identically onmainwith this change stashed, and is unrelated to kernelx.Regression run
Both runs on one retail title (title id
b41e6560), AMD RX 6600, 60 s measured,XCL_PREPARE=0(pipelines built on demand; identical flags for both, so the comparison is fair):Head vs main: 1438 / 1501 frames = 96%, peak commit 18011 / 17206 MB = 105%, no device removal, no crash. The title does not call
XMemGetPhysicalMemoryLayout, so this is a no-regression check on the surrounding runtime rather than a test of the new path.Not tested
AI use
🤖 Generated with Claude Code
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T09:37:37Z.
merge-check
base:
7d86c5d2b7head:
e5776a9a7emerge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2897 passed, 0 failed, 51 ignored; SKIPPED: 28 (20 no wave64, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 1 no heap windows, 1 cannot disable the driver cache, 3 others; the same set as on main); failing: none
review: read the whole diff (+30).
XMemGetPhysicalMemoryLayoutis added as an export; main has no export of that name, so today it falls through to an auto-stub. Findings: (1)LowestPageNumberis written as 0 (kernelx.rs~1654), but XCL never hands out page 0. Page numbers count 4 KiB frames and the first title page ispage_number(0)= 16 (kernelx.rs~1919-1926 on main), while 0 means "no page" and is what the scatter-map path treats as unmap. A title that offsets from the lowest page would be off by 16 frames.page_number(0)(FRAMES) is the consistent value. Writing 0 for the GPU-optimal boundary is harmless: every page counts as fast. (2) Nits: the test comment at ~3259 says "0xCC..-filled", but the buffer holdsusize::MAX. The doc comment says it matches the "single fast-memory pool"XMemGetWorkingSetStatisticsreports, but that function reports a limit and usage, not pools. Fine: the export is registered inhle_exports!like the others, a null pointer getsERROR_INVALID_PARAMETERand FALSE as in the neighbouringXMem*calls, and the test checks the write, a guard word and null. The PR's red CI is the pipeline-library flake that #3221 (2c003dd6) fixed on main. It replaces #3316 (closed). No smoke run here: the retail title doesn't call it.performance: no smoke run (the default path doesn't reach this change); not measured.
verdict: not yet:
LowestPageNumbershould bepage_number(0)(16), the first page XCL hands out, not 0, which XCL uses for "no page" (finding 1)hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5
AI-written and posted by Foniass without a human check of each point.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T09:50:46Z.
Triage (#1607) – head
e5776a9No open or merged PR adds
XMemGetPhysicalMemoryLayout. #3316 carried the same commit and was closed by the same author, so this PR replaces it. The export writes both page numbers as 0 and fails a null pointer with ERROR_INVALID_PARAMETER, and the test checks that nothing is written past the two fields. Minor: the test comment says "0xCC..-filled", but the buffer is filled withusize::MAX. No other problems found in the diff.Recommendation: keep open.
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T01:41:29Z.
Code review location:
crates/xcl/src/hle/kernelx.rs; line 1654LowestPageNumber is reported as 0, but XCL's allocator never hands out page 0:
page_number(index) = (index + 1) * FRAMESmakes the first title page 16, and the module says "0 means no page" (it's the unmap value in XMemMapPhysicalPagesScatter). A title that indexes its page table with(page - LowestPageNumber) / 16, or checkspage >= LowestPageNumber, is off by one 64 KiB page, and the unmap sentinel passes as a valid page. Deriving it frompage_number(0)keeps it in step with the allocator.Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T01:41:29Z.
Code review location:
crates/xcl/src/hle/kernelx.rs; line 1655Not certain about this one: with both fields equal, the standard-bandwidth region is empty (GpuOptimal - Lowest = 0), which no real console reports, since Series X and S both have a non-empty standard region. A title that splits its budget from
LowestPageNumberGpuOptimalBandwidth - LowestPageNumber, or asserts the standard region is non-empty, gets a 0-byte pool and fails its own allocation or breakpoint. Before this PR the stub's failure return at least let such titles fall back.Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T01:41:29Z.
Code review location:
crates/xcl/src/hle/kernelx.rs; line 1649Not certain about this one: the XMEM_PHYSICAL_MEMORY_LAYOUT layout (exactly two ULONG_PTR fields, no size/version field) is assumed and written through an untyped
*mut u8, with no cited source, and no title has been seen calling it. If the real struct has more fields or a leading size/version, the title reads uninitialised stack for them after a TRUE return, which is worse than the old failure return. A#[repr(C)]struct likeTitleMemoryStatusTwould at least pin the assumed layout.Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T01:41:29Z.
Review: COMMENTED
Review of
e5776a9a: 3 finding(s). 3 are inline.These findings come from an AI-assisted review (Claude Code) and focus on correctness. Each is a candidate; please check it before acting on it.
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.