From 49717b10891b8fad44b6d4e3a7a37d6b5b7d6766 Mon Sep 17 00:00:00 2001 From: mailwl Date: Tue, 8 Jul 2025 10:45:12 +0300 Subject: [PATCH 1/3] Log memory alloc on error --- src/core/libraries/kernel/memory.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/core/libraries/kernel/memory.cpp b/src/core/libraries/kernel/memory.cpp index e0c359f2c..b412327e8 100644 --- a/src/core/libraries/kernel/memory.cpp +++ b/src/core/libraries/kernel/memory.cpp @@ -57,17 +57,17 @@ s32 PS4_SYSV_ABI sceKernelAllocateDirectMemory(s64 searchStart, s64 searchEnd, u auto* memory = Core::Memory::Instance(); PAddr phys_addr = memory->Allocate(searchStart, searchEnd, len, alignment, memoryType); - if (phys_addr == -1) { - return ORBIS_KERNEL_ERROR_EAGAIN; - } - - *physAddrOut = static_cast(phys_addr); LOG_INFO(Kernel_Vmm, "searchStart = {:#x}, searchEnd = {:#x}, len = {:#x}, " "alignment = {:#x}, memoryType = {:#x}, physAddrOut = {:#x}", searchStart, searchEnd, len, alignment, memoryType, phys_addr); + if (phys_addr == -1) { + return ORBIS_KERNEL_ERROR_EAGAIN; + } + + *physAddrOut = static_cast(phys_addr); return ORBIS_OK; } From 3f92436a557d8e254d844b0c6e48e0b14a9e054c Mon Sep 17 00:00:00 2001 From: mailwl Date: Tue, 8 Jul 2025 10:51:12 +0300 Subject: [PATCH 2/3] clang-format --- src/core/libraries/kernel/memory.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/libraries/kernel/memory.cpp b/src/core/libraries/kernel/memory.cpp index b412327e8..45cd71266 100644 --- a/src/core/libraries/kernel/memory.cpp +++ b/src/core/libraries/kernel/memory.cpp @@ -66,7 +66,7 @@ s32 PS4_SYSV_ABI sceKernelAllocateDirectMemory(s64 searchStart, s64 searchEnd, u if (phys_addr == -1) { return ORBIS_KERNEL_ERROR_EAGAIN; } - + *physAddrOut = static_cast(phys_addr); return ORBIS_OK; } From e565f998ba24ebf048000901eaa45a12ab6a7240 Mon Sep 17 00:00:00 2001 From: mailwl Date: Wed, 9 Jul 2025 00:50:22 +0300 Subject: [PATCH 3/3] add more info on allocate error --- src/core/memory.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/core/memory.cpp b/src/core/memory.cpp index 3d9bf58a7..dc55373d5 100644 --- a/src/core/memory.cpp +++ b/src/core/memory.cpp @@ -214,7 +214,10 @@ PAddr MemoryManager::Allocate(PAddr search_start, PAddr search_end, u64 size, u6 if (dmem_area == dmem_map.end()) { // There are no suitable mappings in this range - LOG_ERROR(Kernel_Vmm, "Unable to find free direct memory area: size = {:#x}", size); + auto exceed = mapping_end - search_end; + LOG_ERROR(Kernel_Vmm, + "Unable to find free direct memory area: size = {:#x}, exceed = {:#x}", size, + exceed); return -1; }