Fix block hooks being called twice after an early exit from execution. (#1194)

Ensure the TCG exit flag is cleared at the end of cpu_exec. This ensures
that subsequent calls are not polluted by the prior call to request an
early exit. The symptoms of the problem being addressed here are that
after a cpu_exit call triggered within a hook there may still be a
pending tcg_exit_req flag set. This then causes a block to start its
execution and then be aborted (from which point it'll continue because
there's no other condition to service). The start of the execution
causes the block hook to be called, no actual code to be run, and then
the block started again with another block hook call.

This change is discussed in ticket 1193:
    https://github.com/unicorn-engine/unicorn/issues/1193
This commit is contained in:
Charles Ferguson 2020-05-05 01:32:12 +01:00 committed by GitHub
parent 9fedbd96f4
commit b7e64f3c99
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -291,6 +291,9 @@ int cpu_exec(struct uc_struct *uc, CPUArchState *env) // qq
}
} /* for(;;) */
// Unicorn: Clear any TCG exit flag that might have been left set by exit requests
uc->current_cpu->tcg_exit_req = 0;
cc->cpu_exec_exit(cpu);
// Unicorn: flush JIT cache to because emulation might stop in