[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC PATCH v5 07/31] icount: implement icount requesting
From: |
Pavel Dovgalyuk |
Subject: |
[Qemu-devel] [RFC PATCH v5 07/31] icount: implement icount requesting |
Date: |
Wed, 26 Nov 2014 13:39:26 +0300 |
User-agent: |
StGit/0.16 |
Replay uses number of executed instructions to determine corrent events
injection moments. This patch introduces new function for querying the
instructions counter.
Signed-off-by: Pavel Dovgalyuk <address@hidden>
---
cpus.c | 26 +++++++++++++++++++++++---
include/qemu/timer.h | 1 +
2 files changed, 24 insertions(+), 3 deletions(-)
diff --git a/cpus.c b/cpus.c
index a7b6c53..492e19a 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)
+static int64_t cpu_get_instructions_counter_locked(void)
{
int64_t icount;
CPUState *cpu = current_cpu;
@@ -145,10 +144,31 @@ 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;
+}
+
+int64_t cpu_get_instructions_counter(void)
+{
+ /* This function calls are synchnonized to timer changes,
+ calling cpu_get_instructions_counter_locked without lock is safe */
+ int64_t icount = timers_state.qemu_icount;
+ CPUState *cpu = current_cpu;
+
+ if (cpu) {
+ 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_instructions_counter_locked();
return timers_state.qemu_icount_bias + cpu_icount_to_ns(icount);
}
diff --git a/include/qemu/timer.h b/include/qemu/timer.h
index 5f5210d..38a02c5 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_instructions_counter(void);
int64_t cpu_get_icount(void);
int64_t cpu_get_clock(void);
int64_t cpu_get_clock_offset(void);
- [Qemu-devel] [RFC PATCH v5 00/31] Deterministic replay and reverse execution, Pavel Dovgalyuk, 2014/11/26
- [Qemu-devel] [RFC PATCH v5 01/31] cpu-exec: fix cpu_exec_nocache, Pavel Dovgalyuk, 2014/11/26
- [Qemu-devel] [RFC PATCH v5 02/31] acpi: accurate overflow check, Pavel Dovgalyuk, 2014/11/26
- [Qemu-devel] [RFC PATCH v5 03/31] replay: global variables and function stubs, Pavel Dovgalyuk, 2014/11/26
- [Qemu-devel] [RFC PATCH v5 04/31] sysemu: system functions for replay, Pavel Dovgalyuk, 2014/11/26
- [Qemu-devel] [RFC PATCH v5 05/31] replay: internal functions for replay log, Pavel Dovgalyuk, 2014/11/26
- [Qemu-devel] [RFC PATCH v5 06/31] cpu-exec: reset exception_index correctly, Pavel Dovgalyuk, 2014/11/26
- [Qemu-devel] [RFC PATCH v5 07/31] icount: implement icount requesting,
Pavel Dovgalyuk <=
- [Qemu-devel] [RFC PATCH v5 08/31] icount: improve enable/disable ticks, Pavel Dovgalyuk, 2014/11/26
- [Qemu-devel] [RFC PATCH v5 09/31] replay: introduce icount event, Pavel Dovgalyuk, 2014/11/26
- [Qemu-devel] [RFC PATCH v5 10/31] i386: do not cross the pages boundaries in replay mode, Pavel Dovgalyuk, 2014/11/26
- [Qemu-devel] [RFC PATCH v5 11/31] From 7abf2f72777958d395cfd01d97fe707cc06152b5 Mon Sep 17 00:00:00 2001, Pavel Dovgalyuk, 2014/11/26
- [Qemu-devel] [RFC PATCH v5 12/31] From 185a3a47d08857a66332ae862b372a153ce92bb9 Mon Sep 17 00:00:00 2001, Pavel Dovgalyuk, 2014/11/26
- [Qemu-devel] [RFC PATCH v5 13/31] From a0cb9e80ba0de409b5ad556109a1c71ce4d8ce19 Mon Sep 17 00:00:00 2001, Pavel Dovgalyuk, 2014/11/26
- [Qemu-devel] [RFC PATCH v5 14/31] From 04bbd21134dd2c6b7309a7f5f2b780aae2757003 Mon Sep 17 00:00:00 2001, Pavel Dovgalyuk, 2014/11/26
- [Qemu-devel] [RFC PATCH v5 15/31] cpu-exec: allow temporary disabling icount, Pavel Dovgalyuk, 2014/11/26
- [Qemu-devel] [RFC PATCH v5 16/31] cpu-exec: invalidate nocache translation if they are interrupted, Pavel Dovgalyuk, 2014/11/26
- [Qemu-devel] [RFC PATCH v5 17/31] replay: interrupts and exceptions, Pavel Dovgalyuk, 2014/11/26