diff --git a/Utilities/JIT.cpp b/Utilities/JIT.cpp index 844b4ec7a5..994dae2a3c 100644 --- a/Utilities/JIT.cpp +++ b/Utilities/JIT.cpp @@ -207,9 +207,9 @@ struct MemoryManager final : llvm::RTDyldMemoryManager LOG_FATAL(GENERAL, "VirtualFree(%p) failed! Error %u", s_memory, GetLastError()); } #else - if (::mprotect(s_memory, s_memory_size, PROT_NONE)) + if (!::mmap(s_memory, s_memory_size, PROT_NONE, MAP_FIXED | MAP_ANON | MAP_PRIVATE, -1, 0)) { - LOG_FATAL(GENERAL, "mprotect(%p) failed! Error %d", s_memory, errno); + LOG_FATAL(GENERAL, "mmap(%p) failed! Error %d", s_memory, errno); } // TODO: unregister EH frames if necessary diff --git a/Utilities/VirtualMemory.cpp b/Utilities/VirtualMemory.cpp index 7527d3b4dd..f3f81ae734 100644 --- a/Utilities/VirtualMemory.cpp +++ b/Utilities/VirtualMemory.cpp @@ -13,7 +13,7 @@ namespace memory_helper { - void* reserve_memory(size_t size) + void* reserve_memory(std::size_t size) { #ifdef _WIN32 return verify("reserve_memory" HERE, VirtualAlloc(NULL, size, MEM_RESERVE, PAGE_NOACCESS)); @@ -22,21 +22,21 @@ namespace memory_helper #endif } - void commit_page_memory(void* pointer, size_t size) + void commit_page_memory(void* pointer, std::size_t size) { #ifdef _WIN32 verify(HERE), VirtualAlloc(pointer, size, MEM_COMMIT, PAGE_READWRITE); #else - verify(HERE), ::mprotect((void*)((u64)pointer & -4096), size, PROT_READ | PROT_WRITE) != -1; + verify(HERE), ::mprotect((void*)((u64)pointer & -4096), ::align(size, 4096), PROT_READ | PROT_WRITE) != -1; #endif } - void free_reserved_memory(void* pointer, size_t size) + void free_reserved_memory(void* pointer, std::size_t size) { #ifdef _WIN32 verify(HERE), VirtualFree(pointer, 0, MEM_DECOMMIT); #else - verify(HERE), ::mprotect(pointer, size, PROT_NONE) != -1; + verify(HERE), ::mmap(pointer, size, PROT_NONE, MAP_FIXED | MAP_ANON | MAP_PRIVATE, -1, 0); #endif } } diff --git a/rpcs3/Emu/Cell/PPUThread.cpp b/rpcs3/Emu/Cell/PPUThread.cpp index be3431671b..030b19cebb 100644 --- a/rpcs3/Emu/Cell/PPUThread.cpp +++ b/rpcs3/Emu/Cell/PPUThread.cpp @@ -73,6 +73,11 @@ extern void ppu_execute_function(ppu_thread& ppu, u32 index); const auto s_ppu_compiled = static_cast(memory_helper::reserve_memory(0x100000000)); +extern void ppu_finalize() +{ + memory_helper::free_reserved_memory(s_ppu_compiled, 0x100000000); +} + // Get interpreter cache value static u32 ppu_cache(u32 addr) { diff --git a/rpcs3/Emu/System.cpp b/rpcs3/Emu/System.cpp index d5154a28a5..b826314cee 100644 --- a/rpcs3/Emu/System.cpp +++ b/rpcs3/Emu/System.cpp @@ -50,6 +50,7 @@ extern void ppu_load_exec(const ppu_exec_object&); extern void spu_load_exec(const spu_exec_object&); extern void arm_load_exec(const arm_exec_object&); extern std::shared_ptr ppu_load_prx(const ppu_prx_object&); +extern void ppu_finalize(); fs::file g_tty; @@ -460,6 +461,7 @@ void Emulator::Stop() RSXIOMem.Clear(); vm::close(); + ppu_finalize(); if (g_cfg_autoexit) { diff --git a/rpcs3/Gui/InterpreterDisAsm.cpp b/rpcs3/Gui/InterpreterDisAsm.cpp index f77a0f84e6..23209c566d 100644 --- a/rpcs3/Gui/InterpreterDisAsm.cpp +++ b/rpcs3/Gui/InterpreterDisAsm.cpp @@ -424,7 +424,7 @@ void InterpreterDisAsmFrame::DoRun(wxCommandEvent& WXUNUSED(event)) if (cpu && cpu->state.test_and_reset(cpu_flag::dbg_pause)) { - if (!test(cpu->state, cpu_state_pause)) + if (!test(cpu->state, cpu_flag::dbg_pause + cpu_flag::dbg_global_pause)) { cpu->notify(); }