From 03465e769cf544dea1c0c97604845f59bcf672b2 Mon Sep 17 00:00:00 2001 From: STL1te Date: Tue, 29 Sep 2026 21:28:49 +0300 Subject: [PATCH] test(kernel): a second view of direct memory shares the page Since direct memory mapped at two addresses is shared read-only instead of refused, the guest memory test expected an exception that no longer comes. It now maps the second view, reads the first view's bytes through it, and writes through the first view once the second is gone, which faults unless its protection came back. Co-Authored-By: Claude Opus 5.5 --- core/libs/tests/GuestMemory.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/core/libs/tests/GuestMemory.cpp b/core/libs/tests/GuestMemory.cpp index 32cf4a341..4222fa2e5 100644 --- a/core/libs/tests/GuestMemory.cpp +++ b/core/libs/tests/GuestMemory.cpp @@ -70,10 +70,11 @@ static void CheckDirectMemoryFollowsPhysicalPages() { Require(sceKernelMapDirectMemory(&first, page * 2, 3, 0, phys, 0) == 0); static_cast(first)[0] = 11; static_cast(first)[page + 5] = 22; - bool aliased = false; void* alias = nullptr; - try { sceKernelMapDirectMemory(&alias, page, 3, 0, phys + page, 0); } catch (const std::exception&) { aliased = true; } - Require(aliased); + Require(sceKernelMapDirectMemory(&alias, page, 3, 0, phys + page, 0) == 0); + Require(alias != first && static_cast(alias)[5] == 22); + Require(sceKernelMunmap(alias, page) == 0); + static_cast(first)[page + 5] = 22; Require(sceKernelMunmap(first, page * 2) == 0); void* filler = nullptr; Require(sceKernelMapFlexibleMemory(&filler, page * 2, 3, 0) == 0);