fuzz_arm: Handle unicorn overrun on internal jump

This commit is contained in:
Merry 2022-02-15 14:11:02 +00:00
parent 8b3bef13dc
commit 88906b642c

View file

@ -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<u32>(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));