From nobody Sun Apr 28 12:02:31 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1616419805; cv=none; d=zohomail.com; s=zohoarc; b=Ny7RNpLkQNBxJ+u27+fWGNdG7MVXRWW2qBGm32c7OHmFXcX5k5/gYyfoPcEnof/W5jgBXkzGcWrfH/DY+AMHLWPhV3+w7H2qhpPywhqtOa5NNBnqYZws8CgiadPR9NjC6N7bfC2V7rOlGoUu08EbMG2FPDkG/kJaX/IEITyGk10= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616419805; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=v+sSOHR5dHsKpak2I5Haoutencbh3FOX6uMGmmsx4Nw=; b=ke5EIJAhqXwJTV5ZLCAUty+c6D1nTRQQ46hhiQgqhA9zGuGh5mI6CUjrZMMLNWTUTmWB0QX5leLvPuNNvJ7kmUer05PTkDxVIjMhhqgD4T8mkyDAOkfxZebLlj1eJjIEglqDmd/DvXTKSF1A/yxwKukV72SMNyBy0nWNiOOnig0= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1616419804910700.1268993982205; Mon, 22 Mar 2021 06:30:04 -0700 (PDT) Received: from localhost ([::1]:59638 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lOKd8-0002YP-G9 for importer@patchew.org; Mon, 22 Mar 2021 09:30:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53284) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lOKbH-0000hs-B7 for qemu-devel@nongnu.org; Mon, 22 Mar 2021 09:28:07 -0400 Received: from mx2.suse.de ([195.135.220.15]:45000) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lOKbE-0001et-NN for qemu-devel@nongnu.org; Mon, 22 Mar 2021 09:28:07 -0400 Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 75690AD4A; Mon, 22 Mar 2021 13:28:02 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Claudio Fontana To: Paolo Bonzini , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Eduardo Habkost , Peter Maydell , =?UTF-8?q?Alex=20Benn=C3=A9e?= Subject: [RFC] accel: add cpu_reset Date: Mon, 22 Mar 2021 14:27:37 +0100 Message-Id: <20210322132800.7470-2-cfontana@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210322132800.7470-1-cfontana@suse.de> References: <20210322132800.7470-1-cfontana@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=195.135.220.15; envelope-from=cfontana@suse.de; helo=mx2.suse.de X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Thomas Huth , Roman Bolshakov , Claudio Fontana , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" 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 diff --git a/accel/accel-common.c b/accel/accel-common.c index cf07f78421..3331a9dcfd 100644 --- a/accel/accel-common.c +++ b/accel/accel-common.c @@ -121,6 +121,15 @@ bool accel_cpu_realizefn(CPUState *cpu, Error **errp) return true; } =20 +void accel_cpu_reset(CPUState *cpu) +{ + CPUClass *cc =3D 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 =3D { .name =3D TYPE_ACCEL_CPU, .parent =3D TYPE_OBJECT, diff --git a/hw/core/cpu.c b/hw/core/cpu.c index 00330ba07d..590a0d934f 100644 --- a/hw/core/cpu.c +++ b/hw/core/cpu.c @@ -35,6 +35,7 @@ #include "trace/trace-root.h" #include "qemu/plugin.h" #include "sysemu/hw_accel.h" +#include "qemu/accel.h" =20 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); } =20 diff --git a/include/hw/core/accel-cpu.h b/include/hw/core/accel-cpu.h index 5dbfd79955..700a5bd266 100644 --- a/include/hw/core/accel-cpu.h +++ b/include/hw/core/accel-cpu.h @@ -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; =20 #endif /* ACCEL_CPU_H */ diff --git a/include/qemu/accel.h b/include/qemu/accel.h index 4f4c283f6f..8d3a15b916 100644 --- a/include/qemu/accel.h +++ b/include/qemu/accel.h @@ -91,4 +91,10 @@ void accel_cpu_instance_init(CPUState *cpu); */ bool accel_cpu_realizefn(CPUState *cpu, Error **errp); =20 +/** + * accel_cpu_reset: + * @cpu: The CPU that needs to call accel-specific reset. + */ +void accel_cpu_reset(CPUState *cpu); + #endif /* QEMU_ACCEL_H */ diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 48a08df438..ad233b823d 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -5780,10 +5780,6 @@ static void x86_cpu_reset(DeviceState *dev) apic_designate_bsp(cpu->apic_state, s->cpu_index =3D=3D 0); =20 s->halted =3D !cpu_is_bsp(cpu); - - if (kvm_enabled()) { - kvm_arch_reset_vcpu(cpu); - } #endif } =20 diff --git a/target/i386/kvm/kvm-cpu.c b/target/i386/kvm/kvm-cpu.c index c660ad4293..ffdc9afddb 100644 --- a/target/i386/kvm/kvm-cpu.c +++ b/target/i386/kvm/kvm-cpu.c @@ -130,12 +130,18 @@ static void kvm_cpu_instance_init(CPUState *cs) } } =20 +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 =3D ACCEL_CPU_CLASS(oc); =20 acc->cpu_realizefn =3D kvm_cpu_realizefn; acc->cpu_instance_init =3D kvm_cpu_instance_init; + acc->cpu_reset =3D kvm_cpu_reset; } static const TypeInfo kvm_cpu_accel_type_info =3D { .name =3D ACCEL_CPU_NAME("kvm"), --=20 2.26.2