From 9bb409314d307024899c7e41d1b4980ca73bb588 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Wed, 18 Oct 2023 10:43:36 +0200 Subject: [PATCH] coreinit: Fix potential race condition in IPC code --- src/Cafe/IOSU/kernel/iosu_kernel.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Cafe/IOSU/kernel/iosu_kernel.cpp b/src/Cafe/IOSU/kernel/iosu_kernel.cpp index 52097698..666e0373 100644 --- a/src/Cafe/IOSU/kernel/iosu_kernel.cpp +++ b/src/Cafe/IOSU/kernel/iosu_kernel.cpp @@ -578,8 +578,12 @@ namespace iosu return r; } + std::mutex sMtxReply[3]; + void _IPCReplyAndRelease(IOSDispatchableCommand* dispatchCmd, uint32 result) { + cemu_assert(dispatchCmd->ppcCoreIndex < 3); + std::unique_lock _l(sMtxReply[(uint32)dispatchCmd->ppcCoreIndex]); cemu_assert(dispatchCmd >= sIPCDispatchableCommandPool.GetPtr() && dispatchCmd < sIPCDispatchableCommandPool.GetPtr() + sIPCDispatchableCommandPool.GetCount()); dispatchCmd->originalBody->result = result; // submit to COS