@@ -156,6 +156,12 @@ void restore_icount(CPUArchState *env, int save)
/* Return the virtual CPU time, based on the instruction counter. */
int64_t cpu_get_icount(void)
{
+ return qemu_icount_bias + cpu_get_icount_wo_bias();
+}
+
+/* Return the virtual CPU time, really based on the instruction counter. */
+int64_t cpu_get_icount_wo_bias(void)
+{
int64_t icount;
CPUArchState *env = cpu_single_env;
@@ -166,7 +172,7 @@ int64_t cpu_get_icount(void)
}
icount -= (env->icount_decr.u16.low + env->icount_extra);
}
- return qemu_icount_bias + (icount << icount_time_shift);
+ return icount << icount_time_shift;
}
/* return the host CPU cycle counter and handle stop/restart */
@@ -1165,7 +1171,7 @@ static int tcg_cpu_exec(CPUArchState *env)
qemu_icount -= (env->icount_decr.u16.low + env->icount_extra);
env->icount_decr.u16.low = 0;
env->icount_extra = 0;
- count = qemu_icount_round(qemu_clock_deadline(vm_clock));
+ count = qemu_icount_round(qemu_clock_deadline(ic_clock));
qemu_icount += count;
decr = (count > 0xffff) ? 0xffff : count;
count -= decr;
@@ -32,6 +32,9 @@ extern QEMUClock *vm_clock;
the virtual clock. */
extern QEMUClock *host_clock;
+/* A new clock based on icount only. */
+extern QEMUClock *ic_clock;
+
int64_t qemu_get_clock_ns(QEMUClock *clock);
int64_t qemu_clock_has_timers(QEMUClock *clock);
int64_t qemu_clock_expired(QEMUClock *clock);
@@ -136,6 +139,7 @@ void qemu_put_timer(QEMUFile *f, QEMUTimer *ts);
/* icount */
int64_t cpu_get_icount(void);
+int64_t cpu_get_icount_wo_bias(void);
int64_t cpu_get_clock(void);
/*******************************************/
@@ -43,6 +43,7 @@
#define QEMU_CLOCK_REALTIME 0
#define QEMU_CLOCK_VIRTUAL 1
#define QEMU_CLOCK_HOST 2
+#define QEMU_CLOCK_ICOUNT 3
struct QEMUClock {
QEMUTimer *active_timers;
@@ -230,6 +231,7 @@ next:
QEMUClock *rt_clock;
QEMUClock *vm_clock;
QEMUClock *host_clock;
+QEMUClock *ic_clock;
static QEMUClock *qemu_new_clock(int type)
{
@@ -413,6 +415,8 @@ int64_t qemu_get_clock_ns(QEMUClock *clock)
} else {
return cpu_get_clock();
}
+ case QEMU_CLOCK_ICOUNT:
+ return cpu_get_icount_wo_bias();
case QEMU_CLOCK_HOST:
now = get_clock_realtime();
last = clock->last;
@@ -440,6 +444,7 @@ void init_clocks(void)
rt_clock = qemu_new_clock(QEMU_CLOCK_REALTIME);
vm_clock = qemu_new_clock(QEMU_CLOCK_VIRTUAL);
host_clock = qemu_new_clock(QEMU_CLOCK_HOST);
+ ic_clock = qemu_new_clock(QEMU_CLOCK_ICOUNT);
}
}
@@ -456,6 +461,7 @@ void qemu_run_all_timers(void)
qemu_run_timers(vm_clock);
qemu_run_timers(rt_clock);
qemu_run_timers(host_clock);
+ qemu_run_timers(ic_clock);
/* rearm timer, if not periodic */
if (alarm_timer->expired) {