[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 3/7] cpu-exec: avoid cpu_loop_exit in cpu_handle_int
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PATCH 3/7] cpu-exec: avoid cpu_loop_exit in cpu_handle_interrupt |
Date: |
Sun, 29 Jan 2017 22:09:06 +0100 |
The siglongjmp goes straight back to the beginning of cpu_exec's
outermost loop. We do not need a non-local jump; we can simply
leave the inner TB execution loop whose structure now becomes
clearer, too.
Signed-off-by: Paolo Bonzini <address@hidden>
---
cpu-exec.c | 23 ++++++++++++-----------
1 file changed, 12 insertions(+), 11 deletions(-)
diff --git a/cpu-exec.c b/cpu-exec.c
index 4065e0e..e62abed 100644
--- a/cpu-exec.c
+++ b/cpu-exec.c
@@ -461,7 +461,7 @@ static inline bool cpu_handle_exception(CPUState *cpu, int
*ret)
return false;
}
-static inline void cpu_handle_interrupt(CPUState *cpu,
+static inline bool cpu_handle_interrupt(CPUState *cpu,
TranslationBlock **last_tb)
{
CPUClass *cc = CPU_GET_CLASS(cpu);
@@ -475,7 +475,7 @@ static inline void cpu_handle_interrupt(CPUState *cpu,
if (interrupt_request & CPU_INTERRUPT_DEBUG) {
cpu->interrupt_request &= ~CPU_INTERRUPT_DEBUG;
cpu->exception_index = EXCP_DEBUG;
- cpu_loop_exit(cpu);
+ return true;
}
if (replay_mode == REPLAY_MODE_PLAY && !replay_has_interrupt()) {
/* Do nothing */
@@ -484,7 +484,7 @@ static inline void cpu_handle_interrupt(CPUState *cpu,
cpu->interrupt_request &= ~CPU_INTERRUPT_HALT;
cpu->halted = 1;
cpu->exception_index = EXCP_HLT;
- cpu_loop_exit(cpu);
+ return true;
}
#if defined(TARGET_I386)
else if (interrupt_request & CPU_INTERRUPT_INIT) {
@@ -494,13 +494,13 @@ static inline void cpu_handle_interrupt(CPUState *cpu,
cpu_svm_check_intercept_param(env, SVM_EXIT_INIT, 0);
do_cpu_init(x86_cpu);
cpu->exception_index = EXCP_HALTED;
- cpu_loop_exit(cpu);
+ return true;
}
#else
else if (interrupt_request & CPU_INTERRUPT_RESET) {
replay_interrupt();
cpu_reset(cpu);
- cpu_loop_exit(cpu);
+ return true;
}
#endif
/* The target hook has 3 exit conditions:
@@ -526,8 +526,10 @@ static inline void cpu_handle_interrupt(CPUState *cpu,
if (unlikely(atomic_read(&cpu->exit_request) || replay_has_interrupt())) {
atomic_set(&cpu->exit_request, 0);
cpu->exception_index = EXCP_INTERRUPT;
- cpu_loop_exit(cpu);
+ return true;
}
+
+ return false;
}
static inline void cpu_loop_exec_tb(CPUState *cpu, TranslationBlock *tb,
@@ -625,7 +627,7 @@ int cpu_exec(CPUState *cpu)
for(;;) {
/* prepare setjmp context for exception handling */
if (sigsetjmp(cpu->jmp_env, 0) == 0) {
- TranslationBlock *tb, *last_tb = NULL;
+ TranslationBlock *last_tb = NULL;
int tb_exit = 0;
/* if an exception is pending, we execute it here */
@@ -633,14 +635,13 @@ int cpu_exec(CPUState *cpu)
break;
}
- for(;;) {
- cpu_handle_interrupt(cpu, &last_tb);
- tb = tb_find(cpu, last_tb, tb_exit);
+ 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(;;) */
+ }
} else {
#if defined(__clang__) || !QEMU_GNUC_PREREQ(4, 6)
/* Some compilers wrongly smash all local variables after
--
2.9.3
- [Qemu-devel] [RFC/RFT PATCH 0/7] cpu-exec: simplify cpu_exec and remove some icount special cases, Paolo Bonzini, 2017/01/29
- [Qemu-devel] [PATCH 2/7] cpu-exec: tighten barrier on TCG_EXIT_REQUESTED, Paolo Bonzini, 2017/01/29
- [Qemu-devel] [PATCH 1/7] cpu-exec: fix jmp_first out-of-bounds access with icount, Paolo Bonzini, 2017/01/29
- [Qemu-devel] [PATCH 5/7] cpu-exec: remove outermost infinite loop, Paolo Bonzini, 2017/01/29
- [Qemu-devel] [PATCH 4/7] cpu-exec: avoid repeated sigsetjmp on interrupts, Paolo Bonzini, 2017/01/29
- [Qemu-devel] [PATCH 3/7] cpu-exec: avoid cpu_loop_exit in cpu_handle_interrupt,
Paolo Bonzini <=
- [Qemu-devel] [PATCH 6/7] cpu-exec: unify icount_decr and tcg_exit_req, Paolo Bonzini, 2017/01/29
- [Qemu-devel] [PATCH 7/7] cpu-exec: centralize exiting to the main loop, Paolo Bonzini, 2017/01/29
- Re: [Qemu-devel] [RFC/RFT PATCH 0/7] cpu-exec: simplify cpu_exec and remove some icount special cases, no-reply, 2017/01/29
- Re: [Qemu-devel] [RFC/RFT PATCH 0/7] cpu-exec: simplify cpu_exec and remove some icount special cases, Pavel Dovgalyuk, 2017/01/31