cpu-exec: Move halt handling out of cpu_exec()

Simplify cpu_exec() by extracting CPU halt state handling code out of
cpu_exec() into a new static inline function cpu_handle_halt().

Backports commit 8b2d34e997371c9729a0f41e3cc624d4300bbe78 from qemu
This commit is contained in:
Sergey Fedorov 2018-02-23 23:53:15 -05:00 committed by Lioncash
parent 88d00a75ca
commit fc3d135dac
No known key found for this signature in database
GPG key ID: 4E3C3CC1031BA9C7

View file

@ -176,6 +176,19 @@ static inline TranslationBlock *tb_find_fast(CPUState *cpu,
return tb;
}
static inline bool cpu_handle_halt(CPUState *cpu)
{
if (cpu->halted) {
if (!cpu_has_work(cpu)) {
return true;
}
cpu->halted = 0;
}
return false;
}
static void cpu_handle_debug_exception(CPUState *cpu)
{
CPUClass *cc = CPU_GET_CLASS(cpu->uc, cpu);
@ -204,12 +217,8 @@ int cpu_exec(struct uc_struct *uc, CPUState *cpu)
int tb_exit = 0;
struct hook *hook;
if (cpu->halted) {
if (!cpu_has_work(cpu)) {
return EXCP_HALTED;
}
cpu->halted = 0;
if (cpu_handle_halt(cpu)) {
return EXCP_HALTED;
}
uc->current_cpu = cpu;