cpu-timers, icount: new modules

refactoring of cpus.c continues with cpu timer state extraction.

cpu-timers: responsible for the softmmu cpu timers state,
            including cpu clocks and ticks.

icount: counts the TCG instructions executed. As such it is specific to
the TCG accelerator. Therefore, it is built only under CONFIG_TCG.

One complication is due to qtest, which uses an icount field to warp time
as part of qtest (qtest_clock_warp).

In order to solve this problem, provide a separate counter for qtest.

This requires fixing assumptions scattered in the code that
qtest_enabled() implies icount_enabled(), checking each specific case.

Signed-off-by: Claudio Fontana <cfontana@suse.de>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
[remove redundant initialization with qemu_spice_init]
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
[fix lingering calls to icount_get]
Signed-off-by: Claudio Fontana <cfontana@suse.de>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
Claudio Fontana 2020-08-19 13:17:19 +02:00 committed by Paolo Bonzini
parent 0ac0b47c44
commit 740b175973
37 changed files with 1128 additions and 843 deletions

View file

@ -1,7 +0,0 @@
#include "qemu/osdep.h"
#include "qemu/timer.h"
void qemu_start_warp_timer(void)
{
}

View file

@ -1,5 +1,6 @@
#include "qemu/osdep.h"
#include "qemu/timer.h"
#include "sysemu/cpu-timers.h"
#include "qemu/main-loop.h"
int64_t cpu_get_clock(void)
{

View file

@ -1,16 +0,0 @@
#include "qemu/osdep.h"
#include "qemu/timer.h"
#include "sysemu/cpus.h"
#include "qemu/main-loop.h"
int use_icount;
int64_t cpu_get_icount(void)
{
abort();
}
int64_t cpu_get_icount_raw(void)
{
abort();
}

45
stubs/icount.c Normal file
View file

@ -0,0 +1,45 @@
#include "qemu/osdep.h"
#include "qapi/error.h"
#include "sysemu/cpu-timers.h"
/* icount - Instruction Counter API */
int use_icount;
void cpu_update_icount(CPUState *cpu)
{
abort();
}
void configure_icount(QemuOpts *opts, Error **errp)
{
/* signal error */
error_setg(errp, "cannot configure icount, TCG support not available");
}
int64_t cpu_get_icount_raw(void)
{
abort();
return 0;
}
int64_t cpu_get_icount(void)
{
abort();
return 0;
}
int64_t cpu_icount_to_ns(int64_t icount)
{
abort();
return 0;
}
int64_t qemu_icount_round(int64_t count)
{
abort();
return 0;
}
void qemu_start_warp_timer(void)
{
abort();
}
void qemu_account_warp_timer(void)
{
abort();
}

View file

@ -3,10 +3,10 @@ stub_ss.add(files('bdrv-next-monitor-owned.c'))
stub_ss.add(files('blk-commit-all.c'))
stub_ss.add(files('blockdev-close-all-bdrv-states.c'))
stub_ss.add(files('change-state-handler.c'))
stub_ss.add(files('clock-warp.c'))
stub_ss.add(files('cmos.c'))
stub_ss.add(files('cpu-get-clock.c'))
stub_ss.add(files('cpu-get-icount.c'))
stub_ss.add(files('qemu-timer-notify-cb.c'))
stub_ss.add(files('icount.c'))
stub_ss.add(files('dump.c'))
stub_ss.add(files('error-printf.c'))
stub_ss.add(files('fdset.c'))

View file

@ -1,5 +1,5 @@
#include "qemu/osdep.h"
#include "sysemu/cpus.h"
#include "sysemu/cpu-timers.h"
#include "qemu/main-loop.h"
void qemu_timer_notify_cb(void *opaque, QEMUClockType type)

View file

@ -18,3 +18,8 @@ bool qtest_driver(void)
{
return false;
}
int64_t qtest_get_virtual_clock(void)
{
return 0;
}