From b238eb21256ad7f90d5ceb378fec8ef242cd06c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sat, 31 Oct 2026 11:39:19 +0100 Subject: [PATCH] sceKernelCreateLwMutex: Reject a misaligned work area A 6.60 PSP returns SCE_KERNEL_ERROR_ILLEGAL_ADDR for one (checked with a throwaway test; the other bad addresses hang the PSP, so they can't go in pspautotests). Co-Authored-By: Claude Opus 5.5 --- Core/HLE/sceKernelMutex.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Core/HLE/sceKernelMutex.cpp b/Core/HLE/sceKernelMutex.cpp index 3a1c882bc5..508d2ba2c0 100644 --- a/Core/HLE/sceKernelMutex.cpp +++ b/Core/HLE/sceKernelMutex.cpp @@ -609,6 +609,11 @@ int sceKernelCreateLwMutex(MIPSState *mips, u32 workareaPtr, const char *name, u return hleLogError(Log::sceKernel, SCE_KERNEL_ERROR_ILLEGAL_COUNT); } + // A PSP rejects a misaligned work area. One it can't access hangs it instead, so for those the + // error is our choice. + if ((workareaPtr & 3) != 0) { + return hleLogError(Log::sceKernel, SCE_KERNEL_ERROR_ILLEGAL_ADDR, "misaligned workarea"); + } auto workarea = PSPPointer::Create(workareaPtr); if (!workarea.IsValid()) { return hleLogError(Log::sceKernel, SCE_KERNEL_ERROR_ILLEGAL_ADDR, "bad workarea");