Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/libs/prx/libkernel/DirectMemory/DirectMemory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -918,7 +918,7 @@ int DoReserveVirtual(void** addr, size_t len, int flags, size_t alignment) {
}
if (fixed) mutation.RequireAvailable(*addr, len);
constexpr int GuestMapNoCoalesce = 0x400000;
void* mapped = MapAligned(fixed ? *addr : nullptr, len, PROT_NONE, fixed ? GuestMapFixedFlag | (flags & GuestMapNoCoalesce) : 0, alignment);
void* mapped = MapAligned(*addr, len, PROT_NONE, fixed ? GuestMapFixedFlag | (flags & GuestMapNoCoalesce) : 0, alignment);
try {
mutation.Add(mapped, len, false, false, false);
} catch (...) {
Expand Down
17 changes: 17 additions & 0 deletions core/libs/tests/GuestMemory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,22 @@ static void CheckGpuAccessFollowsProtection() {
Require(sceKernelMunmap(flexible, page) == 0);
}

static void CheckHintedVirtualReservation() {
constexpr std::size_t page = 0x4000;
void* probe = nullptr;
Require(sceKernelReserveVirtualRange(&probe, page * 8, 0, 0) == 0);
Require(sceKernelMunmap(probe, page * 8) == 0);
void* const hint = static_cast<unsigned char*>(probe) + page * 2;
void* placed = hint;
Require(sceKernelReserveVirtualRange(&placed, page * 2, 0, 0) == 0);
Require(placed == hint);
void* above = hint;
Require(sceKernelReserveVirtualRange(&above, page * 2, 0, 0) == 0);
Require(above > hint);
Require(sceKernelMunmap(above, page * 2) == 0);
Require(sceKernelMunmap(placed, page * 2) == 0);
}

static void CheckFixedVirtualReservation() {
constexpr std::size_t page = 0x4000;
void* probe = nullptr;
Expand Down Expand Up @@ -1526,6 +1542,7 @@ int main() {
CheckFixedMappingReplacesPartialOverlap();
CheckDirectMemoryGpuProtBits();
CheckGpuAccessFollowsProtection();
CheckHintedVirtualReservation();
CheckFixedVirtualReservation();
CheckReservedRangeIsNotCommitted();
CheckNoOverwriteRefusesLiveMapping();
Expand Down
Loading