[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 09/12] cpus.c: ensure running CPU recalculates icount
From: |
Peter Maydell |
Subject: |
[Qemu-devel] [PULL 09/12] cpus.c: ensure running CPU recalculates icount deadlines on timer expiry |
Date: |
Tue, 10 Apr 2018 13:17:21 +0100 |
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: address@hidden
Fixes: https://bugs.launchpad.net/qemu/+bug/1754038
Signed-off-by: Peter Maydell <address@hidden>
Reviewed-by: Richard Henderson <address@hidden>
Reviewed-by: Alex Bennée <address@hidden>
Message-id: address@hidden
---
cpus.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/cpus.c b/cpus.c
index 2e6701795b..38eba8bff3 100644
--- a/cpus.c
+++ b/cpus.c
@@ -892,11 +892,19 @@ void qemu_timer_notify_cb(void *opaque, QEMUClockType
type)
return;
}
- if (!qemu_in_vcpu_thread() && first_cpu) {
+ if (qemu_in_vcpu_thread()) {
+ /* A CPU is currently running; kick it back out to the
+ * tcg_cpu_exec() loop so it will recalculate its
+ * icount deadline immediately.
+ */
+ qemu_cpu_kick(current_cpu);
+ } else if (first_cpu) {
/* qemu_cpu_kick is not enough to kick a halted CPU out of
* qemu_tcg_wait_io_event. async_run_on_cpu, instead,
* causes cpu_thread_is_idle to return false. This way,
* handle_icount_deadline can run.
+ * If we have no CPUs at all for some reason, we don't
+ * need to do anything.
*/
async_run_on_cpu(first_cpu, do_nothing, RUN_ON_CPU_NULL);
}
--
2.16.2
- [Qemu-devel] [PULL 00/12] target-arm queue, Peter Maydell, 2018/04/10
- [Qemu-devel] [PULL 10/12] linux-user/signal.c: Ensure AArch64 signal frame isn't too small, Peter Maydell, 2018/04/10
- [Qemu-devel] [PULL 12/12] fpu: Fix rounding mode for floatN_to_uintM_round_to_zero, Peter Maydell, 2018/04/10
- [Qemu-devel] [PULL 09/12] cpus.c: ensure running CPU recalculates icount deadlines on timer expiry,
Peter Maydell <=
- [Qemu-devel] [PULL 11/12] tcg: Introduce tcg_set_insn_start_param, Peter Maydell, 2018/04/10
- [Qemu-devel] [PULL 01/12] hw/arm: Allow manually specified /psci node, Peter Maydell, 2018/04/10
- [Qemu-devel] [PULL 08/12] target/arm: Report unsupported MPU region sizes more clearly, Peter Maydell, 2018/04/10
- [Qemu-devel] [PULL 03/12] target-arm: Check undefined opcodes for SWP in A32 decoder, Peter Maydell, 2018/04/10
- [Qemu-devel] [PULL 05/12] hw/sd/bcm2835_sdhost: Don't raise spurious interrupts, Peter Maydell, 2018/04/10
- [Qemu-devel] [PULL 04/12] hw/sd/bcm2835_sdhost: Add tracepoints, Peter Maydell, 2018/04/10
- [Qemu-devel] [PULL 07/12] hw/arm/fsl-imx: Fix introspection problem with fsl-imx6 and fsl-imx7, Peter Maydell, 2018/04/10
- [Qemu-devel] [PULL 02/12] hw/arm/integratorcp: Don't do things that could be fatal in the instance_init, Peter Maydell, 2018/04/10
- [Qemu-devel] [PULL 06/12] hw/arm/allwinner-a10: Do not use nd_table in instance_init function, Peter Maydell, 2018/04/10
- Re: [Qemu-devel] [PULL 00/12] target-arm queue, Peter Maydell, 2018/04/10