From: KONRAD Frederic <fred.kon...@greensocs.com> This takes icount clock in account for icount extra computation so icount clock's timers will be triggered at the exact time.
Signed-off-by: KONRAD Frederic <fred.kon...@greensocs.com> Reviewed-by: Paolo Bonzini <pbonz...@redhat.com> --- cpus.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/cpus.c b/cpus.c index 8bd3423..f63872b 100644 --- a/cpus.c +++ b/cpus.c @@ -1323,6 +1323,7 @@ static int tcg_cpu_exec(CPUArchState *env) if (use_icount) { int64_t count; int64_t deadline; + int64_t icount_deadline; int decr; timers_state.qemu_icount -= (cpu->icount_decr.u16.low + cpu->icount_extra); @@ -1339,6 +1340,15 @@ static int tcg_cpu_exec(CPUArchState *env) deadline = INT32_MAX; } + /* + * Take icount clock deadline in account too, and keep the nearest + * deadline. + */ + icount_deadline = qemu_clock_deadline_ns_all(QEMU_CLOCK_ICOUNT); + if ((icount_deadline >= 0) && (icount_deadline < deadline)) { + deadline = icount_deadline; + } + count = qemu_icount_round(deadline); timers_state.qemu_icount += count; decr = (count > 0xffff) ? 0xffff : count; -- 1.9.0