accel: Remove need for AccelCPUClass
cover accel: Remove need for AccelCPUClass
Move cpu_init/realize hooks from AccelCPUClass to AccelOpsClass. Specialize them for TCG in TCGCPUOps.
This drastically simplifies the need of per-binary QOM types per accelerator per target (see also the nice diff-stat).
Based-on: tag single-binary-20260528
Ignoring checkpatch.pl:
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
accel/accel-target.c
include/accel/accel-cpu-target.h
include/accel/accel-cpu.h
Philippe Mathieu-Daudé (17):
target/loongarch: Remove unused 'accel/accel-cpu-target.h' header
accel: Remove AccelCPUClass::cpu_class_init()
accel: Rename AccelOpsClass::cpu_target_realize() -> cpu_realize() accel/hvf: Remove need for AccelCPUClass::cpu_target_realize accel/kvm: Remove need for AccelCPUClass::cpu_target_realize
accel: Introduce AccelOpsClass::cpu_instance_init handler accel/whpx: Convert AccelCPUClass -> AccelOpsClass::cpu_instance_init accel/nvmm: Convert AccelCPUClass -> AccelOpsClass::cpu_instance_init accel/hvf: Convert AccelCPUClass -> AccelOpsClass::cpu_instance_init accel/kvm: Convert AccelCPUClass -> AccelOpsClass::cpu_instance_init accel/tcg: Convert AccelCPUClass -> new TCGCPUOps::cpu_instance_init
accel: Remove AccelCPUClass::cpu_instance_init() accel/tcg: Convert AccelCPUClass -> new TCGCPUOps::cpu_realize accel/tcg: Convert X86 AccelCPUClass -> TCGCPUOps::cpu_realize accel/tcg: Convert RISCV AccelCPUClass -> TCGCPUOps::cpu_realize
accel: Remove AccelCPUClass::cpu_target_realize()
accel: Remove AccelCPUClass and 'accel/accel-cpu-target.h'
accel/tcg/tcg-accel-ops.h | 1 + include/accel/accel-cpu-ops.h | 3 +- include/accel/accel-cpu-target.h | 31 -------------- include/accel/accel-cpu.h | 23 ----------- include/accel/tcg/cpu-ops.h | 2 + include/system/hvf_int.h | 1 + include/system/kvm.h | 3 ++ target/i386/nvmm/nvmm-accel-ops.h | 2 + accel/accel-common.c | 68 ++++--------------------------- accel/hvf/hvf-accel-ops.c | 3 +- accel/kvm/kvm-accel-ops.c | 2 + accel/tcg/cpu-exec.c | 15 ++++++- accel/tcg/tcg-accel-ops.c | 1 + accel/whpx/whpx-accel-ops.c | 2 + accel/whpx/whpx-common.c | 17 -------- target/arm/hvf/hvf.c | 4 ++ target/arm/whpx/whpx-all.c | 1 - target/i386/hvf/hvf-cpu.c | 25 ++---------- target/i386/hvf/hvf.c | 5 --- target/i386/kvm/kvm-cpu.c | 25 +----------- target/i386/nvmm/nvmm-accel-ops.c | 2 + target/i386/nvmm/nvmm-all.c | 19 +-------- target/i386/tcg/tcg-cpu.c | 28 ++----------- target/i386/whpx/whpx-all.c | 1 - target/loongarch/tcg/tcg_cpu.c | 1 - target/ppc/kvm.c | 23 +---------- target/riscv/kvm/kvm-cpu.c | 33 +-------------- target/riscv/tcg/tcg-cpu.c | 28 +++---------- 28 files changed, 64 insertions(+), 305 deletions(-) delete mode 100644 include/accel/accel-cpu-target.h delete mode 100644 include/accel/accel-cpu.h
Signature · 1 line
2.53.0
PATCH 1/17 target/loongarch: Remove unused 'accel/accel-cpu-target.h' header
"accel/accel-cpu-target.h" is to register accelerator target specific hooks via TypeInfo::ACCEL_CPU_NAME(), which LoongArch TCG frontend does not. Remove as unused header.
--- target/loongarch/tcg/tcg_cpu.c | 1 - 1 file changed, 1 deletion(-)
target/loongarch/tcg/tcg_cpu.c +0 -1
@@ -9,7 +9,6 @@#include "qemu/error-report.h" #include "qemu/log.h" #include "qemu/plugin.h" -#include "accel/accel-cpu-target.h" #include "accel/tcg/cpu-ldst.h" #include "accel/tcg/cpu-ops.h" #include "exec/translation-block.h"
Signature · 1 line
2.53.0
Re: [PATCH 01/17] target/loongarch: Remove unused 'accel/accel-cpu-target.h' header
Quoted 9 lines · Philippe Mathieu-Daudé
"
accel/accel-cpu-target.h" is to register accelerator target specific hooks viaTypeInfo::ACCEL_CPU_NAME(), which LoongArch TCG frontend does not. Remove as unused header.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- target/loongarch/tcg/tcg_cpu.c | 1 - 1 file changed, 1 deletion(-)
PATCH 2/17 accel: Remove AccelCPUClass::cpu_class_init()
In reply to Philippe Mathieu-DaudéLast implementation were removed in commits f50d0f335a6 and a522b04bb9c ("Remove AccelCPUClass::cpu_class_init need"). Remove as dead code.
--- include/accel/accel-cpu.h | 1 - accel/accel-common.c | 33 --------------------------------- 2 files changed, 34 deletions(-)
include/accel/accel-cpu.h +0 -1
@@ -15,7 +15,6 @@typedef struct AccelCPUClass {ObjectClass parent_class; -void (*cpu_class_init)(CPUClass *cc);void (*cpu_instance_init)(CPUState *cpu);bool (*cpu_target_realize)(CPUState *cpu,Error **errp); }AccelCPUClass ;
accel/accel-common.c +0 -33
@@ -32,42 +32,9 @@ const char *current_accel_name(void)return ac->name; } -static void accel_init_cpu_int_aux (ObjectClass *klass,void *opaque) -{ -CPUClass *cc =CPU_CLASS (klass); -AccelCPUClass *accel_cpu = opaque; - - cc->accel_cpu = accel_cpu; -if (accel_cpu->cpu_class_init) { - accel_cpu->cpu_class_init (cc); - } -} - -/* initialize the arch-specific accel CpuClass interfaces */ -static void accel_init_cpu_interfaces (AccelClass *ac) -{ -const char *ac_name;/* AccelClass name */ -char *acc_name;/* AccelCPUClass name */ -ObjectClass *acc;/* AccelCPUClass */ -const char *cpu_resolving_type =target_cpu_type (); - - ac_name =object_class_get_name (OBJECT_CLASS (ac)); -g_assert (ac_name !=NULL ); - - acc_name =g_strdup_printf ("%s-%s" , ac_name, cpu_resolving_type); - acc =object_class_by_name (acc_name); -g_free (acc_name); - -if (acc) { -object_class_foreach (accel_init_cpu_int_aux, - cpu_resolving_type, false, acc); - } -} -void accel_init_interfaces (AccelClass *ac) {accel_init_ops_interfaces (ac); -accel_init_cpu_interfaces (ac); }void accel_cpu_instance_init (CPUState *cpu)
Signature · 1 line
2.53.0
Re: [PATCH 02/17] accel: Remove AccelCPUClass::cpu_class_init()
Quoted 10 lines · Philippe Mathieu-Daudé
Last implementation were removed in commits
f50d0f335a6anda522b04bb9c("RemoveAccelCPUClass::cpu_class_initneed"). Remove as dead code.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- include/accel/accel-cpu.h | 1 - accel/accel-common.c | 33 --------------------------------- 2 files changed, 34 deletions(-)
PATCH 3/17 accel: Rename AccelOpsClass::cpu_target_realize() -> cpu_realize()
In reply to Philippe Mathieu-Daudécpu_target_realize() is misleading, we simply want the host accelerator to realize its things on a vCPU. Rename more generically.
--- include/accel/accel-cpu-ops.h | 2 +- accel/accel-common.c | 5 +++-- accel/hvf/hvf-accel-ops.c | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-)
include/accel/accel-cpu-ops.h +1 -1
@@ -34,7 +34,7 @@ struct AccelOpsClass {/* initialization function called when accel is chosen */ void (*ops_init)(AccelClass *ac); -bool (*cpu_target_realize)(CPUState *cpu,Error **errp); +bool (*cpu_realize)(CPUState *cpu,Error **errp);bool (*cpus_are_resettable)(void );void (*cpu_reset_hold)(CPUState *cpu);
accel/accel-common.c +3 -2
@@ -60,9 +60,10 @@ bool accel_cpu_common_realize(CPUState *cpu, Error **errp)if (acc->cpu_common_realize && !acc->cpu_common_realize (cpu, errp)) {return false; } + +/* specialize with target specific realization */ if (acc->ops - && acc->ops->cpu_target_realize - && !acc->ops->cpu_target_realize (cpu, errp)) { + && acc->ops->cpu_realize && !acc->ops->cpu_realize (cpu, errp)) {return false; }
accel/hvf/hvf-accel-ops.c +1 -1
@@ -356,7 +356,7 @@ static void hvf_accel_ops_class_init(ObjectClass *oc, const void *data) {AccelOpsClass *ops =ACCEL_OPS_CLASS (oc); - ops->cpu_target_realize = hvf_arch_cpu_realize; + ops->cpu_realize = hvf_arch_cpu_realize; ops->create_vcpu_thread = hvf_start_vcpu_thread; ops->kick_vcpu_thread = hvf_kick_vcpu_thread;
Signature · 1 line
2.53.0
Re: [PATCH 03/17] accel: Rename AccelOpsClass::cpu_target_realize() -> cpu_realize()
Quoted 10 lines · Philippe Mathieu-Daudé
cpu_target_realize()is misleading, we simply want the host accelerator to realize its things on a vCPU. Rename more generically.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- include/accel/accel-cpu-ops.h | 2 +- accel/accel-common.c | 5 +++-- accel/hvf/hvf-accel-ops.c | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-)
I guess this is a new addition, and the next two patch descriptions need updating?
r~
Re: [PATCH 03/17] accel: Rename AccelOpsClass::cpu_target_realize() -> cpu_realize()
In reply to Philippe Mathieu-DaudéQuoted 11 lines · Philippe Mathieu-Daudé
cpu_target_realize()is misleading, we simply want the host accelerator to realize its things on a vCPU. Rename more generically.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- include/accel/accel-cpu-ops.h | 2 +- accel/accel-common.c | 5 +++-- accel/hvf/hvf-accel-ops.c | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-)
PATCH 4/17 accel/hvf: Remove need for AccelCPUClass::cpu_target_realize
In reply to Philippe Mathieu-Daudéaccel_cpu_common_realize() first calls accel_cpu->cpu_target_realize then ops->cpu_realize, which is set to hvf_arch_cpu_realize() on HVF.
We want to remove accel_cpu->cpu_target_realize, so have hvf_arch_cpu_realize directly call HVF AccelCPUClass target_realize handler.
--- target/i386/hvf/hvf-cpu.c | 6 +++++- target/i386/hvf/hvf.c | 5 ----- 2 files changed, 5 insertions(+), 6 deletions(-)
target/i386/hvf/hvf-cpu.c +5 -1
@@ -73,11 +73,15 @@ static void hvf_cpu_instance_init(CPUState *cs)hvf_cpu_xsave_init (); } +bool hvf_arch_cpu_realize (CPUState *cs,Error **errp) +{ +return host_cpu_realizefn (cs, errp); +} +static void hvf_cpu_accel_class_init (ObjectClass *oc,const void *data) {AccelCPUClass *acc =ACCEL_CPU_CLASS (oc); - acc->cpu_target_realize = host_cpu_realizefn; acc->cpu_instance_init = hvf_cpu_instance_init; }
target/i386/hvf/hvf.c +0 -5
@@ -369,11 +369,6 @@ int hvf_arch_init_vcpu(CPUState *cpu)return 0 ; } -bool hvf_arch_cpu_realize (CPUState *cs,Error **errp) -{ -return true; -} -static void hvf_store_events (CPUState *cpu,uint32_t ins_len,uint64_t idtvec_info) {X86CPU *x86_cpu =X86_CPU (cpu);
Signature · 1 line
2.53.0
Re: [PATCH 04/17] accel/hvf: Remove need for AccelCPUClass::cpu_target_realize
Quoted 7 lines · Philippe Mathieu-Daudé
accel_cpu_common_realize()first callsaccel_cpu->cpu_target_realizethenops->cpu_realize, which is set tohvf_arch_cpu_realize()on HVF.We want to remove
accel_cpu->cpu_target_realize, so havehvf_arch_cpu_realizedirectly call HVF AccelCPUClasstarget_realizehandler.
Quoted 6 lines
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- target/i386/hvf/hvf-cpu.c | 6 +++++- target/i386/hvf/hvf.c | 5 ----- 2 files changed, 5 insertions(+), 6 deletions(-)
Need to update commit description with new cpu_realize name as Richard noticed also.
Regards,
Pierrick
PATCH 5/17 accel/kvm: Remove need for AccelCPUClass::cpu_target_realize
In reply to Philippe Mathieu-Daudéaccel_cpu_common_realize() first calls accel_cpu->cpu_target_realize then ops->cpu_realize.
Rather than having one handler for each host architecture, use a single host-specific method (prefixed with kvm_arch_* like other similar KVM methods). Register it once as AccelOpsClass cpu_target_realize handler.
PPC's ACCEL_CPU_NAME("kvm") TypeInfo is now empty, remove it.
--- include/system/kvm.h | 2 ++ accel/kvm/kvm-accel-ops.c | 1 + target/i386/kvm/kvm-cpu.c | 3 +-- target/ppc/kvm.c | 23 +---------------------- target/riscv/kvm/kvm-cpu.c | 10 +--------- 5 files changed, 6 insertions(+), 33 deletions(-)
include/system/kvm.h +2 -0
@@ -364,6 +364,8 @@ int kvm_arch_pre_create_vcpu(CPUState *cpu, Error **errp);int kvm_arch_init_vcpu (CPUState *cpu);int kvm_arch_destroy_vcpu (CPUState *cpu); +bool kvm_arch_cpu_realize (CPUState *cpu,Error **errp); +#ifdef TARGET_KVM_HAVE_RESET_PARKED_VCPU void kvm_arch_reset_parked_vcpu (unsigned long vcpu_id,int kvm_fd);#else
accel/kvm/kvm-accel-ops.c +1 -0
@@ -97,6 +97,7 @@ static void kvm_accel_ops_class_init(ObjectClass *oc, const void *data)AccelOpsClass *ops =ACCEL_OPS_CLASS (oc); ops->create_vcpu_thread = kvm_start_vcpu_thread; + ops->cpu_target_realize = kvm_arch_cpu_realize; ops->cpu_thread_is_idle = kvm_vcpu_thread_is_idle; ops->cpus_are_resettable = kvm_cpus_are_resettable; ops->synchronize_post_reset = kvm_cpu_synchronize_post_reset;
target/i386/kvm/kvm-cpu.c +1 -2
@@ -39,7 +39,7 @@ static void kvm_set_guest_phys_bits(CPUState *cs) } } -static bool kvm_cpu_realizefn (CPUState *cs,Error **errp) +bool kvm_arch_cpu_realize (CPUState *cs,Error **errp) {X86CPU *cpu =X86_CPU (cs);X86CPUClass *xcc =X86_CPU_GET_CLASS (cpu);
@@ -237,7 +237,6 @@ static void kvm_cpu_accel_class_init(ObjectClass *oc, const void *data) {AccelCPUClass *acc =ACCEL_CPU_CLASS (oc); - acc->cpu_target_realize = kvm_cpu_realizefn; acc->cpu_instance_init = kvm_cpu_instance_init; }static const TypeInfo kvm_cpu_accel_type_info = {
target/ppc/kvm.c +1 -22
@@ -49,7 +49,6 @@#include "elf.h" #include "system/kvm_int.h" #include "system/kvm.h" -#include "accel/accel-cpu-target.h" #include CONFIG_DEVICES
@@ -2353,7 +2352,7 @@ static void alter_insns(uint64_t *word, uint64_t flags, bool on) } } -static bool kvmppc_cpu_realize (CPUState *cs,Error **errp) +bool kvm_arch_cpu_realize (CPUState *cs,Error **errp) {int ret; const char *vcpu_str = (cs->parent_obj.hotplugged == true) ?
@@ -2995,23 +2994,3 @@ void kvmppc_set_reg_tb_offset(PowerPCCPU *cpu, int64_t tb_offset)void kvm_arch_accel_class_init (ObjectClass *oc) { } - -static void kvm_cpu_accel_class_init (ObjectClass *oc,const void *data) -{ -AccelCPUClass *acc =ACCEL_CPU_CLASS (oc); - - acc->cpu_target_realize = kvmppc_cpu_realize; -} - -static const TypeInfo kvm_cpu_accel_type_info = { - .name =ACCEL_CPU_NAME ("kvm" ), - - .parent =TYPE_ACCEL_CPU , - .class_init = kvm_cpu_accel_class_init, - .abstract = true, -}; -static void kvm_cpu_accel_register_types (void ) -{ -type_register_static (&kvm_cpu_accel_type_info); -} -type_init (kvm_cpu_accel_register_types);
target/riscv/kvm/kvm-cpu.c +1 -9
@@ -1990,14 +1990,7 @@ static void kvm_cpu_instance_init(CPUState *cs)kvm_riscv_add_cpu_user_properties (obj); } -/* -* We'll get here via the following path: -* -* riscv_cpu_realize() -* -> cpu_exec_realizefn() -* -> kvm_cpu_realize() (via accel_cpu_common_realize()) -*/ -static bool kvm_cpu_realize (CPUState *cs,Error **errp) +bool kvm_arch_cpu_realize (CPUState *cs,Error **errp) {RISCVCPU *cpu =RISCV_CPU (cs);int ret;
@@ -2120,7 +2113,6 @@ static void kvm_cpu_accel_class_init(ObjectClass *oc, const void *data)AccelCPUClass *acc =ACCEL_CPU_CLASS (oc); acc->cpu_instance_init = kvm_cpu_instance_init; - acc->cpu_target_realize = kvm_cpu_realize; }static const TypeInfo kvm_cpu_accel_type_info = {
Signature · 1 line
2.53.0
Re: [PATCH 05/17] accel/kvm: Remove need for AccelCPUClass::cpu_target_realize
Quoted 37 lines · Philippe Mathieu-Daudé
accel_cpu_common_realize()first callsaccel_cpu->cpu_target_realizethenops->cpu_realize.Rather than having one handler for each host architecture, use a single host-specific method (prefixed with kvm_arch_* like other similar KVM methods). Register it once as AccelOpsClass
cpu_target_realizehandler.PPC's
ACCEL_CPU_NAME("kvm")TypeInfo is now empty, remove it.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- include/system/kvm.h | 2 ++ accel/kvm/kvm-accel-ops.c | 1 + target/i386/kvm/kvm-cpu.c | 3 +-- target/ppc/kvm.c | 23 +---------------------- target/riscv/kvm/kvm-cpu.c | 10 +--------- 5 files changed, 6 insertions(+), 33 deletions(-)include/system/kvm.h +2
-0@@ -364,6 +364,8 @@ int kvm_arch_pre_create_vcpu(CPUState *cpu, Error **errp);int kvm_arch_init_vcpu (CPUState *cpu);int kvm_arch_destroy_vcpu (CPUState *cpu); +bool kvm_arch_cpu_realize (CPUState *cpu,Error **errp); +#ifdef TARGET_KVM_HAVE_RESET_PARKED_VCPU void kvm_arch_reset_parked_vcpu (unsigned long vcpu_id,int kvm_fd);#else accel/kvm/kvm-accel-ops.c +0
-0
accel/kvm/kvm-accel-ops.c static void kvm_accel_ops_class_init(ObjectClass *oc, const void *data) · line 100
Quoted 4 lines
accel/kvm/kvm-accel-ops.c +1
-0@@ -97,6 +97,7 @@ static void kvm_accel_ops_class_init(ObjectClass *oc, const void *data)AccelOpsClass *ops =ACCEL_OPS_CLASS (oc); ops->create_vcpu_thread = kvm_start_vcpu_thread; + ops->cpu_target_realize = kvm_arch_cpu_realize;
cpu_realize
Quoted 90 lines
accel/kvm/kvm-accel-ops.c +0
-0ops->cpu_thread_is_idle = kvm_vcpu_thread_is_idle; ops->cpus_are_resettable = kvm_cpus_are_resettable; ops->synchronize_post_reset = kvm_cpu_synchronize_post_reset;target/i386/kvm/kvm-cpu.c +1
-2@@ -39,7 +39,7 @@ static void kvm_set_guest_phys_bits(CPUState *cs) } } -static bool kvm_cpu_realizefn (CPUState *cs,Error **errp) +bool kvm_arch_cpu_realize (CPUState *cs,Error **errp) {X86CPU *cpu =X86_CPU (cs);X86CPUClass *xcc =X86_CPU_GET_CLASS (cpu);@@ -237,7 +237,6 @@ static void kvm_cpu_accel_class_init(ObjectClass *oc, const void *data) {AccelCPUClass *acc =ACCEL_CPU_CLASS (oc); - acc->cpu_target_realize = kvm_cpu_realizefn; acc->cpu_instance_init = kvm_cpu_instance_init; }static const TypeInfo kvm_cpu_accel_type_info = {target/ppc/kvm.c +1
-22@@ -49,7 +49,6 @@#include "elf.h" #include "system/kvm_int.h" #include "system/kvm.h" -#include "accel/accel-cpu-target.h" #include CONFIG_DEVICES @@ -2353,7 +2352,7 @@ static void alter_insns(uint64_t *word, uint64_t flags, bool on) } } -static bool kvmppc_cpu_realize (CPUState *cs,Error **errp) +bool kvm_arch_cpu_realize (CPUState *cs,Error **errp) {int ret; const char *vcpu_str = (cs->parent_obj.hotplugged == true) ?@@ -2995,23 +2994,3 @@ void kvmppc_set_reg_tb_offset(PowerPCCPU *cpu, int64_t tb_offset)void kvm_arch_accel_class_init (ObjectClass *oc) { } - -static void kvm_cpu_accel_class_init (ObjectClass *oc,const void *data) -{ -AccelCPUClass *acc =ACCEL_CPU_CLASS (oc); - - acc->cpu_target_realize = kvmppc_cpu_realize; -} - -static const TypeInfo kvm_cpu_accel_type_info = { - .name =ACCEL_CPU_NAME ("kvm" ), - - .parent =TYPE_ACCEL_CPU , - .class_init = kvm_cpu_accel_class_init, - .abstract = true, -}; -static void kvm_cpu_accel_register_types (void ) -{ -type_register_static (&kvm_cpu_accel_type_info); -} -type_init (kvm_cpu_accel_register_types);target/riscv/kvm/kvm-cpu.c +1
-8@@ -1990,14 +1990,7 @@ static void kvm_cpu_instance_init(CPUState *cs)kvm_riscv_add_cpu_user_properties (obj); } -/* -* We'll get here via the following path: -* -* riscv_cpu_realize() -* -> cpu_exec_realizefn() -* -> kvm_cpu_realize() (via accel_cpu_common_realize()) -*/ -static bool kvm_cpu_realize (CPUState *cs,Error **errp) +bool kvm_arch_cpu_realize (CPUState *cs,Error **errp) {RISCVCPU *cpu =RISCV_CPU (cs);int ret;
target/riscv/kvm/kvm-cpu.c static void kvm_cpu_accel_class_init(ObjectClass *oc, const void *data) · line 2118
Quoted 7 lines
target/riscv/kvm/kvm-cpu.c +0
-1@@ -2120,7 +2113,6 @@ static void kvm_cpu_accel_class_init(ObjectClass *oc, const void *data)AccelCPUClass *acc =ACCEL_CPU_CLASS (oc); acc->cpu_instance_init = kvm_cpu_instance_init; - acc->cpu_target_realize = kvm_cpu_realize; }static const TypeInfo kvm_cpu_accel_type_info = {
Regards,
Pierrick
Re: [PATCH 05/17] accel/kvm: Remove need for AccelCPUClass::cpu_target_realize
Quoted 40 lines · Pierrick Bouvier
Quoted 39 lines · Philippe Mathieu-Daudé
accel_cpu_common_realize()first callsaccel_cpu->cpu_target_realizethenops->cpu_realize.Rather than having one handler for each host architecture, use a single host-specific method (prefixed with kvm_arch_* like other similar KVM methods). Register it once as AccelOpsClass
cpu_target_realizehandler.PPC's
ACCEL_CPU_NAME("kvm")TypeInfo is now empty, remove it.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- include/system/kvm.h | 2 ++ accel/kvm/kvm-accel-ops.c | 1 + target/i386/kvm/kvm-cpu.c | 3 +-- target/ppc/kvm.c | 23 +---------------------- target/riscv/kvm/kvm-cpu.c | 10 +--------- 5 files changed, 6 insertions(+), 33 deletions(-)include/system/kvm.h +2
-0@@ -364,6 +364,8 @@ int kvm_arch_pre_create_vcpu(CPUState *cpu, Error **errp);int kvm_arch_init_vcpu (CPUState *cpu);int kvm_arch_destroy_vcpu (CPUState *cpu); +bool kvm_arch_cpu_realize (CPUState *cpu,Error **errp); +#ifdef TARGET_KVM_HAVE_RESET_PARKED_VCPU void kvm_arch_reset_parked_vcpu (unsigned long vcpu_id,int kvm_fd);#else accel/kvm/kvm-accel-ops.c +0
-0@@ -97,6 +97,7 @@ static void kvm_accel_ops_class_init(ObjectClass *oc, const void *data)AccelOpsClass *ops =ACCEL_OPS_CLASS (oc);
Quoted 4 lines
accel/kvm/kvm-accel-ops.c static void kvm_accel_ops_class_init(ObjectClass *oc, const void *data) · line 100
Quoted 2 lines
accel/kvm/kvm-accel-ops.c +1
-0ops->create_vcpu_thread = kvm_start_vcpu_thread; + ops->cpu_target_realize = kvm_arch_cpu_realize;
cpu_realize
Ignore, I was wrong, confused that with AccelCPUClass.
Quoted 104 lines
Quoted 91 lines
accel/kvm/kvm-accel-ops.c +0
-0ops->cpu_thread_is_idle = kvm_vcpu_thread_is_idle; ops->cpus_are_resettable = kvm_cpus_are_resettable; ops->synchronize_post_reset = kvm_cpu_synchronize_post_reset;target/i386/kvm/kvm-cpu.c +1
-2@@ -39,7 +39,7 @@ static void kvm_set_guest_phys_bits(CPUState *cs) } } -static bool kvm_cpu_realizefn (CPUState *cs,Error **errp) +bool kvm_arch_cpu_realize (CPUState *cs,Error **errp) {X86CPU *cpu =X86_CPU (cs);X86CPUClass *xcc =X86_CPU_GET_CLASS (cpu);@@ -237,7 +237,6 @@ static void kvm_cpu_accel_class_init(ObjectClass *oc, const void *data) {AccelCPUClass *acc =ACCEL_CPU_CLASS (oc); - acc->cpu_target_realize = kvm_cpu_realizefn; acc->cpu_instance_init = kvm_cpu_instance_init; }static const TypeInfo kvm_cpu_accel_type_info = {target/ppc/kvm.c +1
-22@@ -49,7 +49,6 @@#include "elf.h" #include "system/kvm_int.h" #include "system/kvm.h" -#include "accel/accel-cpu-target.h" #include CONFIG_DEVICES @@ -2353,7 +2352,7 @@ static void alter_insns(uint64_t *word, uint64_t flags, bool on) } } -static bool kvmppc_cpu_realize (CPUState *cs,Error **errp) +bool kvm_arch_cpu_realize (CPUState *cs,Error **errp) {int ret; const char *vcpu_str = (cs->parent_obj.hotplugged == true) ?@@ -2995,23 +2994,3 @@ void kvmppc_set_reg_tb_offset(PowerPCCPU *cpu, int64_t tb_offset)void kvm_arch_accel_class_init (ObjectClass *oc) { } - -static void kvm_cpu_accel_class_init (ObjectClass *oc,const void *data) -{ -AccelCPUClass *acc =ACCEL_CPU_CLASS (oc); - - acc->cpu_target_realize = kvmppc_cpu_realize; -} - -static const TypeInfo kvm_cpu_accel_type_info = { - .name =ACCEL_CPU_NAME ("kvm" ), - - .parent =TYPE_ACCEL_CPU , - .class_init = kvm_cpu_accel_class_init, - .abstract = true, -}; -static void kvm_cpu_accel_register_types (void ) -{ -type_register_static (&kvm_cpu_accel_type_info); -} -type_init (kvm_cpu_accel_register_types);target/riscv/kvm/kvm-cpu.c +1
-8@@ -1990,14 +1990,7 @@ static void kvm_cpu_instance_init(CPUState *cs)kvm_riscv_add_cpu_user_properties (obj); } -/* -* We'll get here via the following path: -* -* riscv_cpu_realize() -* -> cpu_exec_realizefn() -* -> kvm_cpu_realize() (via accel_cpu_common_realize()) -*/ -static bool kvm_cpu_realize (CPUState *cs,Error **errp) +bool kvm_arch_cpu_realize (CPUState *cs,Error **errp) {RISCVCPU *cpu =RISCV_CPU (cs);int ret;target/riscv/kvm/kvm-cpu.c static void kvm_cpu_accel_class_init(ObjectClass *oc, const void *data) · line 2118
Quoted 7 lines
target/riscv/kvm/kvm-cpu.c +0
-1@@ -2120,7 +2113,6 @@ static void kvm_cpu_accel_class_init(ObjectClass *oc, const void *data)AccelCPUClass *acc =ACCEL_CPU_CLASS (oc); acc->cpu_instance_init = kvm_cpu_instance_init; - acc->cpu_target_realize = kvm_cpu_realize; }static const TypeInfo kvm_cpu_accel_type_info = {Reviewed-by Pierrick Bouvier <[email protected]>Regards,
Pierrick
Re: [PATCH 05/17] accel/kvm: Remove need for AccelCPUClass::cpu_target_realize
Quoted 41 lines · Pierrick Bouvier
Quoted 40 lines · Pierrick Bouvier
Quoted 39 lines · Philippe Mathieu-Daudé
accel_cpu_common_realize()first callsaccel_cpu->cpu_target_realizethenops->cpu_realize.Rather than having one handler for each host architecture, use a single host-specific method (prefixed with kvm_arch_* like other similar KVM methods). Register it once as AccelOpsClass
cpu_target_realizehandler.PPC's
ACCEL_CPU_NAME("kvm")TypeInfo is now empty, remove it.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- include/system/kvm.h | 2 ++ accel/kvm/kvm-accel-ops.c | 1 + target/i386/kvm/kvm-cpu.c | 3 +-- target/ppc/kvm.c | 23 +---------------------- target/riscv/kvm/kvm-cpu.c | 10 +--------- 5 files changed, 6 insertions(+), 33 deletions(-)include/system/kvm.h +2
-0@@ -364,6 +364,8 @@ int kvm_arch_pre_create_vcpu(CPUState *cpu, Error **errp);int kvm_arch_init_vcpu (CPUState *cpu);int kvm_arch_destroy_vcpu (CPUState *cpu); +bool kvm_arch_cpu_realize (CPUState *cpu,Error **errp); +#ifdef TARGET_KVM_HAVE_RESET_PARKED_VCPU void kvm_arch_reset_parked_vcpu (unsigned long vcpu_id,int kvm_fd);#else accel/kvm/kvm-accel-ops.c +0
-0@@ -97,6 +97,7 @@ static void kvm_accel_ops_class_init(ObjectClass *oc, const void *data)AccelOpsClass *ops =ACCEL_OPS_CLASS (oc);
Quoted 6 lines
Quoted 4 lines
accel/kvm/kvm-accel-ops.c static void kvm_accel_ops_class_init(ObjectClass *oc, const void *data) · line 100
Quoted 2 lines
accel/kvm/kvm-accel-ops.c +1
-0ops->create_vcpu_thread = kvm_start_vcpu_thread; + ops->cpu_target_realize = kvm_arch_cpu_realize;
cpu_realizeIgnore, I was wrong, confused that with AccelCPUClass.
No, you are right.
Quoted 106 lines
Quoted 105 lines
Quoted 92 lines
accel/kvm/kvm-accel-ops.c +0
-0ops->cpu_thread_is_idle = kvm_vcpu_thread_is_idle; ops->cpus_are_resettable = kvm_cpus_are_resettable; ops->synchronize_post_reset = kvm_cpu_synchronize_post_reset;target/i386/kvm/kvm-cpu.c +1
-2@@ -39,7 +39,7 @@ static void kvm_set_guest_phys_bits(CPUState *cs) } } -static bool kvm_cpu_realizefn (CPUState *cs,Error **errp) +bool kvm_arch_cpu_realize (CPUState *cs,Error **errp) {X86CPU *cpu =X86_CPU (cs);X86CPUClass *xcc =X86_CPU_GET_CLASS (cpu);@@ -237,7 +237,6 @@ static void kvm_cpu_accel_class_init(ObjectClass *oc, const void *data) {AccelCPUClass *acc =ACCEL_CPU_CLASS (oc); - acc->cpu_target_realize = kvm_cpu_realizefn; acc->cpu_instance_init = kvm_cpu_instance_init; }static const TypeInfo kvm_cpu_accel_type_info = {target/ppc/kvm.c +1
-22@@ -49,7 +49,6 @@#include "elf.h" #include "system/kvm_int.h" #include "system/kvm.h" -#include "accel/accel-cpu-target.h" #include CONFIG_DEVICES @@ -2353,7 +2352,7 @@ static void alter_insns(uint64_t *word, uint64_t flags, bool on) } } -static bool kvmppc_cpu_realize (CPUState *cs,Error **errp) +bool kvm_arch_cpu_realize (CPUState *cs,Error **errp) {int ret; const char *vcpu_str = (cs->parent_obj.hotplugged == true) ?@@ -2995,23 +2994,3 @@ void kvmppc_set_reg_tb_offset(PowerPCCPU *cpu, int64_t tb_offset)void kvm_arch_accel_class_init (ObjectClass *oc) { } - -static void kvm_cpu_accel_class_init (ObjectClass *oc,const void *data) -{ -AccelCPUClass *acc =ACCEL_CPU_CLASS (oc); - - acc->cpu_target_realize = kvmppc_cpu_realize; -} - -static const TypeInfo kvm_cpu_accel_type_info = { - .name =ACCEL_CPU_NAME ("kvm" ), - - .parent =TYPE_ACCEL_CPU , - .class_init = kvm_cpu_accel_class_init, - .abstract = true, -}; -static void kvm_cpu_accel_register_types (void ) -{ -type_register_static (&kvm_cpu_accel_type_info); -} -type_init (kvm_cpu_accel_register_types);target/riscv/kvm/kvm-cpu.c +1
-8@@ -1990,14 +1990,7 @@ static void kvm_cpu_instance_init(CPUState *cs)kvm_riscv_add_cpu_user_properties (obj); } -/* -* We'll get here via the following path: -* -* riscv_cpu_realize() -* -> cpu_exec_realizefn() -* -> kvm_cpu_realize() (via accel_cpu_common_realize()) -*/ -static bool kvm_cpu_realize (CPUState *cs,Error **errp) +bool kvm_arch_cpu_realize (CPUState *cs,Error **errp) {RISCVCPU *cpu =RISCV_CPU (cs);int ret;target/riscv/kvm/kvm-cpu.c static void kvm_cpu_accel_class_init(ObjectClass *oc, const void *data) · line 2118
Quoted 7 lines
target/riscv/kvm/kvm-cpu.c +0
-1@@ -2120,7 +2113,6 @@ static void kvm_cpu_accel_class_init(ObjectClass *oc, const void *data)AccelCPUClass *acc =ACCEL_CPU_CLASS (oc); acc->cpu_instance_init = kvm_cpu_instance_init; - acc->cpu_target_realize = kvm_cpu_realize; }static const TypeInfo kvm_cpu_accel_type_info = {Reviewed-by Pierrick Bouvier <[email protected]>Regards,
Pierrick
PATCH 6/17 accel: Introduce AccelOpsClass::cpu_instance_init handler
In reply to Philippe Mathieu-Daudéaccel_cpu_instance_init() currently dispatch via target specific AccelCPUClass which we want to remove. Introduce a similar hook in the generic AccelOpsClass structure.
We will convert implementations from one struct to the other, so add an assertion to be sure only one implementation at a time.
--- include/accel/accel-cpu-ops.h | 1 + accel/accel-common.c | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-)
include/accel/accel-cpu-ops.h +1 -0
@@ -34,6 +34,7 @@ struct AccelOpsClass {/* initialization function called when accel is chosen */ void (*ops_init)(AccelClass *ac); +void (*cpu_instance_init)(CPUState *cpu);bool (*cpu_realize)(CPUState *cpu,Error **errp);bool (*cpus_are_resettable)(void );void (*cpu_reset_hold)(CPUState *cpu);
accel/accel-common.c +9 -1
@@ -39,7 +39,15 @@ void accel_init_interfaces(AccelClass *ac)void accel_cpu_instance_init (CPUState *cpu) { -if (cpu->cc->accel_cpu && cpu->cc->accel_cpu->cpu_instance_init) { +AccelState *accel =current_accel (); +AccelClass *acc =ACCEL_GET_CLASS (accel); + +if (acc->ops && acc->ops->cpu_instance_init) { +if (cpu->cc->accel_cpu) { +assert (!cpu->cc->accel_cpu->cpu_instance_init); + } + acc->ops->cpu_instance_init (cpu); + }else if (cpu->cc->accel_cpu && cpu->cc->accel_cpu->cpu_instance_init) { cpu->cc->accel_cpu->cpu_instance_init (cpu); } }
Signature · 1 line
2.53.0
Re: [PATCH 06/17] accel: Introduce AccelOpsClass::cpu_instance_init handler
Quoted 6 lines · Philippe Mathieu-Daudé
accel_cpu_instance_init()currently dispatch via target specific AccelCPUClass which we want to remove. Introduce a similar hook in the generic AccelOpsClass structure.
We will convert implementations from one struct to the other, so add an assertion to be sure only one implementation at a time.
Quoted 6 lines
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- include/accel/accel-cpu-ops.h | 1 + accel/accel-common.c | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-)
PATCH 7/17 accel/whpx: Convert AccelCPUClass -> AccelOpsClass::cpu_instance_init
In reply to Philippe Mathieu-DaudéRegister the new AccelOpsClass::cpu_instance_init hook.
ACCEL_CPU_NAME("whpx") TypeInfo is now empty, remove it.
--- accel/whpx/whpx-accel-ops.c | 2 ++ accel/whpx/whpx-common.c | 17 ----------------- target/arm/whpx/whpx-all.c | 1 - target/i386/whpx/whpx-all.c | 1 - 4 files changed, 2 insertions(+), 19 deletions(-)
accel/whpx/whpx-accel-ops.c +2 -0
@@ -98,6 +98,8 @@ static void whpx_accel_ops_class_init(ObjectClass *oc, const void *data) ops->handle_interrupt = generic_handle_interrupt; ops->supports_guest_debug = whpx_supports_guest_debug; + ops->cpu_instance_init = whpx_cpu_instance_init; + ops->synchronize_post_reset = whpx_cpu_synchronize_post_reset; ops->synchronize_post_init = whpx_cpu_synchronize_post_init; ops->synchronize_state = whpx_cpu_synchronize_state;
accel/whpx/whpx-common.c +0 -17
@@ -24,7 +24,6 @@#include "qapi/qapi-types-common.h" #include "qapi/qapi-visit-common.h" #include "migration/blocker.h" -#include "accel/accel-cpu-target.h" #include <winerror.h> #include "system/whpx-internal.h"
@@ -505,21 +504,6 @@ static void whpx_set_hyperv(Object *obj, Visitor *v, } } -static void whpx_cpu_accel_class_init (ObjectClass *oc,const void *data) -{ -AccelCPUClass *acc =ACCEL_CPU_CLASS (oc); - - acc->cpu_instance_init = whpx_cpu_instance_init; -} - -static const TypeInfo whpx_cpu_accel_type = { - .name =ACCEL_CPU_NAME ("whpx" ), - - .parent =TYPE_ACCEL_CPU , - .class_init = whpx_cpu_accel_class_init, - .abstract = true, -}; -static void whpx_accel_class_init (ObjectClass *oc,const void *data) {AccelClass *ac =ACCEL_CLASS (oc);
@@ -569,7 +553,6 @@ static const TypeInfo whpx_accel_type = {static void whpx_type_init (void ) {type_register_static (&whpx_accel_type); -type_register_static (&whpx_cpu_accel_type); }bool init_whp_dispatch (void )
target/arm/whpx/whpx-all.c +0 -1
@@ -23,7 +23,6 @@#include "qapi/qapi-types-common.h" #include "qapi/qapi-visit-common.h" #include "migration/blocker.h" -#include "accel/accel-cpu-target.h" #include <winerror.h> #include "syndrome.h"
target/i386/whpx/whpx-all.c +0 -1
@@ -33,7 +33,6 @@#include "qapi/qapi-visit-common.h" #include "migration/blocker.h" #include "host-cpu.h" -#include "accel/accel-cpu-target.h" #include <winerror.h> #include "system/whpx-internal.h"
Signature · 1 line
2.53.0
Re: [PATCH 07/17] accel/whpx: Convert AccelCPUClass -> AccelOpsClass::cpu_instance_init
Quoted 4 lines · Philippe Mathieu-Daudé
Register the new
AccelOpsClass::cpu_instance_inithook.
ACCEL_CPU_NAME("whpx")TypeInfo is now empty, remove it.
Quoted 8 lines
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- accel/whpx/whpx-accel-ops.c | 2 ++ accel/whpx/whpx-common.c | 17 ----------------- target/arm/whpx/whpx-all.c | 1 - target/i386/whpx/whpx-all.c | 1 - 4 files changed, 2 insertions(+), 19 deletions(-)
Re: [PATCH 07/17] accel/whpx: Convert AccelCPUClass -> AccelOpsClass::cpu_instance_init
In reply to Philippe Mathieu-DaudéQuoted 21 lines · Philippe Mathieu-Daudé
Register the new
AccelOpsClass::cpu_instance_inithook.
ACCEL_CPU_NAME("whpx")TypeInfo is now empty, remove it.Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
accel/whpx/whpx-accel-ops.c | 2 ++ accel/whpx/whpx-common.c | 17 ----------------- target/arm/whpx/whpx-all.c | 1 - target/i386/whpx/whpx-all.c | 1 - 4 files changed, 2 insertions(+), 19 deletions(-)accel/whpx/whpx-accel-ops.c +0
-0
accel/whpx/whpx-accel-ops.c static void whpx_accel_ops_class_init(ObjectClass *oc, const void *data) · line 102
Quoted 5 lines
accel/whpx/whpx-accel-ops.c +2
-0@@ -98,6 +98,8 @@ static void whpx_accel_ops_class_init(ObjectClass *oc, const void *data) ops->handle_interrupt = generic_handle_interrupt; ops->supports_guest_debug = whpx_supports_guest_debug; + ops->cpu_instance_init = whpx_cpu_instance_init; +
Hi,
No whpx_cpu_instance_init implementation present in the commit as far as I can tell.
Did you miss it? Other than that things look fine and a stub implementation should be okay.
Quoted 73 lines
accel/whpx/whpx-accel-ops.c +0
-0ops->synchronize_post_reset = whpx_cpu_synchronize_post_reset; ops->synchronize_post_init = whpx_cpu_synchronize_post_init; ops->synchronize_state = whpx_cpu_synchronize_state;accel/whpx/whpx-common.c +0
-17@@ -24,7 +24,6 @@#include "qapi/qapi-types-common.h" #include "qapi/qapi-visit-common.h" #include "migration/blocker.h" -#include "accel/accel-cpu-target.h" #include <winerror.h> #include "system/whpx-internal.h" @@ -505,21 +504,6 @@ static void whpx_set_hyperv(Object *obj, Visitor *v, } } -static void whpx_cpu_accel_class_init (ObjectClass *oc,const void *data) -{ -AccelCPUClass *acc =ACCEL_CPU_CLASS (oc); - - acc->cpu_instance_init = whpx_cpu_instance_init; -} - -static const TypeInfo whpx_cpu_accel_type = { - .name =ACCEL_CPU_NAME ("whpx" ), - - .parent =TYPE_ACCEL_CPU , - .class_init = whpx_cpu_accel_class_init, - .abstract = true, -}; -static void whpx_accel_class_init (ObjectClass *oc,const void *data) {AccelClass *ac =ACCEL_CLASS (oc);@@ -569,7 +553,6 @@ static const TypeInfo whpx_accel_type = {static void whpx_type_init (void ) {type_register_static (&whpx_accel_type); -type_register_static (&whpx_cpu_accel_type); }bool init_whp_dispatch (void )target/arm/whpx/whpx-all.c +0
-1@@ -23,7 +23,6 @@#include "qapi/qapi-types-common.h" #include "qapi/qapi-visit-common.h" #include "migration/blocker.h" -#include "accel/accel-cpu-target.h" #include <winerror.h> #include "syndrome.h" target/i386/whpx/whpx-all.c +0
-1@@ -33,7 +33,6 @@#include "qapi/qapi-visit-common.h" #include "migration/blocker.h" #include "host-cpu.h" -#include "accel/accel-cpu-target.h" #include <winerror.h> #include "system/whpx-internal.h" Signature · 1 line
2.53.0
Re: [PATCH 07/17] accel/whpx: Convert AccelCPUClass -> AccelOpsClass::cpu_instance_init
Quoted 24 lines · Mohamed Mediouni
Quoted 24 lines · Philippe Mathieu-Daudé
Register the new
AccelOpsClass::cpu_instance_inithook.
ACCEL_CPU_NAME("whpx")TypeInfo is now empty, remove it.Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
accel/whpx/whpx-accel-ops.c | 2 ++ accel/whpx/whpx-common.c | 17 ----------------- target/arm/whpx/whpx-all.c | 1 - target/i386/whpx/whpx-all.c | 1 - 4 files changed, 2 insertions(+), 19 deletions(-)accel/whpx/whpx-accel-ops.c +0
-0@@ -98,6 +98,8 @@ static void whpx_accel_ops_class_init(ObjectClass *oc, const void *data) ops->handle_interrupt = generic_handle_interrupt; ops->supports_guest_debug = whpx_supports_guest_debug;
Quoted 6 lines
accel/whpx/whpx-accel-ops.c static void whpx_accel_ops_class_init(ObjectClass *oc, const void *data) · line 102
Quoted 2 lines
accel/whpx/whpx-accel-ops.c +2
-0+ ops->cpu_instance_init = whpx_cpu_instance_init; +Hi,
No
whpx_cpu_instance_initimplementation present in the commit as far as I can tell.
You exposed it in commit 4610fee3242 ("whpx: reshuffle common code") :)
Quoted 7 lines
Did you miss it? Other than that things look fine and a stub implementation should be okay.
Quoted 3 lines
accel/whpx/whpx-accel-ops.c +0
-0ops->synchronize_post_reset = whpx_cpu_synchronize_post_reset; ops->synchronize_post_init = whpx_cpu_synchronize_post_init; ops->synchronize_state = whpx_cpu_synchronize_state;
PATCH 8/17 accel/nvmm: Convert AccelCPUClass -> AccelOpsClass::cpu_instance_init
In reply to Philippe Mathieu-DaudéRegister the new AccelOpsClass::cpu_instance_init hook.
ACCEL_CPU_NAME("nvmm") TypeInfo is now empty, remove it.
--- target/i386/nvmm/nvmm-accel-ops.h | 2 ++ target/i386/nvmm/nvmm-accel-ops.c | 2 ++ target/i386/nvmm/nvmm-all.c | 19 +------------------ 3 files changed, 5 insertions(+), 18 deletions(-)
target/i386/nvmm/nvmm-accel-ops.h +2 -0
@@ -16,6 +16,8 @@ int nvmm_init_vcpu(CPUState *cpu);int nvmm_vcpu_exec (CPUState *cpu);void nvmm_destroy_vcpu (CPUState *cpu); +void nvmm_arch_cpu_instance_init (CPUState *cpu); +void nvmm_cpu_synchronize_state (CPUState *cpu);void nvmm_cpu_synchronize_post_reset (CPUState *cpu);void nvmm_cpu_synchronize_post_init (CPUState *cpu);
target/i386/nvmm/nvmm-accel-ops.c +2 -0
@@ -87,6 +87,8 @@ static void nvmm_accel_ops_class_init(ObjectClass *oc, const void *data) ops->kick_vcpu_thread = nvmm_kick_vcpu_thread; ops->handle_interrupt = generic_handle_interrupt; + ops->cpu_instance_init = nvmm_arch_cpu_instance_init; + ops->synchronize_post_reset = nvmm_cpu_synchronize_post_reset; ops->synchronize_post_init = nvmm_cpu_synchronize_post_init; ops->synchronize_state = nvmm_cpu_synchronize_state;
target/i386/nvmm/nvmm-all.c +1 -18
@@ -22,7 +22,6 @@#include "qemu/error-report.h" #include "qapi/error.h" #include "qemu/queue.h" -#include "accel/accel-cpu-target.h" #include "host-cpu.h" #include "migration/blocker.h" #include "strings.h"
@@ -1212,33 +1211,17 @@ static const TypeInfo nvmm_accel_type = { .class_init = nvmm_accel_class_init, }; -static void nvmm_cpu_instance_init (CPUState *cs) +void nvmm_arch_cpu_instance_init (CPUState *cpu) {X86CPU *cpu =X86_CPU (cs);host_cpu_instance_init (cpu); } -static void nvmm_cpu_accel_class_init (ObjectClass *oc,const void *data) -{ -AccelCPUClass *acc =ACCEL_CPU_CLASS (oc); - - acc->cpu_instance_init = nvmm_cpu_instance_init; -} - -static const TypeInfo nvmm_cpu_accel_type = { - .name =ACCEL_CPU_NAME ("nvmm" ), - - .parent =TYPE_ACCEL_CPU , - .class_init = nvmm_cpu_accel_class_init, - .abstract = true, -}; -static void nvmm_type_init (void ) {type_register_static (&nvmm_accel_type); -type_register_static (&nvmm_cpu_accel_type); }type_init (nvmm_type_init);
Signature · 1 line
2.53.0
Re: [PATCH 08/17] accel/nvmm: Convert AccelCPUClass -> AccelOpsClass::cpu_instance_init
Quoted 11 lines · Philippe Mathieu-Daudé
Register the new
AccelOpsClass::cpu_instance_inithook.
ACCEL_CPU_NAME("nvmm")TypeInfo is now empty, remove it.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- target/i386/nvmm/nvmm-accel-ops.h | 2 ++ target/i386/nvmm/nvmm-accel-ops.c | 2 ++ target/i386/nvmm/nvmm-all.c | 19 +------------------ 3 files changed, 5 insertions(+), 18 deletions(-)
PATCH 9/17 accel/hvf: Convert AccelCPUClass -> AccelOpsClass::cpu_instance_init
In reply to Philippe Mathieu-DaudéHVF cpu_instance_init() was only implemented for X86. Add a stub for ARM, allowing to register as generic AccelOpsClass::cpu_instance_init hook.
X86's ACCEL_CPU_NAME("hvf") TypeInfo is now empty, remove it.
--- include/system/hvf_int.h | 1 + accel/hvf/hvf-accel-ops.c | 1 + target/arm/hvf/hvf.c | 4 ++++ target/i386/hvf/hvf-cpu.c | 25 +------------------------ 4 files changed, 7 insertions(+), 24 deletions(-)
include/system/hvf_int.h +1 -0
@@ -109,6 +109,7 @@ int hvf_update_guest_debug(CPUState *cpu);*/ bool hvf_arch_supports_guest_debug (void ); +void hvf_arch_cpu_instance_init (CPUState *cpu);bool hvf_arch_cpu_realize (CPUState *cpu,Error **errp);uint32_t hvf_arch_get_default_ipa_bit_size (void );uint32_t hvf_arch_get_max_ipa_bit_size (void );
accel/hvf/hvf-accel-ops.c +1 -0
@@ -356,6 +356,7 @@ static void hvf_accel_ops_class_init(ObjectClass *oc, const void *data) {AccelOpsClass *ops =ACCEL_OPS_CLASS (oc); + ops->cpu_instance_init = hvf_arch_cpu_instance_init; ops->cpu_realize = hvf_arch_cpu_realize; ops->create_vcpu_thread = hvf_start_vcpu_thread;
target/arm/hvf/hvf.c +4 -0
@@ -1504,6 +1504,10 @@ int hvf_arch_init_vcpu(CPUState *cpu)return 0 ; } +void hvf_arch_cpu_instance_init (CPUState *cpu) +{ +} +bool hvf_arch_cpu_realize (CPUState *cs,Error **errp) {ARMCPU *cpu =ARM_CPU (cs);
target/i386/hvf/hvf-cpu.c +1 -24
@@ -14,7 +14,6 @@#include "system/system.h" #include "hw/core/boards.h" #include "system/hvf.h" -#include "accel/accel-cpu-target.h" #include "hvf-i386.h" static void hvf_cpu_max_instance_init (X86CPU *cpu)
@@ -56,7 +55,7 @@ static void hvf_cpu_xsave_init(void) } } -static void hvf_cpu_instance_init (CPUState *cs) +void hvf_arch_cpu_instance_init (CPUState *cpu) {X86CPU *cpu =X86_CPU (cs);X86CPUClass *xcc =X86_CPU_GET_CLASS (cpu);
@@ -77,25 +76,3 @@ bool hvf_arch_cpu_realize(CPUState *cs, Error **errp) {return host_cpu_realizefn (cs, errp); } - -static void hvf_cpu_accel_class_init (ObjectClass *oc,const void *data) -{ -AccelCPUClass *acc =ACCEL_CPU_CLASS (oc); - - acc->cpu_instance_init = hvf_cpu_instance_init; -} - -static const TypeInfo hvf_cpu_accel_type_info = { - .name =ACCEL_CPU_NAME ("hvf" ), - - .parent =TYPE_ACCEL_CPU , - .class_init = hvf_cpu_accel_class_init, - .abstract = true, -}; - -static void hvf_cpu_accel_register_types (void ) -{ -type_register_static (&hvf_cpu_accel_type_info); -} - -type_init (hvf_cpu_accel_register_types);
Signature · 1 line
2.53.0
Re: [PATCH 09/17] accel/hvf: Convert AccelCPUClass -> AccelOpsClass::cpu_instance_init
Quoted 6 lines · Philippe Mathieu-Daudé
HVF
cpu_instance_init()was only implemented for X86. Add a stub for ARM, allowing to register as genericAccelOpsClass::cpu_instance_inithook.X86's
ACCEL_CPU_NAME("hvf")TypeInfo is now empty, remove it.
Quoted 8 lines
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- include/system/hvf_int.h | 1 + accel/hvf/hvf-accel-ops.c | 1 + target/arm/hvf/hvf.c | 4 ++++ target/i386/hvf/hvf-cpu.c | 25 +------------------------ 4 files changed, 7 insertions(+), 24 deletions(-)
PATCH 10/17 accel/kvm: Convert AccelCPUClass -> AccelOpsClass::cpu_instance_init
In reply to Philippe Mathieu-DaudéExpose kvm_arch_cpu_instance_init() and register it as generic AccelOpsClass::cpu_instance_init hook.
Both X86 / RISCV's ACCEL_CPU_NAME("kvm") TypeInfo are now empty, remove them.
--- include/system/kvm.h | 1 + accel/kvm/kvm-accel-ops.c | 1 + target/i386/kvm/kvm-cpu.c | 22 +--------------------- target/riscv/kvm/kvm-cpu.c | 23 +---------------------- 4 files changed, 4 insertions(+), 43 deletions(-)
include/system/kvm.h +1 -0
@@ -364,6 +364,7 @@ int kvm_arch_pre_create_vcpu(CPUState *cpu, Error **errp);int kvm_arch_init_vcpu (CPUState *cpu);int kvm_arch_destroy_vcpu (CPUState *cpu); +void kvm_arch_cpu_instance_init (CPUState *cpu);bool kvm_arch_cpu_realize (CPUState *cpu,Error **errp);#ifdef TARGET_KVM_HAVE_RESET_PARKED_VCPU
accel/kvm/kvm-accel-ops.c +1 -0
@@ -97,6 +97,7 @@ static void kvm_accel_ops_class_init(ObjectClass *oc, const void *data)AccelOpsClass *ops =ACCEL_OPS_CLASS (oc); ops->create_vcpu_thread = kvm_start_vcpu_thread; + ops->cpu_instance_init = kvm_arch_cpu_instance_init; ops->cpu_target_realize = kvm_arch_cpu_realize; ops->cpu_thread_is_idle = kvm_vcpu_thread_is_idle; ops->cpus_are_resettable = kvm_cpus_are_resettable;
target/i386/kvm/kvm-cpu.c +1 -21
@@ -16,7 +16,6 @@#include "hw/i386/x86.h" #include "kvm_i386.h" -#include "accel/accel-cpu-target.h" static void kvm_set_guest_phys_bits (CPUState *cs) {
@@ -207,7 +206,7 @@ static void x86_cpu_change_kvm_default(const char *prop, const char *value)assert (pv->prop); } -static void kvm_cpu_instance_init (CPUState *cs) +void kvm_arch_cpu_instance_init (CPUState *cs) {X86CPU *cpu =X86_CPU (cs);X86CPUClass *xcc =X86_CPU_GET_CLASS (cpu);
@@ -232,22 +231,3 @@ static void kvm_cpu_instance_init(CPUState *cs)kvm_cpu_xsave_init (); } - -static void kvm_cpu_accel_class_init (ObjectClass *oc,const void *data) -{ -AccelCPUClass *acc =ACCEL_CPU_CLASS (oc); - - acc->cpu_instance_init = kvm_cpu_instance_init; -} -static const TypeInfo kvm_cpu_accel_type_info = { - .name =ACCEL_CPU_NAME ("kvm" ), - - .parent =TYPE_ACCEL_CPU , - .class_init = kvm_cpu_accel_class_init, - .abstract = true, -}; -static void kvm_cpu_accel_register_types (void ) -{ -type_register_static (&kvm_cpu_accel_type_info); -} -type_init (kvm_cpu_accel_register_types);
target/riscv/kvm/kvm-cpu.c +1 -22
@@ -32,7 +32,6 @@#include "system/kvm_int.h" #include "cpu.h" #include "trace.h" -#include "accel/accel-cpu-target.h" #include "hw/pci/pci.h" #include "exec/memattrs.h" #include "system/address-spaces.h"
@@ -1981,7 +1980,7 @@ void kvm_riscv_aia_create(MachineState *machine, uint64_t group_shift, kvm_msi_via_irqfd_allowed = true; } -static void kvm_cpu_instance_init (CPUState *cs) +void kvm_arch_cpu_instance_init (CPUState *cs) {Object *obj =OBJECT (RISCV_CPU (cs));
@@ -2108,26 +2107,6 @@ void riscv_kvm_cpu_finalize_features(RISCVCPU *cpu, Error **errp)kvm_riscv_destroy_scratch_vcpu (&kvmcpu); } -static void kvm_cpu_accel_class_init (ObjectClass *oc,const void *data) -{ -AccelCPUClass *acc =ACCEL_CPU_CLASS (oc); - - acc->cpu_instance_init = kvm_cpu_instance_init; -} - -static const TypeInfo kvm_cpu_accel_type_info = { - .name =ACCEL_CPU_NAME ("kvm" ), - - .parent =TYPE_ACCEL_CPU , - .class_init = kvm_cpu_accel_class_init, - .abstract = true, -}; -static void kvm_cpu_accel_register_types (void ) -{ -type_register_static (&kvm_cpu_accel_type_info); -} -type_init (kvm_cpu_accel_register_types); -static const TypeInfo riscv_kvm_cpu_type_infos[] = { { .name =TYPE_RISCV_CPU_HOST ,
Signature · 1 line
2.53.0
Re: [PATCH 10/17] accel/kvm: Convert AccelCPUClass -> AccelOpsClass::cpu_instance_init
Quoted 6 lines · Philippe Mathieu-Daudé
Expose
kvm_arch_cpu_instance_init()and register it as genericAccelOpsClass::cpu_instance_inithook.Both X86 / RISCV's
ACCEL_CPU_NAME("kvm")TypeInfo are now empty, remove them.
Quoted 8 lines
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- include/system/kvm.h | 1 + accel/kvm/kvm-accel-ops.c | 1 + target/i386/kvm/kvm-cpu.c | 22 +--------------------- target/riscv/kvm/kvm-cpu.c | 23 +---------------------- 4 files changed, 4 insertions(+), 43 deletions(-)
PATCH 11/17 accel/tcg: Convert AccelCPUClass -> new TCGCPUOps::cpu_instance_init
In reply to Philippe Mathieu-DaudéIntroduce a TCGCPUOps::cpu_instance_init hook and call it with tcg_cpu_instance_init(). Register tcg_cpu_instance_init() as AccelOpsClass::cpu_instance_init.
At the same time, convert X86 and RISCV AccelCPUClass hooks, after forward-declaring each target method (to avoid moving code around).
--- accel/tcg/tcg-accel-ops.h | 1 + include/accel/tcg/cpu-ops.h | 1 + accel/tcg/cpu-exec.c | 9 +++++++++ accel/tcg/tcg-accel-ops.c | 1 + target/i386/tcg/tcg-cpu.c | 5 +++-- target/riscv/tcg/tcg-cpu.c | 4 +++- 6 files changed, 18 insertions(+), 3 deletions(-)
accel/tcg/tcg-accel-ops.h +1 -0
@@ -14,6 +14,7 @@#include "system/cpus.h" +void tcg_cpu_instance_init (CPUState *cpu);void tcg_cpu_destroy (CPUState *cpu);int tcg_cpu_exec (CPUState *cpu);void tcg_handle_interrupt (CPUState *cpu,int mask);
include/accel/tcg/cpu-ops.h +1 -0
@@ -48,6 +48,7 @@ struct TCGCPUOps {* Called when the first CPU is realized. */ void (*initialize)(void ); +void (*cpu_instance_init)(CPUState *cpu);/** * @translate_code: Translate guest instructions to TCGOps * @cpu: cpu context
accel/tcg/cpu-exec.c +9 -0
@@ -1045,6 +1045,15 @@ int cpu_exec(CPUState *cpu)return ret; } +void tcg_cpu_instance_init (CPUState *cpu) +{ +const TCGCPUOps *tcg_ops = cpu->cc->tcg_ops; + +if (tcg_ops->cpu_instance_init) { + tcg_ops->cpu_instance_init (cpu); + } +} +bool tcg_exec_realizefn (CPUState *cpu,Error **errp) {static bool tcg_target_initialized;
accel/tcg/tcg-accel-ops.c +1 -0
@@ -219,6 +219,7 @@ static void tcg_accel_ops_init(AccelClass *ac) } } + ops->cpu_instance_init = tcg_cpu_instance_init; ops->cpu_reset_hold = tcg_cpu_reset_hold; ops->supports_guest_debug = tcg_supports_guest_debug; ops->insert_breakpoint = tcg_insert_breakpoint;
target/i386/tcg/tcg-cpu.c +3 -2
@@ -157,6 +157,8 @@ static vaddr x86_pointer_wrap(CPUState *cs, int mmu_idx, }#endif +static void x86_tcg_cpu_instance_init (CPUState *cs); +const TCGCPUOps x86_tcg_ops = { .mttcg_supported = true, .precise_smc = true,
@@ -165,6 +167,7 @@ const TCGCPUOps x86_tcg_ops = {*/ .guest_default_memory_order = TCG_MO_ALL & ~TCG_MO_ST_LD, .initialize = tcg_x86_init, + .cpu_instance_init = x86_tcg_cpu_instance_init, .translate_code = x86_translate_code, .get_tb_cpu_state = x86_get_tb_cpu_state, .synchronize_from_tb = x86_cpu_synchronize_from_tb,
@@ -237,8 +240,6 @@ static void x86_tcg_cpu_accel_class_init(ObjectClass *oc, const void *data)#ifndef CONFIG_USER_ONLY acc->cpu_target_realize = tcg_cpu_realizefn;#endif /* CONFIG_USER_ONLY */ - - acc->cpu_instance_init = x86_tcg_cpu_instance_init; }static const TypeInfo x86_tcg_cpu_accel_type_info = { .name =ACCEL_CPU_NAME ("tcg" ),
target/riscv/tcg/tcg-cpu.c +3 -1
@@ -268,11 +268,14 @@ static vaddr riscv_pointer_wrap(CPUState *cs, int mmu_idx, }#endif +static void riscv_tcg_cpu_instance_init (CPUState *cs); +const TCGCPUOps riscv_tcg_ops = { .mttcg_supported = true, .guest_default_memory_order =0 , .initialize = riscv_translate_init, + .cpu_instance_init = riscv_tcg_cpu_instance_init, .translate_code = riscv_translate_code, .get_tb_cpu_state = riscv_get_tb_cpu_state, .synchronize_from_tb = riscv_cpu_synchronize_from_tb,
@@ -1678,7 +1681,6 @@ static void riscv_tcg_cpu_accel_class_init(ObjectClass *oc, const void *data) {AccelCPUClass *acc =ACCEL_CPU_CLASS (oc); - acc->cpu_instance_init = riscv_tcg_cpu_instance_init; acc->cpu_target_realize = riscv_tcg_cpu_realize; }
Signature · 1 line
2.53.0
Re: [PATCH 11/17] accel/tcg: Convert AccelCPUClass -> new TCGCPUOps::cpu_instance_init
Quoted 9 lines · Philippe Mathieu-Daudé
Introduce a
TCGCPUOps::cpu_instance_inithook and call it withtcg_cpu_instance_init(). Registertcg_cpu_instance_init()asAccelOpsClass::cpu_instance_init.At the same time, convert X86 and RISCV AccelCPUClass hooks, after forward-declaring each target method (to avoid moving code around).
Signed-off-by Philippe Mathieu-Daudé <[email protected]>
Quoted 9 lines
--- accel/tcg/tcg-accel-ops.h | 1 + include/accel/tcg/cpu-ops.h | 1 + accel/tcg/cpu-exec.c | 9 +++++++++ accel/tcg/tcg-accel-ops.c | 1 + target/i386/tcg/tcg-cpu.c | 5 +++-- target/riscv/tcg/tcg-cpu.c | 4 +++- 6 files changed, 18 insertions(+), 3 deletions(-)
PATCH 12/17 accel: Remove AccelCPUClass::cpu_instance_init()
In reply to Philippe Mathieu-DaudéWe removed all implementations: remove as dead code.
--- include/accel/accel-cpu.h | 1 - accel/accel-common.c | 5 ----- 2 files changed, 6 deletions(-)
include/accel/accel-cpu.h +0 -1
@@ -15,7 +15,6 @@typedef struct AccelCPUClass {ObjectClass parent_class; -void (*cpu_instance_init)(CPUState *cpu);bool (*cpu_target_realize)(CPUState *cpu,Error **errp); }AccelCPUClass ;
accel/accel-common.c +0 -5
@@ -43,12 +43,7 @@ void accel_cpu_instance_init(CPUState *cpu)AccelClass *acc =ACCEL_GET_CLASS (accel);if (acc->ops && acc->ops->cpu_instance_init) { -if (cpu->cc->accel_cpu) { -assert (!cpu->cc->accel_cpu->cpu_instance_init); - } acc->ops->cpu_instance_init (cpu); - }else if (cpu->cc->accel_cpu && cpu->cc->accel_cpu->cpu_instance_init) { - cpu->cc->accel_cpu->cpu_instance_init (cpu); } }
Signature · 1 line
2.53.0
Re: [PATCH 12/17] accel: Remove AccelCPUClass::cpu_instance_init()
Quoted 8 lines · Philippe Mathieu-Daudé
We removed all implementations: remove as dead code.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- include/accel/accel-cpu.h | 1 - accel/accel-common.c | 5 ----- 2 files changed, 6 deletions(-)
PATCH 13/17 accel/tcg: Convert AccelCPUClass -> new TCGCPUOps::cpu_realize
In reply to Philippe Mathieu-DaudéIntroduce a TCGCPUOps::cpu_realize hook and call it at the end of tcg_exec_realizefn().
--- include/accel/tcg/cpu-ops.h | 1 + accel/tcg/cpu-exec.c | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-)
include/accel/tcg/cpu-ops.h +1 -0
@@ -49,6 +49,7 @@ struct TCGCPUOps {*/ void (*initialize)(void );void (*cpu_instance_init)(CPUState *cpu); +bool (*cpu_realize)(CPUState *cpu,Error **errp);/** * @translate_code: Translate guest instructions to TCGOps * @cpu: cpu context
accel/tcg/cpu-exec.c +5 -1
@@ -1056,11 +1056,11 @@ void tcg_cpu_instance_init(CPUState *cpu)bool tcg_exec_realizefn (CPUState *cpu,Error **errp) { +const TCGCPUOps *tcg_ops = cpu->cc->tcg_ops;static bool tcg_target_initialized;if (!tcg_target_initialized) {/* Check mandatory TCGCPUOps handlers */ -const TCGCPUOps *tcg_ops = cpu->cc->tcg_ops;#ifndef CONFIG_USER_ONLY assert (tcg_ops->cpu_exec_halt);assert (tcg_ops->cpu_exec_interrupt);
@@ -1081,6 +1081,10 @@ bool tcg_exec_realizefn(CPUState *cpu, Error **errp)#endif /* !CONFIG_USER_ONLY */ /* qemu_plugin_vcpu_init_hook delayed until cpu_index assigned. */ +if (tcg_ops->cpu_realize && !tcg_ops->cpu_realize (cpu, errp)) { +return false; + } +return true; }
Signature · 1 line
2.53.0
Re: [PATCH 13/17] accel/tcg: Convert AccelCPUClass -> new TCGCPUOps::cpu_realize
Quoted 9 lines · Philippe Mathieu-Daudé
Introduce a
TCGCPUOps::cpu_realizehook and call it at the end oftcg_exec_realizefn().Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- include/accel/tcg/cpu-ops.h | 1 + accel/tcg/cpu-exec.c | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-)
PATCH 14/17 accel/tcg: Convert X86 AccelCPUClass -> TCGCPUOps::cpu_realize
In reply to Philippe Mathieu-DaudéRegister AccelCPUClass::cpu_target_realize as x86_tcg_ops::cpu_realize. X86's ACCEL_CPU_NAME("tcg") TypeInfo is now empty, remove it.
--- target/i386/tcg/tcg-cpu.c | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-)
target/i386/tcg/tcg-cpu.c +1 -22
@@ -21,7 +21,6 @@#include "cpu.h" #include "helper-tcg.h" #include "qemu/accel.h" -#include "accel/accel-cpu-target.h" #include "exec/translation-block.h" #include "exec/target_page.h" #include "accel/tcg/cpu-ops.h"
@@ -180,6 +179,7 @@ const TCGCPUOps x86_tcg_ops = { .record_sigsegv = x86_cpu_record_sigsegv, .record_sigbus = x86_cpu_record_sigbus, #else + .cpu_realize = tcg_cpu_realizefn, .tlb_fill = x86_cpu_tlb_fill, .pointer_wrap = x86_pointer_wrap, .do_interrupt = x86_cpu_do_interrupt,
@@ -232,24 +232,3 @@ static void x86_tcg_cpu_instance_init(CPUState *cs)x86_tcg_cpu_xsave_init (); } - -static void x86_tcg_cpu_accel_class_init (ObjectClass *oc,const void *data) -{ -AccelCPUClass *acc =ACCEL_CPU_CLASS (oc); - -#ifndef CONFIG_USER_ONLY - acc->cpu_target_realize = tcg_cpu_realizefn; -#endif /* CONFIG_USER_ONLY */ -} -static const TypeInfo x86_tcg_cpu_accel_type_info = { - .name =ACCEL_CPU_NAME ("tcg" ), - - .parent =TYPE_ACCEL_CPU , - .class_init = x86_tcg_cpu_accel_class_init, - .abstract = true, -}; -static void x86_tcg_cpu_accel_register_types (void ) -{ -type_register_static (&x86_tcg_cpu_accel_type_info); -} -type_init (x86_tcg_cpu_accel_register_types);
Signature · 1 line
2.53.0
Re: [PATCH 14/17] accel/tcg: Convert X86 AccelCPUClass -> TCGCPUOps::cpu_realize
Quoted 8 lines · Philippe Mathieu-Daudé
Register
AccelCPUClass::cpu_target_realizeasx86_tcg_ops::cpu_realize. X86'sACCEL_CPU_NAME("tcg")TypeInfo is now empty, remove it.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- target/i386/tcg/tcg-cpu.c | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-)
PATCH 15/17 accel/tcg: Convert RISCV AccelCPUClass -> TCGCPUOps::cpu_realize
In reply to Philippe Mathieu-DaudéRegister AccelCPUClass::cpu_target_realize as riscv_tcg_ops::cpu_realize. RISCV's ACCEL_CPU_NAME("tcg") TypeInfo is now empty, remove it.
--- target/riscv/tcg/tcg-cpu.c | 24 ++---------------------- 1 file changed, 2 insertions(+), 22 deletions(-)
target/riscv/tcg/tcg-cpu.c +2 -22
@@ -30,7 +30,6 @@#include "qemu/accel.h" #include "qemu/error-report.h" #include "qemu/log.h" -#include "accel/accel-cpu-target.h" #include "accel/tcg/cpu-ops.h" #include "tcg/tcg.h" #ifndef CONFIG_USER_ONLY
@@ -269,6 +268,7 @@ static vaddr riscv_pointer_wrap(CPUState *cs, int mmu_idx,#endif static void riscv_tcg_cpu_instance_init (CPUState *cs); +static bool riscv_tcg_cpu_realize (CPUState *cs,Error **errp);const TCGCPUOps riscv_tcg_ops = { .mttcg_supported = true,
@@ -276,6 +276,7 @@ const TCGCPUOps riscv_tcg_ops = { .initialize = riscv_translate_init, .cpu_instance_init = riscv_tcg_cpu_instance_init, + .cpu_realize = riscv_tcg_cpu_realize, .translate_code = riscv_translate_code, .get_tb_cpu_state = riscv_get_tb_cpu_state, .synchronize_from_tb = riscv_cpu_synchronize_from_tb,
@@ -1676,24 +1677,3 @@ static void riscv_tcg_cpu_instance_init(CPUState *cs)riscv_init_max_cpu_extensions (obj); } } - -static void riscv_tcg_cpu_accel_class_init (ObjectClass *oc,const void *data) -{ -AccelCPUClass *acc =ACCEL_CPU_CLASS (oc); - - acc->cpu_target_realize = riscv_tcg_cpu_realize; -} - -static const TypeInfo riscv_tcg_cpu_accel_type_info = { - .name =ACCEL_CPU_NAME ("tcg" ), - - .parent =TYPE_ACCEL_CPU , - .class_init = riscv_tcg_cpu_accel_class_init, - .abstract = true, -}; - -static void riscv_tcg_cpu_accel_register_types (void ) -{ -type_register_static (&riscv_tcg_cpu_accel_type_info); -} -type_init (riscv_tcg_cpu_accel_register_types);
Signature · 1 line
2.53.0
Re: [PATCH 15/17] accel/tcg: Convert RISCV AccelCPUClass -> TCGCPUOps::cpu_realize
Quoted 9 lines · Philippe Mathieu-Daudé
Register
AccelCPUClass::cpu_target_realizeasriscv_tcg_ops::cpu_realize. RISCV'sACCEL_CPU_NAME("tcg")TypeInfo is now empty, remove it.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- target/riscv/tcg/tcg-cpu.c | 24 ++---------------------- 1 file changed, 2 insertions(+), 22 deletions(-)
PATCH 16/17 accel: Remove AccelCPUClass::cpu_target_realize()
In reply to Philippe Mathieu-DaudéWe removed all implementations of AccelCPUClass::cpu_target_realize, remove the calls in accel_cpu_common_realize().
--- include/accel/accel-cpu.h | 2 -- accel/accel-common.c | 7 ------- 2 files changed, 9 deletions(-)
include/accel/accel-cpu.h +0 -2
@@ -14,8 +14,6 @@typedef struct AccelCPUClass {ObjectClass parent_class; - -bool (*cpu_target_realize)(CPUState *cpu,Error **errp); }AccelCPUClass ;#endif /* ACCEL_CPU_H */
accel/accel-common.c +0 -7
@@ -52,13 +52,6 @@ bool accel_cpu_common_realize(CPUState *cpu, Error **errp)AccelState *accel =current_accel ();AccelClass *acc =ACCEL_GET_CLASS (accel); -/* target specific realization */ -if (cpu->cc->accel_cpu - && cpu->cc->accel_cpu->cpu_target_realize - && !cpu->cc->accel_cpu->cpu_target_realize (cpu, errp)) { -return false; - } -/* generic realization */ if (acc->cpu_common_realize && !acc->cpu_common_realize (cpu, errp)) {return false;
Signature · 1 line
2.53.0
Re: [PATCH 16/17] accel: Remove AccelCPUClass::cpu_target_realize()
Quoted 9 lines · Philippe Mathieu-Daudé
We removed all implementations of
AccelCPUClass::cpu_target_realize, remove the calls inaccel_cpu_common_realize().Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- include/accel/accel-cpu.h | 2 -- accel/accel-common.c | 7 ------- 2 files changed, 9 deletions(-)
PATCH 17/17 accel: Remove AccelCPUClass and 'accel/accel-cpu-target.h'
In reply to Philippe Mathieu-DaudéAccelCPUClass is now an empty class. We removed all uses of the TYPE_ACCEL_CPU definition. Remove as dead code, along with register_accel_target_type().
--- include/accel/accel-cpu-target.h | 31 ------------------------------- include/accel/accel-cpu.h | 19 ------------------- accel/accel-common.c | 16 ---------------- 3 files changed, 66 deletions(-) delete mode 100644 include/accel/accel-cpu-target.h delete mode 100644 include/accel/accel-cpu.h
include/accel/accel-cpu-target.h deleted +0 -31
@@ -1,31 +0,0 @@ -/* -* Accelerator interface, specializes CPUClass -* This header is used only by target-specific code. -* -* Copyright 2021 SUSE LLC -* -* This work is licensed under the terms of the GNU GPL, version 2 or later. -* See the COPYING file in the top-level directory. -*/ - -#ifndef ACCEL_CPU_TARGET_H -#define ACCEL_CPU_TARGET_H - -/* -* This header is used to define new accelerator-specific target-specific -* accelerator cpu subclasses. -* It uses CPU_RESOLVING_TYPE, so this is clearly target-specific. -* -* Do not try to use for any other purpose than the implementation of new -* subclasses in target/, or the accel implementation itself in accel/ -*/ - -#include "qom/object.h" -#include "accel/accel-cpu.h" -#include "cpu.h" - -#define TYPE_ACCEL_CPU "accel-" CPU_RESOLVING_TYPE -#define ACCEL_CPU_NAME (name) (name "-" TYPE_ACCEL_CPU) -DECLARE_CLASS_CHECKERS(AccelCPUClass, ACCEL_CPU, TYPE_ACCEL_CPU) - -#endif /* ACCEL_CPU_H */
include/accel/accel-cpu.h deleted +0 -19
@@ -1,19 +0,0 @@ -/* -* Accelerator interface, specializes CPUClass -* -* Copyright 2021 SUSE LLC -* -* SPDX-License-Identifier: GPL-2.0-or-later -*/ - -#ifndef ACCEL_CPU_H -#define ACCEL_CPU_H - -#include "qom/object.h" -#include "hw/core/cpu.h" - -typedef struct AccelCPUClass { -ObjectClass parent_class; -}AccelCPUClass ; - -#endif /* ACCEL_CPU_H */
accel/accel-common.c +0 -16
@@ -11,7 +11,6 @@#include "qemu/accel.h" #include "qemu/target-info.h" #include "accel/accel-ops.h" -#include "accel/accel-cpu.h" #include "accel/accel-cpu-ops.h" #include "accel-internal.h"
@@ -98,18 +97,3 @@ static const TypeInfo accel_types[] = { };DEFINE_TYPES (accel_types) - -static void register_accel_target_type(void) -{ - g_autofree char *name = g_strconcat("accel-", target_cpu_type(), NULL); -const TypeInfo accel_cpu_type = { - .name = name, - .parent =TYPE_OBJECT , - .abstract = true, - .class_size =sizeof (AccelCPUClass), - }; - -type_register_static (&accel_cpu_type); -} - -type_init (register_accel_target_type);
Signature · 1 line
2.53.0
Re: [PATCH 17/17] accel: Remove AccelCPUClass and 'accel/accel-cpu-target.h'
Quoted 4 lines · Philippe Mathieu-Daudé
AccelCPUClass is now an empty class. We removed all uses of the
TYPE_ACCEL_CPUdefinition. Remove as dead code, along withregister_accel_target_type().
Quoted 9 lines
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- include/accel/accel-cpu-target.h | 31 ------------------------------- include/accel/accel-cpu.h | 19 ------------------- accel/accel-common.c | 16 ---------------- 3 files changed, 66 deletions(-) delete mode 100644 include/accel/accel-cpu-target.h delete mode 100644 include/accel/accel-cpu.h
👍
Quoted 26 lines · Philippe Mathieu-Daudé
Move cpu_init/realize hooks from AccelCPUClass to AccelOpsClass. Specialize them for TCG in TCGCPUOps.
This drastically simplifies the need of per-binary QOM types per accelerator per target (see also the nice diff-stat).
Based-on: tag single-binary-20260528
Ignoring checkpatch.pl:
WARNING: added, moved or deleted file(s), does
MAINTAINERSneed updating?
accel/accel-target.c
include/accel/accel-cpu-target.h
include/accel/accel-cpu.hPhilippe Mathieu-Daudé (17):
target/loongarch: Remove unused 'accel/accel-cpu-target.h' header accel: RemoveAccelCPUClass::cpu_class_init() accel: RenameAccelOpsClass::cpu_target_realize() -> cpu_realize() accel/hvf: Remove need forAccelCPUClass::cpu_target_realize accel/kvm: Remove need forAccelCPUClass::cpu_target_realize accel: IntroduceAccelOpsClass::cpu_instance_init handler accel/whpx: Convert AccelCPUClass ->AccelOpsClass::cpu_instance_init accel/nvmm: Convert AccelCPUClass ->AccelOpsClass::cpu_instance_init accel/hvf: Convert AccelCPUClass ->AccelOpsClass::cpu_instance_init
Quoted 8 lines
accel/kvm: Convert AccelCPUClass ->AccelOpsClass::cpu_instance_init accel/tcg: Convert AccelCPUClass -> newTCGCPUOps::cpu_instance_init accel: RemoveAccelCPUClass::cpu_instance_init() accel/tcg: Convert AccelCPUClass -> newTCGCPUOps::cpu_realize accel/tcg: Convert X86 AccelCPUClass ->TCGCPUOps::cpu_realize accel/tcg: Convert RISCV AccelCPUClass ->TCGCPUOps::cpu_realize accel: RemoveAccelCPUClass::cpu_target_realize() accel: Remove AccelCPUClass and 'accel/accel-cpu-target.h'
Modulo patch description for patches 4 & 5, series
r~
Quoted 64 lines · Philippe Mathieu-Daudé
Move cpu_init/realize hooks from AccelCPUClass to AccelOpsClass. Specialize them for TCG in TCGCPUOps.
This drastically simplifies the need of per-binary QOM types per accelerator per target (see also the nice diff-stat).
Based-on: tag single-binary-20260528
Ignoring checkpatch.pl:
WARNING: added, moved or deleted file(s), does
MAINTAINERSneed updating?
accel/accel-target.c
include/accel/accel-cpu-target.h
include/accel/accel-cpu.hPhilippe Mathieu-Daudé (17):
target/loongarch: Remove unused 'accel/accel-cpu-target.h' header accel: Remove AccelCPUClass::cpu_class_init() accel: Rename AccelOpsClass::cpu_target_realize() -> cpu_realize() accel/hvf: Remove need for AccelCPUClass::cpu_target_realize accel/kvm: Remove need for AccelCPUClass::cpu_target_realize accel: Introduce AccelOpsClass::cpu_instance_init handler accel/whpx: Convert AccelCPUClass -> AccelOpsClass::cpu_instance_init accel/nvmm: Convert AccelCPUClass -> AccelOpsClass::cpu_instance_init accel/hvf: Convert AccelCPUClass -> AccelOpsClass::cpu_instance_init accel/kvm: Convert AccelCPUClass -> AccelOpsClass::cpu_instance_init accel/tcg: Convert AccelCPUClass -> new TCGCPUOps::cpu_instance_init accel: Remove AccelCPUClass::cpu_instance_init() accel/tcg: Convert AccelCPUClass -> new TCGCPUOps::cpu_realize accel/tcg: Convert X86 AccelCPUClass -> TCGCPUOps::cpu_realize accel/tcg: Convert RISCV AccelCPUClass -> TCGCPUOps::cpu_realize accel: Remove AccelCPUClass::cpu_target_realize() accel: Remove AccelCPUClass and 'accel/accel-cpu-target.h'accel/tcg/tcg-accel-ops.h | 1 + include/accel/accel-cpu-ops.h | 3 +- include/accel/accel-cpu-target.h | 31 -------------- include/accel/accel-cpu.h | 23 ----------- include/accel/tcg/cpu-ops.h | 2 + include/system/hvf_int.h | 1 + include/system/kvm.h | 3 ++ target/i386/nvmm/nvmm-accel-ops.h | 2 + accel/accel-common.c | 68 ++++--------------------------- accel/hvf/hvf-accel-ops.c | 3 +- accel/kvm/kvm-accel-ops.c | 2 + accel/tcg/cpu-exec.c | 15 ++++++- accel/tcg/tcg-accel-ops.c | 1 + accel/whpx/whpx-accel-ops.c | 2 + accel/whpx/whpx-common.c | 17 -------- target/arm/hvf/hvf.c | 4 ++ target/arm/whpx/whpx-all.c | 1 - target/i386/hvf/hvf-cpu.c | 25 ++---------- target/i386/hvf/hvf.c | 5 --- target/i386/kvm/kvm-cpu.c | 25 +----------- target/i386/nvmm/nvmm-accel-ops.c | 2 + target/i386/nvmm/nvmm-all.c | 19 +-------- target/i386/tcg/tcg-cpu.c | 28 ++----------- target/i386/whpx/whpx-all.c | 1 - target/loongarch/tcg/tcg_cpu.c | 1 - target/ppc/kvm.c | 23 +---------- target/riscv/kvm/kvm-cpu.c | 33 +-------------- target/riscv/tcg/tcg-cpu.c | 28 +++---------- 28 files changed, 64 insertions(+), 305 deletions(-)
Quoted 3 lines
delete mode 100644
include/accel/accel-cpu-target.hdelete mode 100644include/accel/accel-cpu.h
Hi Philippe,
I am seeing a compilation issue when I am building the qemu after applying this series of patch. I have tested this for arch PPC.
After applying the patch when I ran make command it failed with the below error:
[2418/2928] Compiling C object libqemu-ppc64-softmmu.a.p/hw_intc_xics_pnv.c.o
[2419/2928] Compiling C object libqemu-ppc64-softmmu.a.p/hw_ppc_spapr_drc.c.o
[2420/2928] Compiling C object libqemu-ppc64-softmmu.a.p/libdecnumber_dpd_decimal32.c.o
[2421/2928] Compiling C object libqemu-ppc64-softmmu.a.p/target_ppc_mmu_helper.c.o
[2422/2928] Compiling C object libqemu-ppc64-softmmu.a.p/accel_kvm_kvm-accel-ops.c.o
FAILED: [code=1] libqemu-ppc64-softmmu.a.p/accel_kvm_kvm-accel-ops.c.o
cc -m64 -mlittle-endian -Ilibqemu-ppc64-softmmu.a.p -I. -I.. -Itarget/ppc -I../target/ppc -Isubprojects/dtc/libfdt -I../subprojects/dtc/libfdt -Isubprojects/libvduse -I../subprojects/libvduse -Iqapi -Itrace -Iui -Iui/shader -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/gio-unix-2.0 -fdiagnostics-color=auto -Wall -Winvalid-pch -Werror -std=gnu11 -O2 -g -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fno-strict-aliasing -fno-common -fwrapv -ftrivial-auto-var-init=zero -fzero-init-padding-bits=all -fzero-call-used-regs=used-gpr -fstack-protector-strong -Wempty-body -Wendif-labels -Wexpansion-to-defined -Wformat-overflow=2 -Wformat-security -Wformat-y2k -Wignored-qualifiers -Wimplicit-fallthrough=2 -Winit-self -Wmissing-format-attribute -Wmissing-prototypes -Wnested-externs -Wold-style-declaration -Wold-style-definition -Wredundant-decls -Wshadow=local -Wstrict-prototypes -Wtype-limits -Wundef -Wvla -Wwrite-strings -Wno-missing-include-dirs -Wno-psabi -Wno-shift-negative-value -isystem /home/Anu/qemu/linux-headers -isystem linux-headers -iquote . -iquote /home/Anu/qemu -iquote /home/Anu/qemu/include -iquote /home/Anu/qemu/host/include/ppc64 -iquote /home/Anu/qemu/host/include/generic -iquote /home/Anu/qemu/tcg/ppc64 -pthread -fPIE -isystem../linux-headers -isystemlinux-headers -DCOMPILING_PER_TARGET '-DCONFIG_TARGET="ppc64-softmmu-config-target.h"' '-DCONFIG_DEVICES="ppc64-softmmu-config-devices.h"' -MD -MQ libqemu-ppc64-softmmu.a.p/accel_kvm_kvm-accel-ops.c.o -MF libqemu-ppc64-softmmu.a.p/accel_kvm_kvm-accel-ops.c.o.d -o libqemu-ppc64-softmmu.a.p/accel_kvm_kvm-accel-ops.c.o -c ../accel/kvm/kvm-accel-ops.c ../accel/kvm/kvm-accel-ops.c: In function ‘kvm_accel_ops_class_init’:../accel/kvm/kvm-accel-ops.c:101:8: error: ‘AccelOpsClass’ has no member named ‘cpu_target_realize’
101 | ops->cpu_target_realize = kvm_arch_cpu_realize;
| ^~
[2423/2928] Compiling C object libqemu-ppc64-softmmu.a.p/hw_ppc_spapr_nested.c.o
[2424/2928] Compiling C object libqemu-ppc64-softmmu.a.p/hw_remote_memory.c.o
[2425/2928] Compiling C object libqemu-ppc64-softmmu.a.p/libdecnumber_decContext.c.o
[2426/2928] Compiling C object qga/qemu-ga.p/meson-generated_.._qga-qapi-emit-events.c.o
[2427/2928] Compiling C object libqemu-ppc64-softmmu.a.p/hw_intc_ppc-uic.c.o
Thank you,
Anushree Mathur