Skip to content

Commit

Permalink
icount: introduce cpu_get_icount_raw
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
  • Loading branch information
Dovgalyuk authored and bonzini committed Dec 15, 2014
1 parent 626cf8f commit 2a62914
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
13 changes: 10 additions & 3 deletions cpus.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,19 +136,26 @@ 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;

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);
}

Expand Down
1 change: 1 addition & 0 deletions include/qemu/timer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 2a62914

Please sign in to comment.