mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-10-10 01:28:44 +02:00
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 <noreply@anthropic.com>
This commit is contained in:
@@ -70,10 +70,11 @@ static void CheckDirectMemoryFollowsPhysicalPages() {
|
||||
Require(sceKernelMapDirectMemory(&first, page * 2, 3, 0, phys, 0) == 0);
|
||||
static_cast<unsigned char*>(first)[0] = 11;
|
||||
static_cast<unsigned char*>(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<unsigned char*>(alias)[5] == 22);
|
||||
Require(sceKernelMunmap(alias, page) == 0);
|
||||
static_cast<unsigned char*>(first)[page + 5] = 22;
|
||||
Require(sceKernelMunmap(first, page * 2) == 0);
|
||||
void* filler = nullptr;
|
||||
Require(sceKernelMapFlexibleMemory(&filler, page * 2, 3, 0) == 0);
|
||||
|
||||
Reference in New Issue
Block a user