From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49779) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b09sP-0001md-RE for qemu-devel@nongnu.org; Tue, 10 May 2016 11:47:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b09sN-0008Up-FR for qemu-devel@nongnu.org; Tue, 10 May 2016 11:47:12 -0400 Received: from mail-lf0-x233.google.com ([2a00:1450:4010:c07::233]:35354) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b09sM-0008UO-JY for qemu-devel@nongnu.org; Tue, 10 May 2016 11:47:11 -0400 Received: by mail-lf0-x233.google.com with SMTP id j8so19607769lfd.2 for ; Tue, 10 May 2016 08:47:10 -0700 (PDT) From: Sergey Fedorov Date: Tue, 10 May 2016 18:46:41 +0300 Message-Id: <1462895205-8411-2-git-send-email-sergey.fedorov@linaro.org> In-Reply-To: <1462895205-8411-1-git-send-email-sergey.fedorov@linaro.org> References: <1462895205-8411-1-git-send-email-sergey.fedorov@linaro.org> Subject: [Qemu-devel] [PATCH 1/5] cpu-exec: Move halt handling out of cpu_exec() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Sergey Fedorov , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Sergey Fedorov , Paolo Bonzini , Peter Crosthwaite , Richard Henderson From: Sergey Fedorov Simplify cpu_exec() by extracting CPU halt state handling code out of cpu_exec() into a new static inline function cpu_handle_halt(). Signed-off-by: Sergey Fedorov Signed-off-by: Sergey Fedorov --- cpu-exec.c | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/cpu-exec.c b/cpu-exec.c index d55faa5114c7..fb72f102742c 100644 --- a/cpu-exec.c +++ b/cpu-exec.c @@ -352,6 +352,29 @@ static inline TranslationBlock *tb_find_fast(CPUState *cpu, return tb; } +static inline bool cpu_handle_halt(CPUState *cpu) +{ + if (cpu->halted) { +#if defined(TARGET_I386) && !defined(CONFIG_USER_ONLY) + X86CPU *x86_cpu = X86_CPU(cpu); + + if ((cpu->interrupt_request & CPU_INTERRUPT_POLL) + && replay_interrupt()) { + apic_poll_irq(x86_cpu->apic_state); + cpu_reset_interrupt(cpu, CPU_INTERRUPT_POLL); + } +#endif + if (!cpu_has_work(cpu)) { + current_cpu = NULL; + return true; + } + + cpu->halted = 0; + } + + return false; +} + static void cpu_handle_debug_exception(CPUState *cpu) { CPUClass *cc = CPU_GET_CLASS(cpu); @@ -383,20 +406,8 @@ int cpu_exec(CPUState *cpu) /* replay_interrupt may need current_cpu */ current_cpu = cpu; - if (cpu->halted) { -#if defined(TARGET_I386) && !defined(CONFIG_USER_ONLY) - if ((cpu->interrupt_request & CPU_INTERRUPT_POLL) - && replay_interrupt()) { - apic_poll_irq(x86_cpu->apic_state); - cpu_reset_interrupt(cpu, CPU_INTERRUPT_POLL); - } -#endif - if (!cpu_has_work(cpu)) { - current_cpu = NULL; - return EXCP_HALTED; - } - - cpu->halted = 0; + if (cpu_handle_halt(cpu)) { + return EXCP_HALTED; } atomic_mb_set(&tcg_current_cpu, cpu); -- 1.9.1