upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/runtime/test/xmem_test.cpp
diff options
context:
space:
mode:
authorkurrutako <kurrutako@users.noreply.github.com>2026-11-25 18:02:47 +0100
committerkurrutako <kurrutako@users.noreply.github.com>2026-11-25 18:02:47 +0100
commitca00cc0e0338d27ff018f94d9a7e6e3da58abe7d (patch)
tree9d2d0b2b0e75d9e165826efc89df805ed9e4cb87 /runtime/test/xmem_test.cpp
parent9e7720c9e764211e0021aa23907d2d3ecd58963f (diff)
xmem: a slot-31 copy leaves the title's own mappings at the paired CPU range
copy_page_mappings (queue slot 31, CopyPageMappingsBatchX) mirrors every page it maps or unmaps at a GPU-only destination onto the paired CPU range (title_gpu_views::to_cpu). It did so even where the title had mapped that CPU page itself with XMemMapPhysicalPages or XMemMapPhysicalPagesScatter: a copy replaced the title's page, and an unmap (kind 2) left the title's CPU page reserved. The title's next read of it faulted, and the run ended. The console's CopyPageMappingsBatchX edits only the GPU-only range's page table, so a CPU page holding a mapping of the title's (physical, scatter or a slot-31 copy onto that address) is now left as it is. Pages the mirror made itself, zero plants and pages with no mapping still follow the GPU-only range, so the D3D12 layer's reads at the CPU view keep working. Each page kept is counted and the first ones are logged. The unmaps these paths make are now labelled in the read-fault report (CopyPageMappingsBatchX unmap / paired CPU page / remap / hole, XMemMapPhysicalPagesScatter unmap / remap) instead of the default "unmap". xmem_test: test_copy_page_mappings_cpu_view now checks that a copy onto, and an unmap of, a GPU-only page whose paired CPU page the title mapped keep the title's bytes at the CPU page. Both checks fail on the old code. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'runtime/test/xmem_test.cpp')
-rw-r--r--runtime/test/xmem_test.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/runtime/test/xmem_test.cpp b/runtime/test/xmem_test.cpp
index 991388c7f..58143ae49 100644
--- a/runtime/test/xmem_test.cpp
+++ b/runtime/test/xmem_test.cpp
@@ -741,7 +741,19 @@ void test_copy_page_mappings_cpu_view(const PhysicalApi& api) {
741 check(readable(other) && page_holds(other, 0x7300u), 741 check(readable(other) && page_holds(other, 0x7300u),
742 "a GPU-only source page unmapped there is looked up at its CPU range"); 742 "a GPU-only source page unmapped there is looked up at its CPU range");
743 743
744 // A null source unmaps both ranges. 744 // A CPU page the title mapped itself is the title's: a copy onto its GPU-only page, or an unmap of it, changes the
745 // GPU-only page alone (the console's CopyPageMappingsBatchX edits only that range's page table).
746 check(copy(gpu + 2 * kPage64k, pool + kPage64k, 1, false), "a copy onto a GPU-only page whose CPU page is the title's");
747 check(readable(gpu + 2 * kPage64k) && page_holds(gpu + 2 * kPage64k, 0x7301u),
748 "the GPU-only page shows the copied pool page");
749 check(readable(cpu + 2 * kPage64k) && page_holds(cpu + 2 * kPage64k, 0x7300u),
750 "the title's own mapping at the paired CPU page is kept, not replaced by the copy");
751 check(copy(gpu + 2 * kPage64k, nullptr, 1, false), "a null source unmaps a GPU-only page whose CPU page is the title's");
752 check(!readable(gpu + 2 * kPage64k), "the GPU-only page is unmapped");
753 check(readable(cpu + 2 * kPage64k) && page_holds(cpu + 2 * kPage64k, 0x7300u),
754 "the title's own mapping at the paired CPU page survives the unmap");
755
756 // A null source unmaps both ranges where the CPU pages are the copy's own.
745 check(copy(gpu, nullptr, kPool, false), "a null source unmaps the GPU-only range"); 757 check(copy(gpu, nullptr, kPool, false), "a null source unmaps the GPU-only range");
746 check(!readable(gpu) && !readable(cpu) && !readable(cpu + kPage64k), "the paired CPU range is unmapped with it"); 758 check(!readable(gpu) && !readable(cpu) && !readable(cpu + kPage64k), "the paired CPU range is unmapped with it");
747 759