From 0a5b6ad928806e920659a64f56e090a799dcf754 Mon Sep 17 00:00:00 2001 From: Eladash Date: Mon, 29 Jul 2019 00:45:38 +0300 Subject: [PATCH] Add missing EALIGN check for sys_mmapper_search_and_map --- rpcs3/Emu/Cell/lv2/sys_mmapper.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/rpcs3/Emu/Cell/lv2/sys_mmapper.cpp b/rpcs3/Emu/Cell/lv2/sys_mmapper.cpp index ac0513d363..adedb082c5 100644 --- a/rpcs3/Emu/Cell/lv2/sys_mmapper.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_mmapper.cpp @@ -346,14 +346,22 @@ error_code sys_mmapper_search_and_map(ppu_thread& ppu, u32 start_addr, u32 mem_i const auto area = vm::get(vm::any, start_addr); - if (!area || start_addr < 0x20000000 || start_addr >= 0xC0000000) + if (!area || start_addr != area->addr || start_addr < 0x20000000 || start_addr >= 0xC0000000) { return {CELL_EINVAL, start_addr}; } - const auto mem = idm::get(mem_id, [&](lv2_memory& mem) + const auto mem = idm::get(mem_id, [&](lv2_memory& mem) -> CellError { + const u32 page_alignment = area->flags & SYS_MEMORY_PAGE_SIZE_64K ? 0x10000 : 0x100000; + + if (mem.align < page_alignment) + { + return CELL_EALIGN; + } + mem.counter++; + return {}; }); if (!mem) @@ -361,6 +369,11 @@ error_code sys_mmapper_search_and_map(ppu_thread& ppu, u32 start_addr, u32 mem_i return CELL_ESRCH; } + if (mem.ret) + { + return mem.ret; + } + const u32 addr = area->alloc(mem->size, mem->align, &mem->shm, mem->align == 0x10000 ? SYS_MEMORY_PAGE_SIZE_64K : SYS_MEMORY_PAGE_SIZE_1M); if (!addr)