]> git.ipfire.org Git - thirdparty/qemu.git/commit
cpus.c: ensure running CPU recalculates icount deadlines on timer expiry
authorPeter Maydell <peter.maydell@linaro.org>
Tue, 10 Apr 2018 12:02:25 +0000 (13:02 +0100)
committerMichael Roth <mdroth@linux.vnet.ibm.com>
Thu, 21 Jun 2018 01:45:01 +0000 (20:45 -0500)
commit28895d021eccdaa6f9fa910ed232adf50f4afa58
treea29f992a2c678c4d034a21a2ee82b38bb8c9684e
parent12fc0de2ab398d6cc379b5ff15895aa7e6a19fe6
cpus.c: ensure running CPU recalculates icount deadlines on timer expiry

When we run in TCG icount mode, we calculate the number of instructions
to execute using tcg_get_icount_limit(), which ensures that we stop
execution at the next timer deadline. However there is a bug where
currently we do not recalculate that limit if the guest reprograms
a timer so that the next deadline moves closer, and so we will
continue execution until the original limit and fire the timer
later than we should.

Fix this bug in qemu_timer_notify_cb(): if we are currently running
a VCPU in icount mode, we simply need to kick it out of the main
loop and back to tcg_cpu_exec(), where it will recalculate the
icount limit. If we are not currently running a VCPU, then we
retain the existing logic for waking up a halted CPU.

Cc: qemu-stable@nongnu.org
Fixes: https://bugs.launchpad.net/qemu/+bug/1754038
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Message-id: 20180406123838.21249-1-peter.maydell@linaro.org
(cherry picked from commit c52e7132d7c885841500f5277f7305f62767fe1d)
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
cpus.c