[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 15/23] cpu-exec: remove outermost infinite loop
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 15/23] cpu-exec: remove outermost infinite loop |
Date: |
Thu, 16 Feb 2017 15:31:39 +0100 |
Reorganize the sigsetjmp so that the restart case falls through
to cpu_handle_exception and the execution loop.
Signed-off-by: Paolo Bonzini <address@hidden>
---
cpu-exec.c | 58 +++++++++++++++++++++++++++-------------------------------
1 file changed, 27 insertions(+), 31 deletions(-)
diff --git a/cpu-exec.c b/cpu-exec.c
index 865015c..b8ebb5c 100644
--- a/cpu-exec.c
+++ b/cpu-exec.c
@@ -624,41 +624,37 @@ int cpu_exec(CPUState *cpu)
*/
init_delay_params(&sc, cpu);
- for(;;) {
- /* prepare setjmp context for exception handling */
- if (sigsetjmp(cpu->jmp_env, 0) == 0) {
- /* if an exception is pending, we execute it here */
- while (!cpu_handle_exception(cpu, &ret)) {
- TranslationBlock *last_tb = NULL;
- int tb_exit = 0;
-
- while (!cpu_handle_interrupt(cpu, &last_tb)) {
- TranslationBlock *tb = tb_find(cpu, last_tb, tb_exit);
- cpu_loop_exec_tb(cpu, tb, &last_tb, &tb_exit, &sc);
- /* Try to align the host and virtual clocks
- if the guest is in advance */
- align_clocks(&sc, cpu);
- }
- }
- break;
-
- } else {
+ /* prepare setjmp context for exception handling */
+ if (sigsetjmp(cpu->jmp_env, 0) != 0) {
#if defined(__clang__) || !QEMU_GNUC_PREREQ(4, 6)
- /* Some compilers wrongly smash all local variables after
- * siglongjmp. There were bug reports for gcc 4.5.0 and clang.
- * Reload essential local variables here for those compilers.
- * Newer versions of gcc would complain about this code
(-Wclobbered). */
- cpu = current_cpu;
- cc = CPU_GET_CLASS(cpu);
+ /* Some compilers wrongly smash all local variables after
+ * siglongjmp. There were bug reports for gcc 4.5.0 and clang.
+ * Reload essential local variables here for those compilers.
+ * Newer versions of gcc would complain about this code (-Wclobbered).
*/
+ cpu = current_cpu;
+ cc = CPU_GET_CLASS(cpu);
#else /* buggy compiler */
- /* Assert that the compiler does not smash local variables. */
- g_assert(cpu == current_cpu);
- g_assert(cc == CPU_GET_CLASS(cpu));
+ /* Assert that the compiler does not smash local variables. */
+ g_assert(cpu == current_cpu);
+ g_assert(cc == CPU_GET_CLASS(cpu));
#endif /* buggy compiler */
- cpu->can_do_io = 1;
- tb_lock_reset();
+ cpu->can_do_io = 1;
+ tb_lock_reset();
+ }
+
+ /* if an exception is pending, we execute it here */
+ while (!cpu_handle_exception(cpu, &ret)) {
+ TranslationBlock *last_tb = NULL;
+ int tb_exit = 0;
+
+ while (!cpu_handle_interrupt(cpu, &last_tb)) {
+ TranslationBlock *tb = tb_find(cpu, last_tb, tb_exit);
+ cpu_loop_exec_tb(cpu, tb, &last_tb, &tb_exit, &sc);
+ /* Try to align the host and virtual clocks
+ if the guest is in advance */
+ align_clocks(&sc, cpu);
}
- } /* for(;;) */
+ }
cc->cpu_exec_exit(cpu);
rcu_read_unlock();
--
1.8.3.1
- [Qemu-devel] [PULL 06/23] apic: reset apic_delivered global variable on machine reset, (continued)
- [Qemu-devel] [PULL 06/23] apic: reset apic_delivered global variable on machine reset, Paolo Bonzini, 2017/02/16
- [Qemu-devel] [PULL 07/23] char: drop data written to a disconnected pty, Paolo Bonzini, 2017/02/16
- [Qemu-devel] [PULL 09/23] gdbstub: Fix vCont behaviour, Paolo Bonzini, 2017/02/16
- [Qemu-devel] [PULL 08/23] move vm_start to cpus.c, Paolo Bonzini, 2017/02/16
- [Qemu-devel] [PULL 10/23] hw/char/mcf_uart: QOMify the ColdFire UART, Paolo Bonzini, 2017/02/16
- [Qemu-devel] [PULL 11/23] cpu-exec: fix icount out-of-bounds access, Paolo Bonzini, 2017/02/16
- [Qemu-devel] [PULL 13/23] cpu-exec: avoid cpu_loop_exit in cpu_handle_interrupt, Paolo Bonzini, 2017/02/16
- [Qemu-devel] [PULL 12/23] cpu-exec: tighten barrier on TCG_EXIT_REQUESTED, Paolo Bonzini, 2017/02/16
- [Qemu-devel] [PULL 14/23] cpu-exec: avoid repeated sigsetjmp on interrupts, Paolo Bonzini, 2017/02/16
- [Qemu-devel] [PULL 16/23] qemu-doc: Clarify that -vga std is now the default, Paolo Bonzini, 2017/02/16
- [Qemu-devel] [PULL 15/23] cpu-exec: remove outermost infinite loop,
Paolo Bonzini <=
- [Qemu-devel] [PULL 17/23] qemu-nbd: Implement socket activation., Paolo Bonzini, 2017/02/16
- [Qemu-devel] [PULL 18/23] vl: Move the cpu_synchronize_all_post_init() after generic devices initialization, Paolo Bonzini, 2017/02/16
- [Qemu-devel] [PULL 19/23] Makefile: avoid leaving the temporary QEMU_PKGVERSION header file, Paolo Bonzini, 2017/02/16
- [Qemu-devel] [PULL 20/23] i386/cpu: add crash-information QOM property, Paolo Bonzini, 2017/02/16
- [Qemu-devel] [PULL 21/23] report guest crash information in GUEST_PANICKED event, Paolo Bonzini, 2017/02/16
[Qemu-devel] [PULL 22/23] vl: log available guest crash information, Paolo Bonzini, 2017/02/16