From 88906b642c055e71ad17ebcd061c5a90be28fbe8 Mon Sep 17 00:00:00 2001 From: Merry Date: Tue, 15 Feb 2022 14:11:02 +0000 Subject: [PATCH] fuzz_arm: Handle unicorn overrun on internal jump --- tests/A32/fuzz_arm.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/A32/fuzz_arm.cpp b/tests/A32/fuzz_arm.cpp index 258353bf..a2654dd9 100644 --- a/tests/A32/fuzz_arm.cpp +++ b/tests/A32/fuzz_arm.cpp @@ -285,6 +285,7 @@ static void RunTestInstance(Dynarmic::A32::Jit& jit, const u32 initial_pc = regs[15]; const u32 num_words = initial_pc / sizeof(typename TestEnv::InstructionType); const u32 code_mem_size = num_words + static_cast(instructions.size()); + const u32 expected_end_pc = code_mem_size * sizeof(typename TestEnv::InstructionType); jit_env.code_mem.resize(code_mem_size); uni_env.code_mem.resize(code_mem_size); @@ -393,6 +394,14 @@ static void RunTestInstance(Dynarmic::A32::Jit& jit, uni.SetPC(new_uni_pc); } + if (uni.GetRegisters()[15] > jit.Regs()[15]) { + const u32 final_pc = jit.Regs()[15]; + if (final_pc >= initial_pc && final_pc < expected_end_pc) { + fmt::print("Warning: Possible unicorn overrrun, attempt recovery\n"); + jit.Step(); + } + } + REQUIRE(uni.GetRegisters() == jit.Regs()); REQUIRE(uni.GetExtRegs() == jit.ExtRegs()); REQUIRE((uni.GetCpsr() & 0xFFFFFDDF) == (jit.Cpsr() & 0xFFFFFDDF));