[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC v8 27/27] cpu: introduce cpu_accel_instance_init
From: |
Claudio Fontana |
Subject: |
[RFC v8 27/27] cpu: introduce cpu_accel_instance_init |
Date: |
Sat, 5 Dec 2020 17:15:18 +0100 |
centralize the calls to cpu->accel_cpu_interface
Signed-off-by: Claudio Fontana <cfontana@suse.de>
---
hw/core/cpu.c | 9 +++++++++
include/hw/core/cpu.h | 6 ++++++
target/i386/cpu.c | 9 ++-------
3 files changed, 17 insertions(+), 7 deletions(-)
diff --git a/hw/core/cpu.c b/hw/core/cpu.c
index f41c009e6c..873cf5e4ef 100644
--- a/hw/core/cpu.c
+++ b/hw/core/cpu.c
@@ -242,6 +242,15 @@ void cpu_reset(CPUState *cpu)
trace_guest_cpu_reset(cpu);
}
+void cpu_accel_instance_init(CPUState *cpu)
+{
+ CPUClass *cc = CPU_GET_CLASS(cpu);
+
+ if (cc->accel_cpu_interface) {
+ cc->accel_cpu_interface->cpu_instance_init(cpu);
+ }
+}
+
static void cpu_common_reset(DeviceState *dev)
{
CPUState *cpu = CPU(dev);
diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h
index fee3a68194..0a09f0dd8b 100644
--- a/include/hw/core/cpu.h
+++ b/include/hw/core/cpu.h
@@ -677,6 +677,12 @@ void cpu_list_remove(CPUState *cpu);
*/
void cpu_reset(CPUState *cpu);
+/**
+ * cpu_accel_instance_init:
+ * @cpu: The CPU that needs to do accel-specific object initializations.
+ */
+void cpu_accel_instance_init(CPUState *cpu);
+
/**
* cpu_class_by_name:
* @typename: The CPU base type.
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index aabb8edfe0..e2f16a1f37 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -28,7 +28,6 @@
#include "sysemu/kvm.h"
#include "sysemu/reset.h"
#include "sysemu/hvf.h"
-#include "hw/core/accel-cpu.h"
#include "sysemu/xen.h"
#include "kvm/kvm_i386.h"
#include "sev_i386.h"
@@ -6621,8 +6620,6 @@ static void x86_cpu_initfn(Object *obj)
{
X86CPU *cpu = X86_CPU(obj);
X86CPUClass *xcc = X86_CPU_GET_CLASS(obj);
- CPUClass *cc = CPU_CLASS(xcc);
-
CPUX86State *env = &cpu->env;
FeatureWord w;
@@ -6680,10 +6677,8 @@ static void x86_cpu_initfn(Object *obj)
x86_cpu_load_model(cpu, xcc->model);
}
- /* if required, do the accelerator-specific cpu initialization */
- if (cc->accel_cpu_interface) {
- cc->accel_cpu_interface->cpu_instance_init(CPU(obj));
- }
+ /* if required, do accelerator-specific cpu initializations */
+ cpu_accel_instance_init(CPU(obj));
}
static int64_t x86_cpu_get_arch_id(CPUState *cs)
--
2.26.2
- [RFC v8 15/27] cpu: Introduce TCGCpuOperations struct, (continued)
- [RFC v8 15/27] cpu: Introduce TCGCpuOperations struct, Claudio Fontana, 2020/12/05
- [RFC v8 17/27] cpu: Move synchronize_from_tb() to tcg_ops, Claudio Fontana, 2020/12/05
- [RFC v8 19/27] cpu: Move tlb_fill to tcg_ops, Claudio Fontana, 2020/12/05
- [RFC v8 12/27] tcg: make CPUClass.cpu_exec_* optional, Claudio Fontana, 2020/12/05
- [RFC v8 10/27] i386: move TCG cpu class initialization out of helper.c, Claudio Fontana, 2020/12/05
- [RFC v8 26/27] hw/core/cpu: call qemu_init_vcpu in cpu_common_realizefn, Claudio Fontana, 2020/12/05
- [RFC v8 23/27] accel: introduce AccelCPUClass extending CPUClass, Claudio Fontana, 2020/12/05
- [RFC v8 24/27] i386: split cpu accelerators from cpu.c, using AccelCPUClass, Claudio Fontana, 2020/12/05
- [RFC v8 27/27] cpu: introduce cpu_accel_instance_init,
Claudio Fontana <=
- [RFC v8 14/27] cpu: Remove unnecessary noop methods, Claudio Fontana, 2020/12/05
- [RFC v8 13/27] tcg: Make CPUClass.debug_excp_handler optional, Claudio Fontana, 2020/12/05
- [RFC v8 20/27] cpu: Move debug_excp_handler to tcg_ops, Claudio Fontana, 2020/12/05
- [RFC v8 16/27] accel/tcg: split TCG-only code from cpu_exec_realizefn, Claudio Fontana, 2020/12/05
- [RFC v8 18/27] cpu: Move cpu_exec_* to tcg_ops, Claudio Fontana, 2020/12/05
- [RFC v8 21/27] accel: extend AccelState and AccelClass to user-mode, Claudio Fontana, 2020/12/05
- [RFC v8 25/27] cpu: call AccelCPUClass::cpu_realizefn in cpu_exec_realizefn, Claudio Fontana, 2020/12/05