From 2a62914bd8209d97e918f30f0de74bec2bf622c4 Mon Sep 17 00:00:00 2001 From: Pavel Dovgalyuk Date: Mon, 8 Dec 2014 10:53:45 +0300 Subject: [PATCH] icount: introduce cpu_get_icount_raw Separate accessing the instruction counter from the compensation for speed and halting that are introduced by qemu_icount_bias. This introduces new infrastructure used by the record/replay patches. Signed-off-by: Pavel Dovgalyuk Signed-off-by: Paolo Bonzini --- cpus.c | 13 ++++++++++--- include/qemu/timer.h | 1 + 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/cpus.c b/cpus.c index 615d4ae07d..5f8acba15d 100644 --- a/cpus.c +++ b/cpus.c @@ -136,8 +136,7 @@ typedef struct TimersState { static TimersState timers_state; -/* Return the virtual CPU time, based on the instruction counter. */ -static int64_t cpu_get_icount_locked(void) +int64_t cpu_get_icount_raw(void) { int64_t icount; CPUState *cpu = current_cpu; @@ -145,10 +144,18 @@ static int64_t cpu_get_icount_locked(void) icount = timers_state.qemu_icount; if (cpu) { if (!cpu_can_do_io(cpu)) { - fprintf(stderr, "Bad clock read\n"); + fprintf(stderr, "Bad icount read\n"); + exit(1); } icount -= (cpu->icount_decr.u16.low + cpu->icount_extra); } + return icount; +} + +/* Return the virtual CPU time, based on the instruction counter. */ +static int64_t cpu_get_icount_locked(void) +{ + int64_t icount = cpu_get_icount_raw(); return timers_state.qemu_icount_bias + cpu_icount_to_ns(icount); } diff --git a/include/qemu/timer.h b/include/qemu/timer.h index 5f5210d543..3dae414f40 100644 --- a/include/qemu/timer.h +++ b/include/qemu/timer.h @@ -743,6 +743,7 @@ static inline int64_t get_clock(void) #endif /* icount */ +int64_t cpu_get_icount_raw(void); int64_t cpu_get_icount(void); int64_t cpu_get_clock(void); int64_t cpu_get_clock_offset(void); -- GitLab