Repository navigation
Conversation
XMemGetPhysicalMemoryLayout was auto-stubbed, so a title that queries the split between standard- and GPU-optimal-bandwidth physical memory got no answer. Export it and fill XMEM_PHYSICAL_MEMORY_LAYOUT: both page numbers are 0 -- one pool with no bandwidth split on the PC, matching the single fast-memory pool XMemGetWorkingSetStatistics already reports. Returns FALSE with ERROR_INVALID_PARAMETER on a null layout. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
merge-check AI-written and posted by Foniass without a human check of each point. |
|
No open or merged PR adds AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human. |
bmjask
left a comment
There was a problem hiding this comment.
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.
| fnd::SetLastError(fnd::ERROR_INVALID_PARAMETER); | ||
| return 0; | ||
| } | ||
| (layout as *mut usize).write_unaligned(0); // LowestPageNumber |
There was a problem hiding this comment.
LowestPageNumber is reported as 0, but XCL's allocator never hands out page 0: page_number(index) = (index + 1) * FRAMES makes 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 checks page >= LowestPageNumber, is off by one 64 KiB page, and the unmap sentinel passes as a valid page. Deriving it from page_number(0) keeps it in step with the allocator.
| return 0; | ||
| } | ||
| (layout as *mut usize).write_unaligned(0); // LowestPageNumber | ||
| (layout.add(std::mem::size_of::<usize>()) as *mut usize).write_unaligned(0); // LowestPageNumberGpuOptimalBandwidth |
There was a problem hiding this comment.
Not 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.
| /// GPU-optimal-bandwidth regions; here it is one pool with no bandwidth split, so both are 0 – all | ||
| /// title memory counts as GPU-optimal from page 0, matching the single fast-memory pool | ||
| /// `XMemGetWorkingSetStatistics` reports. | ||
| pub unsafe extern "system" fn XMemGetPhysicalMemoryLayout(layout: *mut u8) -> BOOL { |
There was a problem hiding this comment.
Not 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 like TitleMemoryStatusT would at least pin the assumed layout.
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