@@ -33,6 +33,8 @@ typedef struct AccelCPUClass {
void (*cpu_class_init)(CPUClass *cc);
void (*cpu_instance_init)(CPUState *cpu);
bool (*cpu_realizefn)(CPUState *cpu, Error **errp);
+ void (*cpu_reset)(CPUState *cpu);
+
} AccelCPUClass;
#endif /* ACCEL_CPU_H */
@@ -91,4 +91,10 @@ void accel_cpu_instance_init(CPUState *cpu);
*/
bool accel_cpu_realizefn(CPUState *cpu, Error **errp);
+/**
+ * accel_cpu_reset:
+ * @cpu: The CPU that needs to call accel-specific reset.
+ */
+void accel_cpu_reset(CPUState *cpu);
+
#endif /* QEMU_ACCEL_H */
@@ -121,6 +121,15 @@ bool accel_cpu_realizefn(CPUState *cpu, Error **errp)
return true;
}
+void accel_cpu_reset(CPUState *cpu)
+{
+ CPUClass *cc = CPU_GET_CLASS(cpu);
+
+ if (cc->accel_cpu && cc->accel_cpu->cpu_reset) {
+ cc->accel_cpu->cpu_reset(cpu);
+ }
+}
+
static const TypeInfo accel_cpu_type = {
.name = TYPE_ACCEL_CPU,
.parent = TYPE_OBJECT,
@@ -34,6 +34,7 @@
#include "hw/qdev-properties.h"
#include "trace/trace-root.h"
#include "qemu/plugin.h"
+#include "qemu/accel.h"
CPUState *cpu_by_arch_id(int64_t id)
{
@@ -112,7 +113,7 @@ void cpu_dump_state(CPUState *cpu, FILE *f, int flags)
void cpu_reset(CPUState *cpu)
{
device_cold_reset(DEVICE(cpu));
-
+ accel_cpu_reset(cpu);
trace_guest_cpu_reset(cpu);
}
@@ -5749,10 +5749,6 @@ static void x86_cpu_reset(DeviceState *dev)
apic_designate_bsp(cpu->apic_state, s->cpu_index == 0);
s->halted = !cpu_is_bsp(cpu);
-
- if (kvm_enabled()) {
- kvm_arch_reset_vcpu(cpu);
- }
#endif
}
@@ -135,12 +135,18 @@ static void kvm_cpu_instance_init(CPUState *cs)
}
}
+static void kvm_cpu_reset(CPUState *cpu)
+{
+ kvm_arch_reset_vcpu(X86_CPU(cpu));
+}
+
static void kvm_cpu_accel_class_init(ObjectClass *oc, void *data)
{
AccelCPUClass *acc = ACCEL_CPU_CLASS(oc);
acc->cpu_realizefn = kvm_cpu_realizefn;
acc->cpu_instance_init = kvm_cpu_instance_init;
+ acc->cpu_reset = kvm_cpu_reset;
}
static const TypeInfo kvm_cpu_accel_type_info = {
.name = ACCEL_CPU_NAME("kvm"),