[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v3 11/12] cpus: call cpu_update_icount on read
From: |
Alex Bennée |
Subject: |
[Qemu-devel] [PATCH v3 11/12] cpus: call cpu_update_icount on read |
Date: |
Fri, 7 Apr 2017 16:42:20 +0100 |
This ensures each time the vCPU thread reads the icount we update the
master timer_state.qemu_icount field. This way as long as updates are
in BQL protected sections (which they should be) the main-loop can
never come to update the log and find time has gone backwards.
Signed-off-by: Alex Bennée <address@hidden>
---
cpus.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/cpus.c b/cpus.c
index 14c2149987..a6a85bfdba 100644
--- a/cpus.c
+++ b/cpus.c
@@ -253,19 +253,21 @@ void cpu_update_icount(CPUState *cpu)
int64_t cpu_get_icount_raw(void)
{
- int64_t icount;
CPUState *cpu = current_cpu;
- icount = atomic_read(&timers_state.qemu_icount);
if (cpu && cpu->running) {
if (!cpu->can_do_io) {
fprintf(stderr, "Bad icount read\n");
exit(1);
}
/* Take into account what has run */
- icount += cpu_get_icount_executed(cpu);
+ cpu_update_icount(cpu);
}
- return icount;
+#ifdef CONFIG_ATOMIC64
+ return atomic_read__nocheck(&timers_state.qemu_icount);
+#else /* FIXME: we need 64bit atomics to do this safely */
+ return timers_state.qemu_icount;
+#endif
}
/* Return the virtual CPU time, based on the instruction counter. */
--
2.11.0
- [Qemu-devel] [PATCH v3 05/12] cpus: remove icount handling from qemu_tcg_cpu_thread_fn, (continued)
- [Qemu-devel] [PATCH v3 05/12] cpus: remove icount handling from qemu_tcg_cpu_thread_fn, Alex Bennée, 2017/04/07
- [Qemu-devel] [PATCH v3 01/12] scripts/qemugdb/mtree.py: fix up mtree dump, Alex Bennée, 2017/04/07
- [Qemu-devel] [PATCH v3 10/12] cpu-exec: update icount after each TB_EXIT, Alex Bennée, 2017/04/07
- [Qemu-devel] [PATCH v3 04/12] target/i386/misc_helper: wrap BQL around another IRQ generator, Alex Bennée, 2017/04/07
- [Qemu-devel] [PATCH v3 02/12] scripts/qemu-gdb/timers.py: new helper to dump timer state, Alex Bennée, 2017/04/07
- [Qemu-devel] [PATCH v3 07/12] cpus: move icount preparation out of tcg_exec_cpu, Alex Bennée, 2017/04/07
- [Qemu-devel] [PATCH v3 09/12] cpus: introduce cpu_update_icount helper, Alex Bennée, 2017/04/07
- [Qemu-devel] [PATCH v3 06/12] cpus: check cpu->running in cpu_get_icount_raw(), Alex Bennée, 2017/04/07
- [Qemu-devel] [PATCH v3 03/12] scripts/replay-dump.py: replay log dumper, Alex Bennée, 2017/04/07
- [Qemu-devel] [PATCH v3 08/12] cpus: don't credit executed instructions before they have run, Alex Bennée, 2017/04/07
- [Qemu-devel] [PATCH v3 11/12] cpus: call cpu_update_icount on read,
Alex Bennée <=
- [Qemu-devel] [PATCH v3 12/12] replay: assert time only goes forward, Alex Bennée, 2017/04/07