accel: add cpu_reset
RFC 1/1 accel: add cpu_reset
XXX
--- accel/accel-common.c | 9 +++++++++ hw/core/cpu.c | 3 ++- include/hw/core/accel-cpu.h | 2 ++ include/qemu/accel.h | 6 ++++++ target/i386/cpu.c | 4 ---- target/i386/kvm/kvm-cpu.c | 6 ++++++ 6 files changed, 25 insertions(+), 5 deletions(-)
This surprisingly works without moving cpu_reset() to a specific_ss module, even though
accel-common.c is specific_ss,hw/core/cpu.c is common_ss.
How come the call to accel_reset_cpu works?
Ciao,
Claudio
accel/accel-common.c +9 -0
@@ -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 ,
hw/core/cpu.c +2 -1
@@ -35,6 +35,7 @@#include "trace/trace-root.h" #include "qemu/plugin.h" #include "sysemu/hw_accel.h" +#include "qemu/accel.h" CPUState *cpu_by_arch_id (int64_t id) {
@@ -230,7 +231,7 @@ void cpu_dump_statistics(CPUState *cpu, int flags)void cpu_reset (CPUState *cpu) {device_cold_reset (DEVICE (cpu)); - +accel_cpu_reset (cpu);trace_guest_cpu_reset (cpu); }
include/hw/core/accel-cpu.h +2 -0
@@ -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 */
include/qemu/accel.h +6 -0
@@ -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 */
target/i386/cpu.c +0 -4
@@ -5780,10 +5780,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 }
target/i386/kvm/kvm-cpu.c +6 -0
@@ -130,12 +130,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" ),
Signature · 1 line
2.26.2