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
12 changes: 10 additions & 2 deletions core/libs/prx/libSceAgcDriver/tests/GcnColorTarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,20 @@ std::byte* LowMemory(std::size_t bytes) {
#else
#ifdef ANYPS5_ENABLE_ASAN
constexpr std::uintptr_t FirstHint = 0x60000000;
constexpr std::uintptr_t MinimumStride = std::uintptr_t{1} << 12u;
#else
constexpr std::uintptr_t FirstHint = std::uintptr_t{1} << 32u;
constexpr std::uintptr_t MinimumStride = std::uintptr_t{1} << 32u;
#endif
for (std::uintptr_t hint = FirstHint; hint < (std::uintptr_t{1} << 40u); hint += std::uintptr_t{1} << 32u) {
const std::uintptr_t rounded = (bytes + 0xfffu) & ~std::uintptr_t{0xfffu};
const std::uintptr_t stride = rounded < MinimumStride ? MinimumStride : rounded;
static std::uintptr_t next = FirstHint;
for (std::uintptr_t hint = next; hint < (std::uintptr_t{1} << 40u); hint += stride) {
void* mapped = mmap(reinterpret_cast<void*>(hint), bytes, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED_NOREPLACE, -1, 0);
if (mapped != MAP_FAILED) return static_cast<std::byte*>(mapped);
if (mapped != MAP_FAILED) {
next = hint + stride;
return static_cast<std::byte*>(mapped);
}
}
return nullptr;
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,20 @@ class LowBlock {
#else
#ifdef ANYPS5_ENABLE_ASAN
constexpr std::uintptr_t FirstHint = 0x60000000;
constexpr std::uintptr_t MinimumStride = std::uintptr_t{1} << 12u;
#else
constexpr std::uintptr_t FirstHint = std::uintptr_t{1} << 32u;
constexpr std::uintptr_t MinimumStride = std::uintptr_t{1} << 32u;
#endif
for (std::uintptr_t hint = FirstHint; data == nullptr && hint < GcnAddressLimit; hint += std::uintptr_t{1} << 32u) {
const std::uintptr_t rounded = (BlockBytes + 0xfffu) & ~std::uintptr_t{0xfffu};
const std::uintptr_t stride = rounded < MinimumStride ? MinimumStride : rounded;
static std::uintptr_t next = FirstHint;
for (std::uintptr_t hint = next; data == nullptr && hint < GcnAddressLimit; hint += stride) {
void* mapped = mmap(reinterpret_cast<void*>(hint), BlockBytes, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED_NOREPLACE, -1, 0);
if (mapped != MAP_FAILED) data = static_cast<std::uint8_t*>(mapped);
if (mapped != MAP_FAILED) {
next = hint + stride;
data = static_cast<std::uint8_t*>(mapped);
}
}
if (data != nullptr && AgcDriver::GuestMemory::WriteWatched()) GuestWriteWatch::GuestWriteWatchRegister_nid_postfix(data, BlockBytes);
#endif
Expand Down
Loading