Commit 55e8b85e4891dafd0d0222ad1ced78e3c5f24e1e
1 parent
0c5f3c8d
Add safety net against potential infinite loop
cpu_interrupt might be called while translating the TB, but before it is linked into a potentially infinite loop and becomes env->current_tb. Currently this can (and does) cause huge problems only when using dyntick clock, with other (periodic) clocks host_alarm_handler will eventually be executed resulting in a call to cpu_interrupt which will reset the recursion of running TB and the damage is "only" latency. git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5620 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
8 additions
and
0 deletions
cpu-exec.c
... | ... | @@ -623,6 +623,14 @@ int cpu_exec(CPUState *env1) |
623 | 623 | } |
624 | 624 | spin_unlock(&tb_lock); |
625 | 625 | env->current_tb = tb; |
626 | + | |
627 | + /* cpu_interrupt might be called while translating the | |
628 | + TB, but before it is linked into a potentially | |
629 | + infinite loop and becomes env->current_tb. Avoid | |
630 | + starting execution if there is a pending interrupt. */ | |
631 | + if (unlikely (env->interrupt_request & CPU_INTERRUPT_EXIT)) | |
632 | + env->current_tb = NULL; | |
633 | + | |
626 | 634 | while (env->current_tb) { |
627 | 635 | tc_ptr = tb->tc_ptr; |
628 | 636 | /* execute the generated code */ | ... | ... |