Skip to content

Commit

Permalink
accel: Add missing AccelOpsClass::has_work() and drop SysemuCPUOps one
Browse files Browse the repository at this point in the history
cpu_common_has_work() is the default has_work() implementation
and returns 'false'.

Explicit it for the QTest / HAX / HVF / NVMM / Xen accelerators
and remove cpu_common_has_work().

Since there are no more implementations of SysemuCPUOps::has_work,
remove it along with the assertion in cpu_has_work().

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Acked-by: Paul Durrant <paul@xen.org>
Message-Id: <20210912172731.789788-31-f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
  • Loading branch information
philmd authored and rth7680 committed Sep 16, 2021
1 parent 487cb00 commit 282f279
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 15 deletions.
6 changes: 6 additions & 0 deletions accel/hvf/hvf-accel-ops.c
Expand Up @@ -446,6 +446,11 @@ static void hvf_start_vcpu_thread(CPUState *cpu)
cpu, QEMU_THREAD_JOINABLE);
}

static bool hvf_cpu_has_work(CPUState *cpu)
{
return false;
}

static void hvf_accel_ops_class_init(ObjectClass *oc, void *data)
{
AccelOpsClass *ops = ACCEL_OPS_CLASS(oc);
Expand All @@ -456,6 +461,7 @@ static void hvf_accel_ops_class_init(ObjectClass *oc, void *data)
ops->synchronize_post_init = hvf_cpu_synchronize_post_init;
ops->synchronize_state = hvf_cpu_synchronize_state;
ops->synchronize_pre_loadvm = hvf_cpu_synchronize_pre_loadvm;
ops->has_work = hvf_cpu_has_work;
};
static const TypeInfo hvf_accel_ops_type = {
.name = ACCEL_OPS_NAME("hvf"),
Expand Down
6 changes: 6 additions & 0 deletions accel/qtest/qtest.c
Expand Up @@ -47,12 +47,18 @@ static const TypeInfo qtest_accel_type = {
};
module_obj(TYPE_QTEST_ACCEL);

static bool qtest_cpu_has_work(CPUState *cpu)
{
return false;
}

static void qtest_accel_ops_class_init(ObjectClass *oc, void *data)
{
AccelOpsClass *ops = ACCEL_OPS_CLASS(oc);

ops->create_vcpu_thread = dummy_start_vcpu_thread;
ops->get_virtual_clock = qtest_get_virtual_clock;
ops->has_work = qtest_cpu_has_work;
};

static const TypeInfo qtest_accel_ops_type = {
Expand Down
6 changes: 6 additions & 0 deletions accel/xen/xen-all.c
Expand Up @@ -215,11 +215,17 @@ static const TypeInfo xen_accel_type = {
.class_init = xen_accel_class_init,
};

static bool xen_cpu_has_work(CPUState *cpu)
{
return false;
}

static void xen_accel_ops_class_init(ObjectClass *oc, void *data)
{
AccelOpsClass *ops = ACCEL_OPS_CLASS(oc);

ops->create_vcpu_thread = dummy_start_vcpu_thread;
ops->has_work = xen_cpu_has_work;
}

static const TypeInfo xen_accel_ops_type = {
Expand Down
6 changes: 0 additions & 6 deletions hw/core/cpu-common.c
Expand Up @@ -143,11 +143,6 @@ static void cpu_common_reset(DeviceState *dev)
}
}

static bool cpu_common_has_work(CPUState *cs)
{
return false;
}

ObjectClass *cpu_class_by_name(const char *typename, const char *cpu_model)
{
CPUClass *cc = CPU_CLASS(object_class_by_name(typename));
Expand Down Expand Up @@ -279,7 +274,6 @@ static void cpu_class_init(ObjectClass *klass, void *data)

k->parse_features = cpu_common_parse_features;
k->get_arch_id = cpu_common_get_arch_id;
k->has_work = cpu_common_has_work;
k->gdb_read_register = cpu_common_gdb_read_register;
k->gdb_write_register = cpu_common_gdb_write_register;
set_bit(DEVICE_CATEGORY_CPU, dc->categories);
Expand Down
2 changes: 0 additions & 2 deletions include/hw/core/cpu.h
Expand Up @@ -89,7 +89,6 @@ struct SysemuCPUOps;
* instantiatable CPU type.
* @parse_features: Callback to parse command line arguments.
* @reset_dump_flags: #CPUDumpFlags to use for reset logging.
* @has_work: Callback for checking if there is work to do.
* @memory_rw_debug: Callback for GDB memory access.
* @dump_state: Callback for dumping state.
* @get_arch_id: Callback for getting architecture-dependent CPU ID.
Expand Down Expand Up @@ -132,7 +131,6 @@ struct CPUClass {
void (*parse_features)(const char *typename, char *str, Error **errp);

int reset_dump_flags;
bool (*has_work)(CPUState *cpu);
int (*memory_rw_debug)(CPUState *cpu, vaddr addr,
uint8_t *buf, int len, bool is_write);
void (*dump_state)(CPUState *cpu, FILE *, int flags);
Expand Down
9 changes: 2 additions & 7 deletions softmmu/cpus.c
Expand Up @@ -251,13 +251,8 @@ void cpu_interrupt(CPUState *cpu, int mask)

bool cpu_has_work(CPUState *cpu)
{
CPUClass *cc = CPU_GET_CLASS(cpu);

if (cpus_accel->has_work) {
return cpus_accel->has_work(cpu);
}
g_assert(cc->has_work);
return cc->has_work(cpu);
g_assert(cpus_accel->has_work);
return cpus_accel->has_work(cpu);
}

static int do_vm_stop(RunState state, bool send_stop)
Expand Down
6 changes: 6 additions & 0 deletions target/i386/hax/hax-accel-ops.c
Expand Up @@ -74,6 +74,11 @@ static void hax_start_vcpu_thread(CPUState *cpu)
#endif
}

static bool hax_cpu_has_work(CPUState *cpu)
{
return false;
}

static void hax_accel_ops_class_init(ObjectClass *oc, void *data)
{
AccelOpsClass *ops = ACCEL_OPS_CLASS(oc);
Expand All @@ -85,6 +90,7 @@ static void hax_accel_ops_class_init(ObjectClass *oc, void *data)
ops->synchronize_post_init = hax_cpu_synchronize_post_init;
ops->synchronize_state = hax_cpu_synchronize_state;
ops->synchronize_pre_loadvm = hax_cpu_synchronize_pre_loadvm;
ops->has_work = hax_cpu_has_work;
}

static const TypeInfo hax_accel_ops_type = {
Expand Down
6 changes: 6 additions & 0 deletions target/i386/nvmm/nvmm-accel-ops.c
Expand Up @@ -83,6 +83,11 @@ static void nvmm_kick_vcpu_thread(CPUState *cpu)
cpus_kick_thread(cpu);
}

static bool nvmm_cpu_has_work(CPUState *cpu)
{
return false;
}

static void nvmm_accel_ops_class_init(ObjectClass *oc, void *data)
{
AccelOpsClass *ops = ACCEL_OPS_CLASS(oc);
Expand All @@ -94,6 +99,7 @@ static void nvmm_accel_ops_class_init(ObjectClass *oc, void *data)
ops->synchronize_post_init = nvmm_cpu_synchronize_post_init;
ops->synchronize_state = nvmm_cpu_synchronize_state;
ops->synchronize_pre_loadvm = nvmm_cpu_synchronize_pre_loadvm;
ops->has_work = nvmm_cpu_has_work;
}

static const TypeInfo nvmm_accel_ops_type = {
Expand Down

0 comments on commit 282f279

Please sign in to comment.