[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH v5 64/69] accel: Always register AccelOpsClass::get_virtual_clock() handler
In order to dispatch over AccelOpsClass::get_virtual_clock(), we need it always defined, not calling a hidden handler under the hood. Make AccelOpsClass::get_virtual_clock() mandatory. Register the default cpu_get_clock() for each accelerator. Signed-off-by: Philippe Mathieu-Daudé <philmd@xxxxxxxxxx> Reviewed-by: Pierrick Bouvier <pierrick.bouvier@xxxxxxxxxx> Reviewed-by: Zhao Liu <zhao1.liu@xxxxxxxxx> --- include/system/accel-ops.h | 2 ++ accel/hvf/hvf-accel-ops.c | 1 + accel/kvm/kvm-accel-ops.c | 1 + accel/tcg/tcg-accel-ops.c | 2 ++ accel/xen/xen-all.c | 1 + system/cpus.c | 7 ++++--- target/i386/nvmm/nvmm-accel-ops.c | 1 + target/i386/whpx/whpx-accel-ops.c | 1 + 8 files changed, 13 insertions(+), 3 deletions(-) diff --git a/include/system/accel-ops.h b/include/system/accel-ops.h index 8683cd37716..d5154acc75a 100644 --- a/include/system/accel-ops.h +++ b/include/system/accel-ops.h @@ -82,6 +82,8 @@ struct AccelOpsClass { * fetch time. The set function is needed if the accelerator wants * to track the changes to time as the timer is warped through * various timer events. + * + * get_virtual_clock() is mandatory. */ int64_t (*get_virtual_clock)(void); void (*set_virtual_clock)(int64_t time); diff --git a/accel/hvf/hvf-accel-ops.c b/accel/hvf/hvf-accel-ops.c index 17776e700eb..cf623a1ea47 100644 --- a/accel/hvf/hvf-accel-ops.c +++ b/accel/hvf/hvf-accel-ops.c @@ -369,6 +369,7 @@ static void hvf_accel_ops_class_init(ObjectClass *oc, const void *data) ops->update_guest_debug = hvf_update_guest_debug; ops->get_elapsed_ticks = cpu_get_ticks; + ops->get_virtual_clock = cpu_get_clock; ops->get_vcpu_stats = hvf_get_vcpu_stats; }; diff --git a/accel/kvm/kvm-accel-ops.c b/accel/kvm/kvm-accel-ops.c index f27228d4cd9..dde498e0626 100644 --- a/accel/kvm/kvm-accel-ops.c +++ b/accel/kvm/kvm-accel-ops.c @@ -97,6 +97,7 @@ static void kvm_accel_ops_class_init(ObjectClass *oc, const void *data) #endif ops->get_elapsed_ticks = cpu_get_ticks; + ops->get_virtual_clock = cpu_get_clock; } static const TypeInfo kvm_accel_ops_type = { diff --git a/accel/tcg/tcg-accel-ops.c b/accel/tcg/tcg-accel-ops.c index f22f5d73abe..780e9debbc4 100644 --- a/accel/tcg/tcg-accel-ops.c +++ b/accel/tcg/tcg-accel-ops.c @@ -207,6 +207,7 @@ static void tcg_accel_ops_init(AccelClass *ac) ops->kick_vcpu_thread = mttcg_kick_vcpu_thread; ops->handle_interrupt = tcg_handle_interrupt; ops->get_elapsed_ticks = cpu_get_ticks; + ops->get_virtual_clock = cpu_get_clock; } else { ops->create_vcpu_thread = rr_start_vcpu_thread; ops->kick_vcpu_thread = rr_kick_vcpu_thread; @@ -217,6 +218,7 @@ static void tcg_accel_ops_init(AccelClass *ac) ops->get_elapsed_ticks = icount_get; } else { ops->handle_interrupt = tcg_handle_interrupt; + ops->get_virtual_clock = cpu_get_clock; ops->get_elapsed_ticks = cpu_get_ticks; } } diff --git a/accel/xen/xen-all.c b/accel/xen/xen-all.c index 48d458bc4c7..85fb9d1606c 100644 --- a/accel/xen/xen-all.c +++ b/accel/xen/xen-all.c @@ -158,6 +158,7 @@ static void xen_accel_ops_class_init(ObjectClass *oc, const void *data) ops->kick_vcpu_thread = cpus_kick_thread; ops->handle_interrupt = generic_handle_interrupt; ops->get_elapsed_ticks = cpu_get_ticks; + ops->get_virtual_clock = cpu_get_clock; } static const TypeInfo xen_accel_ops_type = { diff --git a/system/cpus.c b/system/cpus.c index d32b89ecf7b..6c99756346a 100644 --- a/system/cpus.c +++ b/system/cpus.c @@ -216,10 +216,10 @@ int64_t cpus_get_virtual_clock(void) * * XXX */ - if (cpus_accel && cpus_accel->get_virtual_clock) { - return cpus_accel->get_virtual_clock(); + if (!cpus_accel) { + return cpu_get_clock(); } - return cpu_get_clock(); + return cpus_accel->get_virtual_clock(); } /* @@ -666,6 +666,7 @@ void cpus_register_accel(const AccelOpsClass *ops) assert(ops->kick_vcpu_thread); assert(ops->handle_interrupt); assert(ops->get_elapsed_ticks); + assert(ops->get_virtual_clock); cpus_accel = ops; } diff --git a/target/i386/nvmm/nvmm-accel-ops.c b/target/i386/nvmm/nvmm-accel-ops.c index 4deff57471c..a2e84cb087a 100644 --- a/target/i386/nvmm/nvmm-accel-ops.c +++ b/target/i386/nvmm/nvmm-accel-ops.c @@ -86,6 +86,7 @@ static void nvmm_accel_ops_class_init(ObjectClass *oc, const void *data) ops->synchronize_pre_loadvm = nvmm_cpu_synchronize_pre_loadvm; ops->get_elapsed_ticks = cpu_get_ticks; + ops->get_virtual_clock = cpu_get_clock; } static const TypeInfo nvmm_accel_ops_type = { diff --git a/target/i386/whpx/whpx-accel-ops.c b/target/i386/whpx/whpx-accel-ops.c index f47033a502c..d27e89dd9c5 100644 --- a/target/i386/whpx/whpx-accel-ops.c +++ b/target/i386/whpx/whpx-accel-ops.c @@ -89,6 +89,7 @@ static void whpx_accel_ops_class_init(ObjectClass *oc, const void *data) ops->synchronize_pre_loadvm = whpx_cpu_synchronize_pre_loadvm; ops->get_elapsed_ticks = cpu_get_ticks; + ops->get_virtual_clock = cpu_get_clock; } static const TypeInfo whpx_accel_ops_type = { -- 2.49.0
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |