From 36bede11ae03cf2ed23246fef3c02a2afd17bc58 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Sun, 11 Oct 2020 15:04:49 +1000 Subject: [PATCH] CPU/Recompiler/AArch64: Fix crash when icache is enabled --- src/core/cpu_recompiler_code_generator_generic.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/core/cpu_recompiler_code_generator_generic.cpp b/src/core/cpu_recompiler_code_generator_generic.cpp index 0acd1559f..60344d650 100644 --- a/src/core/cpu_recompiler_code_generator_generic.cpp +++ b/src/core/cpu_recompiler_code_generator_generic.cpp @@ -35,8 +35,9 @@ void CodeGenerator::EmitICacheCheckAndUpdate() LabelType is_cached; LabelType ready_to_execute; EmitConditionalBranch(Condition::LessEqual, false, temp.GetHostRegister(), Value::FromConstantU32(4), &is_cached); - EmitAddCPUStructField(offsetof(State, pending_ticks), - Value::FromConstantU32(static_cast(m_block->uncached_fetch_ticks))); + EmitLoadCPUStructField(temp.host_reg, RegSize_32, offsetof(State, pending_ticks)); + EmitAdd(temp.host_reg, temp.host_reg, Value::FromConstantU32(static_cast(m_block->uncached_fetch_ticks)), false); + EmitStoreCPUStructField(offsetof(State, pending_ticks), temp); EmitBranch(&ready_to_execute); EmitBindLabel(&is_cached); @@ -55,8 +56,10 @@ void CodeGenerator::EmitICacheCheckAndUpdate() EmitLoadCPUStructField(temp.GetHostRegister(), RegSize_32, offset); EmitConditionalBranch(Condition::Equal, false, temp.GetHostRegister(), pc, &cache_hit); - EmitAddCPUStructField(offsetof(State, pending_ticks), Value::FromConstantU32(static_cast(fill_ticks))); + EmitLoadCPUStructField(temp.host_reg, RegSize_32, offsetof(State, pending_ticks)); EmitStoreCPUStructField(offset, pc); + EmitAdd(temp.host_reg, temp.host_reg, Value::FromConstantU32(static_cast(fill_ticks)), false); + EmitStoreCPUStructField(offsetof(State, pending_ticks), temp); EmitBindLabel(&cache_hit); EmitAdd(pc.GetHostRegister(), pc.GetHostRegister(), Value::FromConstantU32(ICACHE_LINE_SIZE), false); }