aboutsummaryrefslogtreecommitdiff
path: root/cpu-exec.c
diff options
context:
space:
mode:
authorSergey Fedorov <serge.fdrv@gmail.com>2016-05-11 13:21:47 +0300
committerRichard Henderson <rth@twiddle.net>2016-05-12 14:06:42 -1000
commit8b2d34e997371c9729a0f41e3cc624d4300bbe78 (patch)
tree3997b2e2c0d3d04a7b9797819cb3ef652adee6b0 /cpu-exec.c
parentc6f0d9f84c43ae973270df1a77482466558ee487 (diff)
downloadqemu-8b2d34e997371c9729a0f41e3cc624d4300bbe78.zip
qemu-8b2d34e997371c9729a0f41e3cc624d4300bbe78.tar.gz
qemu-8b2d34e997371c9729a0f41e3cc624d4300bbe78.tar.bz2
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(). Signed-off-by: Sergey Fedorov <serge.fdrv@gmail.com> Signed-off-by: Sergey Fedorov <sergey.fedorov@linaro.org> Reviewed-by: Richard Henderson <rth@twiddle.net> Message-Id: <1462962111-32237-2-git-send-email-sergey.fedorov@linaro.org> Signed-off-by: Richard Henderson <rth@twiddle.net>
Diffstat (limited to 'cpu-exec.c')
-rw-r--r--cpu-exec.c38
1 files changed, 24 insertions, 14 deletions
diff --git a/cpu-exec.c b/cpu-exec.c
index d55faa5..529cac2 100644
--- a/cpu-exec.c
+++ b/cpu-exec.c
@@ -352,6 +352,28 @@ 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)
+ if ((cpu->interrupt_request & CPU_INTERRUPT_POLL)
+ && replay_interrupt()) {
+ X86CPU *x86_cpu = X86_CPU(cpu);
+ 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 +405,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);