SPU: Detect invalid STOP codes (code mining)

This commit is contained in:
Eladash 2024-03-07 16:22:32 +02:00 committed by Elad.Ash
parent 069ca214ff
commit 2930d609ea

View file

@ -4144,9 +4144,32 @@ bool spu_thread::is_exec_code(u32 addr, std::span<const u8> ls_ptr, u32 base_add
return false;
}
if (type == spu_itype::STOP && op.rb)
if (type == spu_itype::STOP)
{
return false;
if (op.rb)
{
return false;
}
if (avoid_dead_code)
{
switch (op.opcode)
{
case SYS_SPU_THREAD_STOP_YIELD:
case SYS_SPU_THREAD_STOP_GROUP_EXIT:
case SYS_SPU_THREAD_STOP_THREAD_EXIT:
case SYS_SPU_THREAD_STOP_RECEIVE_EVENT:
case SYS_SPU_THREAD_STOP_TRY_RECEIVE_EVENT:
case SYS_SPU_THREAD_STOP_SWITCH_SYSTEM_MODULE:
{
break;
}
default:
{
return false;
}
}
}
}
if (type & spu_itype::branch)
@ -6105,6 +6128,12 @@ bool spu_thread::stop_and_signal(u32 code)
return true;
}
case SYS_SPU_THREAD_STOP_SWITCH_SYSTEM_MODULE:
{
fmt::throw_exception("SYS_SPU_THREAD_STOP_SWITCH_SYSTEM_MODULE (op=0x%x, Out_MBox=%s)", code, _ref<u32>(pc), ch_out_mbox);
return true;
}
case SYS_SPU_THREAD_STOP_YIELD:
{
// SPU thread group yield (TODO)