From nobody Thu Apr 25 18:08:54 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=1610474792; cv=none; d=zohomail.com; s=zohoarc; b=gjT4rh1u9zDoV5sZ8cPZjmejjJLjIwMJ5vIVKvjGVI8uCSpSVl2oe4aZKe5YBfE+VlJ3XFlFhLWItPb/LzNcvolneZyhtiHRHof5hgdg25v/N6sM6MTdh8i//0VSwc8r+dxn9RYrQGul1kG1Te2Piu7UcQwn8//nDi5v6zat47E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610474792; h=Content-Type: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=od468MP14XeNGKSnwM/fKZivbEOOi1eizIHSEuh0bCs=; b=LBt3kvjygNSFPBO222fmX/PyZa4BWJfpde6BwmRaz7uvXRvuJt7dNby8GYMX/p1BCs+tD18a9vnBkKwgTs5CQd2fgpWnvEsV3d5NPfZ/Ib07+czcTHkPuYvwgnNgaUguQ+KOTul/UBVIjVT5vEDc6MjDTLmsJa0AgOClh3yzNHM= 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 1610474792567255.79000205318766; Tue, 12 Jan 2021 10:06:32 -0800 (PST) Received: from localhost ([::1]:53536 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kzO3r-0007Ee-CE for importer@patchew.org; Tue, 12 Jan 2021 13:06:31 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47922) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kzO0o-0005Eg-3D for qemu-devel@nongnu.org; Tue, 12 Jan 2021 13:03:22 -0500 Received: from mx2.suse.de ([195.135.220.15]:33312) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kzO0j-0004t5-VZ for qemu-devel@nongnu.org; Tue, 12 Jan 2021 13:03:21 -0500 Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id AC036AC5B; Tue, 12 Jan 2021 18:03:16 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Claudio Fontana To: Paolo Bonzini , Thomas Huth , Richard Henderson , Stefano Stabellini , Wenchao Wang , Roman Bolshakov , Sunil Muthuswamy , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v12 01/22] cpu: Introduce TCGCpuOperations struct Date: Tue, 12 Jan 2021 19:02:51 +0100 Message-Id: <20210112180312.26043-2-cfontana@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210112180312.26043-1-cfontana@suse.de> References: <20210112180312.26043-1-cfontana@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 , Peter Maydell , Eduardo Habkost , Paul Durrant , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Jason Wang , Marcelo Tosatti , qemu-devel@nongnu.org, Peter Xu , Dario Faggioli , Cameron Esfahani , haxm-team@intel.com, Colin Xu , Anthony Perard , Bruce Rogers , Olaf Hering , "Emilio G . Cota" , Claudio Fontana Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" From: Eduardo Habkost The TCG-specific CPU methods will be moved to a separate struct, to make it easier to move accel-specific code outside generic CPU code in the future. Start by moving tcg_initialize(). The new CPUClass.tcg_opts field may eventually become a pointer, but keep it an embedded struct for now, to make code conversion easier. Signed-off-by: Eduardo Habkost [claudio: make the tcg code build for CONFIG_TCG only] Signed-off-by: Claudio Fontana Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Alex Benn=C3=A9e Reviewed-by: Richard Henderson [claudio: move TCGCpuOperations inside include/hw/core/cpu.h] --- include/hw/core/cpu.h | 20 +++++++++++++++++++- cpu.c | 6 +++++- target/alpha/cpu.c | 2 +- target/arm/cpu.c | 2 +- target/avr/cpu.c | 2 +- target/cris/cpu.c | 12 ++++++------ target/hppa/cpu.c | 2 +- target/i386/tcg/tcg-cpu.c | 2 +- target/lm32/cpu.c | 2 +- target/m68k/cpu.c | 2 +- target/microblaze/cpu.c | 2 +- target/mips/cpu.c | 2 +- target/moxie/cpu.c | 2 +- target/nios2/cpu.c | 2 +- target/openrisc/cpu.c | 2 +- target/riscv/cpu.c | 2 +- target/rx/cpu.c | 2 +- target/s390x/cpu.c | 2 +- target/sh4/cpu.c | 2 +- target/sparc/cpu.c | 2 +- target/tilegx/cpu.c | 2 +- target/tricore/cpu.c | 2 +- target/unicore32/cpu.c | 2 +- target/xtensa/cpu.c | 2 +- target/ppc/translate_init.c.inc | 2 +- 25 files changed, 52 insertions(+), 30 deletions(-) diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index 140fa32a5e..5b981c1730 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -76,6 +76,21 @@ typedef struct CPUWatchpoint CPUWatchpoint; =20 struct TranslationBlock; =20 +#ifdef CONFIG_TCG +/** + * struct TcgCpuOperations: TCG operations specific to a CPU class + */ +typedef struct TcgCpuOperations { + /** + * @initialize: Initalize TCG state + * + * Called when the first CPU is realized. + */ + void (*initialize)(void); + +} TcgCpuOperations; +#endif /* CONFIG_TCG */ + /** * CPUClass: * @class_by_name: Callback to map -cpu command line model name to an @@ -222,12 +237,15 @@ struct CPUClass { =20 void (*disas_set_info)(CPUState *cpu, disassemble_info *info); vaddr (*adjust_watchpoint_address)(CPUState *cpu, vaddr addr, int len); - void (*tcg_initialize)(void); =20 const char *deprecation_note; /* Keep non-pointer data at the end to minimize holes. */ int gdb_num_core_regs; bool gdb_stop_before_watchpoint; + +#ifdef CONFIG_TCG + TcgCpuOperations tcg_ops; +#endif /* CONFIG_TCG */ }; =20 /* diff --git a/cpu.c b/cpu.c index 0b245cda2e..79a2bf12b3 100644 --- a/cpu.c +++ b/cpu.c @@ -159,14 +159,18 @@ void cpu_exec_initfn(CPUState *cpu) void cpu_exec_realizefn(CPUState *cpu, Error **errp) { CPUClass *cc =3D CPU_GET_CLASS(cpu); +#ifdef CONFIG_TCG static bool tcg_target_initialized; +#endif /* CONFIG_TCG */ =20 cpu_list_add(cpu); =20 +#ifdef CONFIG_TCG if (tcg_enabled() && !tcg_target_initialized) { tcg_target_initialized =3D true; - cc->tcg_initialize(); + cc->tcg_ops.initialize(); } +#endif /* CONFIG_TCG */ tlb_init(cpu); =20 qemu_plugin_vcpu_init_hook(cpu); diff --git a/target/alpha/cpu.c b/target/alpha/cpu.c index b3fd6643e8..d66f0351a9 100644 --- a/target/alpha/cpu.c +++ b/target/alpha/cpu.c @@ -231,7 +231,7 @@ static void alpha_cpu_class_init(ObjectClass *oc, void = *data) dc->vmsd =3D &vmstate_alpha_cpu; #endif cc->disas_set_info =3D alpha_cpu_disas_set_info; - cc->tcg_initialize =3D alpha_translate_init; + cc->tcg_ops.initialize =3D alpha_translate_init; =20 cc->gdb_num_core_regs =3D 67; } diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 8387e94b94..7c8b0c3af6 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -2263,7 +2263,7 @@ static void arm_cpu_class_init(ObjectClass *oc, void = *data) cc->gdb_stop_before_watchpoint =3D true; cc->disas_set_info =3D arm_disas_set_info; #ifdef CONFIG_TCG - cc->tcg_initialize =3D arm_translate_init; + cc->tcg_ops.initialize =3D arm_translate_init; cc->tlb_fill =3D arm_cpu_tlb_fill; cc->debug_excp_handler =3D arm_debug_excp_handler; cc->debug_check_watchpoint =3D arm_debug_check_watchpoint; diff --git a/target/avr/cpu.c b/target/avr/cpu.c index 6f3d5a9e4a..fb66695fbb 100644 --- a/target/avr/cpu.c +++ b/target/avr/cpu.c @@ -207,7 +207,7 @@ static void avr_cpu_class_init(ObjectClass *oc, void *d= ata) cc->tlb_fill =3D avr_cpu_tlb_fill; cc->vmsd =3D &vms_avr_cpu; cc->disas_set_info =3D avr_cpu_disas_set_info; - cc->tcg_initialize =3D avr_cpu_tcg_init; + cc->tcg_ops.initialize =3D avr_cpu_tcg_init; cc->synchronize_from_tb =3D avr_cpu_synchronize_from_tb; cc->gdb_read_register =3D avr_cpu_gdb_read_register; cc->gdb_write_register =3D avr_cpu_gdb_write_register; diff --git a/target/cris/cpu.c b/target/cris/cpu.c index cff6b9eabf..4328f8e6c9 100644 --- a/target/cris/cpu.c +++ b/target/cris/cpu.c @@ -201,7 +201,7 @@ static void crisv8_cpu_class_init(ObjectClass *oc, void= *data) ccc->vr =3D 8; cc->do_interrupt =3D crisv10_cpu_do_interrupt; cc->gdb_read_register =3D crisv10_cpu_gdb_read_register; - cc->tcg_initialize =3D cris_initialize_crisv10_tcg; + cc->tcg_ops.initialize =3D cris_initialize_crisv10_tcg; } =20 static void crisv9_cpu_class_init(ObjectClass *oc, void *data) @@ -212,7 +212,7 @@ static void crisv9_cpu_class_init(ObjectClass *oc, void= *data) ccc->vr =3D 9; cc->do_interrupt =3D crisv10_cpu_do_interrupt; cc->gdb_read_register =3D crisv10_cpu_gdb_read_register; - cc->tcg_initialize =3D cris_initialize_crisv10_tcg; + cc->tcg_ops.initialize =3D cris_initialize_crisv10_tcg; } =20 static void crisv10_cpu_class_init(ObjectClass *oc, void *data) @@ -223,7 +223,7 @@ static void crisv10_cpu_class_init(ObjectClass *oc, voi= d *data) ccc->vr =3D 10; cc->do_interrupt =3D crisv10_cpu_do_interrupt; cc->gdb_read_register =3D crisv10_cpu_gdb_read_register; - cc->tcg_initialize =3D cris_initialize_crisv10_tcg; + cc->tcg_ops.initialize =3D cris_initialize_crisv10_tcg; } =20 static void crisv11_cpu_class_init(ObjectClass *oc, void *data) @@ -234,7 +234,7 @@ static void crisv11_cpu_class_init(ObjectClass *oc, voi= d *data) ccc->vr =3D 11; cc->do_interrupt =3D crisv10_cpu_do_interrupt; cc->gdb_read_register =3D crisv10_cpu_gdb_read_register; - cc->tcg_initialize =3D cris_initialize_crisv10_tcg; + cc->tcg_ops.initialize =3D cris_initialize_crisv10_tcg; } =20 static void crisv17_cpu_class_init(ObjectClass *oc, void *data) @@ -245,7 +245,7 @@ static void crisv17_cpu_class_init(ObjectClass *oc, voi= d *data) ccc->vr =3D 17; cc->do_interrupt =3D crisv10_cpu_do_interrupt; cc->gdb_read_register =3D crisv10_cpu_gdb_read_register; - cc->tcg_initialize =3D cris_initialize_crisv10_tcg; + cc->tcg_ops.initialize =3D cris_initialize_crisv10_tcg; } =20 static void crisv32_cpu_class_init(ObjectClass *oc, void *data) @@ -284,7 +284,7 @@ static void cris_cpu_class_init(ObjectClass *oc, void *= data) cc->gdb_stop_before_watchpoint =3D true; =20 cc->disas_set_info =3D cris_disas_set_info; - cc->tcg_initialize =3D cris_initialize_tcg; + cc->tcg_ops.initialize =3D cris_initialize_tcg; } =20 #define DEFINE_CRIS_CPU_TYPE(cpu_model, initfn) \ diff --git a/target/hppa/cpu.c b/target/hppa/cpu.c index e28f047d10..80e3081631 100644 --- a/target/hppa/cpu.c +++ b/target/hppa/cpu.c @@ -154,7 +154,7 @@ static void hppa_cpu_class_init(ObjectClass *oc, void *= data) #endif cc->do_unaligned_access =3D hppa_cpu_do_unaligned_access; cc->disas_set_info =3D hppa_cpu_disas_set_info; - cc->tcg_initialize =3D hppa_translate_init; + cc->tcg_ops.initialize =3D hppa_translate_init; =20 cc->gdb_num_core_regs =3D 128; } diff --git a/target/i386/tcg/tcg-cpu.c b/target/i386/tcg/tcg-cpu.c index 4fa013720e..d90502a0cc 100644 --- a/target/i386/tcg/tcg-cpu.c +++ b/target/i386/tcg/tcg-cpu.c @@ -64,7 +64,7 @@ void tcg_cpu_common_class_init(CPUClass *cc) cc->synchronize_from_tb =3D x86_cpu_synchronize_from_tb; cc->cpu_exec_enter =3D x86_cpu_exec_enter; cc->cpu_exec_exit =3D x86_cpu_exec_exit; - cc->tcg_initialize =3D tcg_x86_init; + cc->tcg_ops.initialize =3D tcg_x86_init; cc->tlb_fill =3D x86_cpu_tlb_fill; #ifndef CONFIG_USER_ONLY cc->debug_excp_handler =3D breakpoint_handler; diff --git a/target/lm32/cpu.c b/target/lm32/cpu.c index c50ad5fa15..ef795b81a4 100644 --- a/target/lm32/cpu.c +++ b/target/lm32/cpu.c @@ -237,7 +237,7 @@ static void lm32_cpu_class_init(ObjectClass *oc, void *= data) cc->gdb_stop_before_watchpoint =3D true; cc->debug_excp_handler =3D lm32_debug_excp_handler; cc->disas_set_info =3D lm32_cpu_disas_set_info; - cc->tcg_initialize =3D lm32_translate_init; + cc->tcg_ops.initialize =3D lm32_translate_init; } =20 #define DEFINE_LM32_CPU_TYPE(cpu_model, initfn) \ diff --git a/target/m68k/cpu.c b/target/m68k/cpu.c index b811a0bdde..3604ece49b 100644 --- a/target/m68k/cpu.c +++ b/target/m68k/cpu.c @@ -478,7 +478,7 @@ static void m68k_cpu_class_init(ObjectClass *c, void *d= ata) dc->vmsd =3D &vmstate_m68k_cpu; #endif cc->disas_set_info =3D m68k_cpu_disas_set_info; - cc->tcg_initialize =3D m68k_tcg_init; + cc->tcg_ops.initialize =3D m68k_tcg_init; =20 cc->gdb_num_core_regs =3D 18; } diff --git a/target/microblaze/cpu.c b/target/microblaze/cpu.c index c8e754cfb1..44b40d4d5c 100644 --- a/target/microblaze/cpu.c +++ b/target/microblaze/cpu.c @@ -336,7 +336,7 @@ static void mb_cpu_class_init(ObjectClass *oc, void *da= ta) cc->gdb_num_core_regs =3D 32 + 27; =20 cc->disas_set_info =3D mb_disas_set_info; - cc->tcg_initialize =3D mb_tcg_init; + cc->tcg_ops.initialize =3D mb_tcg_init; } =20 static const TypeInfo mb_cpu_type_info =3D { diff --git a/target/mips/cpu.c b/target/mips/cpu.c index b2864d67d7..8a42470cda 100644 --- a/target/mips/cpu.c +++ b/target/mips/cpu.c @@ -490,7 +490,7 @@ static void mips_cpu_class_init(ObjectClass *c, void *d= ata) #endif cc->disas_set_info =3D mips_cpu_disas_set_info; #ifdef CONFIG_TCG - cc->tcg_initialize =3D mips_tcg_init; + cc->tcg_ops.initialize =3D mips_tcg_init; cc->tlb_fill =3D mips_cpu_tlb_fill; #endif =20 diff --git a/target/moxie/cpu.c b/target/moxie/cpu.c index 6e0443ccb7..224cfc8361 100644 --- a/target/moxie/cpu.c +++ b/target/moxie/cpu.c @@ -116,7 +116,7 @@ static void moxie_cpu_class_init(ObjectClass *oc, void = *data) cc->vmsd =3D &vmstate_moxie_cpu; #endif cc->disas_set_info =3D moxie_cpu_disas_set_info; - cc->tcg_initialize =3D moxie_translate_init; + cc->tcg_ops.initialize =3D moxie_translate_init; } =20 static void moxielite_initfn(Object *obj) diff --git a/target/nios2/cpu.c b/target/nios2/cpu.c index 58688e1623..c28eb05ef0 100644 --- a/target/nios2/cpu.c +++ b/target/nios2/cpu.c @@ -234,7 +234,7 @@ static void nios2_cpu_class_init(ObjectClass *oc, void = *data) cc->gdb_read_register =3D nios2_cpu_gdb_read_register; cc->gdb_write_register =3D nios2_cpu_gdb_write_register; cc->gdb_num_core_regs =3D 49; - cc->tcg_initialize =3D nios2_tcg_init; + cc->tcg_ops.initialize =3D nios2_tcg_init; } =20 static const TypeInfo nios2_cpu_type_info =3D { diff --git a/target/openrisc/cpu.c b/target/openrisc/cpu.c index b0bdfbe4fe..a957f59e2e 100644 --- a/target/openrisc/cpu.c +++ b/target/openrisc/cpu.c @@ -198,7 +198,7 @@ static void openrisc_cpu_class_init(ObjectClass *oc, vo= id *data) dc->vmsd =3D &vmstate_openrisc_cpu; #endif cc->gdb_num_core_regs =3D 32 + 3; - cc->tcg_initialize =3D openrisc_translate_init; + cc->tcg_ops.initialize =3D openrisc_translate_init; cc->disas_set_info =3D openrisc_disas_set_info; } =20 diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 8227d7aea9..ca7a031513 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -593,7 +593,7 @@ static void riscv_cpu_class_init(ObjectClass *c, void *= data) cc->vmsd =3D &vmstate_riscv_cpu; #endif #ifdef CONFIG_TCG - cc->tcg_initialize =3D riscv_translate_init; + cc->tcg_ops.initialize =3D riscv_translate_init; cc->tlb_fill =3D riscv_cpu_tlb_fill; #endif device_class_set_props(dc, riscv_cpu_properties); diff --git a/target/rx/cpu.c b/target/rx/cpu.c index 2bb14144a7..cdcab49c8a 100644 --- a/target/rx/cpu.c +++ b/target/rx/cpu.c @@ -195,7 +195,7 @@ static void rx_cpu_class_init(ObjectClass *klass, void = *data) cc->gdb_write_register =3D rx_cpu_gdb_write_register; cc->get_phys_page_debug =3D rx_cpu_get_phys_page_debug; cc->disas_set_info =3D rx_cpu_disas_set_info; - cc->tcg_initialize =3D rx_translate_init; + cc->tcg_ops.initialize =3D rx_translate_init; cc->tlb_fill =3D rx_cpu_tlb_fill; =20 cc->gdb_num_core_regs =3D 26; diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c index 7da70afbf2..890781e74c 100644 --- a/target/s390x/cpu.c +++ b/target/s390x/cpu.c @@ -515,7 +515,7 @@ static void s390_cpu_class_init(ObjectClass *oc, void *= data) #endif cc->disas_set_info =3D s390_cpu_disas_set_info; #ifdef CONFIG_TCG - cc->tcg_initialize =3D s390x_translate_init; + cc->tcg_ops.initialize =3D s390x_translate_init; cc->tlb_fill =3D s390_cpu_tlb_fill; #endif =20 diff --git a/target/sh4/cpu.c b/target/sh4/cpu.c index 1e0f05a15b..b86753cda5 100644 --- a/target/sh4/cpu.c +++ b/target/sh4/cpu.c @@ -232,7 +232,7 @@ static void superh_cpu_class_init(ObjectClass *oc, void= *data) cc->get_phys_page_debug =3D superh_cpu_get_phys_page_debug; #endif cc->disas_set_info =3D superh_cpu_disas_set_info; - cc->tcg_initialize =3D sh4_translate_init; + cc->tcg_ops.initialize =3D sh4_translate_init; =20 cc->gdb_num_core_regs =3D 59; =20 diff --git a/target/sparc/cpu.c b/target/sparc/cpu.c index 6f14e370ed..3ab71e9d00 100644 --- a/target/sparc/cpu.c +++ b/target/sparc/cpu.c @@ -881,7 +881,7 @@ static void sparc_cpu_class_init(ObjectClass *oc, void = *data) cc->vmsd =3D &vmstate_sparc_cpu; #endif cc->disas_set_info =3D cpu_sparc_disas_set_info; - cc->tcg_initialize =3D sparc_tcg_init; + cc->tcg_ops.initialize =3D sparc_tcg_init; =20 #if defined(TARGET_SPARC64) && !defined(TARGET_ABI32) cc->gdb_num_core_regs =3D 86; diff --git a/target/tilegx/cpu.c b/target/tilegx/cpu.c index 1fee87c094..cd24d0eb9d 100644 --- a/target/tilegx/cpu.c +++ b/target/tilegx/cpu.c @@ -153,7 +153,7 @@ static void tilegx_cpu_class_init(ObjectClass *oc, void= *data) cc->set_pc =3D tilegx_cpu_set_pc; cc->tlb_fill =3D tilegx_cpu_tlb_fill; cc->gdb_num_core_regs =3D 0; - cc->tcg_initialize =3D tilegx_tcg_init; + cc->tcg_ops.initialize =3D tilegx_tcg_init; } =20 static const TypeInfo tilegx_cpu_type_info =3D { diff --git a/target/tricore/cpu.c b/target/tricore/cpu.c index 4bff1d4718..bf135af40f 100644 --- a/target/tricore/cpu.c +++ b/target/tricore/cpu.c @@ -164,7 +164,7 @@ static void tricore_cpu_class_init(ObjectClass *c, void= *data) cc->set_pc =3D tricore_cpu_set_pc; cc->synchronize_from_tb =3D tricore_cpu_synchronize_from_tb; cc->get_phys_page_debug =3D tricore_cpu_get_phys_page_debug; - cc->tcg_initialize =3D tricore_tcg_init; + cc->tcg_ops.initialize =3D tricore_tcg_init; cc->tlb_fill =3D tricore_cpu_tlb_fill; } =20 diff --git a/target/unicore32/cpu.c b/target/unicore32/cpu.c index b27fb9689f..226bf4226e 100644 --- a/target/unicore32/cpu.c +++ b/target/unicore32/cpu.c @@ -137,7 +137,7 @@ static void uc32_cpu_class_init(ObjectClass *oc, void *= data) cc->set_pc =3D uc32_cpu_set_pc; cc->tlb_fill =3D uc32_cpu_tlb_fill; cc->get_phys_page_debug =3D uc32_cpu_get_phys_page_debug; - cc->tcg_initialize =3D uc32_translate_init; + cc->tcg_ops.initialize =3D uc32_translate_init; dc->vmsd =3D &vmstate_uc32_cpu; } =20 diff --git a/target/xtensa/cpu.c b/target/xtensa/cpu.c index 88a32268a1..5a6f5bf88b 100644 --- a/target/xtensa/cpu.c +++ b/target/xtensa/cpu.c @@ -209,7 +209,7 @@ static void xtensa_cpu_class_init(ObjectClass *oc, void= *data) #endif cc->debug_excp_handler =3D xtensa_breakpoint_handler; cc->disas_set_info =3D xtensa_cpu_disas_set_info; - cc->tcg_initialize =3D xtensa_translate_init; + cc->tcg_ops.initialize =3D xtensa_translate_init; dc->vmsd =3D &vmstate_xtensa_cpu; } =20 diff --git a/target/ppc/translate_init.c.inc b/target/ppc/translate_init.c.= inc index 3c05a17343..189f27cd1c 100644 --- a/target/ppc/translate_init.c.inc +++ b/target/ppc/translate_init.c.inc @@ -10878,7 +10878,7 @@ static void ppc_cpu_class_init(ObjectClass *oc, voi= d *data) cc->virtio_is_big_endian =3D ppc_cpu_is_big_endian; #endif #ifdef CONFIG_TCG - cc->tcg_initialize =3D ppc_translate_init; + cc->tcg_ops.initialize =3D ppc_translate_init; cc->tlb_fill =3D ppc_cpu_tlb_fill; #endif #ifndef CONFIG_USER_ONLY --=20 2.26.2 From nobody Thu Apr 25 18:08:54 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=1610474789; cv=none; d=zohomail.com; s=zohoarc; b=lC904+a2cKgB9fKX6qlsMVduRIUDG+f81S2JgmOc7aTSGIrwLgZaSc1+D5ITpnj7Tn9agZdCaJa+1Ax7ARqPCjDCmyf3+2ZcMXf8PilrJUaOX6MGdoqpyPIXOoyJOU+TlRJFBJQyixVtB2ctHxVavCZO12L+UDS+EZYcWIBDwDw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610474789; 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=PAtz5qRk0P1ShXsWLHypmnxnquB8533pxMgamWfnG9c=; b=nRAPfsyVm86iRjsD5KGCX2ZoEklbp7446CZOTwqb0Fd/ULTrumxv3Q5+IptxOJWQ1ZA0Tpk6j5LN3LWRaFmALuaNIsALRAeZHEWZAIkw/NPrUrIZXbyjHBr8JmIFw0NvucoDINocSgAPDSkoW5XhxDV0eLUfdVfXBrSczoDIUBY= 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 1610474789715829.0263053731; Tue, 12 Jan 2021 10:06:29 -0800 (PST) Received: from localhost ([::1]:53386 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kzO3o-0007AV-GB for importer@patchew.org; Tue, 12 Jan 2021 13:06:28 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47904) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kzO0m-0005DV-UT for qemu-devel@nongnu.org; Tue, 12 Jan 2021 13:03:20 -0500 Received: from mx2.suse.de ([195.135.220.15]:33350) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kzO0l-0004tI-9q for qemu-devel@nongnu.org; Tue, 12 Jan 2021 13:03:20 -0500 Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id DEBA7ACBA; Tue, 12 Jan 2021 18:03:17 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Claudio Fontana To: Paolo Bonzini , Thomas Huth , Richard Henderson , Stefano Stabellini , Wenchao Wang , Roman Bolshakov , Sunil Muthuswamy , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v12 02/22] target/riscv: remove CONFIG_TCG, as it is always TCG Date: Tue, 12 Jan 2021 19:02:52 +0100 Message-Id: <20210112180312.26043-3-cfontana@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210112180312.26043-1-cfontana@suse.de> References: <20210112180312.26043-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 , Peter Maydell , Eduardo Habkost , Paul Durrant , Jason Wang , Marcelo Tosatti , qemu-devel@nongnu.org, Peter Xu , Dario Faggioli , Cameron Esfahani , haxm-team@intel.com, Claudio Fontana , Anthony Perard , Alistair Francis , Bruce Rogers , Olaf Hering , "Emilio G . Cota" , Colin Xu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" for now only TCG is allowed as an accelerator for riscv, so remove the CONFIG_TCG use. Signed-off-by: Claudio Fontana Reviewed-by: Alistair Francis --- target/riscv/cpu.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index ca7a031513..229f06b2a3 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -592,10 +592,9 @@ static void riscv_cpu_class_init(ObjectClass *c, void = *data) /* For now, mark unmigratable: */ cc->vmsd =3D &vmstate_riscv_cpu; #endif -#ifdef CONFIG_TCG cc->tcg_ops.initialize =3D riscv_translate_init; cc->tlb_fill =3D riscv_cpu_tlb_fill; -#endif + device_class_set_props(dc, riscv_cpu_properties); } =20 --=20 2.26.2 From nobody Thu Apr 25 18:08:54 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=1610476197; cv=none; d=zohomail.com; s=zohoarc; b=T1qFUfFVM840fkQC3cSXJmQPBZqy7kTushVQskECaXWOZhc6rKaEj3mfEYK7kLCB48eve+V+WBMmxxR4v/rtMgQYGkNyNYrfpdqFyS2GPW884yaHk3znP64cN9FYdCDr+A24j7Y7oyCzlt8C6k6Gyft2mNtseo2/RfYEZ5aJeDI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610476197; h=Content-Type: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=rgtH3AeF3LH3zKqZHdE8JqSVW2RnmTKSofhgWitNwEs=; b=e27ZYNmdgtv6R8zYTyp3shUhz2u4U6GI4+nWMQ05XQxpzReqHgYQmHraQ2AUkAYqgJ5bSHnF0P4hMTrUxm2RLla6sOcVdCIXFpUP2RdZmTm+TPj6vFn6+OPy+gxtS764r8IED+iLnFMYORWvJLAZtWxy8Lt2SeJPyvqA9pNArKE= 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 1610476197884476.2013197626517; Tue, 12 Jan 2021 10:29:57 -0800 (PST) Received: from localhost ([::1]:36088 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kzOQW-0003g8-PS for importer@patchew.org; Tue, 12 Jan 2021 13:29:56 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47964) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kzO0q-0005He-MG for qemu-devel@nongnu.org; Tue, 12 Jan 2021 13:03:26 -0500 Received: from mx2.suse.de ([195.135.220.15]:33384) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kzO0m-0004tS-1r for qemu-devel@nongnu.org; Tue, 12 Jan 2021 13:03:24 -0500 Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id C9183ACE1; Tue, 12 Jan 2021 18:03:18 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Claudio Fontana To: Paolo Bonzini , Thomas Huth , Richard Henderson , Stefano Stabellini , Wenchao Wang , Roman Bolshakov , Sunil Muthuswamy , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v12 03/22] accel/tcg: split TCG-only code from cpu_exec_realizefn Date: Tue, 12 Jan 2021 19:02:53 +0100 Message-Id: <20210112180312.26043-4-cfontana@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210112180312.26043-1-cfontana@suse.de> References: <20210112180312.26043-1-cfontana@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 , Peter Maydell , Eduardo Habkost , Paul Durrant , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Jason Wang , Marcelo Tosatti , qemu-devel@nongnu.org, Peter Xu , Dario Faggioli , Cameron Esfahani , haxm-team@intel.com, Claudio Fontana , Anthony Perard , Bruce Rogers , Olaf Hering , "Emilio G . Cota" , Colin Xu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" move away TCG-only code, make it compile only on TCG. Signed-off-by: Claudio Fontana Reviewed-by: Alex Benn=C3=A9e Reviewed-by: Richard Henderson [claudio: moved the prototypes from hw/core/cpu.h to exec/cpu-all.h] --- include/exec/cpu-all.h | 11 +++++-- include/hw/core/cpu.h | 2 ++ accel/tcg/cpu-exec.c | 28 +++++++++++++++++ cpu.c | 70 ++++++++++++++++++++---------------------- hw/core/cpu.c | 6 +++- 5 files changed, 77 insertions(+), 40 deletions(-) diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h index 4b5408c341..cfb1d79331 100644 --- a/include/exec/cpu-all.h +++ b/include/exec/cpu-all.h @@ -410,19 +410,26 @@ static inline bool tlb_hit(target_ulong tlb_addr, tar= get_ulong addr) } =20 #ifdef CONFIG_TCG +/* accel/tcg/cpu-exec.c */ void dump_drift_info(void); +/* accel/tcg/translate-all.c */ void dump_exec_info(void); void dump_opcount_info(void); #endif /* CONFIG_TCG */ =20 #endif /* !CONFIG_USER_ONLY */ =20 +#ifdef CONFIG_TCG +/* accel/tcg/cpu-exec.c */ +int cpu_exec(CPUState *cpu); +void tcg_exec_realizefn(CPUState *cpu, Error **errp); +void tcg_exec_unrealizefn(CPUState *cpu); +#endif /* CONFIG_TCG */ + /* Returns: 0 on success, -1 on error */ int cpu_memory_rw_debug(CPUState *cpu, target_ulong addr, void *ptr, target_ulong len, bool is_write); =20 -int cpu_exec(CPUState *cpu); - /** * cpu_set_cpustate_pointers(cpu) * @cpu: The cpu object diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index 5b981c1730..96fdca39d2 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -1130,6 +1130,8 @@ AddressSpace *cpu_get_address_space(CPUState *cpu, in= t asidx); =20 void QEMU_NORETURN cpu_abort(CPUState *cpu, const char *fmt, ...) GCC_FMT_ATTR(2, 3); + +/* $(top_srcdir)/cpu.c */ void cpu_exec_initfn(CPUState *cpu); void cpu_exec_realizefn(CPUState *cpu, Error **errp); void cpu_exec_unrealizefn(CPUState *cpu); diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index e0df9b6a1d..5fb5304278 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -821,6 +821,34 @@ int cpu_exec(CPUState *cpu) return ret; } =20 +void tcg_exec_realizefn(CPUState *cpu, Error **errp) +{ + static bool tcg_target_initialized; + CPUClass *cc =3D CPU_GET_CLASS(cpu); + + if (!tcg_target_initialized) { + cc->tcg_ops.initialize(); + tcg_target_initialized =3D true; + } + tlb_init(cpu); + qemu_plugin_vcpu_init_hook(cpu); + +#ifndef CONFIG_USER_ONLY + tcg_iommu_init_notifier_list(cpu); +#endif /* !CONFIG_USER_ONLY */ +} + +/* undo the initializations in reverse order */ +void tcg_exec_unrealizefn(CPUState *cpu) +{ +#ifndef CONFIG_USER_ONLY + tcg_iommu_free_notifier_list(cpu); +#endif /* !CONFIG_USER_ONLY */ + + qemu_plugin_vcpu_exit_hook(cpu); + tlb_destroy(cpu); +} + #ifndef CONFIG_USER_ONLY =20 void dump_drift_info(void) diff --git a/cpu.c b/cpu.c index 79a2bf12b3..bfbe5a66f9 100644 --- a/cpu.c +++ b/cpu.c @@ -124,13 +124,35 @@ const VMStateDescription vmstate_cpu_common =3D { }; #endif =20 +void cpu_exec_realizefn(CPUState *cpu, Error **errp) +{ + CPUClass *cc =3D CPU_GET_CLASS(cpu); + + cpu_list_add(cpu); + +#ifdef CONFIG_TCG + /* NB: errp parameter is unused currently */ + if (tcg_enabled()) { + tcg_exec_realizefn(cpu, errp); + } +#endif /* CONFIG_TCG */ + +#ifdef CONFIG_USER_ONLY + assert(cc->vmsd =3D=3D NULL); +#else + if (qdev_get_vmsd(DEVICE(cpu)) =3D=3D NULL) { + vmstate_register(NULL, cpu->cpu_index, &vmstate_cpu_common, cpu); + } + if (cc->vmsd !=3D NULL) { + vmstate_register(NULL, cpu->cpu_index, cc->vmsd, cpu); + } +#endif /* CONFIG_USER_ONLY */ +} + void cpu_exec_unrealizefn(CPUState *cpu) { CPUClass *cc =3D CPU_GET_CLASS(cpu); =20 - tlb_destroy(cpu); - cpu_list_remove(cpu); - #ifdef CONFIG_USER_ONLY assert(cc->vmsd =3D=3D NULL); #else @@ -140,8 +162,15 @@ void cpu_exec_unrealizefn(CPUState *cpu) if (qdev_get_vmsd(DEVICE(cpu)) =3D=3D NULL) { vmstate_unregister(NULL, &vmstate_cpu_common, cpu); } - tcg_iommu_free_notifier_list(cpu); #endif +#ifdef CONFIG_TCG + /* NB: errp parameter is unused currently */ + if (tcg_enabled()) { + tcg_exec_unrealizefn(cpu); + } +#endif /* CONFIG_TCG */ + + cpu_list_remove(cpu); } =20 void cpu_exec_initfn(CPUState *cpu) @@ -156,39 +185,6 @@ void cpu_exec_initfn(CPUState *cpu) #endif } =20 -void cpu_exec_realizefn(CPUState *cpu, Error **errp) -{ - CPUClass *cc =3D CPU_GET_CLASS(cpu); -#ifdef CONFIG_TCG - static bool tcg_target_initialized; -#endif /* CONFIG_TCG */ - - cpu_list_add(cpu); - -#ifdef CONFIG_TCG - if (tcg_enabled() && !tcg_target_initialized) { - tcg_target_initialized =3D true; - cc->tcg_ops.initialize(); - } -#endif /* CONFIG_TCG */ - tlb_init(cpu); - - qemu_plugin_vcpu_init_hook(cpu); - -#ifdef CONFIG_USER_ONLY - assert(cc->vmsd =3D=3D NULL); -#else /* !CONFIG_USER_ONLY */ - if (qdev_get_vmsd(DEVICE(cpu)) =3D=3D NULL) { - vmstate_register(NULL, cpu->cpu_index, &vmstate_cpu_common, cpu); - } - if (cc->vmsd !=3D NULL) { - vmstate_register(NULL, cpu->cpu_index, cc->vmsd, cpu); - } - - tcg_iommu_init_notifier_list(cpu); -#endif -} - const char *parse_cpu_option(const char *cpu_option) { ObjectClass *oc; diff --git a/hw/core/cpu.c b/hw/core/cpu.c index 7553411653..57542b6906 100644 --- a/hw/core/cpu.c +++ b/hw/core/cpu.c @@ -199,6 +199,10 @@ static bool cpu_common_virtio_is_big_endian(CPUState *= cpu) return target_words_bigendian(); } =20 +/* + * XXX the following #if is always true because this is a common_ss + * module, so target CONFIG_* is never defined. + */ #if !defined(CONFIG_USER_ONLY) GuestPanicInformation *cpu_get_crash_info(CPUState *cpu) { @@ -340,9 +344,9 @@ static void cpu_common_realizefn(DeviceState *dev, Erro= r **errp) static void cpu_common_unrealizefn(DeviceState *dev) { CPUState *cpu =3D CPU(dev); + /* NOTE: latest generic point before the cpu is fully unrealized */ trace_fini_vcpu(cpu); - qemu_plugin_vcpu_exit_hook(cpu); cpu_exec_unrealizefn(cpu); } =20 --=20 2.26.2 From nobody Thu Apr 25 18:08:54 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=1610474792; cv=none; d=zohomail.com; s=zohoarc; b=DV80ZfIeyWVMcxPbalJBtMq88ci4IvnbeiE6S12zpXUTb1SCpJDgDFh34OPwxLFeqKno42rlEREcMgNY+/bUAiS7l1DDwVbwnWIbXRUWrXWv7MA0z+v5VptsAqby7APJtBMqO73iHN+cO7pKVAxepk81benH/RNuUBLmTxCEiy4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610474792; 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=csmIxw1OcPRMR6FcH6DAEia0hzXWVLi4VY8XfIu+LJw=; b=a/8CZtvwGfJ4EPSYe9rbcV48S92BvqjD91pT7/g4KNEtf0OTM8kH/3RFuEL/429mMddERq93gbgnI3aAUVRP7/q5mQR79p4bz0pwu8guy9LSkGFllcobmgxBrUA40mi6avNPqamOvWDg+liIBOO6di+vQwOpMfLnaeOPMZ0KXlg= 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 1610474792419593.5452414908334; Tue, 12 Jan 2021 10:06:32 -0800 (PST) Received: from localhost ([::1]:53604 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kzO3r-0007Gb-8G for importer@patchew.org; Tue, 12 Jan 2021 13:06:31 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47944) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kzO0p-0005Gc-I7 for qemu-devel@nongnu.org; Tue, 12 Jan 2021 13:03:23 -0500 Received: from mx2.suse.de ([195.135.220.15]:33426) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kzO0n-0004uO-3S for qemu-devel@nongnu.org; Tue, 12 Jan 2021 13:03:23 -0500 Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id D2A6EAD5C; Tue, 12 Jan 2021 18:03:19 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Claudio Fontana To: Paolo Bonzini , Thomas Huth , Richard Henderson , Stefano Stabellini , Wenchao Wang , Roman Bolshakov , Sunil Muthuswamy , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v12 04/22] cpu: Move synchronize_from_tb() to tcg_ops Date: Tue, 12 Jan 2021 19:02:54 +0100 Message-Id: <20210112180312.26043-5-cfontana@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210112180312.26043-1-cfontana@suse.de> References: <20210112180312.26043-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 , Peter Maydell , Eduardo Habkost , Paul Durrant , Jason Wang , Marcelo Tosatti , qemu-devel@nongnu.org, Peter Xu , Dario Faggioli , Cameron Esfahani , haxm-team@intel.com, Colin Xu , Anthony Perard , Bruce Rogers , Olaf Hering , "Emilio G . Cota" , Claudio Fontana Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Eduardo Habkost Signed-off-by: Eduardo Habkost [claudio: wrapped in CONFIG_TCG] Signed-off-by: Claudio Fontana --- include/hw/core/cpu.h | 20 +++++++++++--------- accel/tcg/cpu-exec.c | 4 ++-- target/arm/cpu.c | 4 +++- target/avr/cpu.c | 2 +- target/hppa/cpu.c | 2 +- target/i386/tcg/tcg-cpu.c | 2 +- target/microblaze/cpu.c | 2 +- target/mips/cpu.c | 4 +++- target/riscv/cpu.c | 2 +- target/rx/cpu.c | 2 +- target/sh4/cpu.c | 2 +- target/sparc/cpu.c | 2 +- target/tricore/cpu.c | 2 +- 13 files changed, 28 insertions(+), 22 deletions(-) diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index 96fdca39d2..b3c1bb77eb 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -87,6 +87,17 @@ typedef struct TcgCpuOperations { * Called when the first CPU is realized. */ void (*initialize)(void); + /** + * @synchronize_from_tb: Synchronize state from a TCG #TranslationBlock + * + * This is called when we abandon execution of a TB before + * starting it, and must set all parts of the CPU state which + * the previous TB in the chain may not have updated. This + * will need to do more. If this hook is not implemented then + * the default is to call @set_pc(tb->pc). + */ + void (*synchronize_from_tb)(CPUState *cpu, + const struct TranslationBlock *tb); =20 } TcgCpuOperations; #endif /* CONFIG_TCG */ @@ -121,13 +132,6 @@ typedef struct TcgCpuOperations { * If the target behaviour here is anything other than "set * the PC register to the value passed in" then the target must * also implement the synchronize_from_tb hook. - * @synchronize_from_tb: Callback for synchronizing state from a TCG - * #TranslationBlock. This is called when we abandon execution - * of a TB before starting it, and must set all parts of the CPU - * state which the previous TB in the chain may not have updated. - * This always includes at least the program counter; some targets - * will need to do more. If this hook is not implemented then the - * default is to call @set_pc(tb->pc). * @tlb_fill: Callback for handling a softmmu tlb miss or user-only * address fault. For system mode, if the access is valid, call * tlb_set_page and return true; if the access is invalid, and @@ -204,8 +208,6 @@ struct CPUClass { void (*get_memory_mapping)(CPUState *cpu, MemoryMappingList *list, Error **errp); void (*set_pc)(CPUState *cpu, vaddr value); - void (*synchronize_from_tb)(CPUState *cpu, - const struct TranslationBlock *tb); bool (*tlb_fill)(CPUState *cpu, vaddr address, int size, MMUAccessType access_type, int mmu_idx, bool probe, uintptr_t retaddr); diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index 5fb5304278..9578012646 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -211,8 +211,8 @@ cpu_tb_exec(CPUState *cpu, TranslationBlock *itb, int *= tb_exit) TARGET_FMT_lx "] %s\n", last_tb->tc.ptr, last_tb->pc, lookup_symbol(last_tb->pc)); - if (cc->synchronize_from_tb) { - cc->synchronize_from_tb(cpu, last_tb); + if (cc->tcg_ops.synchronize_from_tb) { + cc->tcg_ops.synchronize_from_tb(cpu, last_tb); } else { assert(cc->set_pc); cc->set_pc(cpu, last_tb->pc); diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 7c8b0c3af6..13fabf7ace 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -54,6 +54,7 @@ static void arm_cpu_set_pc(CPUState *cs, vaddr value) } } =20 +#ifdef CONFIG_TCG static void arm_cpu_synchronize_from_tb(CPUState *cs, const TranslationBlock *tb) { @@ -70,6 +71,7 @@ static void arm_cpu_synchronize_from_tb(CPUState *cs, env->regs[15] =3D tb->pc; } } +#endif /* CONFIG_TCG */ =20 static bool arm_cpu_has_work(CPUState *cs) { @@ -2244,7 +2246,6 @@ static void arm_cpu_class_init(ObjectClass *oc, void = *data) cc->cpu_exec_interrupt =3D arm_cpu_exec_interrupt; cc->dump_state =3D arm_cpu_dump_state; cc->set_pc =3D arm_cpu_set_pc; - cc->synchronize_from_tb =3D arm_cpu_synchronize_from_tb; cc->gdb_read_register =3D arm_cpu_gdb_read_register; cc->gdb_write_register =3D arm_cpu_gdb_write_register; #ifndef CONFIG_USER_ONLY @@ -2264,6 +2265,7 @@ static void arm_cpu_class_init(ObjectClass *oc, void = *data) cc->disas_set_info =3D arm_disas_set_info; #ifdef CONFIG_TCG cc->tcg_ops.initialize =3D arm_translate_init; + cc->tcg_ops.synchronize_from_tb =3D arm_cpu_synchronize_from_tb; cc->tlb_fill =3D arm_cpu_tlb_fill; cc->debug_excp_handler =3D arm_debug_excp_handler; cc->debug_check_watchpoint =3D arm_debug_check_watchpoint; diff --git a/target/avr/cpu.c b/target/avr/cpu.c index fb66695fbb..a82fa9d7a8 100644 --- a/target/avr/cpu.c +++ b/target/avr/cpu.c @@ -208,7 +208,7 @@ static void avr_cpu_class_init(ObjectClass *oc, void *d= ata) cc->vmsd =3D &vms_avr_cpu; cc->disas_set_info =3D avr_cpu_disas_set_info; cc->tcg_ops.initialize =3D avr_cpu_tcg_init; - cc->synchronize_from_tb =3D avr_cpu_synchronize_from_tb; + cc->tcg_ops.synchronize_from_tb =3D avr_cpu_synchronize_from_tb; cc->gdb_read_register =3D avr_cpu_gdb_read_register; cc->gdb_write_register =3D avr_cpu_gdb_write_register; cc->gdb_num_core_regs =3D 35; diff --git a/target/hppa/cpu.c b/target/hppa/cpu.c index 80e3081631..94ea3014a3 100644 --- a/target/hppa/cpu.c +++ b/target/hppa/cpu.c @@ -144,7 +144,7 @@ static void hppa_cpu_class_init(ObjectClass *oc, void *= data) cc->cpu_exec_interrupt =3D hppa_cpu_exec_interrupt; cc->dump_state =3D hppa_cpu_dump_state; cc->set_pc =3D hppa_cpu_set_pc; - cc->synchronize_from_tb =3D hppa_cpu_synchronize_from_tb; + cc->tcg_ops.synchronize_from_tb =3D hppa_cpu_synchronize_from_tb; cc->gdb_read_register =3D hppa_cpu_gdb_read_register; cc->gdb_write_register =3D hppa_cpu_gdb_write_register; cc->tlb_fill =3D hppa_cpu_tlb_fill; diff --git a/target/i386/tcg/tcg-cpu.c b/target/i386/tcg/tcg-cpu.c index d90502a0cc..874286de28 100644 --- a/target/i386/tcg/tcg-cpu.c +++ b/target/i386/tcg/tcg-cpu.c @@ -61,7 +61,7 @@ void tcg_cpu_common_class_init(CPUClass *cc) { cc->do_interrupt =3D x86_cpu_do_interrupt; cc->cpu_exec_interrupt =3D x86_cpu_exec_interrupt; - cc->synchronize_from_tb =3D x86_cpu_synchronize_from_tb; + cc->tcg_ops.synchronize_from_tb =3D x86_cpu_synchronize_from_tb; cc->cpu_exec_enter =3D x86_cpu_exec_enter; cc->cpu_exec_exit =3D x86_cpu_exec_exit; cc->tcg_ops.initialize =3D tcg_x86_init; diff --git a/target/microblaze/cpu.c b/target/microblaze/cpu.c index 44b40d4d5c..00424d16f4 100644 --- a/target/microblaze/cpu.c +++ b/target/microblaze/cpu.c @@ -323,7 +323,7 @@ static void mb_cpu_class_init(ObjectClass *oc, void *da= ta) cc->cpu_exec_interrupt =3D mb_cpu_exec_interrupt; cc->dump_state =3D mb_cpu_dump_state; cc->set_pc =3D mb_cpu_set_pc; - cc->synchronize_from_tb =3D mb_cpu_synchronize_from_tb; + cc->tcg_ops.synchronize_from_tb =3D mb_cpu_synchronize_from_tb; cc->gdb_read_register =3D mb_cpu_gdb_read_register; cc->gdb_write_register =3D mb_cpu_gdb_write_register; cc->tlb_fill =3D mb_cpu_tlb_fill; diff --git a/target/mips/cpu.c b/target/mips/cpu.c index 8a42470cda..b4ed63946e 100644 --- a/target/mips/cpu.c +++ b/target/mips/cpu.c @@ -47,6 +47,7 @@ static void mips_cpu_set_pc(CPUState *cs, vaddr value) } } =20 +#ifdef CONFIG_TCG static void mips_cpu_synchronize_from_tb(CPUState *cs, const TranslationBlock *tb) { @@ -57,6 +58,7 @@ static void mips_cpu_synchronize_from_tb(CPUState *cs, env->hflags &=3D ~MIPS_HFLAG_BMASK; env->hflags |=3D tb->flags & MIPS_HFLAG_BMASK; } +#endif /* CONFIG_TCG */ =20 static bool mips_cpu_has_work(CPUState *cs) { @@ -479,7 +481,6 @@ static void mips_cpu_class_init(ObjectClass *c, void *d= ata) cc->cpu_exec_interrupt =3D mips_cpu_exec_interrupt; cc->dump_state =3D mips_cpu_dump_state; cc->set_pc =3D mips_cpu_set_pc; - cc->synchronize_from_tb =3D mips_cpu_synchronize_from_tb; cc->gdb_read_register =3D mips_cpu_gdb_read_register; cc->gdb_write_register =3D mips_cpu_gdb_write_register; #ifndef CONFIG_USER_ONLY @@ -491,6 +492,7 @@ static void mips_cpu_class_init(ObjectClass *c, void *d= ata) cc->disas_set_info =3D mips_cpu_disas_set_info; #ifdef CONFIG_TCG cc->tcg_ops.initialize =3D mips_tcg_init; + cc->tcg_ops.synchronize_from_tb =3D mips_cpu_synchronize_from_tb; cc->tlb_fill =3D mips_cpu_tlb_fill; #endif =20 diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 229f06b2a3..9af0a216c1 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -574,7 +574,7 @@ static void riscv_cpu_class_init(ObjectClass *c, void *= data) cc->cpu_exec_interrupt =3D riscv_cpu_exec_interrupt; cc->dump_state =3D riscv_cpu_dump_state; cc->set_pc =3D riscv_cpu_set_pc; - cc->synchronize_from_tb =3D riscv_cpu_synchronize_from_tb; + cc->tcg_ops.synchronize_from_tb =3D riscv_cpu_synchronize_from_tb; cc->gdb_read_register =3D riscv_cpu_gdb_read_register; cc->gdb_write_register =3D riscv_cpu_gdb_write_register; cc->gdb_num_core_regs =3D 33; diff --git a/target/rx/cpu.c b/target/rx/cpu.c index cdcab49c8a..4e0de14eef 100644 --- a/target/rx/cpu.c +++ b/target/rx/cpu.c @@ -190,7 +190,7 @@ static void rx_cpu_class_init(ObjectClass *klass, void = *data) cc->cpu_exec_interrupt =3D rx_cpu_exec_interrupt; cc->dump_state =3D rx_cpu_dump_state; cc->set_pc =3D rx_cpu_set_pc; - cc->synchronize_from_tb =3D rx_cpu_synchronize_from_tb; + cc->tcg_ops.synchronize_from_tb =3D rx_cpu_synchronize_from_tb; cc->gdb_read_register =3D rx_cpu_gdb_read_register; cc->gdb_write_register =3D rx_cpu_gdb_write_register; cc->get_phys_page_debug =3D rx_cpu_get_phys_page_debug; diff --git a/target/sh4/cpu.c b/target/sh4/cpu.c index b86753cda5..130debe074 100644 --- a/target/sh4/cpu.c +++ b/target/sh4/cpu.c @@ -223,7 +223,7 @@ static void superh_cpu_class_init(ObjectClass *oc, void= *data) cc->cpu_exec_interrupt =3D superh_cpu_exec_interrupt; cc->dump_state =3D superh_cpu_dump_state; cc->set_pc =3D superh_cpu_set_pc; - cc->synchronize_from_tb =3D superh_cpu_synchronize_from_tb; + cc->tcg_ops.synchronize_from_tb =3D superh_cpu_synchronize_from_tb; cc->gdb_read_register =3D superh_cpu_gdb_read_register; cc->gdb_write_register =3D superh_cpu_gdb_write_register; cc->tlb_fill =3D superh_cpu_tlb_fill; diff --git a/target/sparc/cpu.c b/target/sparc/cpu.c index 3ab71e9d00..0ae38eb496 100644 --- a/target/sparc/cpu.c +++ b/target/sparc/cpu.c @@ -870,7 +870,7 @@ static void sparc_cpu_class_init(ObjectClass *oc, void = *data) cc->memory_rw_debug =3D sparc_cpu_memory_rw_debug; #endif cc->set_pc =3D sparc_cpu_set_pc; - cc->synchronize_from_tb =3D sparc_cpu_synchronize_from_tb; + cc->tcg_ops.synchronize_from_tb =3D sparc_cpu_synchronize_from_tb; cc->gdb_read_register =3D sparc_cpu_gdb_read_register; cc->gdb_write_register =3D sparc_cpu_gdb_write_register; cc->tlb_fill =3D sparc_cpu_tlb_fill; diff --git a/target/tricore/cpu.c b/target/tricore/cpu.c index bf135af40f..09cc6a0e62 100644 --- a/target/tricore/cpu.c +++ b/target/tricore/cpu.c @@ -162,7 +162,7 @@ static void tricore_cpu_class_init(ObjectClass *c, void= *data) =20 cc->dump_state =3D tricore_cpu_dump_state; cc->set_pc =3D tricore_cpu_set_pc; - cc->synchronize_from_tb =3D tricore_cpu_synchronize_from_tb; + cc->tcg_ops.synchronize_from_tb =3D tricore_cpu_synchronize_from_tb; cc->get_phys_page_debug =3D tricore_cpu_get_phys_page_debug; cc->tcg_ops.initialize =3D tricore_tcg_init; cc->tlb_fill =3D tricore_cpu_tlb_fill; --=20 2.26.2 From nobody Thu Apr 25 18:08:54 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=1610474993; cv=none; d=zohomail.com; s=zohoarc; b=Pc0mYQSVrl5VDAxALBfjr8dvWgfPPdJWNc5MsZSw4LxDsTfSKRPTtx3M+UMuP8h2X+jlieXsufAs5qhkxP57uKlAU9Wab8yZJ2nHnyKZNI4ZlIM52Vei9omIDV7f3VVQNDoL9RGlfK0CanP/eSCuSmEWhIrQJhQSByZGca4x2Vo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610474993; h=Content-Type: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=+QqVKg0xkyMJNolvaPMSF/7i+fFQaQhVlXNlGs0ZhqY=; b=MdQIy4gqMoaZz9AqicoBtaPv5peM+wew/Uol56LdlVDxUZOpV/nr0iGnr1JWBlk9hdPiWvWVtBWu5Gus19RG0gpelfHwzDRou33iEFIrGG+VeiRfXr159Vrl6v4F3NkOtnsxqBbRcHFKrZxRwYq5zc9vwZyhR1CRCIvt3GpLpcI= 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 1610474993020539.21663965691; Tue, 12 Jan 2021 10:09:53 -0800 (PST) Received: from localhost ([::1]:34160 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kzO75-0002pm-KN for importer@patchew.org; Tue, 12 Jan 2021 13:09:51 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47988) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kzO0s-0005I9-Gu for qemu-devel@nongnu.org; Tue, 12 Jan 2021 13:03:27 -0500 Received: from mx2.suse.de ([195.135.220.15]:33458) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kzO0o-0004ua-6p for qemu-devel@nongnu.org; Tue, 12 Jan 2021 13:03:26 -0500 Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id EC23BACAD; Tue, 12 Jan 2021 18:03:20 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Claudio Fontana To: Paolo Bonzini , Thomas Huth , Richard Henderson , Stefano Stabellini , Wenchao Wang , Roman Bolshakov , Sunil Muthuswamy , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v12 05/22] cpu: Move cpu_exec_* to tcg_ops Date: Tue, 12 Jan 2021 19:02:55 +0100 Message-Id: <20210112180312.26043-6-cfontana@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210112180312.26043-1-cfontana@suse.de> References: <20210112180312.26043-1-cfontana@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 , Peter Maydell , Eduardo Habkost , Paul Durrant , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Jason Wang , Marcelo Tosatti , qemu-devel@nongnu.org, Peter Xu , Dario Faggioli , Cameron Esfahani , haxm-team@intel.com, Colin Xu , Anthony Perard , Bruce Rogers , Olaf Hering , "Emilio G . Cota" , Claudio Fontana Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" From: Eduardo Habkost Signed-off-by: Eduardo Habkost [claudio: wrapped in CONFIG_TCG] Signed-off-by: Claudio Fontana Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Alex Benn=C3=A9e Reviewed-by: Richard Henderson --- include/hw/core/cpu.h | 12 ++++++------ accel/tcg/cpu-exec.c | 12 ++++++------ target/alpha/cpu.c | 2 +- target/arm/cpu.c | 2 +- target/arm/cpu64.c | 5 ++++- target/arm/cpu_tcg.c | 7 ++++++- target/avr/cpu.c | 2 +- target/cris/cpu.c | 2 +- target/hppa/cpu.c | 2 +- target/i386/tcg/tcg-cpu.c | 6 +++--- target/lm32/cpu.c | 2 +- target/m68k/cpu.c | 2 +- target/microblaze/cpu.c | 2 +- target/mips/cpu.c | 2 +- target/nios2/cpu.c | 2 +- target/openrisc/cpu.c | 2 +- target/riscv/cpu.c | 2 +- target/rx/cpu.c | 2 +- target/s390x/cpu.c | 2 +- target/sh4/cpu.c | 2 +- target/sparc/cpu.c | 2 +- target/tilegx/cpu.c | 2 +- target/unicore32/cpu.c | 2 +- target/xtensa/cpu.c | 2 +- target/ppc/translate_init.c.inc | 16 ++++++++++------ 25 files changed, 54 insertions(+), 42 deletions(-) diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index b3c1bb77eb..eacefe28c7 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -98,6 +98,12 @@ typedef struct TcgCpuOperations { */ void (*synchronize_from_tb)(CPUState *cpu, const struct TranslationBlock *tb); + /** @cpu_exec_enter: Callback for cpu_exec preparation */ + void (*cpu_exec_enter)(CPUState *cpu); + /** @cpu_exec_exit: Callback for cpu_exec cleanup */ + void (*cpu_exec_exit)(CPUState *cpu); + /** @cpu_exec_interrupt: Callback for processing interrupts in cpu_exe= c */ + bool (*cpu_exec_interrupt)(CPUState *cpu, int interrupt_request); =20 } TcgCpuOperations; #endif /* CONFIG_TCG */ @@ -168,9 +174,6 @@ typedef struct TcgCpuOperations { * @gdb_get_dynamic_xml: Callback to return dynamically generated XML for = the * gdb stub. Returns a pointer to the XML contents for the specified XML= file * or NULL if the CPU doesn't have a dynamically generated content for i= t. - * @cpu_exec_enter: Callback for cpu_exec preparation. - * @cpu_exec_exit: Callback for cpu_exec cleanup. - * @cpu_exec_interrupt: Callback for processing interrupts in cpu_exec. * @disas_set_info: Setup architecture specific components of disassembly = info * @adjust_watchpoint_address: Perform a target-specific adjustment to an * address before attempting to match it against watchpoints. @@ -233,9 +236,6 @@ struct CPUClass { const char *gdb_core_xml_file; gchar * (*gdb_arch_name)(CPUState *cpu); const char * (*gdb_get_dynamic_xml)(CPUState *cpu, const char *xmlname= ); - void (*cpu_exec_enter)(CPUState *cpu); - void (*cpu_exec_exit)(CPUState *cpu); - bool (*cpu_exec_interrupt)(CPUState *cpu, int interrupt_request); =20 void (*disas_set_info)(CPUState *cpu, disassemble_info *info); vaddr (*adjust_watchpoint_address)(CPUState *cpu, vaddr addr, int len); diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index 9578012646..f3943fe732 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -260,8 +260,8 @@ static void cpu_exec_enter(CPUState *cpu) { CPUClass *cc =3D CPU_GET_CLASS(cpu); =20 - if (cc->cpu_exec_enter) { - cc->cpu_exec_enter(cpu); + if (cc->tcg_ops.cpu_exec_enter) { + cc->tcg_ops.cpu_exec_enter(cpu); } } =20 @@ -269,8 +269,8 @@ static void cpu_exec_exit(CPUState *cpu) { CPUClass *cc =3D CPU_GET_CLASS(cpu); =20 - if (cc->cpu_exec_exit) { - cc->cpu_exec_exit(cpu); + if (cc->tcg_ops.cpu_exec_exit) { + cc->tcg_ops.cpu_exec_exit(cpu); } } =20 @@ -648,8 +648,8 @@ static inline bool cpu_handle_interrupt(CPUState *cpu, True when it is, and we should restart on a new TB, and via longjmp via cpu_loop_exit. */ else { - if (cc->cpu_exec_interrupt && - cc->cpu_exec_interrupt(cpu, interrupt_request)) { + if (cc->tcg_ops.cpu_exec_interrupt && + cc->tcg_ops.cpu_exec_interrupt(cpu, interrupt_request)) { if (need_replay_interrupt(interrupt_request)) { replay_interrupt(); } diff --git a/target/alpha/cpu.c b/target/alpha/cpu.c index d66f0351a9..d9ced1635a 100644 --- a/target/alpha/cpu.c +++ b/target/alpha/cpu.c @@ -218,7 +218,7 @@ static void alpha_cpu_class_init(ObjectClass *oc, void = *data) cc->class_by_name =3D alpha_cpu_class_by_name; cc->has_work =3D alpha_cpu_has_work; cc->do_interrupt =3D alpha_cpu_do_interrupt; - cc->cpu_exec_interrupt =3D alpha_cpu_exec_interrupt; + cc->tcg_ops.cpu_exec_interrupt =3D alpha_cpu_exec_interrupt; cc->dump_state =3D alpha_cpu_dump_state; cc->set_pc =3D alpha_cpu_set_pc; cc->gdb_read_register =3D alpha_cpu_gdb_read_register; diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 13fabf7ace..1a53427b70 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -2243,7 +2243,6 @@ static void arm_cpu_class_init(ObjectClass *oc, void = *data) =20 cc->class_by_name =3D arm_cpu_class_by_name; cc->has_work =3D arm_cpu_has_work; - cc->cpu_exec_interrupt =3D arm_cpu_exec_interrupt; cc->dump_state =3D arm_cpu_dump_state; cc->set_pc =3D arm_cpu_set_pc; cc->gdb_read_register =3D arm_cpu_gdb_read_register; @@ -2265,6 +2264,7 @@ static void arm_cpu_class_init(ObjectClass *oc, void = *data) cc->disas_set_info =3D arm_disas_set_info; #ifdef CONFIG_TCG cc->tcg_ops.initialize =3D arm_translate_init; + cc->tcg_ops.cpu_exec_interrupt =3D arm_cpu_exec_interrupt; cc->tcg_ops.synchronize_from_tb =3D arm_cpu_synchronize_from_tb; cc->tlb_fill =3D arm_cpu_tlb_fill; cc->debug_excp_handler =3D arm_debug_excp_handler; diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c index 7cf9fc4bc6..2e2eab208b 100644 --- a/target/arm/cpu64.c +++ b/target/arm/cpu64.c @@ -775,7 +775,10 @@ static void aarch64_cpu_class_init(ObjectClass *oc, vo= id *data) { CPUClass *cc =3D CPU_CLASS(oc); =20 - cc->cpu_exec_interrupt =3D arm_cpu_exec_interrupt; +#ifdef CONFIG_TCG + cc->tcg_ops.cpu_exec_interrupt =3D arm_cpu_exec_interrupt; +#endif /* CONFIG_TCG */ + cc->gdb_read_register =3D aarch64_cpu_gdb_read_register; cc->gdb_write_register =3D aarch64_cpu_gdb_write_register; cc->gdb_num_core_regs =3D 34; diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c index 98544db2df..f2e565166e 100644 --- a/target/arm/cpu_tcg.c +++ b/target/arm/cpu_tcg.c @@ -15,6 +15,7 @@ /* CPU models. These are not needed for the AArch64 linux-user build. */ #if !defined(CONFIG_USER_ONLY) || !defined(TARGET_AARCH64) =20 +#ifdef CONFIG_TCG static bool arm_v7m_cpu_exec_interrupt(CPUState *cs, int interrupt_request) { CPUClass *cc =3D CPU_GET_CLASS(cs); @@ -38,6 +39,7 @@ static bool arm_v7m_cpu_exec_interrupt(CPUState *cs, int = interrupt_request) } return ret; } +#endif /* CONFIG_TCG */ =20 static void arm926_initfn(Object *obj) { @@ -668,7 +670,10 @@ static void arm_v7m_class_init(ObjectClass *oc, void *= data) cc->do_interrupt =3D arm_v7m_cpu_do_interrupt; #endif =20 - cc->cpu_exec_interrupt =3D arm_v7m_cpu_exec_interrupt; +#ifdef CONFIG_TCG + cc->tcg_ops.cpu_exec_interrupt =3D arm_v7m_cpu_exec_interrupt; +#endif /* CONFIG_TCG */ + cc->gdb_core_xml_file =3D "arm-m-profile.xml"; } =20 diff --git a/target/avr/cpu.c b/target/avr/cpu.c index a82fa9d7a8..499a98dcee 100644 --- a/target/avr/cpu.c +++ b/target/avr/cpu.c @@ -199,7 +199,7 @@ static void avr_cpu_class_init(ObjectClass *oc, void *d= ata) =20 cc->has_work =3D avr_cpu_has_work; cc->do_interrupt =3D avr_cpu_do_interrupt; - cc->cpu_exec_interrupt =3D avr_cpu_exec_interrupt; + cc->tcg_ops.cpu_exec_interrupt =3D avr_cpu_exec_interrupt; cc->dump_state =3D avr_cpu_dump_state; cc->set_pc =3D avr_cpu_set_pc; cc->memory_rw_debug =3D avr_cpu_memory_rw_debug; diff --git a/target/cris/cpu.c b/target/cris/cpu.c index 4328f8e6c9..7489fc20c8 100644 --- a/target/cris/cpu.c +++ b/target/cris/cpu.c @@ -269,7 +269,7 @@ static void cris_cpu_class_init(ObjectClass *oc, void *= data) cc->class_by_name =3D cris_cpu_class_by_name; cc->has_work =3D cris_cpu_has_work; cc->do_interrupt =3D cris_cpu_do_interrupt; - cc->cpu_exec_interrupt =3D cris_cpu_exec_interrupt; + cc->tcg_ops.cpu_exec_interrupt =3D cris_cpu_exec_interrupt; cc->dump_state =3D cris_cpu_dump_state; cc->set_pc =3D cris_cpu_set_pc; cc->gdb_read_register =3D cris_cpu_gdb_read_register; diff --git a/target/hppa/cpu.c b/target/hppa/cpu.c index 94ea3014a3..34c598230e 100644 --- a/target/hppa/cpu.c +++ b/target/hppa/cpu.c @@ -141,7 +141,7 @@ static void hppa_cpu_class_init(ObjectClass *oc, void *= data) cc->class_by_name =3D hppa_cpu_class_by_name; cc->has_work =3D hppa_cpu_has_work; cc->do_interrupt =3D hppa_cpu_do_interrupt; - cc->cpu_exec_interrupt =3D hppa_cpu_exec_interrupt; + cc->tcg_ops.cpu_exec_interrupt =3D hppa_cpu_exec_interrupt; cc->dump_state =3D hppa_cpu_dump_state; cc->set_pc =3D hppa_cpu_set_pc; cc->tcg_ops.synchronize_from_tb =3D hppa_cpu_synchronize_from_tb; diff --git a/target/i386/tcg/tcg-cpu.c b/target/i386/tcg/tcg-cpu.c index 874286de28..b7c485aa76 100644 --- a/target/i386/tcg/tcg-cpu.c +++ b/target/i386/tcg/tcg-cpu.c @@ -60,10 +60,10 @@ static void x86_cpu_synchronize_from_tb(CPUState *cs, void tcg_cpu_common_class_init(CPUClass *cc) { cc->do_interrupt =3D x86_cpu_do_interrupt; - cc->cpu_exec_interrupt =3D x86_cpu_exec_interrupt; + cc->tcg_ops.cpu_exec_interrupt =3D x86_cpu_exec_interrupt; cc->tcg_ops.synchronize_from_tb =3D x86_cpu_synchronize_from_tb; - cc->cpu_exec_enter =3D x86_cpu_exec_enter; - cc->cpu_exec_exit =3D x86_cpu_exec_exit; + cc->tcg_ops.cpu_exec_enter =3D x86_cpu_exec_enter; + cc->tcg_ops.cpu_exec_exit =3D x86_cpu_exec_exit; cc->tcg_ops.initialize =3D tcg_x86_init; cc->tlb_fill =3D x86_cpu_tlb_fill; #ifndef CONFIG_USER_ONLY diff --git a/target/lm32/cpu.c b/target/lm32/cpu.c index ef795b81a4..eea2d3e515 100644 --- a/target/lm32/cpu.c +++ b/target/lm32/cpu.c @@ -223,7 +223,7 @@ static void lm32_cpu_class_init(ObjectClass *oc, void *= data) cc->class_by_name =3D lm32_cpu_class_by_name; cc->has_work =3D lm32_cpu_has_work; cc->do_interrupt =3D lm32_cpu_do_interrupt; - cc->cpu_exec_interrupt =3D lm32_cpu_exec_interrupt; + cc->tcg_ops.cpu_exec_interrupt =3D lm32_cpu_exec_interrupt; cc->dump_state =3D lm32_cpu_dump_state; cc->set_pc =3D lm32_cpu_set_pc; cc->gdb_read_register =3D lm32_cpu_gdb_read_register; diff --git a/target/m68k/cpu.c b/target/m68k/cpu.c index 3604ece49b..0d5f8e0dd8 100644 --- a/target/m68k/cpu.c +++ b/target/m68k/cpu.c @@ -466,7 +466,7 @@ static void m68k_cpu_class_init(ObjectClass *c, void *d= ata) cc->class_by_name =3D m68k_cpu_class_by_name; cc->has_work =3D m68k_cpu_has_work; cc->do_interrupt =3D m68k_cpu_do_interrupt; - cc->cpu_exec_interrupt =3D m68k_cpu_exec_interrupt; + cc->tcg_ops.cpu_exec_interrupt =3D m68k_cpu_exec_interrupt; cc->dump_state =3D m68k_cpu_dump_state; cc->set_pc =3D m68k_cpu_set_pc; cc->gdb_read_register =3D m68k_cpu_gdb_read_register; diff --git a/target/microblaze/cpu.c b/target/microblaze/cpu.c index 00424d16f4..7f42066db4 100644 --- a/target/microblaze/cpu.c +++ b/target/microblaze/cpu.c @@ -320,7 +320,7 @@ static void mb_cpu_class_init(ObjectClass *oc, void *da= ta) cc->has_work =3D mb_cpu_has_work; cc->do_interrupt =3D mb_cpu_do_interrupt; cc->do_unaligned_access =3D mb_cpu_do_unaligned_access; - cc->cpu_exec_interrupt =3D mb_cpu_exec_interrupt; + cc->tcg_ops.cpu_exec_interrupt =3D mb_cpu_exec_interrupt; cc->dump_state =3D mb_cpu_dump_state; cc->set_pc =3D mb_cpu_set_pc; cc->tcg_ops.synchronize_from_tb =3D mb_cpu_synchronize_from_tb; diff --git a/target/mips/cpu.c b/target/mips/cpu.c index b4ed63946e..4f88359314 100644 --- a/target/mips/cpu.c +++ b/target/mips/cpu.c @@ -478,7 +478,6 @@ static void mips_cpu_class_init(ObjectClass *c, void *d= ata) cc->class_by_name =3D mips_cpu_class_by_name; cc->has_work =3D mips_cpu_has_work; cc->do_interrupt =3D mips_cpu_do_interrupt; - cc->cpu_exec_interrupt =3D mips_cpu_exec_interrupt; cc->dump_state =3D mips_cpu_dump_state; cc->set_pc =3D mips_cpu_set_pc; cc->gdb_read_register =3D mips_cpu_gdb_read_register; @@ -492,6 +491,7 @@ static void mips_cpu_class_init(ObjectClass *c, void *d= ata) cc->disas_set_info =3D mips_cpu_disas_set_info; #ifdef CONFIG_TCG cc->tcg_ops.initialize =3D mips_tcg_init; + cc->tcg_ops.cpu_exec_interrupt =3D mips_cpu_exec_interrupt; cc->tcg_ops.synchronize_from_tb =3D mips_cpu_synchronize_from_tb; cc->tlb_fill =3D mips_cpu_tlb_fill; #endif diff --git a/target/nios2/cpu.c b/target/nios2/cpu.c index c28eb05ef0..b0d51f77f5 100644 --- a/target/nios2/cpu.c +++ b/target/nios2/cpu.c @@ -222,7 +222,7 @@ static void nios2_cpu_class_init(ObjectClass *oc, void = *data) cc->class_by_name =3D nios2_cpu_class_by_name; cc->has_work =3D nios2_cpu_has_work; cc->do_interrupt =3D nios2_cpu_do_interrupt; - cc->cpu_exec_interrupt =3D nios2_cpu_exec_interrupt; + cc->tcg_ops.cpu_exec_interrupt =3D nios2_cpu_exec_interrupt; cc->dump_state =3D nios2_cpu_dump_state; cc->set_pc =3D nios2_cpu_set_pc; cc->disas_set_info =3D nios2_cpu_disas_set_info; diff --git a/target/openrisc/cpu.c b/target/openrisc/cpu.c index a957f59e2e..48c416e138 100644 --- a/target/openrisc/cpu.c +++ b/target/openrisc/cpu.c @@ -187,7 +187,7 @@ static void openrisc_cpu_class_init(ObjectClass *oc, vo= id *data) cc->class_by_name =3D openrisc_cpu_class_by_name; cc->has_work =3D openrisc_cpu_has_work; cc->do_interrupt =3D openrisc_cpu_do_interrupt; - cc->cpu_exec_interrupt =3D openrisc_cpu_exec_interrupt; + cc->tcg_ops.cpu_exec_interrupt =3D openrisc_cpu_exec_interrupt; cc->dump_state =3D openrisc_cpu_dump_state; cc->set_pc =3D openrisc_cpu_set_pc; cc->gdb_read_register =3D openrisc_cpu_gdb_read_register; diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 9af0a216c1..019f2037de 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -571,7 +571,7 @@ static void riscv_cpu_class_init(ObjectClass *c, void *= data) cc->class_by_name =3D riscv_cpu_class_by_name; cc->has_work =3D riscv_cpu_has_work; cc->do_interrupt =3D riscv_cpu_do_interrupt; - cc->cpu_exec_interrupt =3D riscv_cpu_exec_interrupt; + cc->tcg_ops.cpu_exec_interrupt =3D riscv_cpu_exec_interrupt; cc->dump_state =3D riscv_cpu_dump_state; cc->set_pc =3D riscv_cpu_set_pc; cc->tcg_ops.synchronize_from_tb =3D riscv_cpu_synchronize_from_tb; diff --git a/target/rx/cpu.c b/target/rx/cpu.c index 4e0de14eef..9493e9031a 100644 --- a/target/rx/cpu.c +++ b/target/rx/cpu.c @@ -187,7 +187,7 @@ static void rx_cpu_class_init(ObjectClass *klass, void = *data) cc->class_by_name =3D rx_cpu_class_by_name; cc->has_work =3D rx_cpu_has_work; cc->do_interrupt =3D rx_cpu_do_interrupt; - cc->cpu_exec_interrupt =3D rx_cpu_exec_interrupt; + cc->tcg_ops.cpu_exec_interrupt =3D rx_cpu_exec_interrupt; cc->dump_state =3D rx_cpu_dump_state; cc->set_pc =3D rx_cpu_set_pc; cc->tcg_ops.synchronize_from_tb =3D rx_cpu_synchronize_from_tb; diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c index 890781e74c..53c2f6f89e 100644 --- a/target/s390x/cpu.c +++ b/target/s390x/cpu.c @@ -508,7 +508,7 @@ static void s390_cpu_class_init(ObjectClass *oc, void *= data) cc->get_crash_info =3D s390_cpu_get_crash_info; cc->write_elf64_note =3D s390_cpu_write_elf64_note; #ifdef CONFIG_TCG - cc->cpu_exec_interrupt =3D s390_cpu_exec_interrupt; + cc->tcg_ops.cpu_exec_interrupt =3D s390_cpu_exec_interrupt; cc->debug_excp_handler =3D s390x_cpu_debug_excp_handler; cc->do_unaligned_access =3D s390x_cpu_do_unaligned_access; #endif diff --git a/target/sh4/cpu.c b/target/sh4/cpu.c index 130debe074..b2d4e3648c 100644 --- a/target/sh4/cpu.c +++ b/target/sh4/cpu.c @@ -220,7 +220,7 @@ static void superh_cpu_class_init(ObjectClass *oc, void= *data) cc->class_by_name =3D superh_cpu_class_by_name; cc->has_work =3D superh_cpu_has_work; cc->do_interrupt =3D superh_cpu_do_interrupt; - cc->cpu_exec_interrupt =3D superh_cpu_exec_interrupt; + cc->tcg_ops.cpu_exec_interrupt =3D superh_cpu_exec_interrupt; cc->dump_state =3D superh_cpu_dump_state; cc->set_pc =3D superh_cpu_set_pc; cc->tcg_ops.synchronize_from_tb =3D superh_cpu_synchronize_from_tb; diff --git a/target/sparc/cpu.c b/target/sparc/cpu.c index 0ae38eb496..139939494e 100644 --- a/target/sparc/cpu.c +++ b/target/sparc/cpu.c @@ -864,7 +864,7 @@ static void sparc_cpu_class_init(ObjectClass *oc, void = *data) cc->parse_features =3D sparc_cpu_parse_features; cc->has_work =3D sparc_cpu_has_work; cc->do_interrupt =3D sparc_cpu_do_interrupt; - cc->cpu_exec_interrupt =3D sparc_cpu_exec_interrupt; + cc->tcg_ops.cpu_exec_interrupt =3D sparc_cpu_exec_interrupt; cc->dump_state =3D sparc_cpu_dump_state; #if !defined(TARGET_SPARC64) && !defined(CONFIG_USER_ONLY) cc->memory_rw_debug =3D sparc_cpu_memory_rw_debug; diff --git a/target/tilegx/cpu.c b/target/tilegx/cpu.c index cd24d0eb9d..4c6176d26e 100644 --- a/target/tilegx/cpu.c +++ b/target/tilegx/cpu.c @@ -148,7 +148,7 @@ static void tilegx_cpu_class_init(ObjectClass *oc, void= *data) cc->class_by_name =3D tilegx_cpu_class_by_name; cc->has_work =3D tilegx_cpu_has_work; cc->do_interrupt =3D tilegx_cpu_do_interrupt; - cc->cpu_exec_interrupt =3D tilegx_cpu_exec_interrupt; + cc->tcg_ops.cpu_exec_interrupt =3D tilegx_cpu_exec_interrupt; cc->dump_state =3D tilegx_cpu_dump_state; cc->set_pc =3D tilegx_cpu_set_pc; cc->tlb_fill =3D tilegx_cpu_tlb_fill; diff --git a/target/unicore32/cpu.c b/target/unicore32/cpu.c index 226bf4226e..84c3419989 100644 --- a/target/unicore32/cpu.c +++ b/target/unicore32/cpu.c @@ -132,7 +132,7 @@ static void uc32_cpu_class_init(ObjectClass *oc, void *= data) cc->class_by_name =3D uc32_cpu_class_by_name; cc->has_work =3D uc32_cpu_has_work; cc->do_interrupt =3D uc32_cpu_do_interrupt; - cc->cpu_exec_interrupt =3D uc32_cpu_exec_interrupt; + cc->tcg_ops.cpu_exec_interrupt =3D uc32_cpu_exec_interrupt; cc->dump_state =3D uc32_cpu_dump_state; cc->set_pc =3D uc32_cpu_set_pc; cc->tlb_fill =3D uc32_cpu_tlb_fill; diff --git a/target/xtensa/cpu.c b/target/xtensa/cpu.c index 5a6f5bf88b..42a5e4ebe8 100644 --- a/target/xtensa/cpu.c +++ b/target/xtensa/cpu.c @@ -195,7 +195,7 @@ static void xtensa_cpu_class_init(ObjectClass *oc, void= *data) cc->class_by_name =3D xtensa_cpu_class_by_name; cc->has_work =3D xtensa_cpu_has_work; cc->do_interrupt =3D xtensa_cpu_do_interrupt; - cc->cpu_exec_interrupt =3D xtensa_cpu_exec_interrupt; + cc->tcg_ops.cpu_exec_interrupt =3D xtensa_cpu_exec_interrupt; cc->dump_state =3D xtensa_cpu_dump_state; cc->set_pc =3D xtensa_cpu_set_pc; cc->gdb_read_register =3D xtensa_cpu_gdb_read_register; diff --git a/target/ppc/translate_init.c.inc b/target/ppc/translate_init.c.= inc index 189f27cd1c..2b0343686f 100644 --- a/target/ppc/translate_init.c.inc +++ b/target/ppc/translate_init.c.inc @@ -10700,6 +10700,7 @@ static void ppc_cpu_reset(DeviceState *dev) } =20 #ifndef CONFIG_USER_ONLY + static bool ppc_cpu_is_big_endian(CPUState *cs) { PowerPCCPU *cpu =3D POWERPC_CPU(cs); @@ -10710,6 +10711,7 @@ static bool ppc_cpu_is_big_endian(CPUState *cs) return !msr_le; } =20 +#ifdef CONFIG_TCG static void ppc_cpu_exec_enter(CPUState *cs) { PowerPCCPU *cpu =3D POWERPC_CPU(cs); @@ -10731,7 +10733,9 @@ static void ppc_cpu_exec_exit(CPUState *cs) vhc->cpu_exec_exit(cpu->vhyp, cpu); } } -#endif +#endif /* CONFIG_TCG */ + +#endif /* !CONFIG_USER_ONLY */ =20 static void ppc_cpu_instance_init(Object *obj) { @@ -10842,7 +10846,6 @@ static void ppc_cpu_class_init(ObjectClass *oc, voi= d *data) cc->class_by_name =3D ppc_cpu_class_by_name; cc->has_work =3D ppc_cpu_has_work; cc->do_interrupt =3D ppc_cpu_do_interrupt; - cc->cpu_exec_interrupt =3D ppc_cpu_exec_interrupt; cc->dump_state =3D ppc_cpu_dump_state; cc->dump_statistics =3D ppc_cpu_dump_statistics; cc->set_pc =3D ppc_cpu_set_pc; @@ -10879,12 +10882,13 @@ static void ppc_cpu_class_init(ObjectClass *oc, v= oid *data) #endif #ifdef CONFIG_TCG cc->tcg_ops.initialize =3D ppc_translate_init; + cc->tcg_ops.cpu_exec_interrupt =3D ppc_cpu_exec_interrupt; cc->tlb_fill =3D ppc_cpu_tlb_fill; -#endif #ifndef CONFIG_USER_ONLY - cc->cpu_exec_enter =3D ppc_cpu_exec_enter; - cc->cpu_exec_exit =3D ppc_cpu_exec_exit; -#endif + cc->tcg_ops.cpu_exec_enter =3D ppc_cpu_exec_enter; + cc->tcg_ops.cpu_exec_exit =3D ppc_cpu_exec_exit; +#endif /* !CONFIG_USER_ONLY */ +#endif /* CONFIG_TCG */ =20 cc->disas_set_info =3D ppc_disas_set_info; =20 --=20 2.26.2 From nobody Thu Apr 25 18:08:54 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=1610475227; cv=none; d=zohomail.com; s=zohoarc; b=CdlIih2Bu3aNjLFTVdX3KEeanWf1XmZfZ+xCfHkornTcJ0dVdBsHXRkE0nMDKTc+tqVxtkTp157XI7QGIH4CFQuFl/E+l7PQFhWc2cl4b+yg6WCMw0zleKkP+h8njdZ98zYSvGccs0+C2nQEgN3DLmfvPv36Q9l5E8QXB74bvTM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610475227; h=Content-Type: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=nBCHX69QYr0+d9/3Rtsdf95tMozuBaz8YUv1KZ/K6Qk=; b=dH1qULv1YwDpLJew5Z5A7z+kWoA0cMTleONV5H/KdhjK3rDFpHghDY4lkdm3o6G1mrL0c8obqexx+pfhz1kP5afO1fbzUezjovihJvXZZOmAagI3N3ItLsfy/AH24e397kk1wwqr6SaW8qxOzjqJL9YIsn/G+g1Bx7OkiSS1qUw= 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 1610475227146187.25325900763755; Tue, 12 Jan 2021 10:13:47 -0800 (PST) Received: from localhost ([::1]:42780 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kzOAr-0006bm-NQ for importer@patchew.org; Tue, 12 Jan 2021 13:13:45 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48000) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kzO0u-0005Ij-D0 for qemu-devel@nongnu.org; Tue, 12 Jan 2021 13:03:29 -0500 Received: from mx2.suse.de ([195.135.220.15]:33498) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kzO0p-0004um-A5 for qemu-devel@nongnu.org; Tue, 12 Jan 2021 13:03:28 -0500 Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 070F2ACBA; Tue, 12 Jan 2021 18:03:22 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Claudio Fontana To: Paolo Bonzini , Thomas Huth , Richard Henderson , Stefano Stabellini , Wenchao Wang , Roman Bolshakov , Sunil Muthuswamy , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v12 06/22] cpu: Move tlb_fill to tcg_ops Date: Tue, 12 Jan 2021 19:02:56 +0100 Message-Id: <20210112180312.26043-7-cfontana@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210112180312.26043-1-cfontana@suse.de> References: <20210112180312.26043-1-cfontana@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 , Peter Maydell , Eduardo Habkost , Paul Durrant , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Jason Wang , Marcelo Tosatti , qemu-devel@nongnu.org, Peter Xu , Dario Faggioli , Cameron Esfahani , haxm-team@intel.com, Colin Xu , Anthony Perard , Bruce Rogers , Olaf Hering , "Emilio G . Cota" , Claudio Fontana Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" From: Eduardo Habkost Signed-off-by: Eduardo Habkost [claudio: wrapped in CONFIG_TCG] Signed-off-by: Claudio Fontana Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Alex Benn=C3=A9e Reviewed-by: Richard Henderson --- include/hw/core/cpu.h | 21 ++++++++++++--------- accel/tcg/cputlb.c | 7 ++++--- accel/tcg/user-exec.c | 6 +++--- target/alpha/cpu.c | 2 +- target/arm/cpu.c | 2 +- target/avr/cpu.c | 2 +- target/cris/cpu.c | 2 +- target/hppa/cpu.c | 2 +- target/i386/tcg/tcg-cpu.c | 2 +- target/lm32/cpu.c | 2 +- target/m68k/cpu.c | 2 +- target/microblaze/cpu.c | 2 +- target/mips/cpu.c | 2 +- target/moxie/cpu.c | 2 +- target/nios2/cpu.c | 2 +- target/openrisc/cpu.c | 2 +- target/riscv/cpu.c | 2 +- target/rx/cpu.c | 2 +- target/s390x/cpu.c | 2 +- target/sh4/cpu.c | 2 +- target/sparc/cpu.c | 2 +- target/tilegx/cpu.c | 2 +- target/tricore/cpu.c | 2 +- target/unicore32/cpu.c | 2 +- target/xtensa/cpu.c | 2 +- target/ppc/translate_init.c.inc | 2 +- 26 files changed, 42 insertions(+), 38 deletions(-) diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index eacefe28c7..aa464c9633 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -104,6 +104,18 @@ typedef struct TcgCpuOperations { void (*cpu_exec_exit)(CPUState *cpu); /** @cpu_exec_interrupt: Callback for processing interrupts in cpu_exe= c */ bool (*cpu_exec_interrupt)(CPUState *cpu, int interrupt_request); + /** + * @tlb_fill: Handle a softmmu tlb miss or user-only address fault + * + * For system mode, if the access is valid, call tlb_set_page + * and return true; if the access is invalid, and probe is + * true, return false; otherwise raise an exception and do + * not return. For user-only mode, always raise an exception + * and do not return. + */ + bool (*tlb_fill)(CPUState *cpu, vaddr address, int size, + MMUAccessType access_type, int mmu_idx, + bool probe, uintptr_t retaddr); =20 } TcgCpuOperations; #endif /* CONFIG_TCG */ @@ -138,12 +150,6 @@ typedef struct TcgCpuOperations { * If the target behaviour here is anything other than "set * the PC register to the value passed in" then the target must * also implement the synchronize_from_tb hook. - * @tlb_fill: Callback for handling a softmmu tlb miss or user-only - * address fault. For system mode, if the access is valid, call - * tlb_set_page and return true; if the access is invalid, and - * probe is true, return false; otherwise raise an exception and - * do not return. For user-only mode, always raise an exception - * and do not return. * @get_phys_page_debug: Callback for obtaining a physical address. * @get_phys_page_attrs_debug: Callback for obtaining a physical address a= nd the * associated memory transaction attributes to use for the access. @@ -211,9 +217,6 @@ struct CPUClass { void (*get_memory_mapping)(CPUState *cpu, MemoryMappingList *list, Error **errp); void (*set_pc)(CPUState *cpu, vaddr value); - bool (*tlb_fill)(CPUState *cpu, vaddr address, int size, - MMUAccessType access_type, int mmu_idx, - bool probe, uintptr_t retaddr); hwaddr (*get_phys_page_debug)(CPUState *cpu, vaddr addr); hwaddr (*get_phys_page_attrs_debug)(CPUState *cpu, vaddr addr, MemTxAttrs *attrs); diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index ced3dc077e..d3ad40f380 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -1286,7 +1286,8 @@ static void tlb_fill(CPUState *cpu, target_ulong addr= , int size, * This is not a probe, so only valid return is success; failure * should result in exception + longjmp to the cpu loop. */ - ok =3D cc->tlb_fill(cpu, addr, size, access_type, mmu_idx, false, reta= ddr); + ok =3D cc->tcg_ops.tlb_fill(cpu, addr, size, + access_type, mmu_idx, false, retaddr); assert(ok); } =20 @@ -1557,8 +1558,8 @@ static int probe_access_internal(CPUArchState *env, t= arget_ulong addr, CPUState *cs =3D env_cpu(env); CPUClass *cc =3D CPU_GET_CLASS(cs); =20 - if (!cc->tlb_fill(cs, addr, fault_size, access_type, - mmu_idx, nonfault, retaddr)) { + if (!cc->tcg_ops.tlb_fill(cs, addr, fault_size, access_type, + mmu_idx, nonfault, retaddr)) { /* Non-faulting page table read failed. */ *phost =3D NULL; return TLB_INVALID_MASK; diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c index 1215b55ca0..5509dd53e9 100644 --- a/accel/tcg/user-exec.c +++ b/accel/tcg/user-exec.c @@ -187,7 +187,7 @@ static inline int handle_cpu_signal(uintptr_t pc, sigin= fo_t *info, clear_helper_retaddr(); =20 cc =3D CPU_GET_CLASS(cpu); - cc->tlb_fill(cpu, address, 0, access_type, MMU_USER_IDX, false, pc); + cc->tcg_ops.tlb_fill(cpu, address, 0, access_type, MMU_USER_IDX, false= , pc); g_assert_not_reached(); } =20 @@ -217,8 +217,8 @@ static int probe_access_internal(CPUArchState *env, tar= get_ulong addr, } else { CPUState *cpu =3D env_cpu(env); CPUClass *cc =3D CPU_GET_CLASS(cpu); - cc->tlb_fill(cpu, addr, fault_size, access_type, - MMU_USER_IDX, false, ra); + cc->tcg_ops.tlb_fill(cpu, addr, fault_size, access_type, + MMU_USER_IDX, false, ra); g_assert_not_reached(); } } diff --git a/target/alpha/cpu.c b/target/alpha/cpu.c index d9ced1635a..9f36f824fd 100644 --- a/target/alpha/cpu.c +++ b/target/alpha/cpu.c @@ -223,7 +223,7 @@ static void alpha_cpu_class_init(ObjectClass *oc, void = *data) cc->set_pc =3D alpha_cpu_set_pc; cc->gdb_read_register =3D alpha_cpu_gdb_read_register; cc->gdb_write_register =3D alpha_cpu_gdb_write_register; - cc->tlb_fill =3D alpha_cpu_tlb_fill; + cc->tcg_ops.tlb_fill =3D alpha_cpu_tlb_fill; #ifndef CONFIG_USER_ONLY cc->do_transaction_failed =3D alpha_cpu_do_transaction_failed; cc->do_unaligned_access =3D alpha_cpu_do_unaligned_access; diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 1a53427b70..fff6eec13b 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -2266,7 +2266,7 @@ static void arm_cpu_class_init(ObjectClass *oc, void = *data) cc->tcg_ops.initialize =3D arm_translate_init; cc->tcg_ops.cpu_exec_interrupt =3D arm_cpu_exec_interrupt; cc->tcg_ops.synchronize_from_tb =3D arm_cpu_synchronize_from_tb; - cc->tlb_fill =3D arm_cpu_tlb_fill; + cc->tcg_ops.tlb_fill =3D arm_cpu_tlb_fill; cc->debug_excp_handler =3D arm_debug_excp_handler; cc->debug_check_watchpoint =3D arm_debug_check_watchpoint; cc->do_unaligned_access =3D arm_cpu_do_unaligned_access; diff --git a/target/avr/cpu.c b/target/avr/cpu.c index 499a98dcee..d6e93049b4 100644 --- a/target/avr/cpu.c +++ b/target/avr/cpu.c @@ -204,7 +204,7 @@ static void avr_cpu_class_init(ObjectClass *oc, void *d= ata) cc->set_pc =3D avr_cpu_set_pc; cc->memory_rw_debug =3D avr_cpu_memory_rw_debug; cc->get_phys_page_debug =3D avr_cpu_get_phys_page_debug; - cc->tlb_fill =3D avr_cpu_tlb_fill; + cc->tcg_ops.tlb_fill =3D avr_cpu_tlb_fill; cc->vmsd =3D &vms_avr_cpu; cc->disas_set_info =3D avr_cpu_disas_set_info; cc->tcg_ops.initialize =3D avr_cpu_tcg_init; diff --git a/target/cris/cpu.c b/target/cris/cpu.c index 7489fc20c8..9222717f3e 100644 --- a/target/cris/cpu.c +++ b/target/cris/cpu.c @@ -274,7 +274,7 @@ static void cris_cpu_class_init(ObjectClass *oc, void *= data) cc->set_pc =3D cris_cpu_set_pc; cc->gdb_read_register =3D cris_cpu_gdb_read_register; cc->gdb_write_register =3D cris_cpu_gdb_write_register; - cc->tlb_fill =3D cris_cpu_tlb_fill; + cc->tcg_ops.tlb_fill =3D cris_cpu_tlb_fill; #ifndef CONFIG_USER_ONLY cc->get_phys_page_debug =3D cris_cpu_get_phys_page_debug; dc->vmsd =3D &vmstate_cris_cpu; diff --git a/target/hppa/cpu.c b/target/hppa/cpu.c index 34c598230e..d5a25014e8 100644 --- a/target/hppa/cpu.c +++ b/target/hppa/cpu.c @@ -147,7 +147,7 @@ static void hppa_cpu_class_init(ObjectClass *oc, void *= data) cc->tcg_ops.synchronize_from_tb =3D hppa_cpu_synchronize_from_tb; cc->gdb_read_register =3D hppa_cpu_gdb_read_register; cc->gdb_write_register =3D hppa_cpu_gdb_write_register; - cc->tlb_fill =3D hppa_cpu_tlb_fill; + cc->tcg_ops.tlb_fill =3D hppa_cpu_tlb_fill; #ifndef CONFIG_USER_ONLY cc->get_phys_page_debug =3D hppa_cpu_get_phys_page_debug; dc->vmsd =3D &vmstate_hppa_cpu; diff --git a/target/i386/tcg/tcg-cpu.c b/target/i386/tcg/tcg-cpu.c index b7c485aa76..85b69224a9 100644 --- a/target/i386/tcg/tcg-cpu.c +++ b/target/i386/tcg/tcg-cpu.c @@ -65,7 +65,7 @@ void tcg_cpu_common_class_init(CPUClass *cc) cc->tcg_ops.cpu_exec_enter =3D x86_cpu_exec_enter; cc->tcg_ops.cpu_exec_exit =3D x86_cpu_exec_exit; cc->tcg_ops.initialize =3D tcg_x86_init; - cc->tlb_fill =3D x86_cpu_tlb_fill; + cc->tcg_ops.tlb_fill =3D x86_cpu_tlb_fill; #ifndef CONFIG_USER_ONLY cc->debug_excp_handler =3D breakpoint_handler; #endif diff --git a/target/lm32/cpu.c b/target/lm32/cpu.c index eea2d3e515..76dc728858 100644 --- a/target/lm32/cpu.c +++ b/target/lm32/cpu.c @@ -228,7 +228,7 @@ static void lm32_cpu_class_init(ObjectClass *oc, void *= data) cc->set_pc =3D lm32_cpu_set_pc; cc->gdb_read_register =3D lm32_cpu_gdb_read_register; cc->gdb_write_register =3D lm32_cpu_gdb_write_register; - cc->tlb_fill =3D lm32_cpu_tlb_fill; + cc->tcg_ops.tlb_fill =3D lm32_cpu_tlb_fill; #ifndef CONFIG_USER_ONLY cc->get_phys_page_debug =3D lm32_cpu_get_phys_page_debug; cc->vmsd =3D &vmstate_lm32_cpu; diff --git a/target/m68k/cpu.c b/target/m68k/cpu.c index 0d5f8e0dd8..e38e4d5456 100644 --- a/target/m68k/cpu.c +++ b/target/m68k/cpu.c @@ -471,7 +471,7 @@ static void m68k_cpu_class_init(ObjectClass *c, void *d= ata) cc->set_pc =3D m68k_cpu_set_pc; cc->gdb_read_register =3D m68k_cpu_gdb_read_register; cc->gdb_write_register =3D m68k_cpu_gdb_write_register; - cc->tlb_fill =3D m68k_cpu_tlb_fill; + cc->tcg_ops.tlb_fill =3D m68k_cpu_tlb_fill; #if defined(CONFIG_SOFTMMU) cc->do_transaction_failed =3D m68k_cpu_transaction_failed; cc->get_phys_page_debug =3D m68k_cpu_get_phys_page_debug; diff --git a/target/microblaze/cpu.c b/target/microblaze/cpu.c index 7f42066db4..68df0c20d8 100644 --- a/target/microblaze/cpu.c +++ b/target/microblaze/cpu.c @@ -326,7 +326,7 @@ static void mb_cpu_class_init(ObjectClass *oc, void *da= ta) cc->tcg_ops.synchronize_from_tb =3D mb_cpu_synchronize_from_tb; cc->gdb_read_register =3D mb_cpu_gdb_read_register; cc->gdb_write_register =3D mb_cpu_gdb_write_register; - cc->tlb_fill =3D mb_cpu_tlb_fill; + cc->tcg_ops.tlb_fill =3D mb_cpu_tlb_fill; #ifndef CONFIG_USER_ONLY cc->do_transaction_failed =3D mb_cpu_transaction_failed; cc->get_phys_page_debug =3D mb_cpu_get_phys_page_debug; diff --git a/target/mips/cpu.c b/target/mips/cpu.c index 4f88359314..85b3161b25 100644 --- a/target/mips/cpu.c +++ b/target/mips/cpu.c @@ -493,7 +493,7 @@ static void mips_cpu_class_init(ObjectClass *c, void *d= ata) cc->tcg_ops.initialize =3D mips_tcg_init; cc->tcg_ops.cpu_exec_interrupt =3D mips_cpu_exec_interrupt; cc->tcg_ops.synchronize_from_tb =3D mips_cpu_synchronize_from_tb; - cc->tlb_fill =3D mips_cpu_tlb_fill; + cc->tcg_ops.tlb_fill =3D mips_cpu_tlb_fill; #endif =20 cc->gdb_num_core_regs =3D 73; diff --git a/target/moxie/cpu.c b/target/moxie/cpu.c index 224cfc8361..1177d092c1 100644 --- a/target/moxie/cpu.c +++ b/target/moxie/cpu.c @@ -110,7 +110,7 @@ static void moxie_cpu_class_init(ObjectClass *oc, void = *data) cc->do_interrupt =3D moxie_cpu_do_interrupt; cc->dump_state =3D moxie_cpu_dump_state; cc->set_pc =3D moxie_cpu_set_pc; - cc->tlb_fill =3D moxie_cpu_tlb_fill; + cc->tcg_ops.tlb_fill =3D moxie_cpu_tlb_fill; #ifndef CONFIG_USER_ONLY cc->get_phys_page_debug =3D moxie_cpu_get_phys_page_debug; cc->vmsd =3D &vmstate_moxie_cpu; diff --git a/target/nios2/cpu.c b/target/nios2/cpu.c index b0d51f77f5..1384836de0 100644 --- a/target/nios2/cpu.c +++ b/target/nios2/cpu.c @@ -226,7 +226,7 @@ static void nios2_cpu_class_init(ObjectClass *oc, void = *data) cc->dump_state =3D nios2_cpu_dump_state; cc->set_pc =3D nios2_cpu_set_pc; cc->disas_set_info =3D nios2_cpu_disas_set_info; - cc->tlb_fill =3D nios2_cpu_tlb_fill; + cc->tcg_ops.tlb_fill =3D nios2_cpu_tlb_fill; #ifndef CONFIG_USER_ONLY cc->do_unaligned_access =3D nios2_cpu_do_unaligned_access; cc->get_phys_page_debug =3D nios2_cpu_get_phys_page_debug; diff --git a/target/openrisc/cpu.c b/target/openrisc/cpu.c index 48c416e138..9857bfde23 100644 --- a/target/openrisc/cpu.c +++ b/target/openrisc/cpu.c @@ -192,7 +192,7 @@ static void openrisc_cpu_class_init(ObjectClass *oc, vo= id *data) cc->set_pc =3D openrisc_cpu_set_pc; cc->gdb_read_register =3D openrisc_cpu_gdb_read_register; cc->gdb_write_register =3D openrisc_cpu_gdb_write_register; - cc->tlb_fill =3D openrisc_cpu_tlb_fill; + cc->tcg_ops.tlb_fill =3D openrisc_cpu_tlb_fill; #ifndef CONFIG_USER_ONLY cc->get_phys_page_debug =3D openrisc_cpu_get_phys_page_debug; dc->vmsd =3D &vmstate_openrisc_cpu; diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 019f2037de..05c97e7e73 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -593,7 +593,7 @@ static void riscv_cpu_class_init(ObjectClass *c, void *= data) cc->vmsd =3D &vmstate_riscv_cpu; #endif cc->tcg_ops.initialize =3D riscv_translate_init; - cc->tlb_fill =3D riscv_cpu_tlb_fill; + cc->tcg_ops.tlb_fill =3D riscv_cpu_tlb_fill; =20 device_class_set_props(dc, riscv_cpu_properties); } diff --git a/target/rx/cpu.c b/target/rx/cpu.c index 9493e9031a..77609728b8 100644 --- a/target/rx/cpu.c +++ b/target/rx/cpu.c @@ -196,7 +196,7 @@ static void rx_cpu_class_init(ObjectClass *klass, void = *data) cc->get_phys_page_debug =3D rx_cpu_get_phys_page_debug; cc->disas_set_info =3D rx_cpu_disas_set_info; cc->tcg_ops.initialize =3D rx_translate_init; - cc->tlb_fill =3D rx_cpu_tlb_fill; + cc->tcg_ops.tlb_fill =3D rx_cpu_tlb_fill; =20 cc->gdb_num_core_regs =3D 26; cc->gdb_core_xml_file =3D "rx-core.xml"; diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c index 53c2f6f89e..ceee62ddca 100644 --- a/target/s390x/cpu.c +++ b/target/s390x/cpu.c @@ -516,7 +516,7 @@ static void s390_cpu_class_init(ObjectClass *oc, void *= data) cc->disas_set_info =3D s390_cpu_disas_set_info; #ifdef CONFIG_TCG cc->tcg_ops.initialize =3D s390x_translate_init; - cc->tlb_fill =3D s390_cpu_tlb_fill; + cc->tcg_ops.tlb_fill =3D s390_cpu_tlb_fill; #endif =20 cc->gdb_num_core_regs =3D S390_NUM_CORE_REGS; diff --git a/target/sh4/cpu.c b/target/sh4/cpu.c index b2d4e3648c..1f6c687c3c 100644 --- a/target/sh4/cpu.c +++ b/target/sh4/cpu.c @@ -226,7 +226,7 @@ static void superh_cpu_class_init(ObjectClass *oc, void= *data) cc->tcg_ops.synchronize_from_tb =3D superh_cpu_synchronize_from_tb; cc->gdb_read_register =3D superh_cpu_gdb_read_register; cc->gdb_write_register =3D superh_cpu_gdb_write_register; - cc->tlb_fill =3D superh_cpu_tlb_fill; + cc->tcg_ops.tlb_fill =3D superh_cpu_tlb_fill; #ifndef CONFIG_USER_ONLY cc->do_unaligned_access =3D superh_cpu_do_unaligned_access; cc->get_phys_page_debug =3D superh_cpu_get_phys_page_debug; diff --git a/target/sparc/cpu.c b/target/sparc/cpu.c index 139939494e..19e90a414d 100644 --- a/target/sparc/cpu.c +++ b/target/sparc/cpu.c @@ -873,7 +873,7 @@ static void sparc_cpu_class_init(ObjectClass *oc, void = *data) cc->tcg_ops.synchronize_from_tb =3D sparc_cpu_synchronize_from_tb; cc->gdb_read_register =3D sparc_cpu_gdb_read_register; cc->gdb_write_register =3D sparc_cpu_gdb_write_register; - cc->tlb_fill =3D sparc_cpu_tlb_fill; + cc->tcg_ops.tlb_fill =3D sparc_cpu_tlb_fill; #ifndef CONFIG_USER_ONLY cc->do_transaction_failed =3D sparc_cpu_do_transaction_failed; cc->do_unaligned_access =3D sparc_cpu_do_unaligned_access; diff --git a/target/tilegx/cpu.c b/target/tilegx/cpu.c index 4c6176d26e..75b3a4bae3 100644 --- a/target/tilegx/cpu.c +++ b/target/tilegx/cpu.c @@ -151,7 +151,7 @@ static void tilegx_cpu_class_init(ObjectClass *oc, void= *data) cc->tcg_ops.cpu_exec_interrupt =3D tilegx_cpu_exec_interrupt; cc->dump_state =3D tilegx_cpu_dump_state; cc->set_pc =3D tilegx_cpu_set_pc; - cc->tlb_fill =3D tilegx_cpu_tlb_fill; + cc->tcg_ops.tlb_fill =3D tilegx_cpu_tlb_fill; cc->gdb_num_core_regs =3D 0; cc->tcg_ops.initialize =3D tilegx_tcg_init; } diff --git a/target/tricore/cpu.c b/target/tricore/cpu.c index 09cc6a0e62..9b21b640e2 100644 --- a/target/tricore/cpu.c +++ b/target/tricore/cpu.c @@ -165,7 +165,7 @@ static void tricore_cpu_class_init(ObjectClass *c, void= *data) cc->tcg_ops.synchronize_from_tb =3D tricore_cpu_synchronize_from_tb; cc->get_phys_page_debug =3D tricore_cpu_get_phys_page_debug; cc->tcg_ops.initialize =3D tricore_tcg_init; - cc->tlb_fill =3D tricore_cpu_tlb_fill; + cc->tcg_ops.tlb_fill =3D tricore_cpu_tlb_fill; } =20 #define DEFINE_TRICORE_CPU_TYPE(cpu_model, initfn) \ diff --git a/target/unicore32/cpu.c b/target/unicore32/cpu.c index 84c3419989..a57d315d2f 100644 --- a/target/unicore32/cpu.c +++ b/target/unicore32/cpu.c @@ -135,7 +135,7 @@ static void uc32_cpu_class_init(ObjectClass *oc, void *= data) cc->tcg_ops.cpu_exec_interrupt =3D uc32_cpu_exec_interrupt; cc->dump_state =3D uc32_cpu_dump_state; cc->set_pc =3D uc32_cpu_set_pc; - cc->tlb_fill =3D uc32_cpu_tlb_fill; + cc->tcg_ops.tlb_fill =3D uc32_cpu_tlb_fill; cc->get_phys_page_debug =3D uc32_cpu_get_phys_page_debug; cc->tcg_ops.initialize =3D uc32_translate_init; dc->vmsd =3D &vmstate_uc32_cpu; diff --git a/target/xtensa/cpu.c b/target/xtensa/cpu.c index 42a5e4ebe8..e764dbeb73 100644 --- a/target/xtensa/cpu.c +++ b/target/xtensa/cpu.c @@ -201,7 +201,7 @@ static void xtensa_cpu_class_init(ObjectClass *oc, void= *data) cc->gdb_read_register =3D xtensa_cpu_gdb_read_register; cc->gdb_write_register =3D xtensa_cpu_gdb_write_register; cc->gdb_stop_before_watchpoint =3D true; - cc->tlb_fill =3D xtensa_cpu_tlb_fill; + cc->tcg_ops.tlb_fill =3D xtensa_cpu_tlb_fill; #ifndef CONFIG_USER_ONLY cc->do_unaligned_access =3D xtensa_cpu_do_unaligned_access; cc->get_phys_page_debug =3D xtensa_cpu_get_phys_page_debug; diff --git a/target/ppc/translate_init.c.inc b/target/ppc/translate_init.c.= inc index 2b0343686f..1e0fc5ac3d 100644 --- a/target/ppc/translate_init.c.inc +++ b/target/ppc/translate_init.c.inc @@ -10883,7 +10883,7 @@ static void ppc_cpu_class_init(ObjectClass *oc, voi= d *data) #ifdef CONFIG_TCG cc->tcg_ops.initialize =3D ppc_translate_init; cc->tcg_ops.cpu_exec_interrupt =3D ppc_cpu_exec_interrupt; - cc->tlb_fill =3D ppc_cpu_tlb_fill; + cc->tcg_ops.tlb_fill =3D ppc_cpu_tlb_fill; #ifndef CONFIG_USER_ONLY cc->tcg_ops.cpu_exec_enter =3D ppc_cpu_exec_enter; cc->tcg_ops.cpu_exec_exit =3D ppc_cpu_exec_exit; --=20 2.26.2 From nobody Thu Apr 25 18:08:54 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=1610475209; cv=none; d=zohomail.com; s=zohoarc; b=hs1oAdCnitUUEH8BsPymYa6yhIIbPM1bJzhfj3ma2bBgCDd1lftz98S3nN8/VDE/VQf4XQTQ8Kotj00yFxxOokT+q679bOrVFRu7xpe8RhV+3z9bnodF8AUhEiNT8dIMcM4T0OmNLxzFAmO2qEyTpnEPKQufnupbCn47F6hCQCw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610475209; h=Content-Type: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=SSUhYmMLrZmakOUF+B/wKBrhz5uP1JaFW3nSo/TXpX8=; b=WjkznuL+k/CuQsYQUIVPqVA0/IX9FmadXVxlgnnQI156zNUHEansQ/xVmz05RZuDk4uVZnIJUFA6BzVMCkOfKL10XMQ2id19avoeiGTbKOVir+lpsHBqUGRonpVPO8FdvmijI+3mZTNBS1aO7tB6+ZVOGOi2cJTeqHWAAgt4aUk= 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 1610475209374945.543911455296; Tue, 12 Jan 2021 10:13:29 -0800 (PST) Received: from localhost ([::1]:42350 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kzOAW-0006Qv-Kb for importer@patchew.org; Tue, 12 Jan 2021 13:13:24 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48022) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kzO0y-0005KN-7W for qemu-devel@nongnu.org; Tue, 12 Jan 2021 13:03:35 -0500 Received: from mx2.suse.de ([195.135.220.15]:33552) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kzO0q-0004vj-AV for qemu-devel@nongnu.org; Tue, 12 Jan 2021 13:03:31 -0500 Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 0CFF5AD6A; Tue, 12 Jan 2021 18:03:23 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Claudio Fontana To: Paolo Bonzini , Thomas Huth , Richard Henderson , Stefano Stabellini , Wenchao Wang , Roman Bolshakov , Sunil Muthuswamy , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v12 07/22] cpu: Move debug_excp_handler to tcg_ops Date: Tue, 12 Jan 2021 19:02:57 +0100 Message-Id: <20210112180312.26043-8-cfontana@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210112180312.26043-1-cfontana@suse.de> References: <20210112180312.26043-1-cfontana@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 , Peter Maydell , Eduardo Habkost , Paul Durrant , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Jason Wang , Marcelo Tosatti , qemu-devel@nongnu.org, Peter Xu , Dario Faggioli , Cameron Esfahani , haxm-team@intel.com, Colin Xu , Anthony Perard , Bruce Rogers , Olaf Hering , "Emilio G . Cota" , Claudio Fontana Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" From: Eduardo Habkost Signed-off-by: Eduardo Habkost Signed-off-by: Claudio Fontana Reviewed-by: Alex Benn=C3=A9e Reviewed-by: Richard Henderson --- include/hw/core/cpu.h | 4 ++-- accel/tcg/cpu-exec.c | 4 ++-- target/arm/cpu.c | 2 +- target/i386/tcg/tcg-cpu.c | 2 +- target/lm32/cpu.c | 2 +- target/s390x/cpu.c | 2 +- target/xtensa/cpu.c | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index aa464c9633..a0e040c617 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -116,6 +116,8 @@ typedef struct TcgCpuOperations { bool (*tlb_fill)(CPUState *cpu, vaddr address, int size, MMUAccessType access_type, int mmu_idx, bool probe, uintptr_t retaddr); + /** @debug_excp_handler: Callback for handling debug exceptions */ + void (*debug_excp_handler)(CPUState *cpu); =20 } TcgCpuOperations; #endif /* CONFIG_TCG */ @@ -161,7 +163,6 @@ typedef struct TcgCpuOperations { * @gdb_write_register: Callback for letting GDB write a register. * @debug_check_watchpoint: Callback: return true if the architectural * watchpoint whose address has matched should really fire. - * @debug_excp_handler: Callback for handling debug exceptions. * @write_elf64_note: Callback for writing a CPU-specific ELF note to a * 64-bit VM coredump. * @write_elf32_qemunote: Callback for writing a CPU- and QEMU-specific ELF @@ -224,7 +225,6 @@ struct CPUClass { int (*gdb_read_register)(CPUState *cpu, GByteArray *buf, int reg); int (*gdb_write_register)(CPUState *cpu, uint8_t *buf, int reg); bool (*debug_check_watchpoint)(CPUState *cpu, CPUWatchpoint *wp); - void (*debug_excp_handler)(CPUState *cpu); =20 int (*write_elf64_note)(WriteCoreDumpFunction f, CPUState *cpu, int cpuid, void *opaque); diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index f3943fe732..b4d863b927 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -505,8 +505,8 @@ static inline void cpu_handle_debug_exception(CPUState = *cpu) } } =20 - if (cc->debug_excp_handler) { - cc->debug_excp_handler(cpu); + if (cc->tcg_ops.debug_excp_handler) { + cc->tcg_ops.debug_excp_handler(cpu); } } =20 diff --git a/target/arm/cpu.c b/target/arm/cpu.c index fff6eec13b..e0dfa9ca4e 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -2267,7 +2267,7 @@ static void arm_cpu_class_init(ObjectClass *oc, void = *data) cc->tcg_ops.cpu_exec_interrupt =3D arm_cpu_exec_interrupt; cc->tcg_ops.synchronize_from_tb =3D arm_cpu_synchronize_from_tb; cc->tcg_ops.tlb_fill =3D arm_cpu_tlb_fill; - cc->debug_excp_handler =3D arm_debug_excp_handler; + cc->tcg_ops.debug_excp_handler =3D arm_debug_excp_handler; cc->debug_check_watchpoint =3D arm_debug_check_watchpoint; cc->do_unaligned_access =3D arm_cpu_do_unaligned_access; #if !defined(CONFIG_USER_ONLY) diff --git a/target/i386/tcg/tcg-cpu.c b/target/i386/tcg/tcg-cpu.c index 85b69224a9..6c1ebbdcc6 100644 --- a/target/i386/tcg/tcg-cpu.c +++ b/target/i386/tcg/tcg-cpu.c @@ -67,6 +67,6 @@ void tcg_cpu_common_class_init(CPUClass *cc) cc->tcg_ops.initialize =3D tcg_x86_init; cc->tcg_ops.tlb_fill =3D x86_cpu_tlb_fill; #ifndef CONFIG_USER_ONLY - cc->debug_excp_handler =3D breakpoint_handler; + cc->tcg_ops.debug_excp_handler =3D breakpoint_handler; #endif } diff --git a/target/lm32/cpu.c b/target/lm32/cpu.c index 76dc728858..bbe1405e32 100644 --- a/target/lm32/cpu.c +++ b/target/lm32/cpu.c @@ -235,7 +235,7 @@ static void lm32_cpu_class_init(ObjectClass *oc, void *= data) #endif cc->gdb_num_core_regs =3D 32 + 7; cc->gdb_stop_before_watchpoint =3D true; - cc->debug_excp_handler =3D lm32_debug_excp_handler; + cc->tcg_ops.debug_excp_handler =3D lm32_debug_excp_handler; cc->disas_set_info =3D lm32_cpu_disas_set_info; cc->tcg_ops.initialize =3D lm32_translate_init; } diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c index ceee62ddca..8ade66178e 100644 --- a/target/s390x/cpu.c +++ b/target/s390x/cpu.c @@ -509,7 +509,7 @@ static void s390_cpu_class_init(ObjectClass *oc, void *= data) cc->write_elf64_note =3D s390_cpu_write_elf64_note; #ifdef CONFIG_TCG cc->tcg_ops.cpu_exec_interrupt =3D s390_cpu_exec_interrupt; - cc->debug_excp_handler =3D s390x_cpu_debug_excp_handler; + cc->tcg_ops.debug_excp_handler =3D s390x_cpu_debug_excp_handler; cc->do_unaligned_access =3D s390x_cpu_do_unaligned_access; #endif #endif diff --git a/target/xtensa/cpu.c b/target/xtensa/cpu.c index e764dbeb73..b6f13ceb32 100644 --- a/target/xtensa/cpu.c +++ b/target/xtensa/cpu.c @@ -207,7 +207,7 @@ static void xtensa_cpu_class_init(ObjectClass *oc, void= *data) cc->get_phys_page_debug =3D xtensa_cpu_get_phys_page_debug; cc->do_transaction_failed =3D xtensa_cpu_do_transaction_failed; #endif - cc->debug_excp_handler =3D xtensa_breakpoint_handler; + cc->tcg_ops.debug_excp_handler =3D xtensa_breakpoint_handler; cc->disas_set_info =3D xtensa_cpu_disas_set_info; cc->tcg_ops.initialize =3D xtensa_translate_init; dc->vmsd =3D &vmstate_xtensa_cpu; --=20 2.26.2 From nobody Thu Apr 25 18:08:54 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=1610474990; cv=none; d=zohomail.com; s=zohoarc; b=STG+c5xGS4TwQaY4Gh47X5B+0bE/GWRFJ/av5Kr2Ex3ZgXEgGqweMTevU3czH0xcWqHAhKpireBqoa9giff4TnVeZIWwHDUIyeN1Qs042mQZGcZZcjxJQBHZmFHcCIH9GC15ZAV04bh32O9AybAlvADPhJ+i8I1bh/+rU5zDX/Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610474990; h=Content-Type: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=7jOF6cTnqYLpknZ3AY9MxYC8PcmKwPUe53hQ91S460k=; b=Zw3L15gqMXAzmO2XqNMCI4UOutvtbYp0EyJ7KhibylbRHJNJ0PbhzvjgdIcSIsDaXLUJtEHgs3o0jso2QVPWNci8aH8QX1G/XR0x+oLYqhlR9NH8GAW8kjJptQ4XiimfyUn5tHi5Ax9am7u73PVnbfqz1n4KAUl1TLLKEXg2lBU= 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 1610474990447111.59276603845615; Tue, 12 Jan 2021 10:09:50 -0800 (PST) Received: from localhost ([::1]:33948 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kzO73-0002kK-5u for importer@patchew.org; Tue, 12 Jan 2021 13:09:49 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48018) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kzO0w-0005JC-1D for qemu-devel@nongnu.org; Tue, 12 Jan 2021 13:03:30 -0500 Received: from mx2.suse.de ([195.135.220.15]:33604) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kzO0s-0004vt-6w for qemu-devel@nongnu.org; Tue, 12 Jan 2021 13:03:29 -0500 Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 2659EADE0; Tue, 12 Jan 2021 18:03:24 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Claudio Fontana To: Paolo Bonzini , Thomas Huth , Richard Henderson , Stefano Stabellini , Wenchao Wang , Roman Bolshakov , Sunil Muthuswamy , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v12 08/22] target/arm: do not use cc->do_interrupt for KVM directly Date: Tue, 12 Jan 2021 19:02:58 +0100 Message-Id: <20210112180312.26043-9-cfontana@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210112180312.26043-1-cfontana@suse.de> References: <20210112180312.26043-1-cfontana@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 , Peter Maydell , Eduardo Habkost , Paul Durrant , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Jason Wang , Marcelo Tosatti , qemu-devel@nongnu.org, Peter Xu , Dario Faggioli , Cameron Esfahani , haxm-team@intel.com, Claudio Fontana , Anthony Perard , Bruce Rogers , Olaf Hering , "Emilio G . Cota" , Colin Xu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" cc->do_interrupt is in theory a TCG callback used in accel/tcg only, to prepare the emulated architecture to take an interrupt as defined in the hardware specifications, but in reality the _do_interrupt style of functions in targets are also occasionally reused by KVM to prepare the architecture state in a similar way where userspace code has identified that it needs to deliver an exception to the guest. In the case of ARM, that includes: 1) the vcpu thread got a SIGBUS indicating a memory error, and we need to deliver a Synchronous External Abort to the guest to let it know about the error. 2) the kernel told us about a debug exception (breakpoint, watchpoint) but it is not for one of QEMU's own gdbstub breakpoints/watchpoints so it must be a breakpoint the guest itself has set up, therefore we need to deliver it to the guest. So in order to reuse code, the same arm_do_interrupt function is used. This is all fine, but we need to avoid calling it using the callback registered in CPUClass, since that one is now TCG-only. Fortunately this is easily solved by replacing calls to CPUClass::do_interrupt() with explicit calls to arm_do_interrupt(). Signed-off-by: Claudio Fontana Cc: Peter Maydell Reviewed-by: Alex Benn=C3=A9e Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- target/arm/helper.c | 4 ++++ target/arm/kvm64.c | 6 ++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/target/arm/helper.c b/target/arm/helper.c index d077dd9ef5..8e3f9c5472 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -9891,6 +9891,10 @@ static void handle_semihosting(CPUState *cs) * Do any appropriate logging, handle PSCI calls, and then hand off * to the AArch64-entry or AArch32-entry function depending on the * target exception level's register width. + * + * Note: this is used for both TCG (as the do_interrupt tcg op), + * and KVM to re-inject guest debug exceptions, and to + * inject a Synchronous-External-Abort. */ void arm_cpu_do_interrupt(CPUState *cs) { diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c index f74bac2457..3728b3a336 100644 --- a/target/arm/kvm64.c +++ b/target/arm/kvm64.c @@ -944,7 +944,6 @@ static void kvm_inject_arm_sea(CPUState *c) { ARMCPU *cpu =3D ARM_CPU(c); CPUARMState *env =3D &cpu->env; - CPUClass *cc =3D CPU_GET_CLASS(c); uint32_t esr; bool same_el; =20 @@ -960,7 +959,7 @@ static void kvm_inject_arm_sea(CPUState *c) =20 env->exception.syndrome =3D esr; =20 - cc->do_interrupt(c); + arm_cpu_do_interrupt(c); } =20 #define AARCH64_CORE_REG(x) (KVM_REG_ARM64 | KVM_REG_SIZE_U64 | \ @@ -1491,7 +1490,6 @@ bool kvm_arm_handle_debug(CPUState *cs, struct kvm_de= bug_exit_arch *debug_exit) { int hsr_ec =3D syn_get_ec(debug_exit->hsr); ARMCPU *cpu =3D ARM_CPU(cs); - CPUClass *cc =3D CPU_GET_CLASS(cs); CPUARMState *env =3D &cpu->env; =20 /* Ensure PC is synchronised */ @@ -1545,7 +1543,7 @@ bool kvm_arm_handle_debug(CPUState *cs, struct kvm_de= bug_exit_arch *debug_exit) env->exception.vaddress =3D debug_exit->far; env->exception.target_el =3D 1; qemu_mutex_lock_iothread(); - cc->do_interrupt(cs); + arm_cpu_do_interrupt(cs); qemu_mutex_unlock_iothread(); =20 return false; --=20 2.26.2 From nobody Thu Apr 25 18:08:54 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=1610474989; cv=none; d=zohomail.com; s=zohoarc; b=A02ukh1OJGchWsa/SJYsJoExLKU0CCYDJOLMGvauzWNEdzRSZpUIC2fC6BPxu9OL+BC1cEk5gzEy1zj7RAEC/AZ7KHeULgwjS7By1IwRIEWx62Ofc11arLbJcXNh+Na25KSfzjrZqf8jtnOEDESu4r6frV5wSHy8lUDo9SHcxbU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610474989; h=Content-Type: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=BfP2yJqtWNQoRJuAXUgo5A66UL03F/4u7BscJvLVOJA=; b=e5jDC388UrkPue3fAYGgqTOsHAFNTX3G56BRg4Sy835TyUjf7RhuDYIGNVrHA5BFEs5PN2FFP/ECPfUGGYbvaRJQOFmf//6FdehFLydZIHoFq/EoZc+unsde9/Jgg1/2RBIi4u9ZzkdUUVjNPcjfMyUBmuvxTZ6uFOqpNPaR8y8= 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 1610474989862325.8450912940666; Tue, 12 Jan 2021 10:09:49 -0800 (PST) Received: from localhost ([::1]:33818 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kzO72-0002h3-7n for importer@patchew.org; Tue, 12 Jan 2021 13:09:48 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48020) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kzO0x-0005Jr-Pp for qemu-devel@nongnu.org; Tue, 12 Jan 2021 13:03:31 -0500 Received: from mx2.suse.de ([195.135.220.15]:33646) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kzO0s-0004w0-CA for qemu-devel@nongnu.org; Tue, 12 Jan 2021 13:03:31 -0500 Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 2A709AD62; Tue, 12 Jan 2021 18:03:25 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Claudio Fontana To: Paolo Bonzini , Thomas Huth , Richard Henderson , Stefano Stabellini , Wenchao Wang , Roman Bolshakov , Sunil Muthuswamy , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v12 09/22] cpu: move cc->do_interrupt to tcg_ops Date: Tue, 12 Jan 2021 19:02:59 +0100 Message-Id: <20210112180312.26043-10-cfontana@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210112180312.26043-1-cfontana@suse.de> References: <20210112180312.26043-1-cfontana@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 , Peter Maydell , Eduardo Habkost , Paul Durrant , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Jason Wang , Marcelo Tosatti , qemu-devel@nongnu.org, Peter Xu , Dario Faggioli , Cameron Esfahani , haxm-team@intel.com, Claudio Fontana , Anthony Perard , Bruce Rogers , Olaf Hering , "Emilio G . Cota" , Colin Xu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Claudio Fontana Reviewed-by: Alex Benn=C3=A9e Reviewed-by: Richard Henderson --- include/hw/core/cpu.h | 4 ++-- accel/tcg/cpu-exec.c | 4 ++-- target/alpha/cpu.c | 2 +- target/arm/cpu.c | 4 ++-- target/arm/cpu_tcg.c | 9 ++++----- target/avr/cpu.c | 2 +- target/avr/helper.c | 4 ++-- target/cris/cpu.c | 12 ++++++------ target/cris/helper.c | 4 ++-- target/hppa/cpu.c | 2 +- target/i386/tcg/tcg-cpu.c | 2 +- target/lm32/cpu.c | 2 +- target/m68k/cpu.c | 2 +- target/microblaze/cpu.c | 2 +- target/mips/cpu.c | 4 ++-- target/moxie/cpu.c | 2 +- target/nios2/cpu.c | 2 +- target/openrisc/cpu.c | 2 +- target/riscv/cpu.c | 2 +- target/rx/cpu.c | 2 +- target/s390x/cpu.c | 2 +- target/sh4/cpu.c | 2 +- target/sparc/cpu.c | 2 +- target/tilegx/cpu.c | 2 +- target/unicore32/cpu.c | 2 +- target/xtensa/cpu.c | 2 +- target/ppc/translate_init.c.inc | 2 +- 27 files changed, 41 insertions(+), 42 deletions(-) diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index a0e040c617..8fcdd55494 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -104,6 +104,8 @@ typedef struct TcgCpuOperations { void (*cpu_exec_exit)(CPUState *cpu); /** @cpu_exec_interrupt: Callback for processing interrupts in cpu_exe= c */ bool (*cpu_exec_interrupt)(CPUState *cpu, int interrupt_request); + /** @do_interrupt: Callback for interrupt handling. */ + void (*do_interrupt)(CPUState *cpu); /** * @tlb_fill: Handle a softmmu tlb miss or user-only address fault * @@ -129,7 +131,6 @@ typedef struct TcgCpuOperations { * @parse_features: Callback to parse command line arguments. * @reset_dump_flags: #CPUDumpFlags to use for reset logging. * @has_work: Callback for checking if there is work to do. - * @do_interrupt: Callback for interrupt handling. * @do_unaligned_access: Callback for unaligned access handling, if * the target defines #TARGET_ALIGNED_ONLY. * @do_transaction_failed: Callback for handling failed memory transactions @@ -199,7 +200,6 @@ struct CPUClass { =20 int reset_dump_flags; bool (*has_work)(CPUState *cpu); - void (*do_interrupt)(CPUState *cpu); void (*do_unaligned_access)(CPUState *cpu, vaddr addr, MMUAccessType access_type, int mmu_idx, uintptr_t retaddr); diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index b4d863b927..d44e11d7d2 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -540,7 +540,7 @@ static inline bool cpu_handle_exception(CPUState *cpu, = int *ret) loop */ #if defined(TARGET_I386) CPUClass *cc =3D CPU_GET_CLASS(cpu); - cc->do_interrupt(cpu); + cc->tcg_ops.do_interrupt(cpu); #endif *ret =3D cpu->exception_index; cpu->exception_index =3D -1; @@ -549,7 +549,7 @@ static inline bool cpu_handle_exception(CPUState *cpu, = int *ret) if (replay_exception()) { CPUClass *cc =3D CPU_GET_CLASS(cpu); qemu_mutex_lock_iothread(); - cc->do_interrupt(cpu); + cc->tcg_ops.do_interrupt(cpu); qemu_mutex_unlock_iothread(); cpu->exception_index =3D -1; =20 diff --git a/target/alpha/cpu.c b/target/alpha/cpu.c index 9f36f824fd..66f1166672 100644 --- a/target/alpha/cpu.c +++ b/target/alpha/cpu.c @@ -217,7 +217,7 @@ static void alpha_cpu_class_init(ObjectClass *oc, void = *data) =20 cc->class_by_name =3D alpha_cpu_class_by_name; cc->has_work =3D alpha_cpu_has_work; - cc->do_interrupt =3D alpha_cpu_do_interrupt; + cc->tcg_ops.do_interrupt =3D alpha_cpu_do_interrupt; cc->tcg_ops.cpu_exec_interrupt =3D alpha_cpu_exec_interrupt; cc->dump_state =3D alpha_cpu_dump_state; cc->set_pc =3D alpha_cpu_set_pc; diff --git a/target/arm/cpu.c b/target/arm/cpu.c index e0dfa9ca4e..8c9ca29025 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -590,7 +590,7 @@ bool arm_cpu_exec_interrupt(CPUState *cs, int interrupt= _request) found: cs->exception_index =3D excp_idx; env->exception.target_el =3D target_el; - cc->do_interrupt(cs); + cc->tcg_ops.do_interrupt(cs); return true; } =20 @@ -2248,7 +2248,6 @@ static void arm_cpu_class_init(ObjectClass *oc, void = *data) cc->gdb_read_register =3D arm_cpu_gdb_read_register; cc->gdb_write_register =3D arm_cpu_gdb_write_register; #ifndef CONFIG_USER_ONLY - cc->do_interrupt =3D arm_cpu_do_interrupt; cc->get_phys_page_attrs_debug =3D arm_cpu_get_phys_page_attrs_debug; cc->asidx_from_attrs =3D arm_asidx_from_attrs; cc->vmsd =3D &vmstate_arm_cpu; @@ -2273,6 +2272,7 @@ static void arm_cpu_class_init(ObjectClass *oc, void = *data) #if !defined(CONFIG_USER_ONLY) cc->do_transaction_failed =3D arm_cpu_do_transaction_failed; cc->adjust_watchpoint_address =3D arm_adjust_watchpoint_address; + cc->tcg_ops.do_interrupt =3D arm_cpu_do_interrupt; #endif /* CONFIG_TCG && !CONFIG_USER_ONLY */ #endif } diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c index f2e565166e..d9c160f1ac 100644 --- a/target/arm/cpu_tcg.c +++ b/target/arm/cpu_tcg.c @@ -34,7 +34,7 @@ static bool arm_v7m_cpu_exec_interrupt(CPUState *cs, int = interrupt_request) if (interrupt_request & CPU_INTERRUPT_HARD && (armv7m_nvic_can_take_pending_exception(env->nvic))) { cs->exception_index =3D EXCP_IRQ; - cc->do_interrupt(cs); + cc->tcg_ops.do_interrupt(cs); ret =3D true; } return ret; @@ -666,12 +666,11 @@ static void arm_v7m_class_init(ObjectClass *oc, void = *data) CPUClass *cc =3D CPU_CLASS(oc); =20 acc->info =3D data; +#ifdef CONFIG_TCG + cc->tcg_ops.cpu_exec_interrupt =3D arm_v7m_cpu_exec_interrupt; #ifndef CONFIG_USER_ONLY - cc->do_interrupt =3D arm_v7m_cpu_do_interrupt; + cc->tcg_ops.do_interrupt =3D arm_v7m_cpu_do_interrupt; #endif - -#ifdef CONFIG_TCG - cc->tcg_ops.cpu_exec_interrupt =3D arm_v7m_cpu_exec_interrupt; #endif /* CONFIG_TCG */ =20 cc->gdb_core_xml_file =3D "arm-m-profile.xml"; diff --git a/target/avr/cpu.c b/target/avr/cpu.c index d6e93049b4..476e645b37 100644 --- a/target/avr/cpu.c +++ b/target/avr/cpu.c @@ -198,7 +198,7 @@ static void avr_cpu_class_init(ObjectClass *oc, void *d= ata) cc->class_by_name =3D avr_cpu_class_by_name; =20 cc->has_work =3D avr_cpu_has_work; - cc->do_interrupt =3D avr_cpu_do_interrupt; + cc->tcg_ops.do_interrupt =3D avr_cpu_do_interrupt; cc->tcg_ops.cpu_exec_interrupt =3D avr_cpu_exec_interrupt; cc->dump_state =3D avr_cpu_dump_state; cc->set_pc =3D avr_cpu_set_pc; diff --git a/target/avr/helper.c b/target/avr/helper.c index d96d14372b..69d3b6181f 100644 --- a/target/avr/helper.c +++ b/target/avr/helper.c @@ -34,7 +34,7 @@ bool avr_cpu_exec_interrupt(CPUState *cs, int interrupt_r= equest) if (interrupt_request & CPU_INTERRUPT_RESET) { if (cpu_interrupts_enabled(env)) { cs->exception_index =3D EXCP_RESET; - cc->do_interrupt(cs); + cc->tcg_ops.do_interrupt(cs); =20 cs->interrupt_request &=3D ~CPU_INTERRUPT_RESET; =20 @@ -45,7 +45,7 @@ bool avr_cpu_exec_interrupt(CPUState *cs, int interrupt_r= equest) if (cpu_interrupts_enabled(env) && env->intsrc !=3D 0) { int index =3D ctz32(env->intsrc); cs->exception_index =3D EXCP_INT(index); - cc->do_interrupt(cs); + cc->tcg_ops.do_interrupt(cs); =20 env->intsrc &=3D env->intsrc - 1; /* clear the interrupt */ cs->interrupt_request &=3D ~CPU_INTERRUPT_HARD; diff --git a/target/cris/cpu.c b/target/cris/cpu.c index 9222717f3e..b65743e8ca 100644 --- a/target/cris/cpu.c +++ b/target/cris/cpu.c @@ -199,7 +199,7 @@ static void crisv8_cpu_class_init(ObjectClass *oc, void= *data) CRISCPUClass *ccc =3D CRIS_CPU_CLASS(oc); =20 ccc->vr =3D 8; - cc->do_interrupt =3D crisv10_cpu_do_interrupt; + cc->tcg_ops.do_interrupt =3D crisv10_cpu_do_interrupt; cc->gdb_read_register =3D crisv10_cpu_gdb_read_register; cc->tcg_ops.initialize =3D cris_initialize_crisv10_tcg; } @@ -210,7 +210,7 @@ static void crisv9_cpu_class_init(ObjectClass *oc, void= *data) CRISCPUClass *ccc =3D CRIS_CPU_CLASS(oc); =20 ccc->vr =3D 9; - cc->do_interrupt =3D crisv10_cpu_do_interrupt; + cc->tcg_ops.do_interrupt =3D crisv10_cpu_do_interrupt; cc->gdb_read_register =3D crisv10_cpu_gdb_read_register; cc->tcg_ops.initialize =3D cris_initialize_crisv10_tcg; } @@ -221,7 +221,7 @@ static void crisv10_cpu_class_init(ObjectClass *oc, voi= d *data) CRISCPUClass *ccc =3D CRIS_CPU_CLASS(oc); =20 ccc->vr =3D 10; - cc->do_interrupt =3D crisv10_cpu_do_interrupt; + cc->tcg_ops.do_interrupt =3D crisv10_cpu_do_interrupt; cc->gdb_read_register =3D crisv10_cpu_gdb_read_register; cc->tcg_ops.initialize =3D cris_initialize_crisv10_tcg; } @@ -232,7 +232,7 @@ static void crisv11_cpu_class_init(ObjectClass *oc, voi= d *data) CRISCPUClass *ccc =3D CRIS_CPU_CLASS(oc); =20 ccc->vr =3D 11; - cc->do_interrupt =3D crisv10_cpu_do_interrupt; + cc->tcg_ops.do_interrupt =3D crisv10_cpu_do_interrupt; cc->gdb_read_register =3D crisv10_cpu_gdb_read_register; cc->tcg_ops.initialize =3D cris_initialize_crisv10_tcg; } @@ -243,7 +243,7 @@ static void crisv17_cpu_class_init(ObjectClass *oc, voi= d *data) CRISCPUClass *ccc =3D CRIS_CPU_CLASS(oc); =20 ccc->vr =3D 17; - cc->do_interrupt =3D crisv10_cpu_do_interrupt; + cc->tcg_ops.do_interrupt =3D crisv10_cpu_do_interrupt; cc->gdb_read_register =3D crisv10_cpu_gdb_read_register; cc->tcg_ops.initialize =3D cris_initialize_crisv10_tcg; } @@ -268,7 +268,7 @@ static void cris_cpu_class_init(ObjectClass *oc, void *= data) =20 cc->class_by_name =3D cris_cpu_class_by_name; cc->has_work =3D cris_cpu_has_work; - cc->do_interrupt =3D cris_cpu_do_interrupt; + cc->tcg_ops.do_interrupt =3D cris_cpu_do_interrupt; cc->tcg_ops.cpu_exec_interrupt =3D cris_cpu_exec_interrupt; cc->dump_state =3D cris_cpu_dump_state; cc->set_pc =3D cris_cpu_set_pc; diff --git a/target/cris/helper.c b/target/cris/helper.c index ed45c3d9b7..1f4d6f7d45 100644 --- a/target/cris/helper.c +++ b/target/cris/helper.c @@ -299,7 +299,7 @@ bool cris_cpu_exec_interrupt(CPUState *cs, int interrup= t_request) && (env->pregs[PR_CCS] & I_FLAG) && !env->locked_irq) { cs->exception_index =3D EXCP_IRQ; - cc->do_interrupt(cs); + cc->tcg_ops.do_interrupt(cs); ret =3D true; } if (interrupt_request & CPU_INTERRUPT_NMI) { @@ -311,7 +311,7 @@ bool cris_cpu_exec_interrupt(CPUState *cs, int interrup= t_request) } if ((env->pregs[PR_CCS] & m_flag_archval)) { cs->exception_index =3D EXCP_NMI; - cc->do_interrupt(cs); + cc->tcg_ops.do_interrupt(cs); ret =3D true; } } diff --git a/target/hppa/cpu.c b/target/hppa/cpu.c index d5a25014e8..68233acf53 100644 --- a/target/hppa/cpu.c +++ b/target/hppa/cpu.c @@ -140,7 +140,7 @@ static void hppa_cpu_class_init(ObjectClass *oc, void *= data) =20 cc->class_by_name =3D hppa_cpu_class_by_name; cc->has_work =3D hppa_cpu_has_work; - cc->do_interrupt =3D hppa_cpu_do_interrupt; + cc->tcg_ops.do_interrupt =3D hppa_cpu_do_interrupt; cc->tcg_ops.cpu_exec_interrupt =3D hppa_cpu_exec_interrupt; cc->dump_state =3D hppa_cpu_dump_state; cc->set_pc =3D hppa_cpu_set_pc; diff --git a/target/i386/tcg/tcg-cpu.c b/target/i386/tcg/tcg-cpu.c index 6c1ebbdcc6..4a53cd89e2 100644 --- a/target/i386/tcg/tcg-cpu.c +++ b/target/i386/tcg/tcg-cpu.c @@ -59,7 +59,7 @@ static void x86_cpu_synchronize_from_tb(CPUState *cs, =20 void tcg_cpu_common_class_init(CPUClass *cc) { - cc->do_interrupt =3D x86_cpu_do_interrupt; + cc->tcg_ops.do_interrupt =3D x86_cpu_do_interrupt; cc->tcg_ops.cpu_exec_interrupt =3D x86_cpu_exec_interrupt; cc->tcg_ops.synchronize_from_tb =3D x86_cpu_synchronize_from_tb; cc->tcg_ops.cpu_exec_enter =3D x86_cpu_exec_enter; diff --git a/target/lm32/cpu.c b/target/lm32/cpu.c index bbe1405e32..fb3761b749 100644 --- a/target/lm32/cpu.c +++ b/target/lm32/cpu.c @@ -222,7 +222,7 @@ static void lm32_cpu_class_init(ObjectClass *oc, void *= data) =20 cc->class_by_name =3D lm32_cpu_class_by_name; cc->has_work =3D lm32_cpu_has_work; - cc->do_interrupt =3D lm32_cpu_do_interrupt; + cc->tcg_ops.do_interrupt =3D lm32_cpu_do_interrupt; cc->tcg_ops.cpu_exec_interrupt =3D lm32_cpu_exec_interrupt; cc->dump_state =3D lm32_cpu_dump_state; cc->set_pc =3D lm32_cpu_set_pc; diff --git a/target/m68k/cpu.c b/target/m68k/cpu.c index e38e4d5456..69093a621f 100644 --- a/target/m68k/cpu.c +++ b/target/m68k/cpu.c @@ -465,7 +465,7 @@ static void m68k_cpu_class_init(ObjectClass *c, void *d= ata) =20 cc->class_by_name =3D m68k_cpu_class_by_name; cc->has_work =3D m68k_cpu_has_work; - cc->do_interrupt =3D m68k_cpu_do_interrupt; + cc->tcg_ops.do_interrupt =3D m68k_cpu_do_interrupt; cc->tcg_ops.cpu_exec_interrupt =3D m68k_cpu_exec_interrupt; cc->dump_state =3D m68k_cpu_dump_state; cc->set_pc =3D m68k_cpu_set_pc; diff --git a/target/microblaze/cpu.c b/target/microblaze/cpu.c index 68df0c20d8..b0b133b5be 100644 --- a/target/microblaze/cpu.c +++ b/target/microblaze/cpu.c @@ -318,7 +318,7 @@ static void mb_cpu_class_init(ObjectClass *oc, void *da= ta) =20 cc->class_by_name =3D mb_cpu_class_by_name; cc->has_work =3D mb_cpu_has_work; - cc->do_interrupt =3D mb_cpu_do_interrupt; + cc->tcg_ops.do_interrupt =3D mb_cpu_do_interrupt; cc->do_unaligned_access =3D mb_cpu_do_unaligned_access; cc->tcg_ops.cpu_exec_interrupt =3D mb_cpu_exec_interrupt; cc->dump_state =3D mb_cpu_dump_state; diff --git a/target/mips/cpu.c b/target/mips/cpu.c index 85b3161b25..d72ddc3b21 100644 --- a/target/mips/cpu.c +++ b/target/mips/cpu.c @@ -477,7 +477,6 @@ static void mips_cpu_class_init(ObjectClass *c, void *d= ata) =20 cc->class_by_name =3D mips_cpu_class_by_name; cc->has_work =3D mips_cpu_has_work; - cc->do_interrupt =3D mips_cpu_do_interrupt; cc->dump_state =3D mips_cpu_dump_state; cc->set_pc =3D mips_cpu_set_pc; cc->gdb_read_register =3D mips_cpu_gdb_read_register; @@ -491,10 +490,11 @@ static void mips_cpu_class_init(ObjectClass *c, void = *data) cc->disas_set_info =3D mips_cpu_disas_set_info; #ifdef CONFIG_TCG cc->tcg_ops.initialize =3D mips_tcg_init; + cc->tcg_ops.do_interrupt =3D mips_cpu_do_interrupt; cc->tcg_ops.cpu_exec_interrupt =3D mips_cpu_exec_interrupt; cc->tcg_ops.synchronize_from_tb =3D mips_cpu_synchronize_from_tb; cc->tcg_ops.tlb_fill =3D mips_cpu_tlb_fill; -#endif +#endif /* CONFIG_TCG */ =20 cc->gdb_num_core_regs =3D 73; cc->gdb_stop_before_watchpoint =3D true; diff --git a/target/moxie/cpu.c b/target/moxie/cpu.c index 1177d092c1..36bef4d357 100644 --- a/target/moxie/cpu.c +++ b/target/moxie/cpu.c @@ -107,7 +107,7 @@ static void moxie_cpu_class_init(ObjectClass *oc, void = *data) cc->class_by_name =3D moxie_cpu_class_by_name; =20 cc->has_work =3D moxie_cpu_has_work; - cc->do_interrupt =3D moxie_cpu_do_interrupt; + cc->tcg_ops.do_interrupt =3D moxie_cpu_do_interrupt; cc->dump_state =3D moxie_cpu_dump_state; cc->set_pc =3D moxie_cpu_set_pc; cc->tcg_ops.tlb_fill =3D moxie_cpu_tlb_fill; diff --git a/target/nios2/cpu.c b/target/nios2/cpu.c index 1384836de0..b5fe779ceb 100644 --- a/target/nios2/cpu.c +++ b/target/nios2/cpu.c @@ -221,7 +221,7 @@ static void nios2_cpu_class_init(ObjectClass *oc, void = *data) =20 cc->class_by_name =3D nios2_cpu_class_by_name; cc->has_work =3D nios2_cpu_has_work; - cc->do_interrupt =3D nios2_cpu_do_interrupt; + cc->tcg_ops.do_interrupt =3D nios2_cpu_do_interrupt; cc->tcg_ops.cpu_exec_interrupt =3D nios2_cpu_exec_interrupt; cc->dump_state =3D nios2_cpu_dump_state; cc->set_pc =3D nios2_cpu_set_pc; diff --git a/target/openrisc/cpu.c b/target/openrisc/cpu.c index 9857bfde23..1a31f7564f 100644 --- a/target/openrisc/cpu.c +++ b/target/openrisc/cpu.c @@ -186,7 +186,7 @@ static void openrisc_cpu_class_init(ObjectClass *oc, vo= id *data) =20 cc->class_by_name =3D openrisc_cpu_class_by_name; cc->has_work =3D openrisc_cpu_has_work; - cc->do_interrupt =3D openrisc_cpu_do_interrupt; + cc->tcg_ops.do_interrupt =3D openrisc_cpu_do_interrupt; cc->tcg_ops.cpu_exec_interrupt =3D openrisc_cpu_exec_interrupt; cc->dump_state =3D openrisc_cpu_dump_state; cc->set_pc =3D openrisc_cpu_set_pc; diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 05c97e7e73..86ca452479 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -570,7 +570,7 @@ static void riscv_cpu_class_init(ObjectClass *c, void *= data) =20 cc->class_by_name =3D riscv_cpu_class_by_name; cc->has_work =3D riscv_cpu_has_work; - cc->do_interrupt =3D riscv_cpu_do_interrupt; + cc->tcg_ops.do_interrupt =3D riscv_cpu_do_interrupt; cc->tcg_ops.cpu_exec_interrupt =3D riscv_cpu_exec_interrupt; cc->dump_state =3D riscv_cpu_dump_state; cc->set_pc =3D riscv_cpu_set_pc; diff --git a/target/rx/cpu.c b/target/rx/cpu.c index 77609728b8..e79f009cbd 100644 --- a/target/rx/cpu.c +++ b/target/rx/cpu.c @@ -186,7 +186,7 @@ static void rx_cpu_class_init(ObjectClass *klass, void = *data) =20 cc->class_by_name =3D rx_cpu_class_by_name; cc->has_work =3D rx_cpu_has_work; - cc->do_interrupt =3D rx_cpu_do_interrupt; + cc->tcg_ops.do_interrupt =3D rx_cpu_do_interrupt; cc->tcg_ops.cpu_exec_interrupt =3D rx_cpu_exec_interrupt; cc->dump_state =3D rx_cpu_dump_state; cc->set_pc =3D rx_cpu_set_pc; diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c index 8ade66178e..e6cf933594 100644 --- a/target/s390x/cpu.c +++ b/target/s390x/cpu.c @@ -496,7 +496,7 @@ static void s390_cpu_class_init(ObjectClass *oc, void *= data) cc->class_by_name =3D s390_cpu_class_by_name, cc->has_work =3D s390_cpu_has_work; #ifdef CONFIG_TCG - cc->do_interrupt =3D s390_cpu_do_interrupt; + cc->tcg_ops.do_interrupt =3D s390_cpu_do_interrupt; #endif cc->dump_state =3D s390_cpu_dump_state; cc->set_pc =3D s390_cpu_set_pc; diff --git a/target/sh4/cpu.c b/target/sh4/cpu.c index 1f6c687c3c..f69360fc16 100644 --- a/target/sh4/cpu.c +++ b/target/sh4/cpu.c @@ -219,7 +219,7 @@ static void superh_cpu_class_init(ObjectClass *oc, void= *data) =20 cc->class_by_name =3D superh_cpu_class_by_name; cc->has_work =3D superh_cpu_has_work; - cc->do_interrupt =3D superh_cpu_do_interrupt; + cc->tcg_ops.do_interrupt =3D superh_cpu_do_interrupt; cc->tcg_ops.cpu_exec_interrupt =3D superh_cpu_exec_interrupt; cc->dump_state =3D superh_cpu_dump_state; cc->set_pc =3D superh_cpu_set_pc; diff --git a/target/sparc/cpu.c b/target/sparc/cpu.c index 19e90a414d..871b2a83c6 100644 --- a/target/sparc/cpu.c +++ b/target/sparc/cpu.c @@ -863,7 +863,7 @@ static void sparc_cpu_class_init(ObjectClass *oc, void = *data) cc->class_by_name =3D sparc_cpu_class_by_name; cc->parse_features =3D sparc_cpu_parse_features; cc->has_work =3D sparc_cpu_has_work; - cc->do_interrupt =3D sparc_cpu_do_interrupt; + cc->tcg_ops.do_interrupt =3D sparc_cpu_do_interrupt; cc->tcg_ops.cpu_exec_interrupt =3D sparc_cpu_exec_interrupt; cc->dump_state =3D sparc_cpu_dump_state; #if !defined(TARGET_SPARC64) && !defined(CONFIG_USER_ONLY) diff --git a/target/tilegx/cpu.c b/target/tilegx/cpu.c index 75b3a4bae3..7d4ead4ef1 100644 --- a/target/tilegx/cpu.c +++ b/target/tilegx/cpu.c @@ -147,7 +147,7 @@ static void tilegx_cpu_class_init(ObjectClass *oc, void= *data) =20 cc->class_by_name =3D tilegx_cpu_class_by_name; cc->has_work =3D tilegx_cpu_has_work; - cc->do_interrupt =3D tilegx_cpu_do_interrupt; + cc->tcg_ops.do_interrupt =3D tilegx_cpu_do_interrupt; cc->tcg_ops.cpu_exec_interrupt =3D tilegx_cpu_exec_interrupt; cc->dump_state =3D tilegx_cpu_dump_state; cc->set_pc =3D tilegx_cpu_set_pc; diff --git a/target/unicore32/cpu.c b/target/unicore32/cpu.c index a57d315d2f..e27ffc571a 100644 --- a/target/unicore32/cpu.c +++ b/target/unicore32/cpu.c @@ -131,7 +131,7 @@ static void uc32_cpu_class_init(ObjectClass *oc, void *= data) =20 cc->class_by_name =3D uc32_cpu_class_by_name; cc->has_work =3D uc32_cpu_has_work; - cc->do_interrupt =3D uc32_cpu_do_interrupt; + cc->tcg_ops.do_interrupt =3D uc32_cpu_do_interrupt; cc->tcg_ops.cpu_exec_interrupt =3D uc32_cpu_exec_interrupt; cc->dump_state =3D uc32_cpu_dump_state; cc->set_pc =3D uc32_cpu_set_pc; diff --git a/target/xtensa/cpu.c b/target/xtensa/cpu.c index b6f13ceb32..3ff025f0fe 100644 --- a/target/xtensa/cpu.c +++ b/target/xtensa/cpu.c @@ -194,7 +194,7 @@ static void xtensa_cpu_class_init(ObjectClass *oc, void= *data) =20 cc->class_by_name =3D xtensa_cpu_class_by_name; cc->has_work =3D xtensa_cpu_has_work; - cc->do_interrupt =3D xtensa_cpu_do_interrupt; + cc->tcg_ops.do_interrupt =3D xtensa_cpu_do_interrupt; cc->tcg_ops.cpu_exec_interrupt =3D xtensa_cpu_exec_interrupt; cc->dump_state =3D xtensa_cpu_dump_state; cc->set_pc =3D xtensa_cpu_set_pc; diff --git a/target/ppc/translate_init.c.inc b/target/ppc/translate_init.c.= inc index 1e0fc5ac3d..b16430a9d4 100644 --- a/target/ppc/translate_init.c.inc +++ b/target/ppc/translate_init.c.inc @@ -10845,7 +10845,6 @@ static void ppc_cpu_class_init(ObjectClass *oc, voi= d *data) =20 cc->class_by_name =3D ppc_cpu_class_by_name; cc->has_work =3D ppc_cpu_has_work; - cc->do_interrupt =3D ppc_cpu_do_interrupt; cc->dump_state =3D ppc_cpu_dump_state; cc->dump_statistics =3D ppc_cpu_dump_statistics; cc->set_pc =3D ppc_cpu_set_pc; @@ -10883,6 +10882,7 @@ static void ppc_cpu_class_init(ObjectClass *oc, voi= d *data) #ifdef CONFIG_TCG cc->tcg_ops.initialize =3D ppc_translate_init; cc->tcg_ops.cpu_exec_interrupt =3D ppc_cpu_exec_interrupt; + cc->tcg_ops.do_interrupt =3D ppc_cpu_do_interrupt; cc->tcg_ops.tlb_fill =3D ppc_cpu_tlb_fill; #ifndef CONFIG_USER_ONLY cc->tcg_ops.cpu_exec_enter =3D ppc_cpu_exec_enter; --=20 2.26.2 From nobody Thu Apr 25 18:08:54 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=1610476370; cv=none; d=zohomail.com; s=zohoarc; b=jWCH2HmGA+Xbf2R+HgxhVXc7Tw3VFyt4jr+eRxC4SsR9xh+Hiev54Hcnu0utHpWzwWHAxOphuKAXOv74D8eVpUB9vGo31I99WeKQiCgMxqktwwlYEk2rIe7YHGYN6hOJ8ztRHIDyAA1ORPL6m8wPS6pHlmDMvy/ftA0HUKlR+WI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610476370; h=Content-Type: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=+dc3M6xZlMjYRwRpkPXwGvsz9P47OgXqnlI34rqIC3w=; b=UTYmler+BCOh2FHDyQzc8HHt8as724FU5ocTZzsxF3XCFoQH40Y4VMZCGwmaK9S5JucVXTPIFV9yZNWn7NV0h1U+HEi7Eek35sKTf1Y40EAvdNr++nV6JRIyAkjBl+1KVmSeuBk2ESuHZfbH6ywdSxisL9+t6UsGb24Kweu/fv0= 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 161047637008671.97993530499173; Tue, 12 Jan 2021 10:32:50 -0800 (PST) Received: from localhost ([::1]:42710 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kzOTI-0006U8-Tk for importer@patchew.org; Tue, 12 Jan 2021 13:32:48 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48152) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kzO1I-0005RX-Ta for qemu-devel@nongnu.org; Tue, 12 Jan 2021 13:03:52 -0500 Received: from mx2.suse.de ([195.135.220.15]:33688) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kzO13-0004wB-UD for qemu-devel@nongnu.org; Tue, 12 Jan 2021 13:03:52 -0500 Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 3A9FDAE39; Tue, 12 Jan 2021 18:03:26 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Claudio Fontana To: Paolo Bonzini , Thomas Huth , Richard Henderson , Stefano Stabellini , Wenchao Wang , Roman Bolshakov , Sunil Muthuswamy , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v12 10/22] cpu: move cc->transaction_failed to tcg_ops Date: Tue, 12 Jan 2021 19:03:00 +0100 Message-Id: <20210112180312.26043-11-cfontana@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210112180312.26043-1-cfontana@suse.de> References: <20210112180312.26043-1-cfontana@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 , Peter Maydell , Eduardo Habkost , Paul Durrant , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Jason Wang , Marcelo Tosatti , qemu-devel@nongnu.org, Peter Xu , Dario Faggioli , Cameron Esfahani , haxm-team@intel.com, Claudio Fontana , Anthony Perard , Bruce Rogers , Olaf Hering , "Emilio G . Cota" , Colin Xu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Claudio Fontana Reviewed-by: Alex Benn=C3=A9e Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson [claudio: replaced !CONFIG_USER_ONLY with CONFIG_SOFTMMU in cpu.h] this is working around a dangerous issue of different parts of the code seeing the struct TcgCpuOperations as different, because common_ss sources never see target configuration macros like CONFIG_USER_ONLY. We will keep conditional parts of the struct at the end, so that no other fields' starting addresses can be screwed up by different views of the struct. This will be further improved in a later patch, where we change the CPUClass struct member into a forward declared pointer. code in hw/core/cpu.c and include/hw/core/cpu.h, as well as other code outside of target, in headers, contains other uses of CONFIG_USER_ONLY, and they are potential issues. CONFIG_USER_ONLY should be poisoned, and in general one must be always wary of using CONFIG_ macros in common_ss code. Signed-off-by: Claudio Fontana --- include/hw/core/cpu.h | 32 ++++++++++++++++++++++---------- hw/mips/jazz.c | 9 +++++++-- target/alpha/cpu.c | 2 +- target/arm/cpu.c | 4 ++-- target/m68k/cpu.c | 2 +- target/microblaze/cpu.c | 2 +- target/mips/cpu.c | 4 +++- target/riscv/cpu.c | 2 +- target/riscv/cpu_helper.c | 2 +- target/sparc/cpu.c | 2 +- target/xtensa/cpu.c | 2 +- target/xtensa/helper.c | 4 ++-- 12 files changed, 43 insertions(+), 24 deletions(-) diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index 8fcdd55494..fbd8a9e5c7 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -121,6 +121,20 @@ typedef struct TcgCpuOperations { /** @debug_excp_handler: Callback for handling debug exceptions */ void (*debug_excp_handler)(CPUState *cpu); =20 +#ifdef NEED_CPU_H +#ifdef CONFIG_SOFTMMU + /** + * @do_transaction_failed: Callback for handling failed memory transac= tions + * (ie bus faults or external aborts; not MMU faults) + */ + void (*do_transaction_failed)(CPUState *cpu, hwaddr physaddr, vaddr ad= dr, + unsigned size, MMUAccessType access_type, + int mmu_idx, MemTxAttrs attrs, + MemTxResult response, uintptr_t retaddr); + +#endif /* CONFIG_SOFTMMU */ +#endif /* NEED_CPU_H */ + } TcgCpuOperations; #endif /* CONFIG_TCG */ =20 @@ -133,8 +147,6 @@ typedef struct TcgCpuOperations { * @has_work: Callback for checking if there is work to do. * @do_unaligned_access: Callback for unaligned access handling, if * the target defines #TARGET_ALIGNED_ONLY. - * @do_transaction_failed: Callback for handling failed memory transactions - * (ie bus faults or external aborts; not MMU faults) * @virtio_is_big_endian: Callback to return %true if a CPU which supports * runtime configurable endianness is currently big-endian. Non-configurab= le * CPUs can use the default implementation of this method. This method sho= uld @@ -203,10 +215,6 @@ struct CPUClass { void (*do_unaligned_access)(CPUState *cpu, vaddr addr, MMUAccessType access_type, int mmu_idx, uintptr_t retaddr); - void (*do_transaction_failed)(CPUState *cpu, hwaddr physaddr, vaddr ad= dr, - unsigned size, MMUAccessType access_type, - int mmu_idx, MemTxAttrs attrs, - MemTxResult response, uintptr_t retaddr); bool (*virtio_is_big_endian)(CPUState *cpu); int (*memory_rw_debug)(CPUState *cpu, vaddr addr, uint8_t *buf, int len, bool is_write); @@ -893,6 +901,7 @@ static inline void cpu_unaligned_access(CPUState *cpu, = vaddr addr, cc->do_unaligned_access(cpu, addr, access_type, mmu_idx, retaddr); } =20 +#ifdef CONFIG_TCG static inline void cpu_transaction_failed(CPUState *cpu, hwaddr physaddr, vaddr addr, unsigned size, MMUAccessType access_type, @@ -902,12 +911,15 @@ static inline void cpu_transaction_failed(CPUState *c= pu, hwaddr physaddr, { CPUClass *cc =3D CPU_GET_CLASS(cpu); =20 - if (!cpu->ignore_memory_transaction_failures && cc->do_transaction_fai= led) { - cc->do_transaction_failed(cpu, physaddr, addr, size, access_type, - mmu_idx, attrs, response, retaddr); + if (!cpu->ignore_memory_transaction_failures && + cc->tcg_ops.do_transaction_failed) { + cc->tcg_ops.do_transaction_failed(cpu, physaddr, addr, size, + access_type, mmu_idx, attrs, + response, retaddr); } } -#endif +#endif /* CONFIG_TCG */ +#endif /* CONFIG_SOFTMMU */ =20 #endif /* NEED_CPU_H */ =20 diff --git a/hw/mips/jazz.c b/hw/mips/jazz.c index f9442731dd..46c71a0ac8 100644 --- a/hw/mips/jazz.c +++ b/hw/mips/jazz.c @@ -116,6 +116,8 @@ static const MemoryRegionOps dma_dummy_ops =3D { #define MAGNUM_BIOS_SIZE_MAX 0x7e000 #define MAGNUM_BIOS_SIZE = \ (BIOS_SIZE < MAGNUM_BIOS_SIZE_MAX ? BIOS_SIZE : MAGNUM_BIOS_SIZE_M= AX) + +#if defined(CONFIG_TCG) && !defined(CONFIG_USER_ONLY) static void (*real_do_transaction_failed)(CPUState *cpu, hwaddr physaddr, vaddr addr, unsigned size, MMUAccessType access_type, @@ -137,6 +139,7 @@ static void mips_jazz_do_transaction_failed(CPUState *c= s, hwaddr physaddr, (*real_do_transaction_failed)(cs, physaddr, addr, size, access_type, mmu_idx, attrs, response, retaddr); } +#endif /* CONFIG_TCG && !CONFIG_USER_ONLY */ =20 static void mips_jazz_init(MachineState *machine, enum jazz_model_e jazz_model) @@ -205,8 +208,10 @@ static void mips_jazz_init(MachineState *machine, * memory region that catches all memory accesses, as we do on Malta. */ cc =3D CPU_GET_CLASS(cpu); - real_do_transaction_failed =3D cc->do_transaction_failed; - cc->do_transaction_failed =3D mips_jazz_do_transaction_failed; +#if defined(CONFIG_TCG) && !defined(CONFIG_USER_ONLY) + real_do_transaction_failed =3D cc->tcg_ops.do_transaction_failed; + cc->tcg_ops.do_transaction_failed =3D mips_jazz_do_transaction_failed; +#endif /* CONFIG_TCG && !CONFIG_USER_ONLY */ =20 /* allocate RAM */ memory_region_add_subregion(address_space, 0, machine->ram); diff --git a/target/alpha/cpu.c b/target/alpha/cpu.c index 66f1166672..a1696bebeb 100644 --- a/target/alpha/cpu.c +++ b/target/alpha/cpu.c @@ -225,7 +225,7 @@ static void alpha_cpu_class_init(ObjectClass *oc, void = *data) cc->gdb_write_register =3D alpha_cpu_gdb_write_register; cc->tcg_ops.tlb_fill =3D alpha_cpu_tlb_fill; #ifndef CONFIG_USER_ONLY - cc->do_transaction_failed =3D alpha_cpu_do_transaction_failed; + cc->tcg_ops.do_transaction_failed =3D alpha_cpu_do_transaction_failed; cc->do_unaligned_access =3D alpha_cpu_do_unaligned_access; cc->get_phys_page_debug =3D alpha_cpu_get_phys_page_debug; dc->vmsd =3D &vmstate_alpha_cpu; diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 8c9ca29025..cab8e06baf 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -2270,11 +2270,11 @@ static void arm_cpu_class_init(ObjectClass *oc, voi= d *data) cc->debug_check_watchpoint =3D arm_debug_check_watchpoint; cc->do_unaligned_access =3D arm_cpu_do_unaligned_access; #if !defined(CONFIG_USER_ONLY) - cc->do_transaction_failed =3D arm_cpu_do_transaction_failed; + cc->tcg_ops.do_transaction_failed =3D arm_cpu_do_transaction_failed; cc->adjust_watchpoint_address =3D arm_adjust_watchpoint_address; cc->tcg_ops.do_interrupt =3D arm_cpu_do_interrupt; #endif /* CONFIG_TCG && !CONFIG_USER_ONLY */ -#endif +#endif /* CONFIG_TCG */ } =20 #ifdef CONFIG_KVM diff --git a/target/m68k/cpu.c b/target/m68k/cpu.c index 69093a621f..e68b933c84 100644 --- a/target/m68k/cpu.c +++ b/target/m68k/cpu.c @@ -473,7 +473,7 @@ static void m68k_cpu_class_init(ObjectClass *c, void *d= ata) cc->gdb_write_register =3D m68k_cpu_gdb_write_register; cc->tcg_ops.tlb_fill =3D m68k_cpu_tlb_fill; #if defined(CONFIG_SOFTMMU) - cc->do_transaction_failed =3D m68k_cpu_transaction_failed; + cc->tcg_ops.do_transaction_failed =3D m68k_cpu_transaction_failed; cc->get_phys_page_debug =3D m68k_cpu_get_phys_page_debug; dc->vmsd =3D &vmstate_m68k_cpu; #endif diff --git a/target/microblaze/cpu.c b/target/microblaze/cpu.c index b0b133b5be..4770c44aac 100644 --- a/target/microblaze/cpu.c +++ b/target/microblaze/cpu.c @@ -328,7 +328,7 @@ static void mb_cpu_class_init(ObjectClass *oc, void *da= ta) cc->gdb_write_register =3D mb_cpu_gdb_write_register; cc->tcg_ops.tlb_fill =3D mb_cpu_tlb_fill; #ifndef CONFIG_USER_ONLY - cc->do_transaction_failed =3D mb_cpu_transaction_failed; + cc->tcg_ops.do_transaction_failed =3D mb_cpu_transaction_failed; cc->get_phys_page_debug =3D mb_cpu_get_phys_page_debug; dc->vmsd =3D &vmstate_mb_cpu; #endif diff --git a/target/mips/cpu.c b/target/mips/cpu.c index d72ddc3b21..4234f60c29 100644 --- a/target/mips/cpu.c +++ b/target/mips/cpu.c @@ -482,7 +482,6 @@ static void mips_cpu_class_init(ObjectClass *c, void *d= ata) cc->gdb_read_register =3D mips_cpu_gdb_read_register; cc->gdb_write_register =3D mips_cpu_gdb_write_register; #ifndef CONFIG_USER_ONLY - cc->do_transaction_failed =3D mips_cpu_do_transaction_failed; cc->do_unaligned_access =3D mips_cpu_do_unaligned_access; cc->get_phys_page_debug =3D mips_cpu_get_phys_page_debug; cc->vmsd =3D &vmstate_mips_cpu; @@ -494,6 +493,9 @@ static void mips_cpu_class_init(ObjectClass *c, void *d= ata) cc->tcg_ops.cpu_exec_interrupt =3D mips_cpu_exec_interrupt; cc->tcg_ops.synchronize_from_tb =3D mips_cpu_synchronize_from_tb; cc->tcg_ops.tlb_fill =3D mips_cpu_tlb_fill; +#ifndef CONFIG_USER_ONLY + cc->tcg_ops.do_transaction_failed =3D mips_cpu_do_transaction_failed; +#endif /* CONFIG_USER_ONLY */ #endif /* CONFIG_TCG */ =20 cc->gdb_num_core_regs =3D 73; diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 86ca452479..59557aac47 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -586,7 +586,7 @@ static void riscv_cpu_class_init(ObjectClass *c, void *= data) cc->gdb_stop_before_watchpoint =3D true; cc->disas_set_info =3D riscv_cpu_disas_set_info; #ifndef CONFIG_USER_ONLY - cc->do_transaction_failed =3D riscv_cpu_do_transaction_failed; + cc->tcg_ops.do_transaction_failed =3D riscv_cpu_do_transaction_failed; cc->do_unaligned_access =3D riscv_cpu_do_unaligned_access; cc->get_phys_page_debug =3D riscv_cpu_get_phys_page_debug; /* For now, mark unmigratable: */ diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c index a2afb95fa1..3ddc43257c 100644 --- a/target/riscv/cpu_helper.c +++ b/target/riscv/cpu_helper.c @@ -670,7 +670,7 @@ void riscv_cpu_do_unaligned_access(CPUState *cs, vaddr = addr, env->badaddr =3D addr; riscv_raise_exception(env, cs->exception_index, retaddr); } -#endif +#endif /* !CONFIG_USER_ONLY */ =20 bool riscv_cpu_tlb_fill(CPUState *cs, vaddr address, int size, MMUAccessType access_type, int mmu_idx, diff --git a/target/sparc/cpu.c b/target/sparc/cpu.c index 871b2a83c6..8d6d7c1f83 100644 --- a/target/sparc/cpu.c +++ b/target/sparc/cpu.c @@ -875,7 +875,7 @@ static void sparc_cpu_class_init(ObjectClass *oc, void = *data) cc->gdb_write_register =3D sparc_cpu_gdb_write_register; cc->tcg_ops.tlb_fill =3D sparc_cpu_tlb_fill; #ifndef CONFIG_USER_ONLY - cc->do_transaction_failed =3D sparc_cpu_do_transaction_failed; + cc->tcg_ops.do_transaction_failed =3D sparc_cpu_do_transaction_failed; cc->do_unaligned_access =3D sparc_cpu_do_unaligned_access; cc->get_phys_page_debug =3D sparc_cpu_get_phys_page_debug; cc->vmsd =3D &vmstate_sparc_cpu; diff --git a/target/xtensa/cpu.c b/target/xtensa/cpu.c index 3ff025f0fe..fc52fde696 100644 --- a/target/xtensa/cpu.c +++ b/target/xtensa/cpu.c @@ -205,7 +205,7 @@ static void xtensa_cpu_class_init(ObjectClass *oc, void= *data) #ifndef CONFIG_USER_ONLY cc->do_unaligned_access =3D xtensa_cpu_do_unaligned_access; cc->get_phys_page_debug =3D xtensa_cpu_get_phys_page_debug; - cc->do_transaction_failed =3D xtensa_cpu_do_transaction_failed; + cc->tcg_ops.do_transaction_failed =3D xtensa_cpu_do_transaction_failed; #endif cc->tcg_ops.debug_excp_handler =3D xtensa_breakpoint_handler; cc->disas_set_info =3D xtensa_cpu_disas_set_info; diff --git a/target/xtensa/helper.c b/target/xtensa/helper.c index 05e2b7f70a..eeffee297d 100644 --- a/target/xtensa/helper.c +++ b/target/xtensa/helper.c @@ -261,7 +261,7 @@ bool xtensa_cpu_tlb_fill(CPUState *cs, vaddr address, i= nt size, cpu_loop_exit_restore(cs, retaddr); } =20 -#else +#else /* !CONFIG_USER_ONLY */ =20 void xtensa_cpu_do_unaligned_access(CPUState *cs, vaddr addr, MMUAccessType access_type, @@ -337,4 +337,4 @@ void xtensa_runstall(CPUXtensaState *env, bool runstall) qemu_cpu_kick(cpu); } } -#endif +#endif /* !CONFIG_USER_ONLY */ --=20 2.26.2 From nobody Thu Apr 25 18:08:54 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=1610475258; cv=none; d=zohomail.com; s=zohoarc; b=DiZ8l7rF74Y22Ca+zZ+pWQTboxQ6hjiZJpKUj4cFN+Cet6p1Q9oRSqEFbQUd4kxDxNbgqogmixTnis9cejCm0XOkLNcNyilN1+SEpAWpkXSQwvHKP/M4Iuo+NZp8gPDWOwoG8waWVZGUnaVufNqu1nBqPOXAlN/7PK9WbHV3AWE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610475258; h=Content-Type: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=FRkAgcFUcoSyctcQqm0BjWEYyBaJvKgd/4+83QiMBvs=; b=fGWWx4dPFmB94yO2Nb9iNyWNMCOqfRTmFP2fssj8QCUQqgsUKNWXx//vaT4gLD8Hpfb7Of5/XLKQVuuHMFRQfZG5EhzTsAoAQgyGZtkagHZf9GRBjKd6Y0DrgfxESZPBQb/C9YQnqdI1oAz4KrJSKi3m1fE1HBnISflWkDShrYM= 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 1610475258149766.2510739815016; Tue, 12 Jan 2021 10:14:18 -0800 (PST) Received: from localhost ([::1]:45836 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kzOBM-0007ss-PN for importer@patchew.org; Tue, 12 Jan 2021 13:14:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48096) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kzO1A-0005Nx-4j for qemu-devel@nongnu.org; Tue, 12 Jan 2021 13:03:45 -0500 Received: from mx2.suse.de ([195.135.220.15]:33720) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kzO15-0004wG-Oj for qemu-devel@nongnu.org; Tue, 12 Jan 2021 13:03:43 -0500 Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 499F1AB7A; Tue, 12 Jan 2021 18:03:27 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Claudio Fontana To: Paolo Bonzini , Thomas Huth , Richard Henderson , Stefano Stabellini , Wenchao Wang , Roman Bolshakov , Sunil Muthuswamy , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v12 11/22] cpu: move do_unaligned_access to tcg_ops Date: Tue, 12 Jan 2021 19:03:01 +0100 Message-Id: <20210112180312.26043-12-cfontana@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210112180312.26043-1-cfontana@suse.de> References: <20210112180312.26043-1-cfontana@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 , Peter Maydell , Eduardo Habkost , Paul Durrant , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Jason Wang , Marcelo Tosatti , qemu-devel@nongnu.org, Peter Xu , Dario Faggioli , Cameron Esfahani , haxm-team@intel.com, Claudio Fontana , Anthony Perard , Bruce Rogers , Olaf Hering , "Emilio G . Cota" , Colin Xu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" make it consistently SOFTMMU-only. Signed-off-by: Claudio Fontana Reviewed-by: Alex Benn=C3=A9e Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- include/hw/core/cpu.h | 22 +++++++++------------- target/alpha/cpu.c | 2 +- target/arm/cpu.c | 2 +- target/hppa/cpu.c | 4 +++- target/microblaze/cpu.c | 2 +- target/mips/cpu.c | 3 ++- target/nios2/cpu.c | 2 +- target/riscv/cpu.c | 2 +- target/s390x/cpu.c | 2 +- target/s390x/excp_helper.c | 2 +- target/sh4/cpu.c | 2 +- target/sparc/cpu.c | 2 +- target/xtensa/cpu.c | 2 +- target/ppc/translate_init.c.inc | 2 +- 14 files changed, 25 insertions(+), 26 deletions(-) diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index fbd8a9e5c7..95ff2c9eb0 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -131,7 +131,12 @@ typedef struct TcgCpuOperations { unsigned size, MMUAccessType access_type, int mmu_idx, MemTxAttrs attrs, MemTxResult response, uintptr_t retaddr); - + /** + * @do_unaligned_access: Callback for unaligned access handling + */ + void (*do_unaligned_access)(CPUState *cpu, vaddr addr, + MMUAccessType access_type, + int mmu_idx, uintptr_t retaddr); #endif /* CONFIG_SOFTMMU */ #endif /* NEED_CPU_H */ =20 @@ -145,8 +150,6 @@ typedef struct TcgCpuOperations { * @parse_features: Callback to parse command line arguments. * @reset_dump_flags: #CPUDumpFlags to use for reset logging. * @has_work: Callback for checking if there is work to do. - * @do_unaligned_access: Callback for unaligned access handling, if - * the target defines #TARGET_ALIGNED_ONLY. * @virtio_is_big_endian: Callback to return %true if a CPU which supports * runtime configurable endianness is currently big-endian. Non-configurab= le * CPUs can use the default implementation of this method. This method sho= uld @@ -212,9 +215,6 @@ struct CPUClass { =20 int reset_dump_flags; bool (*has_work)(CPUState *cpu); - void (*do_unaligned_access)(CPUState *cpu, vaddr addr, - MMUAccessType access_type, - int mmu_idx, uintptr_t retaddr); bool (*virtio_is_big_endian)(CPUState *cpu); int (*memory_rw_debug)(CPUState *cpu, vaddr addr, uint8_t *buf, int len, bool is_write); @@ -890,18 +890,16 @@ CPUState *cpu_by_arch_id(int64_t id); void cpu_interrupt(CPUState *cpu, int mask); =20 #ifdef NEED_CPU_H - -#ifdef CONFIG_SOFTMMU +#if defined(CONFIG_SOFTMMU) && defined(CONFIG_TCG) static inline void cpu_unaligned_access(CPUState *cpu, vaddr addr, MMUAccessType access_type, int mmu_idx, uintptr_t retaddr) { CPUClass *cc =3D CPU_GET_CLASS(cpu); =20 - cc->do_unaligned_access(cpu, addr, access_type, mmu_idx, retaddr); + cc->tcg_ops.do_unaligned_access(cpu, addr, access_type, mmu_idx, retad= dr); } =20 -#ifdef CONFIG_TCG static inline void cpu_transaction_failed(CPUState *cpu, hwaddr physaddr, vaddr addr, unsigned size, MMUAccessType access_type, @@ -918,9 +916,7 @@ static inline void cpu_transaction_failed(CPUState *cpu= , hwaddr physaddr, response, retaddr); } } -#endif /* CONFIG_TCG */ -#endif /* CONFIG_SOFTMMU */ - +#endif /* CONFIG_SOFTMMU && CONFIG_TCG */ #endif /* NEED_CPU_H */ =20 /** diff --git a/target/alpha/cpu.c b/target/alpha/cpu.c index a1696bebeb..0710298e5a 100644 --- a/target/alpha/cpu.c +++ b/target/alpha/cpu.c @@ -226,7 +226,7 @@ static void alpha_cpu_class_init(ObjectClass *oc, void = *data) cc->tcg_ops.tlb_fill =3D alpha_cpu_tlb_fill; #ifndef CONFIG_USER_ONLY cc->tcg_ops.do_transaction_failed =3D alpha_cpu_do_transaction_failed; - cc->do_unaligned_access =3D alpha_cpu_do_unaligned_access; + cc->tcg_ops.do_unaligned_access =3D alpha_cpu_do_unaligned_access; cc->get_phys_page_debug =3D alpha_cpu_get_phys_page_debug; dc->vmsd =3D &vmstate_alpha_cpu; #endif diff --git a/target/arm/cpu.c b/target/arm/cpu.c index cab8e06baf..36c3e7fb55 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -2268,9 +2268,9 @@ static void arm_cpu_class_init(ObjectClass *oc, void = *data) cc->tcg_ops.tlb_fill =3D arm_cpu_tlb_fill; cc->tcg_ops.debug_excp_handler =3D arm_debug_excp_handler; cc->debug_check_watchpoint =3D arm_debug_check_watchpoint; - cc->do_unaligned_access =3D arm_cpu_do_unaligned_access; #if !defined(CONFIG_USER_ONLY) cc->tcg_ops.do_transaction_failed =3D arm_cpu_do_transaction_failed; + cc->tcg_ops.do_unaligned_access =3D arm_cpu_do_unaligned_access; cc->adjust_watchpoint_address =3D arm_adjust_watchpoint_address; cc->tcg_ops.do_interrupt =3D arm_cpu_do_interrupt; #endif /* CONFIG_TCG && !CONFIG_USER_ONLY */ diff --git a/target/hppa/cpu.c b/target/hppa/cpu.c index 68233acf53..fd7f849a1c 100644 --- a/target/hppa/cpu.c +++ b/target/hppa/cpu.c @@ -71,6 +71,7 @@ static void hppa_cpu_disas_set_info(CPUState *cs, disasse= mble_info *info) info->print_insn =3D print_insn_hppa; } =20 +#ifndef CONFIG_USER_ONLY static void hppa_cpu_do_unaligned_access(CPUState *cs, vaddr addr, MMUAccessType access_type, int mmu_idx, uintptr_t retaddr) @@ -87,6 +88,7 @@ static void hppa_cpu_do_unaligned_access(CPUState *cs, va= ddr addr, =20 cpu_loop_exit_restore(cs, retaddr); } +#endif /* CONFIG_USER_ONLY */ =20 static void hppa_cpu_realizefn(DeviceState *dev, Error **errp) { @@ -150,9 +152,9 @@ static void hppa_cpu_class_init(ObjectClass *oc, void *= data) cc->tcg_ops.tlb_fill =3D hppa_cpu_tlb_fill; #ifndef CONFIG_USER_ONLY cc->get_phys_page_debug =3D hppa_cpu_get_phys_page_debug; + cc->tcg_ops.do_unaligned_access =3D hppa_cpu_do_unaligned_access; dc->vmsd =3D &vmstate_hppa_cpu; #endif - cc->do_unaligned_access =3D hppa_cpu_do_unaligned_access; cc->disas_set_info =3D hppa_cpu_disas_set_info; cc->tcg_ops.initialize =3D hppa_translate_init; =20 diff --git a/target/microblaze/cpu.c b/target/microblaze/cpu.c index 4770c44aac..d84a374e75 100644 --- a/target/microblaze/cpu.c +++ b/target/microblaze/cpu.c @@ -319,7 +319,6 @@ static void mb_cpu_class_init(ObjectClass *oc, void *da= ta) cc->class_by_name =3D mb_cpu_class_by_name; cc->has_work =3D mb_cpu_has_work; cc->tcg_ops.do_interrupt =3D mb_cpu_do_interrupt; - cc->do_unaligned_access =3D mb_cpu_do_unaligned_access; cc->tcg_ops.cpu_exec_interrupt =3D mb_cpu_exec_interrupt; cc->dump_state =3D mb_cpu_dump_state; cc->set_pc =3D mb_cpu_set_pc; @@ -329,6 +328,7 @@ static void mb_cpu_class_init(ObjectClass *oc, void *da= ta) cc->tcg_ops.tlb_fill =3D mb_cpu_tlb_fill; #ifndef CONFIG_USER_ONLY cc->tcg_ops.do_transaction_failed =3D mb_cpu_transaction_failed; + cc->tcg_ops.do_unaligned_access =3D mb_cpu_do_unaligned_access; cc->get_phys_page_debug =3D mb_cpu_get_phys_page_debug; dc->vmsd =3D &vmstate_mb_cpu; #endif diff --git a/target/mips/cpu.c b/target/mips/cpu.c index 4234f60c29..12c12b1ada 100644 --- a/target/mips/cpu.c +++ b/target/mips/cpu.c @@ -482,7 +482,6 @@ static void mips_cpu_class_init(ObjectClass *c, void *d= ata) cc->gdb_read_register =3D mips_cpu_gdb_read_register; cc->gdb_write_register =3D mips_cpu_gdb_write_register; #ifndef CONFIG_USER_ONLY - cc->do_unaligned_access =3D mips_cpu_do_unaligned_access; cc->get_phys_page_debug =3D mips_cpu_get_phys_page_debug; cc->vmsd =3D &vmstate_mips_cpu; #endif @@ -495,6 +494,8 @@ static void mips_cpu_class_init(ObjectClass *c, void *d= ata) cc->tcg_ops.tlb_fill =3D mips_cpu_tlb_fill; #ifndef CONFIG_USER_ONLY cc->tcg_ops.do_transaction_failed =3D mips_cpu_do_transaction_failed; + cc->tcg_ops.do_unaligned_access =3D mips_cpu_do_unaligned_access; + #endif /* CONFIG_USER_ONLY */ #endif /* CONFIG_TCG */ =20 diff --git a/target/nios2/cpu.c b/target/nios2/cpu.c index b5fe779ceb..c43aa3d4c4 100644 --- a/target/nios2/cpu.c +++ b/target/nios2/cpu.c @@ -228,7 +228,7 @@ static void nios2_cpu_class_init(ObjectClass *oc, void = *data) cc->disas_set_info =3D nios2_cpu_disas_set_info; cc->tcg_ops.tlb_fill =3D nios2_cpu_tlb_fill; #ifndef CONFIG_USER_ONLY - cc->do_unaligned_access =3D nios2_cpu_do_unaligned_access; + cc->tcg_ops.do_unaligned_access =3D nios2_cpu_do_unaligned_access; cc->get_phys_page_debug =3D nios2_cpu_get_phys_page_debug; #endif cc->gdb_read_register =3D nios2_cpu_gdb_read_register; diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 59557aac47..7238a33b7b 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -587,7 +587,7 @@ static void riscv_cpu_class_init(ObjectClass *c, void *= data) cc->disas_set_info =3D riscv_cpu_disas_set_info; #ifndef CONFIG_USER_ONLY cc->tcg_ops.do_transaction_failed =3D riscv_cpu_do_transaction_failed; - cc->do_unaligned_access =3D riscv_cpu_do_unaligned_access; + cc->tcg_ops.do_unaligned_access =3D riscv_cpu_do_unaligned_access; cc->get_phys_page_debug =3D riscv_cpu_get_phys_page_debug; /* For now, mark unmigratable: */ cc->vmsd =3D &vmstate_riscv_cpu; diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c index e6cf933594..a723ede8d1 100644 --- a/target/s390x/cpu.c +++ b/target/s390x/cpu.c @@ -510,7 +510,7 @@ static void s390_cpu_class_init(ObjectClass *oc, void *= data) #ifdef CONFIG_TCG cc->tcg_ops.cpu_exec_interrupt =3D s390_cpu_exec_interrupt; cc->tcg_ops.debug_excp_handler =3D s390x_cpu_debug_excp_handler; - cc->do_unaligned_access =3D s390x_cpu_do_unaligned_access; + cc->tcg_ops.do_unaligned_access =3D s390x_cpu_do_unaligned_access; #endif #endif cc->disas_set_info =3D s390_cpu_disas_set_info; diff --git a/target/s390x/excp_helper.c b/target/s390x/excp_helper.c index 9cf66d3690..ce16af394b 100644 --- a/target/s390x/excp_helper.c +++ b/target/s390x/excp_helper.c @@ -634,4 +634,4 @@ void HELPER(monitor_call)(CPUS390XState *env, uint64_t = monitor_code, } } =20 -#endif /* CONFIG_USER_ONLY */ +#endif /* !CONFIG_USER_ONLY */ diff --git a/target/sh4/cpu.c b/target/sh4/cpu.c index f69360fc16..292152b562 100644 --- a/target/sh4/cpu.c +++ b/target/sh4/cpu.c @@ -228,7 +228,7 @@ static void superh_cpu_class_init(ObjectClass *oc, void= *data) cc->gdb_write_register =3D superh_cpu_gdb_write_register; cc->tcg_ops.tlb_fill =3D superh_cpu_tlb_fill; #ifndef CONFIG_USER_ONLY - cc->do_unaligned_access =3D superh_cpu_do_unaligned_access; + cc->tcg_ops.do_unaligned_access =3D superh_cpu_do_unaligned_access; cc->get_phys_page_debug =3D superh_cpu_get_phys_page_debug; #endif cc->disas_set_info =3D superh_cpu_disas_set_info; diff --git a/target/sparc/cpu.c b/target/sparc/cpu.c index 8d6d7c1f83..1b785f60df 100644 --- a/target/sparc/cpu.c +++ b/target/sparc/cpu.c @@ -876,7 +876,7 @@ static void sparc_cpu_class_init(ObjectClass *oc, void = *data) cc->tcg_ops.tlb_fill =3D sparc_cpu_tlb_fill; #ifndef CONFIG_USER_ONLY cc->tcg_ops.do_transaction_failed =3D sparc_cpu_do_transaction_failed; - cc->do_unaligned_access =3D sparc_cpu_do_unaligned_access; + cc->tcg_ops.do_unaligned_access =3D sparc_cpu_do_unaligned_access; cc->get_phys_page_debug =3D sparc_cpu_get_phys_page_debug; cc->vmsd =3D &vmstate_sparc_cpu; #endif diff --git a/target/xtensa/cpu.c b/target/xtensa/cpu.c index fc52fde696..4b6381569f 100644 --- a/target/xtensa/cpu.c +++ b/target/xtensa/cpu.c @@ -203,7 +203,7 @@ static void xtensa_cpu_class_init(ObjectClass *oc, void= *data) cc->gdb_stop_before_watchpoint =3D true; cc->tcg_ops.tlb_fill =3D xtensa_cpu_tlb_fill; #ifndef CONFIG_USER_ONLY - cc->do_unaligned_access =3D xtensa_cpu_do_unaligned_access; + cc->tcg_ops.do_unaligned_access =3D xtensa_cpu_do_unaligned_access; cc->get_phys_page_debug =3D xtensa_cpu_get_phys_page_debug; cc->tcg_ops.do_transaction_failed =3D xtensa_cpu_do_transaction_failed; #endif diff --git a/target/ppc/translate_init.c.inc b/target/ppc/translate_init.c.= inc index b16430a9d4..27ab243c6e 100644 --- a/target/ppc/translate_init.c.inc +++ b/target/ppc/translate_init.c.inc @@ -10850,7 +10850,6 @@ static void ppc_cpu_class_init(ObjectClass *oc, voi= d *data) cc->set_pc =3D ppc_cpu_set_pc; cc->gdb_read_register =3D ppc_cpu_gdb_read_register; cc->gdb_write_register =3D ppc_cpu_gdb_write_register; - cc->do_unaligned_access =3D ppc_cpu_do_unaligned_access; #ifndef CONFIG_USER_ONLY cc->get_phys_page_debug =3D ppc_cpu_get_phys_page_debug; cc->vmsd =3D &vmstate_ppc_cpu; @@ -10887,6 +10886,7 @@ static void ppc_cpu_class_init(ObjectClass *oc, voi= d *data) #ifndef CONFIG_USER_ONLY cc->tcg_ops.cpu_exec_enter =3D ppc_cpu_exec_enter; cc->tcg_ops.cpu_exec_exit =3D ppc_cpu_exec_exit; + cc->tcg_ops.do_unaligned_access =3D ppc_cpu_do_unaligned_access; #endif /* !CONFIG_USER_ONLY */ #endif /* CONFIG_TCG */ =20 --=20 2.26.2 From nobody Thu Apr 25 18:08:54 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=1610476502; cv=none; d=zohomail.com; s=zohoarc; b=MmDy0w00nQmqRdflK3zH3Og2xzlXUihbqqyu1vKSGhR35j33P9UKSUZKQ0z1h5f2DZHI2gsjaUENhmLVJuNAVeHlChMzGYuS8r77VjBoqR4Y5+gTN6SgXowtJ7BTqZe4ejRjx6TdKgTRi2vgnhISdJ0GZKC82/eV/PzwUDvXxIg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610476502; 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=gwLkkoK/+dydzm8heKck9BBE/YRuiTWrMp/0M2XBSig=; b=hQxgoJt1O1kEAFdw+pSrQilX7aPlDDgs5xpME8UFlf0or+sw9xJakkLqSbSReg/F/20Tte8zVsCyExL/7rMeAPDKicOFIE/XH6dinDbEml9+O3dztP2AICEUftjhnuGXaDmzlOS4WDerPbGj5Y5EMzNsgW8Q5ktFRF+GaW7eHdI= 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 1610476502971471.70784129403785; Tue, 12 Jan 2021 10:35:02 -0800 (PST) Received: from localhost ([::1]:48242 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kzOVR-0000Ho-L1 for importer@patchew.org; Tue, 12 Jan 2021 13:35:01 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48164) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kzO1L-0005Sg-2y for qemu-devel@nongnu.org; Tue, 12 Jan 2021 13:03:55 -0500 Received: from mx2.suse.de ([195.135.220.15]:33762) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kzO15-0004wP-PM for qemu-devel@nongnu.org; Tue, 12 Jan 2021 13:03:53 -0500 Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 4D465AD5C; Tue, 12 Jan 2021 18:03:28 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Claudio Fontana To: Paolo Bonzini , Thomas Huth , Richard Henderson , Stefano Stabellini , Wenchao Wang , Roman Bolshakov , Sunil Muthuswamy , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v12 12/22] physmem: make watchpoint checking code TCG-only Date: Tue, 12 Jan 2021 19:03:02 +0100 Message-Id: <20210112180312.26043-13-cfontana@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210112180312.26043-1-cfontana@suse.de> References: <20210112180312.26043-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=unavailable 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 , Peter Maydell , Eduardo Habkost , Paul Durrant , Jason Wang , Marcelo Tosatti , qemu-devel@nongnu.org, Peter Xu , Dario Faggioli , Cameron Esfahani , haxm-team@intel.com, Claudio Fontana , Anthony Perard , Bruce Rogers , Olaf Hering , "Emilio G . Cota" , Colin Xu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" cpu_check_watchpoint, watchpoint_address_matches are TCG-only. Signed-off-by: Claudio Fontana --- softmmu/physmem.c | 141 +++++++++++++++++++++++----------------------- 1 file changed, 72 insertions(+), 69 deletions(-) diff --git a/softmmu/physmem.c b/softmmu/physmem.c index 6301f4f0a5..9e7c50e0db 100644 --- a/softmmu/physmem.c +++ b/softmmu/physmem.c @@ -840,6 +840,7 @@ void cpu_watchpoint_remove_all(CPUState *cpu, int mask) } } =20 +#ifdef CONFIG_TCG /* Return true if this watchpoint address matches the specified * access (ie the address range covered by the watchpoint overlaps * partially or completely with the address range covered by the @@ -873,6 +874,77 @@ int cpu_watchpoint_address_matches(CPUState *cpu, vadd= r addr, vaddr len) return ret; } =20 +/* Generate a debug exception if a watchpoint has been hit. */ +void cpu_check_watchpoint(CPUState *cpu, vaddr addr, vaddr len, + MemTxAttrs attrs, int flags, uintptr_t ra) +{ + CPUClass *cc =3D CPU_GET_CLASS(cpu); + CPUWatchpoint *wp; + + assert(tcg_enabled()); + if (cpu->watchpoint_hit) { + /* + * We re-entered the check after replacing the TB. + * Now raise the debug interrupt so that it will + * trigger after the current instruction. + */ + qemu_mutex_lock_iothread(); + cpu_interrupt(cpu, CPU_INTERRUPT_DEBUG); + qemu_mutex_unlock_iothread(); + return; + } + + addr =3D cc->adjust_watchpoint_address(cpu, addr, len); + QTAILQ_FOREACH(wp, &cpu->watchpoints, entry) { + if (watchpoint_address_matches(wp, addr, len) + && (wp->flags & flags)) { + if (replay_running_debug()) { + /* + * Don't process the watchpoints when we are + * in a reverse debugging operation. + */ + replay_breakpoint(); + return; + } + if (flags =3D=3D BP_MEM_READ) { + wp->flags |=3D BP_WATCHPOINT_HIT_READ; + } else { + wp->flags |=3D BP_WATCHPOINT_HIT_WRITE; + } + wp->hitaddr =3D MAX(addr, wp->vaddr); + wp->hitattrs =3D attrs; + if (!cpu->watchpoint_hit) { + if (wp->flags & BP_CPU && + !cc->debug_check_watchpoint(cpu, wp)) { + wp->flags &=3D ~BP_WATCHPOINT_HIT; + continue; + } + cpu->watchpoint_hit =3D wp; + + mmap_lock(); + tb_check_watchpoint(cpu, ra); + if (wp->flags & BP_STOP_BEFORE_ACCESS) { + cpu->exception_index =3D EXCP_DEBUG; + mmap_unlock(); + cpu_loop_exit_restore(cpu, ra); + } else { + /* Force execution of one insn next time. */ + cpu->cflags_next_tb =3D 1 | curr_cflags(); + mmap_unlock(); + if (ra) { + cpu_restore_state(cpu, ra, true); + } + cpu_loop_exit_noexc(cpu); + } + } + } else { + wp->flags &=3D ~BP_WATCHPOINT_HIT; + } + } +} + +#endif /* CONFIG_TCG */ + /* Called from RCU critical section */ static RAMBlock *qemu_get_ram_block(ram_addr_t addr) { @@ -2355,75 +2427,6 @@ ram_addr_t qemu_ram_addr_from_host(void *ptr) return block->offset + offset; } =20 -/* Generate a debug exception if a watchpoint has been hit. */ -void cpu_check_watchpoint(CPUState *cpu, vaddr addr, vaddr len, - MemTxAttrs attrs, int flags, uintptr_t ra) -{ - CPUClass *cc =3D CPU_GET_CLASS(cpu); - CPUWatchpoint *wp; - - assert(tcg_enabled()); - if (cpu->watchpoint_hit) { - /* - * We re-entered the check after replacing the TB. - * Now raise the debug interrupt so that it will - * trigger after the current instruction. - */ - qemu_mutex_lock_iothread(); - cpu_interrupt(cpu, CPU_INTERRUPT_DEBUG); - qemu_mutex_unlock_iothread(); - return; - } - - addr =3D cc->adjust_watchpoint_address(cpu, addr, len); - QTAILQ_FOREACH(wp, &cpu->watchpoints, entry) { - if (watchpoint_address_matches(wp, addr, len) - && (wp->flags & flags)) { - if (replay_running_debug()) { - /* - * Don't process the watchpoints when we are - * in a reverse debugging operation. - */ - replay_breakpoint(); - return; - } - if (flags =3D=3D BP_MEM_READ) { - wp->flags |=3D BP_WATCHPOINT_HIT_READ; - } else { - wp->flags |=3D BP_WATCHPOINT_HIT_WRITE; - } - wp->hitaddr =3D MAX(addr, wp->vaddr); - wp->hitattrs =3D attrs; - if (!cpu->watchpoint_hit) { - if (wp->flags & BP_CPU && - !cc->debug_check_watchpoint(cpu, wp)) { - wp->flags &=3D ~BP_WATCHPOINT_HIT; - continue; - } - cpu->watchpoint_hit =3D wp; - - mmap_lock(); - tb_check_watchpoint(cpu, ra); - if (wp->flags & BP_STOP_BEFORE_ACCESS) { - cpu->exception_index =3D EXCP_DEBUG; - mmap_unlock(); - cpu_loop_exit_restore(cpu, ra); - } else { - /* Force execution of one insn next time. */ - cpu->cflags_next_tb =3D 1 | curr_cflags(); - mmap_unlock(); - if (ra) { - cpu_restore_state(cpu, ra, true); - } - cpu_loop_exit_noexc(cpu); - } - } - } else { - wp->flags &=3D ~BP_WATCHPOINT_HIT; - } - } -} - static MemTxResult flatview_read(FlatView *fv, hwaddr addr, MemTxAttrs attrs, void *buf, hwaddr len); static MemTxResult flatview_write(FlatView *fv, hwaddr addr, MemTxAttrs at= trs, --=20 2.26.2 From nobody Thu Apr 25 18:08:54 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=1610475368; cv=none; d=zohomail.com; s=zohoarc; b=diYu+JdrlMHJHLzCTltFJ2Jf7HqimA8Ha6eVxq7J1vW2KnT8mqh4zH71wchGWZ+8rHaxYH2kUNtKU06NkuG/bRCN83r3R0R5gO9DZTZVd+IzezxJL3z/Sd6Gt6IntakxRb0PTltOhy05eXoo7es+bPqYZKTvrZ6I7Bfze+beXqc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610475368; 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=eaOWRfoLdqPBC6G5xbgrzfD4AooFHm/ySpMCp8CUNAU=; b=DDiFJRZCCL0eHrAxfNwirJZhEKyvIsWl9SpgfWp+eVwWff/uNESoNWDnT1lMJhK50wezjycYrfgF5GeKi92obaH1RGjU1imMUYctfuTPSRNGOYTdoC0VIEUORuo6FfgfHJleu6pN2mMHGAADssKpLXaYNztFcKdBKSk6yPMTSmg= 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 161047536836060.43029056990849; Tue, 12 Jan 2021 10:16:08 -0800 (PST) Received: from localhost ([::1]:51230 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kzOD9-0001gI-2G for importer@patchew.org; Tue, 12 Jan 2021 13:16:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48168) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kzO1L-0005T1-7o for qemu-devel@nongnu.org; Tue, 12 Jan 2021 13:03:55 -0500 Received: from mx2.suse.de ([195.135.220.15]:33798) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kzO17-0004wW-HH for qemu-devel@nongnu.org; Tue, 12 Jan 2021 13:03:54 -0500 Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 56A95AC5B; Tue, 12 Jan 2021 18:03:29 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Claudio Fontana To: Paolo Bonzini , Thomas Huth , Richard Henderson , Stefano Stabellini , Wenchao Wang , Roman Bolshakov , Sunil Muthuswamy , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v12 13/22] cpu: move adjust_watchpoint_address to tcg_ops Date: Tue, 12 Jan 2021 19:03:03 +0100 Message-Id: <20210112180312.26043-14-cfontana@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210112180312.26043-1-cfontana@suse.de> References: <20210112180312.26043-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 , Peter Maydell , Eduardo Habkost , Paul Durrant , Jason Wang , Marcelo Tosatti , qemu-devel@nongnu.org, Peter Xu , Dario Faggioli , Cameron Esfahani , haxm-team@intel.com, Claudio Fontana , Anthony Perard , Bruce Rogers , Olaf Hering , "Emilio G . Cota" , Colin Xu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" commit 40612000599e ("arm: Correctly handle watchpoints for BE32 CPUs") introduced this ARM-specific, TCG-specific hack to adjust the address, before checking it with cpu_check_watchpoint. Make adjust_watchpoint_address optional and move it to tcg_ops. Signed-off-by: Claudio Fontana --- include/hw/core/cpu.h | 7 ++++++- hw/core/cpu.c | 6 ------ softmmu/physmem.c | 5 ++++- target/arm/cpu.c | 2 +- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index 95ff2c9eb0..d6c6d32865 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -137,6 +137,12 @@ typedef struct TcgCpuOperations { void (*do_unaligned_access)(CPUState *cpu, vaddr addr, MMUAccessType access_type, int mmu_idx, uintptr_t retaddr); + + /** + * @adjust_watchpoint_address: hack for cpu_check_watchpoint used by A= RM + */ + vaddr (*adjust_watchpoint_address)(CPUState *cpu, vaddr addr, int len); + #endif /* CONFIG_SOFTMMU */ #endif /* NEED_CPU_H */ =20 @@ -249,7 +255,6 @@ struct CPUClass { const char * (*gdb_get_dynamic_xml)(CPUState *cpu, const char *xmlname= ); =20 void (*disas_set_info)(CPUState *cpu, disassemble_info *info); - vaddr (*adjust_watchpoint_address)(CPUState *cpu, vaddr addr, int len); =20 const char *deprecation_note; /* Keep non-pointer data at the end to minimize holes. */ diff --git a/hw/core/cpu.c b/hw/core/cpu.c index 57542b6906..3d5bf9fe02 100644 --- a/hw/core/cpu.c +++ b/hw/core/cpu.c @@ -383,11 +383,6 @@ static int64_t cpu_common_get_arch_id(CPUState *cpu) return cpu->cpu_index; } =20 -static vaddr cpu_adjust_watchpoint_address(CPUState *cpu, vaddr addr, int = len) -{ - return addr; -} - static Property cpu_common_props[] =3D { #ifndef CONFIG_USER_ONLY /* Create a memory property for softmmu CPU object, @@ -421,7 +416,6 @@ static void cpu_class_init(ObjectClass *klass, void *da= ta) k->gdb_write_register =3D cpu_common_gdb_write_register; k->virtio_is_big_endian =3D cpu_common_virtio_is_big_endian; k->debug_check_watchpoint =3D cpu_common_debug_check_watchpoint; - k->adjust_watchpoint_address =3D cpu_adjust_watchpoint_address; set_bit(DEVICE_CATEGORY_CPU, dc->categories); dc->realize =3D cpu_common_realizefn; dc->unrealize =3D cpu_common_unrealizefn; diff --git a/softmmu/physmem.c b/softmmu/physmem.c index 9e7c50e0db..1443621579 100644 --- a/softmmu/physmem.c +++ b/softmmu/physmem.c @@ -894,7 +894,10 @@ void cpu_check_watchpoint(CPUState *cpu, vaddr addr, v= addr len, return; } =20 - addr =3D cc->adjust_watchpoint_address(cpu, addr, len); + if (cc->tcg_ops.adjust_watchpoint_address) { + /* this is currently used only by ARM BE32 */ + addr =3D cc->tcg_ops.adjust_watchpoint_address(cpu, addr, len); + } QTAILQ_FOREACH(wp, &cpu->watchpoints, entry) { if (watchpoint_address_matches(wp, addr, len) && (wp->flags & flags)) { diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 36c3e7fb55..e478d21a19 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -2271,7 +2271,7 @@ static void arm_cpu_class_init(ObjectClass *oc, void = *data) #if !defined(CONFIG_USER_ONLY) cc->tcg_ops.do_transaction_failed =3D arm_cpu_do_transaction_failed; cc->tcg_ops.do_unaligned_access =3D arm_cpu_do_unaligned_access; - cc->adjust_watchpoint_address =3D arm_adjust_watchpoint_address; + cc->tcg_ops.adjust_watchpoint_address =3D arm_adjust_watchpoint_addres= s; cc->tcg_ops.do_interrupt =3D arm_cpu_do_interrupt; #endif /* CONFIG_TCG && !CONFIG_USER_ONLY */ #endif /* CONFIG_TCG */ --=20 2.26.2 From nobody Thu Apr 25 18:08:54 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=1610475373; cv=none; d=zohomail.com; s=zohoarc; b=ko8Y9N+aB3PLDTRIBo/BelN24/QUjTKESmreQNldISYOF3t6DUZ+JUxAUXuIkP4RwF2SNIHFKbeBXLmtqiHe3ZhkXHqdOA7adT40UPTbYoEmmy5202zBEuED3Dpfus9BuqAQHSprLhHPShOUQD1rqvKPaeQ5QfbhQs8sLpUad3w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610475373; 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=QuD05wIDRPkmvhasufIEUvYkezCoIcaCE/aPdsR4r2Y=; b=hvmVCYFbVnIv+ZI2WMCRWyGxvbvBoObr2LwDz7b4H/tUtYIVApSSuR2kA6Q4HK154hXaLLU98EcDAD7gkQZsOfqO49XaGcXS8eTDLCqA2gwm7GD23U5fqGLBaTWffOQhaYsq34Sp8fjvkhn1/Cqus/8PWTUfxkJOTJqj6eE/ueI= 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 1610475373112942.2619851942103; Tue, 12 Jan 2021 10:16:13 -0800 (PST) Received: from localhost ([::1]:51634 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kzODD-0001tT-Vx for importer@patchew.org; Tue, 12 Jan 2021 13:16:12 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48166) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kzO1L-0005Sh-3d for qemu-devel@nongnu.org; Tue, 12 Jan 2021 13:03:55 -0500 Received: from mx2.suse.de ([195.135.220.15]:33846) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kzO17-0004we-Ka for qemu-devel@nongnu.org; Tue, 12 Jan 2021 13:03:54 -0500 Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 5B7FBACAD; Tue, 12 Jan 2021 18:03:30 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Claudio Fontana To: Paolo Bonzini , Thomas Huth , Richard Henderson , Stefano Stabellini , Wenchao Wang , Roman Bolshakov , Sunil Muthuswamy , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v12 14/22] cpu: move debug_check_watchpoint to tcg_ops Date: Tue, 12 Jan 2021 19:03:04 +0100 Message-Id: <20210112180312.26043-15-cfontana@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210112180312.26043-1-cfontana@suse.de> References: <20210112180312.26043-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=unavailable 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 , Peter Maydell , Eduardo Habkost , Paul Durrant , Jason Wang , Marcelo Tosatti , qemu-devel@nongnu.org, Peter Xu , Dario Faggioli , Cameron Esfahani , haxm-team@intel.com, Claudio Fontana , Anthony Perard , Bruce Rogers , Olaf Hering , "Emilio G . Cota" , Colin Xu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" commit 568496c0c0f1 ("cpu: Add callback to check architectural") and commit 3826121d9298 ("target-arm: Implement checking of fired") introduced an ARM-specific hack for cpu_check_watchpoint. Make debug_check_watchpoint optional, and move it to tcg_ops. Signed-off-by: Claudio Fontana --- include/hw/core/cpu.h | 9 ++++++--- accel/tcg/user-exec.c | 3 ++- hw/core/cpu.c | 9 --------- softmmu/physmem.c | 4 ++-- target/arm/cpu.c | 4 ++-- 5 files changed, 12 insertions(+), 17 deletions(-) diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index d6c6d32865..406e8a8606 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -143,6 +143,12 @@ typedef struct TcgCpuOperations { */ vaddr (*adjust_watchpoint_address)(CPUState *cpu, vaddr addr, int len); =20 + /** + * @debug_check_watchpoint: return true if the architectural + * watchpoint whose address has matched should really fire, used by ARM + */ + bool (*debug_check_watchpoint)(CPUState *cpu, CPUWatchpoint *wp); + #endif /* CONFIG_SOFTMMU */ #endif /* NEED_CPU_H */ =20 @@ -183,8 +189,6 @@ typedef struct TcgCpuOperations { * a memory access with the specified memory transaction attributes. * @gdb_read_register: Callback for letting GDB read a register. * @gdb_write_register: Callback for letting GDB write a register. - * @debug_check_watchpoint: Callback: return true if the architectural - * watchpoint whose address has matched should really fire. * @write_elf64_note: Callback for writing a CPU-specific ELF note to a * 64-bit VM coredump. * @write_elf32_qemunote: Callback for writing a CPU- and QEMU-specific ELF @@ -238,7 +242,6 @@ struct CPUClass { int (*asidx_from_attrs)(CPUState *cpu, MemTxAttrs attrs); int (*gdb_read_register)(CPUState *cpu, GByteArray *buf, int reg); int (*gdb_write_register)(CPUState *cpu, uint8_t *buf, int reg); - bool (*debug_check_watchpoint)(CPUState *cpu, CPUWatchpoint *wp); =20 int (*write_elf64_note)(WriteCoreDumpFunction f, CPUState *cpu, int cpuid, void *opaque); diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c index 5509dd53e9..9e6e188d19 100644 --- a/accel/tcg/user-exec.c +++ b/accel/tcg/user-exec.c @@ -187,7 +187,8 @@ static inline int handle_cpu_signal(uintptr_t pc, sigin= fo_t *info, clear_helper_retaddr(); =20 cc =3D CPU_GET_CLASS(cpu); - cc->tcg_ops.tlb_fill(cpu, address, 0, access_type, MMU_USER_IDX, false= , pc); + cc->tcg_ops.tlb_fill(cpu, address, 0, access_type, + MMU_USER_IDX, false, pc); g_assert_not_reached(); } =20 diff --git a/hw/core/cpu.c b/hw/core/cpu.c index 3d5bf9fe02..00330ba07d 100644 --- a/hw/core/cpu.c +++ b/hw/core/cpu.c @@ -186,14 +186,6 @@ static int cpu_common_gdb_write_register(CPUState *cpu= , uint8_t *buf, int reg) return 0; } =20 -static bool cpu_common_debug_check_watchpoint(CPUState *cpu, CPUWatchpoint= *wp) -{ - /* If no extra check is required, QEMU watchpoint match can be conside= red - * as an architectural match. - */ - return true; -} - static bool cpu_common_virtio_is_big_endian(CPUState *cpu) { return target_words_bigendian(); @@ -415,7 +407,6 @@ static void cpu_class_init(ObjectClass *klass, void *da= ta) k->gdb_read_register =3D cpu_common_gdb_read_register; k->gdb_write_register =3D cpu_common_gdb_write_register; k->virtio_is_big_endian =3D cpu_common_virtio_is_big_endian; - k->debug_check_watchpoint =3D cpu_common_debug_check_watchpoint; set_bit(DEVICE_CATEGORY_CPU, dc->categories); dc->realize =3D cpu_common_realizefn; dc->unrealize =3D cpu_common_unrealizefn; diff --git a/softmmu/physmem.c b/softmmu/physmem.c index 1443621579..121ff36c88 100644 --- a/softmmu/physmem.c +++ b/softmmu/physmem.c @@ -917,8 +917,8 @@ void cpu_check_watchpoint(CPUState *cpu, vaddr addr, va= ddr len, wp->hitaddr =3D MAX(addr, wp->vaddr); wp->hitattrs =3D attrs; if (!cpu->watchpoint_hit) { - if (wp->flags & BP_CPU && - !cc->debug_check_watchpoint(cpu, wp)) { + if (wp->flags & BP_CPU && cc->tcg_ops.debug_check_watchpoi= nt && + !cc->tcg_ops.debug_check_watchpoint(cpu, wp)) { wp->flags &=3D ~BP_WATCHPOINT_HIT; continue; } diff --git a/target/arm/cpu.c b/target/arm/cpu.c index e478d21a19..122067133b 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -2267,12 +2267,12 @@ static void arm_cpu_class_init(ObjectClass *oc, voi= d *data) cc->tcg_ops.synchronize_from_tb =3D arm_cpu_synchronize_from_tb; cc->tcg_ops.tlb_fill =3D arm_cpu_tlb_fill; cc->tcg_ops.debug_excp_handler =3D arm_debug_excp_handler; - cc->debug_check_watchpoint =3D arm_debug_check_watchpoint; #if !defined(CONFIG_USER_ONLY) + cc->tcg_ops.do_interrupt =3D arm_cpu_do_interrupt; cc->tcg_ops.do_transaction_failed =3D arm_cpu_do_transaction_failed; cc->tcg_ops.do_unaligned_access =3D arm_cpu_do_unaligned_access; cc->tcg_ops.adjust_watchpoint_address =3D arm_adjust_watchpoint_addres= s; - cc->tcg_ops.do_interrupt =3D arm_cpu_do_interrupt; + cc->tcg_ops.debug_check_watchpoint =3D arm_debug_check_watchpoint; #endif /* CONFIG_TCG && !CONFIG_USER_ONLY */ #endif /* CONFIG_TCG */ } --=20 2.26.2 From nobody Thu Apr 25 18:08:54 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=1610476643; cv=none; d=zohomail.com; s=zohoarc; b=GlrHp+Hi5UyJIfs4vZP+CxJMbeNYNUOvgj77mCj4Hcjot6N195n6XrZzktAfj7axZZdMdFhKNbv/Ihf3e1LhuLtyqr6HOTO/vcjj1hP4CFBoqnEqTvyS2w9JEsAK4j5qjZX2tp6qLNjvBhR/8o7CTGQJcz6qHLd29Zvx0HPRzLk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610476643; 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=OUTpqcIV1EIhGWXEVqxqD047pU7Fp6VAsx7prpRDOao=; b=bYhUVcBNwhKC4IknF5dol4nX5Zy5nen1N5Y0f5PtAO+GepJgtxwa2ta4wIHb9O3cMGbLFABIHkOB0AxAepEArHH1GCXz1XBk+1IeNatNbZi+M6RU6DTrkHXsw0mTsCx3Fgg3FXx3Rxn2gLjbKKBL8lGGq0NSTJ9VV+aNrU5QA6w= 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 1610476643417801.7818778324678; Tue, 12 Jan 2021 10:37:23 -0800 (PST) Received: from localhost ([::1]:53258 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kzOXh-0002YY-OX for importer@patchew.org; Tue, 12 Jan 2021 13:37:21 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48210) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kzO1O-0005bD-4y for qemu-devel@nongnu.org; Tue, 12 Jan 2021 13:03:58 -0500 Received: from mx2.suse.de ([195.135.220.15]:33888) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kzO19-0004wq-BH for qemu-devel@nongnu.org; Tue, 12 Jan 2021 13:03:57 -0500 Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 69223ACBA; Tue, 12 Jan 2021 18:03:31 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Claudio Fontana To: Paolo Bonzini , Thomas Huth , Richard Henderson , Stefano Stabellini , Wenchao Wang , Roman Bolshakov , Sunil Muthuswamy , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v12 15/22] cpu: tcg_ops: move to tcg-cpu-ops.h, keep a pointer in CPUClass Date: Tue, 12 Jan 2021 19:03:05 +0100 Message-Id: <20210112180312.26043-16-cfontana@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210112180312.26043-1-cfontana@suse.de> References: <20210112180312.26043-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 , Peter Maydell , Eduardo Habkost , Paul Durrant , Jason Wang , Marcelo Tosatti , qemu-devel@nongnu.org, Peter Xu , Dario Faggioli , Cameron Esfahani , haxm-team@intel.com, Claudio Fontana , Anthony Perard , Bruce Rogers , Olaf Hering , "Emilio G . Cota" , Colin Xu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" this improves over the workaround in commit 5af415b7d5fd ("cpu: move cc->transaction_failed to tcg_ops") by moving the tcg cpu operations into a separate file, which is only included by target-specific code. The context is that code in ss_common and ss_specific modules might see different data structure layouts, due to missing CONFIG_XXX in ss_common objects. To be on the safe side, move over all details to tcg-cpu-ops.h, which is to be included only by CONFIG_TCG target code, and leave only a pointer in CPUClass, which for non-TCG is just going to be NULL. This also tidies up the code in all targets a bit, having all tcg cpu operations neatly contained by a dedicated data struct. Signed-off-by: Claudio Fontana --- include/hw/core/cpu.h | 122 ++++---------------------------- include/hw/core/tcg-cpu-ops.h | 95 +++++++++++++++++++++++++ target/arm/internals.h | 6 ++ accel/tcg/cpu-exec.c | 27 +++---- accel/tcg/cputlb.c | 35 +++++++-- accel/tcg/user-exec.c | 9 +-- hw/mips/jazz.c | 7 +- softmmu/physmem.c | 13 ++-- target/alpha/cpu.c | 21 ++++-- target/arm/cpu.c | 45 ++++++++---- target/arm/cpu64.c | 6 +- target/arm/cpu_tcg.c | 28 ++++++-- target/avr/cpu.c | 19 +++-- target/avr/helper.c | 5 +- target/cris/cpu.c | 43 +++++++---- target/cris/helper.c | 5 +- target/hppa/cpu.c | 22 ++++-- target/i386/tcg/tcg-cpu.c | 28 +++++--- target/lm32/cpu.c | 19 +++-- target/m68k/cpu.c | 19 +++-- target/microblaze/cpu.c | 25 +++++-- target/mips/cpu.c | 36 ++++++---- target/moxie/cpu.c | 15 +++- target/nios2/cpu.c | 18 +++-- target/openrisc/cpu.c | 17 +++-- target/riscv/cpu.c | 23 ++++-- target/rx/cpu.c | 20 ++++-- target/s390x/cpu.c | 33 +++++---- target/sh4/cpu.c | 21 ++++-- target/sparc/cpu.c | 25 +++++-- target/tilegx/cpu.c | 17 +++-- target/tricore/cpu.c | 12 +++- target/unicore32/cpu.c | 17 +++-- target/xtensa/cpu.c | 23 ++++-- target/ppc/translate_init.c.inc | 33 +++++---- MAINTAINERS | 1 + 36 files changed, 595 insertions(+), 315 deletions(-) create mode 100644 include/hw/core/tcg-cpu-ops.h diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index 406e8a8606..500e2c4fce 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -76,84 +76,11 @@ typedef struct CPUWatchpoint CPUWatchpoint; =20 struct TranslationBlock; =20 -#ifdef CONFIG_TCG -/** - * struct TcgCpuOperations: TCG operations specific to a CPU class - */ -typedef struct TcgCpuOperations { - /** - * @initialize: Initalize TCG state - * - * Called when the first CPU is realized. - */ - void (*initialize)(void); - /** - * @synchronize_from_tb: Synchronize state from a TCG #TranslationBlock - * - * This is called when we abandon execution of a TB before - * starting it, and must set all parts of the CPU state which - * the previous TB in the chain may not have updated. This - * will need to do more. If this hook is not implemented then - * the default is to call @set_pc(tb->pc). - */ - void (*synchronize_from_tb)(CPUState *cpu, - const struct TranslationBlock *tb); - /** @cpu_exec_enter: Callback for cpu_exec preparation */ - void (*cpu_exec_enter)(CPUState *cpu); - /** @cpu_exec_exit: Callback for cpu_exec cleanup */ - void (*cpu_exec_exit)(CPUState *cpu); - /** @cpu_exec_interrupt: Callback for processing interrupts in cpu_exe= c */ - bool (*cpu_exec_interrupt)(CPUState *cpu, int interrupt_request); - /** @do_interrupt: Callback for interrupt handling. */ - void (*do_interrupt)(CPUState *cpu); - /** - * @tlb_fill: Handle a softmmu tlb miss or user-only address fault - * - * For system mode, if the access is valid, call tlb_set_page - * and return true; if the access is invalid, and probe is - * true, return false; otherwise raise an exception and do - * not return. For user-only mode, always raise an exception - * and do not return. - */ - bool (*tlb_fill)(CPUState *cpu, vaddr address, int size, - MMUAccessType access_type, int mmu_idx, - bool probe, uintptr_t retaddr); - /** @debug_excp_handler: Callback for handling debug exceptions */ - void (*debug_excp_handler)(CPUState *cpu); +/* see accel-cpu.h */ +struct AccelCPUClass; =20 -#ifdef NEED_CPU_H -#ifdef CONFIG_SOFTMMU - /** - * @do_transaction_failed: Callback for handling failed memory transac= tions - * (ie bus faults or external aborts; not MMU faults) - */ - void (*do_transaction_failed)(CPUState *cpu, hwaddr physaddr, vaddr ad= dr, - unsigned size, MMUAccessType access_type, - int mmu_idx, MemTxAttrs attrs, - MemTxResult response, uintptr_t retaddr); - /** - * @do_unaligned_access: Callback for unaligned access handling - */ - void (*do_unaligned_access)(CPUState *cpu, vaddr addr, - MMUAccessType access_type, - int mmu_idx, uintptr_t retaddr); - - /** - * @adjust_watchpoint_address: hack for cpu_check_watchpoint used by A= RM - */ - vaddr (*adjust_watchpoint_address)(CPUState *cpu, vaddr addr, int len); - - /** - * @debug_check_watchpoint: return true if the architectural - * watchpoint whose address has matched should really fire, used by ARM - */ - bool (*debug_check_watchpoint)(CPUState *cpu, CPUWatchpoint *wp); - -#endif /* CONFIG_SOFTMMU */ -#endif /* NEED_CPU_H */ - -} TcgCpuOperations; -#endif /* CONFIG_TCG */ +/* see tcg-cpu-ops.h */ +struct TCGCPUOps; =20 /** * CPUClass: @@ -264,9 +191,14 @@ struct CPUClass { int gdb_num_core_regs; bool gdb_stop_before_watchpoint; =20 -#ifdef CONFIG_TCG - TcgCpuOperations tcg_ops; -#endif /* CONFIG_TCG */ + /* + * NB: this should be covered by CONFIG_TCG, but it is unsafe to do it= here, + * as this header is included by both ss_specific and ss_common code, + * leading to potential differences in the data structure between modu= les. + * We could always keep it last, but it seems safer to just leave this + * pointer NULL for non-TCG. + */ + struct TCGCPUOps *tcg_ops; }; =20 /* @@ -897,36 +829,6 @@ CPUState *cpu_by_arch_id(int64_t id); =20 void cpu_interrupt(CPUState *cpu, int mask); =20 -#ifdef NEED_CPU_H -#if defined(CONFIG_SOFTMMU) && defined(CONFIG_TCG) -static inline void cpu_unaligned_access(CPUState *cpu, vaddr addr, - MMUAccessType access_type, - int mmu_idx, uintptr_t retaddr) -{ - CPUClass *cc =3D CPU_GET_CLASS(cpu); - - cc->tcg_ops.do_unaligned_access(cpu, addr, access_type, mmu_idx, retad= dr); -} - -static inline void cpu_transaction_failed(CPUState *cpu, hwaddr physaddr, - vaddr addr, unsigned size, - MMUAccessType access_type, - int mmu_idx, MemTxAttrs attrs, - MemTxResult response, - uintptr_t retaddr) -{ - CPUClass *cc =3D CPU_GET_CLASS(cpu); - - if (!cpu->ignore_memory_transaction_failures && - cc->tcg_ops.do_transaction_failed) { - cc->tcg_ops.do_transaction_failed(cpu, physaddr, addr, size, - access_type, mmu_idx, attrs, - response, retaddr); - } -} -#endif /* CONFIG_SOFTMMU && CONFIG_TCG */ -#endif /* NEED_CPU_H */ - /** * cpu_set_pc: * @cpu: The CPU to set the program counter for. diff --git a/include/hw/core/tcg-cpu-ops.h b/include/hw/core/tcg-cpu-ops.h new file mode 100644 index 0000000000..406ef56184 --- /dev/null +++ b/include/hw/core/tcg-cpu-ops.h @@ -0,0 +1,95 @@ +/* + * TCG CPU-specific operations + * + * Copyright 2020 SUSE LLC + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#ifndef TCG_CPU_OPS_H +#define TCG_CPU_OPS_H + +#include "hw/core/cpu.h" + +struct TCGCPUOps { + /** + * @initialize: Initalize TCG state + * + * Called when the first CPU is realized. + */ + void (*initialize)(void); + /** + * @synchronize_from_tb: Synchronize state from a TCG #TranslationBlock + * + * This is called when we abandon execution of a TB before + * starting it, and must set all parts of the CPU state which + * the previous TB in the chain may not have updated. This + * will need to do more. If this hook is not implemented then + * the default is to call @set_pc(tb->pc). + */ + void (*synchronize_from_tb)(CPUState *cpu, + const struct TranslationBlock *tb); + /** @cpu_exec_enter: Callback for cpu_exec preparation */ + void (*cpu_exec_enter)(CPUState *cpu); + /** @cpu_exec_exit: Callback for cpu_exec cleanup */ + void (*cpu_exec_exit)(CPUState *cpu); + /** @cpu_exec_interrupt: Callback for processing interrupts in cpu_exe= c */ + bool (*cpu_exec_interrupt)(CPUState *cpu, int interrupt_request); + /** + * @do_interrupt: Callback for interrupt handling. + * + * note that this is in general SOFTMMU only, but it actually isn't + * because of an x86 hack (accel/tcg/cpu-exec.c), so we cannot put it + * in the SOFTMMU section in general. + */ + void (*do_interrupt)(CPUState *cpu); + /** + * @tlb_fill: Handle a softmmu tlb miss or user-only address fault + * + * For system mode, if the access is valid, call tlb_set_page + * and return true; if the access is invalid, and probe is + * true, return false; otherwise raise an exception and do + * not return. For user-only mode, always raise an exception + * and do not return. + */ + bool (*tlb_fill)(CPUState *cpu, vaddr address, int size, + MMUAccessType access_type, int mmu_idx, + bool probe, uintptr_t retaddr); + /** @debug_excp_handler: Callback for handling debug exceptions */ + void (*debug_excp_handler)(CPUState *cpu); + +#ifdef NEED_CPU_H +#ifdef CONFIG_SOFTMMU + /** + * @do_transaction_failed: Callback for handling failed memory transac= tions + * (ie bus faults or external aborts; not MMU faults) + */ + void (*do_transaction_failed)(CPUState *cpu, hwaddr physaddr, vaddr ad= dr, + unsigned size, MMUAccessType access_type, + int mmu_idx, MemTxAttrs attrs, + MemTxResult response, uintptr_t retaddr); + /** + * @do_unaligned_access: Callback for unaligned access handling + */ + void (*do_unaligned_access)(CPUState *cpu, vaddr addr, + MMUAccessType access_type, + int mmu_idx, uintptr_t retaddr); + + /** + * @adjust_watchpoint_address: hack for cpu_check_watchpoint used by A= RM + */ + vaddr (*adjust_watchpoint_address)(CPUState *cpu, vaddr addr, int len); + + /** + * @debug_check_watchpoint: return true if the architectural + * watchpoint whose address has matched should really fire, used by ARM + */ + bool (*debug_check_watchpoint)(CPUState *cpu, CPUWatchpoint *wp); + +#endif /* CONFIG_SOFTMMU */ +#endif /* NEED_CPU_H */ + +}; + +#endif /* TCG_CPU_OPS_H */ diff --git a/target/arm/internals.h b/target/arm/internals.h index 5460678756..55da2da9ca 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -171,6 +171,12 @@ static inline int r14_bank_number(int mode) void arm_cpu_register_gdb_regs_for_features(ARMCPU *cpu); void arm_translate_init(void); =20 +#ifdef CONFIG_TCG +void arm_cpu_synchronize_from_tb(CPUState *cs, + const struct TranslationBlock *tb); +#endif /* CONFIG_TCG */ + + enum arm_fprounding { FPROUNDING_TIEEVEN, FPROUNDING_POSINF, diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index d44e11d7d2..b462a39790 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -21,6 +21,7 @@ #include "qemu-common.h" #include "qemu/qemu-print.h" #include "cpu.h" +#include "hw/core/tcg-cpu-ops.h" #include "trace.h" #include "disas/disas.h" #include "exec/exec-all.h" @@ -211,8 +212,8 @@ cpu_tb_exec(CPUState *cpu, TranslationBlock *itb, int *= tb_exit) TARGET_FMT_lx "] %s\n", last_tb->tc.ptr, last_tb->pc, lookup_symbol(last_tb->pc)); - if (cc->tcg_ops.synchronize_from_tb) { - cc->tcg_ops.synchronize_from_tb(cpu, last_tb); + if (cc->tcg_ops->synchronize_from_tb) { + cc->tcg_ops->synchronize_from_tb(cpu, last_tb); } else { assert(cc->set_pc); cc->set_pc(cpu, last_tb->pc); @@ -260,8 +261,8 @@ static void cpu_exec_enter(CPUState *cpu) { CPUClass *cc =3D CPU_GET_CLASS(cpu); =20 - if (cc->tcg_ops.cpu_exec_enter) { - cc->tcg_ops.cpu_exec_enter(cpu); + if (cc->tcg_ops->cpu_exec_enter) { + cc->tcg_ops->cpu_exec_enter(cpu); } } =20 @@ -269,8 +270,8 @@ static void cpu_exec_exit(CPUState *cpu) { CPUClass *cc =3D CPU_GET_CLASS(cpu); =20 - if (cc->tcg_ops.cpu_exec_exit) { - cc->tcg_ops.cpu_exec_exit(cpu); + if (cc->tcg_ops->cpu_exec_exit) { + cc->tcg_ops->cpu_exec_exit(cpu); } } =20 @@ -505,8 +506,8 @@ static inline void cpu_handle_debug_exception(CPUState = *cpu) } } =20 - if (cc->tcg_ops.debug_excp_handler) { - cc->tcg_ops.debug_excp_handler(cpu); + if (cc->tcg_ops->debug_excp_handler) { + cc->tcg_ops->debug_excp_handler(cpu); } } =20 @@ -540,7 +541,7 @@ static inline bool cpu_handle_exception(CPUState *cpu, = int *ret) loop */ #if defined(TARGET_I386) CPUClass *cc =3D CPU_GET_CLASS(cpu); - cc->tcg_ops.do_interrupt(cpu); + cc->tcg_ops->do_interrupt(cpu); #endif *ret =3D cpu->exception_index; cpu->exception_index =3D -1; @@ -549,7 +550,7 @@ static inline bool cpu_handle_exception(CPUState *cpu, = int *ret) if (replay_exception()) { CPUClass *cc =3D CPU_GET_CLASS(cpu); qemu_mutex_lock_iothread(); - cc->tcg_ops.do_interrupt(cpu); + cc->tcg_ops->do_interrupt(cpu); qemu_mutex_unlock_iothread(); cpu->exception_index =3D -1; =20 @@ -648,8 +649,8 @@ static inline bool cpu_handle_interrupt(CPUState *cpu, True when it is, and we should restart on a new TB, and via longjmp via cpu_loop_exit. */ else { - if (cc->tcg_ops.cpu_exec_interrupt && - cc->tcg_ops.cpu_exec_interrupt(cpu, interrupt_request)) { + if (cc->tcg_ops->cpu_exec_interrupt && + cc->tcg_ops->cpu_exec_interrupt(cpu, interrupt_request)) { if (need_replay_interrupt(interrupt_request)) { replay_interrupt(); } @@ -827,7 +828,7 @@ void tcg_exec_realizefn(CPUState *cpu, Error **errp) CPUClass *cc =3D CPU_GET_CLASS(cpu); =20 if (!tcg_target_initialized) { - cc->tcg_ops.initialize(); + cc->tcg_ops->initialize(); tcg_target_initialized =3D true; } tlb_init(cpu); diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index d3ad40f380..23d6b4774e 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -20,6 +20,7 @@ #include "qemu/osdep.h" #include "qemu/main-loop.h" #include "cpu.h" +#include "hw/core/tcg-cpu-ops.h" #include "exec/exec-all.h" #include "exec/memory.h" #include "exec/address-spaces.h" @@ -1286,11 +1287,37 @@ static void tlb_fill(CPUState *cpu, target_ulong ad= dr, int size, * This is not a probe, so only valid return is success; failure * should result in exception + longjmp to the cpu loop. */ - ok =3D cc->tcg_ops.tlb_fill(cpu, addr, size, - access_type, mmu_idx, false, retaddr); + ok =3D cc->tcg_ops->tlb_fill(cpu, addr, size, + access_type, mmu_idx, false, retaddr); assert(ok); } =20 +static inline void cpu_unaligned_access(CPUState *cpu, vaddr addr, + MMUAccessType access_type, + int mmu_idx, uintptr_t retaddr) +{ + CPUClass *cc =3D CPU_GET_CLASS(cpu); + + cc->tcg_ops->do_unaligned_access(cpu, addr, access_type, mmu_idx, reta= ddr); +} + +static inline void cpu_transaction_failed(CPUState *cpu, hwaddr physaddr, + vaddr addr, unsigned size, + MMUAccessType access_type, + int mmu_idx, MemTxAttrs attrs, + MemTxResult response, + uintptr_t retaddr) +{ + CPUClass *cc =3D CPU_GET_CLASS(cpu); + + if (!cpu->ignore_memory_transaction_failures && + cc->tcg_ops->do_transaction_failed) { + cc->tcg_ops->do_transaction_failed(cpu, physaddr, addr, size, + access_type, mmu_idx, attrs, + response, retaddr); + } +} + static uint64_t io_readx(CPUArchState *env, CPUIOTLBEntry *iotlbentry, int mmu_idx, target_ulong addr, uintptr_t retaddr, MMUAccessType access_type, MemOp op) @@ -1558,8 +1585,8 @@ static int probe_access_internal(CPUArchState *env, t= arget_ulong addr, CPUState *cs =3D env_cpu(env); CPUClass *cc =3D CPU_GET_CLASS(cs); =20 - if (!cc->tcg_ops.tlb_fill(cs, addr, fault_size, access_type, - mmu_idx, nonfault, retaddr)) { + if (!cc->tcg_ops->tlb_fill(cs, addr, fault_size, access_type, + mmu_idx, nonfault, retaddr)) { /* Non-faulting page table read failed. */ *phost =3D NULL; return TLB_INVALID_MASK; diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c index 9e6e188d19..0b6f56ca40 100644 --- a/accel/tcg/user-exec.c +++ b/accel/tcg/user-exec.c @@ -18,6 +18,7 @@ */ #include "qemu/osdep.h" #include "cpu.h" +#include "hw/core/tcg-cpu-ops.h" #include "disas/disas.h" #include "exec/exec-all.h" #include "tcg/tcg.h" @@ -187,8 +188,8 @@ static inline int handle_cpu_signal(uintptr_t pc, sigin= fo_t *info, clear_helper_retaddr(); =20 cc =3D CPU_GET_CLASS(cpu); - cc->tcg_ops.tlb_fill(cpu, address, 0, access_type, - MMU_USER_IDX, false, pc); + cc->tcg_ops->tlb_fill(cpu, address, 0, access_type, + MMU_USER_IDX, false, pc); g_assert_not_reached(); } =20 @@ -218,8 +219,8 @@ static int probe_access_internal(CPUArchState *env, tar= get_ulong addr, } else { CPUState *cpu =3D env_cpu(env); CPUClass *cc =3D CPU_GET_CLASS(cpu); - cc->tcg_ops.tlb_fill(cpu, addr, fault_size, access_type, - MMU_USER_IDX, false, ra); + cc->tcg_ops->tlb_fill(cpu, addr, fault_size, access_type, + MMU_USER_IDX, false, ra); g_assert_not_reached(); } } diff --git a/hw/mips/jazz.c b/hw/mips/jazz.c index 46c71a0ac8..83c8086062 100644 --- a/hw/mips/jazz.c +++ b/hw/mips/jazz.c @@ -53,6 +53,9 @@ #include "qapi/error.h" #include "qemu/error-report.h" #include "qemu/help_option.h" +#ifdef CONFIG_TCG +#include "hw/core/tcg-cpu-ops.h" +#endif /* CONFIG_TCG */ =20 enum jazz_model_e { JAZZ_MAGNUM, @@ -209,8 +212,8 @@ static void mips_jazz_init(MachineState *machine, */ cc =3D CPU_GET_CLASS(cpu); #if defined(CONFIG_TCG) && !defined(CONFIG_USER_ONLY) - real_do_transaction_failed =3D cc->tcg_ops.do_transaction_failed; - cc->tcg_ops.do_transaction_failed =3D mips_jazz_do_transaction_failed; + real_do_transaction_failed =3D cc->tcg_ops->do_transaction_failed; + cc->tcg_ops->do_transaction_failed =3D mips_jazz_do_transaction_failed; #endif /* CONFIG_TCG && !CONFIG_USER_ONLY */ =20 /* allocate RAM */ diff --git a/softmmu/physmem.c b/softmmu/physmem.c index 121ff36c88..3bcc80e46f 100644 --- a/softmmu/physmem.c +++ b/softmmu/physmem.c @@ -24,6 +24,11 @@ #include "qemu/cutils.h" #include "qemu/cacheflush.h" #include "cpu.h" + +#ifdef CONFIG_TCG +#include "hw/core/tcg-cpu-ops.h" +#endif /* CONFIG_TCG */ + #include "exec/exec-all.h" #include "exec/target_page.h" #include "hw/qdev-core.h" @@ -894,9 +899,9 @@ void cpu_check_watchpoint(CPUState *cpu, vaddr addr, va= ddr len, return; } =20 - if (cc->tcg_ops.adjust_watchpoint_address) { + if (cc->tcg_ops->adjust_watchpoint_address) { /* this is currently used only by ARM BE32 */ - addr =3D cc->tcg_ops.adjust_watchpoint_address(cpu, addr, len); + addr =3D cc->tcg_ops->adjust_watchpoint_address(cpu, addr, len); } QTAILQ_FOREACH(wp, &cpu->watchpoints, entry) { if (watchpoint_address_matches(wp, addr, len) @@ -917,8 +922,8 @@ void cpu_check_watchpoint(CPUState *cpu, vaddr addr, va= ddr len, wp->hitaddr =3D MAX(addr, wp->vaddr); wp->hitattrs =3D attrs; if (!cpu->watchpoint_hit) { - if (wp->flags & BP_CPU && cc->tcg_ops.debug_check_watchpoi= nt && - !cc->tcg_ops.debug_check_watchpoint(cpu, wp)) { + if (wp->flags & BP_CPU && cc->tcg_ops->debug_check_watchpo= int && + !cc->tcg_ops->debug_check_watchpoint(cpu, wp)) { wp->flags &=3D ~BP_WATCHPOINT_HIT; continue; } diff --git a/target/alpha/cpu.c b/target/alpha/cpu.c index 0710298e5a..27192b62e2 100644 --- a/target/alpha/cpu.c +++ b/target/alpha/cpu.c @@ -206,6 +206,20 @@ static void alpha_cpu_initfn(Object *obj) #endif } =20 +#include "hw/core/tcg-cpu-ops.h" + +static struct TCGCPUOps alpha_tcg_ops =3D { + .initialize =3D alpha_translate_init, + .cpu_exec_interrupt =3D alpha_cpu_exec_interrupt, + .tlb_fill =3D alpha_cpu_tlb_fill, + +#ifndef CONFIG_USER_ONLY + .do_interrupt =3D alpha_cpu_do_interrupt, + .do_transaction_failed =3D alpha_cpu_do_transaction_failed, + .do_unaligned_access =3D alpha_cpu_do_unaligned_access, +#endif /* !CONFIG_USER_ONLY */ +}; + static void alpha_cpu_class_init(ObjectClass *oc, void *data) { DeviceClass *dc =3D DEVICE_CLASS(oc); @@ -217,22 +231,17 @@ static void alpha_cpu_class_init(ObjectClass *oc, voi= d *data) =20 cc->class_by_name =3D alpha_cpu_class_by_name; cc->has_work =3D alpha_cpu_has_work; - cc->tcg_ops.do_interrupt =3D alpha_cpu_do_interrupt; - cc->tcg_ops.cpu_exec_interrupt =3D alpha_cpu_exec_interrupt; cc->dump_state =3D alpha_cpu_dump_state; cc->set_pc =3D alpha_cpu_set_pc; cc->gdb_read_register =3D alpha_cpu_gdb_read_register; cc->gdb_write_register =3D alpha_cpu_gdb_write_register; - cc->tcg_ops.tlb_fill =3D alpha_cpu_tlb_fill; #ifndef CONFIG_USER_ONLY - cc->tcg_ops.do_transaction_failed =3D alpha_cpu_do_transaction_failed; - cc->tcg_ops.do_unaligned_access =3D alpha_cpu_do_unaligned_access; cc->get_phys_page_debug =3D alpha_cpu_get_phys_page_debug; dc->vmsd =3D &vmstate_alpha_cpu; #endif cc->disas_set_info =3D alpha_cpu_disas_set_info; - cc->tcg_ops.initialize =3D alpha_translate_init; =20 + cc->tcg_ops =3D &alpha_tcg_ops; cc->gdb_num_core_regs =3D 67; } =20 diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 122067133b..b8b34f1b3a 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -26,6 +26,9 @@ #include "qapi/error.h" #include "qapi/visitor.h" #include "cpu.h" +#ifdef CONFIG_TCG +#include "hw/core/tcg-cpu-ops.h" +#endif /* CONFIG_TCG */ #include "internals.h" #include "exec/exec-all.h" #include "hw/qdev-properties.h" @@ -55,8 +58,8 @@ static void arm_cpu_set_pc(CPUState *cs, vaddr value) } =20 #ifdef CONFIG_TCG -static void arm_cpu_synchronize_from_tb(CPUState *cs, - const TranslationBlock *tb) +void arm_cpu_synchronize_from_tb(CPUState *cs, + const TranslationBlock *tb) { ARMCPU *cpu =3D ARM_CPU(cs); CPUARMState *env =3D &cpu->env; @@ -590,7 +593,7 @@ bool arm_cpu_exec_interrupt(CPUState *cs, int interrupt= _request) found: cs->exception_index =3D excp_idx; env->exception.target_el =3D target_el; - cc->tcg_ops.do_interrupt(cs); + cc->tcg_ops->do_interrupt(cs); return true; } =20 @@ -2229,6 +2232,28 @@ static gchar *arm_gdb_arch_name(CPUState *cs) return g_strdup("arm"); } =20 +#ifdef CONFIG_TCG +/* + * NB: cannot be const, as some elements are changed for specific + * arm cpu classes. + */ +static struct TCGCPUOps arm_tcg_ops =3D { + .initialize =3D arm_translate_init, + .synchronize_from_tb =3D arm_cpu_synchronize_from_tb, + .cpu_exec_interrupt =3D arm_cpu_exec_interrupt, + .tlb_fill =3D arm_cpu_tlb_fill, + .debug_excp_handler =3D arm_debug_excp_handler, + +#if !defined(CONFIG_USER_ONLY) + .do_interrupt =3D arm_cpu_do_interrupt, + .do_transaction_failed =3D arm_cpu_do_transaction_failed, + .do_unaligned_access =3D arm_cpu_do_unaligned_access, + .adjust_watchpoint_address =3D arm_adjust_watchpoint_address, + .debug_check_watchpoint =3D arm_debug_check_watchpoint, +#endif /* !CONFIG_USER_ONLY */ +}; +#endif /* CONFIG_TCG */ + static void arm_cpu_class_init(ObjectClass *oc, void *data) { ARMCPUClass *acc =3D ARM_CPU_CLASS(oc); @@ -2261,19 +2286,9 @@ static void arm_cpu_class_init(ObjectClass *oc, void= *data) cc->gdb_get_dynamic_xml =3D arm_gdb_get_dynamic_xml; cc->gdb_stop_before_watchpoint =3D true; cc->disas_set_info =3D arm_disas_set_info; + #ifdef CONFIG_TCG - cc->tcg_ops.initialize =3D arm_translate_init; - cc->tcg_ops.cpu_exec_interrupt =3D arm_cpu_exec_interrupt; - cc->tcg_ops.synchronize_from_tb =3D arm_cpu_synchronize_from_tb; - cc->tcg_ops.tlb_fill =3D arm_cpu_tlb_fill; - cc->tcg_ops.debug_excp_handler =3D arm_debug_excp_handler; -#if !defined(CONFIG_USER_ONLY) - cc->tcg_ops.do_interrupt =3D arm_cpu_do_interrupt; - cc->tcg_ops.do_transaction_failed =3D arm_cpu_do_transaction_failed; - cc->tcg_ops.do_unaligned_access =3D arm_cpu_do_unaligned_access; - cc->tcg_ops.adjust_watchpoint_address =3D arm_adjust_watchpoint_addres= s; - cc->tcg_ops.debug_check_watchpoint =3D arm_debug_check_watchpoint; -#endif /* CONFIG_TCG && !CONFIG_USER_ONLY */ + cc->tcg_ops =3D &arm_tcg_ops; #endif /* CONFIG_TCG */ } =20 diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c index 2e2eab208b..cc9991c812 100644 --- a/target/arm/cpu64.c +++ b/target/arm/cpu64.c @@ -21,6 +21,9 @@ #include "qemu/osdep.h" #include "qapi/error.h" #include "cpu.h" +#ifdef CONFIG_TCG +#include "hw/core/tcg-cpu-ops.h" +#endif /* CONFIG_TCG */ #include "qemu/module.h" #if !defined(CONFIG_USER_ONLY) #include "hw/loader.h" @@ -775,8 +778,9 @@ static void aarch64_cpu_class_init(ObjectClass *oc, voi= d *data) { CPUClass *cc =3D CPU_CLASS(oc); =20 + /* XXX is this really needed? It is already set in cpu.c */ #ifdef CONFIG_TCG - cc->tcg_ops.cpu_exec_interrupt =3D arm_cpu_exec_interrupt; + cc->tcg_ops->cpu_exec_interrupt =3D arm_cpu_exec_interrupt; #endif /* CONFIG_TCG */ =20 cc->gdb_read_register =3D aarch64_cpu_gdb_read_register; diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c index d9c160f1ac..c29b434c60 100644 --- a/target/arm/cpu_tcg.c +++ b/target/arm/cpu_tcg.c @@ -10,6 +10,9 @@ =20 #include "qemu/osdep.h" #include "cpu.h" +#ifdef CONFIG_TCG +#include "hw/core/tcg-cpu-ops.h" +#endif /* CONFIG_TCG */ #include "internals.h" =20 /* CPU models. These are not needed for the AArch64 linux-user build. */ @@ -34,7 +37,7 @@ static bool arm_v7m_cpu_exec_interrupt(CPUState *cs, int = interrupt_request) if (interrupt_request & CPU_INTERRUPT_HARD && (armv7m_nvic_can_take_pending_exception(env->nvic))) { cs->exception_index =3D EXCP_IRQ; - cc->tcg_ops.do_interrupt(cs); + cc->tcg_ops->do_interrupt(cs); ret =3D true; } return ret; @@ -660,6 +663,24 @@ static void pxa270c5_initfn(Object *obj) cpu->reset_sctlr =3D 0x00000078; } =20 +#ifdef CONFIG_TCG +static struct TCGCPUOps arm_v7m_tcg_ops =3D { + .initialize =3D arm_translate_init, + .synchronize_from_tb =3D arm_cpu_synchronize_from_tb, + .cpu_exec_interrupt =3D arm_v7m_cpu_exec_interrupt, + .tlb_fill =3D arm_cpu_tlb_fill, + .debug_excp_handler =3D arm_debug_excp_handler, + +#if !defined(CONFIG_USER_ONLY) + .do_interrupt =3D arm_v7m_cpu_do_interrupt, + .do_transaction_failed =3D arm_cpu_do_transaction_failed, + .do_unaligned_access =3D arm_cpu_do_unaligned_access, + .adjust_watchpoint_address =3D arm_adjust_watchpoint_address, + .debug_check_watchpoint =3D arm_debug_check_watchpoint, +#endif /* !CONFIG_USER_ONLY */ +}; +#endif /* CONFIG_TCG */ + static void arm_v7m_class_init(ObjectClass *oc, void *data) { ARMCPUClass *acc =3D ARM_CPU_CLASS(oc); @@ -667,10 +688,7 @@ static void arm_v7m_class_init(ObjectClass *oc, void *= data) =20 acc->info =3D data; #ifdef CONFIG_TCG - cc->tcg_ops.cpu_exec_interrupt =3D arm_v7m_cpu_exec_interrupt; -#ifndef CONFIG_USER_ONLY - cc->tcg_ops.do_interrupt =3D arm_v7m_cpu_do_interrupt; -#endif + cc->tcg_ops =3D &arm_v7m_tcg_ops; #endif /* CONFIG_TCG */ =20 cc->gdb_core_xml_file =3D "arm-m-profile.xml"; diff --git a/target/avr/cpu.c b/target/avr/cpu.c index 476e645b37..fa0f8e0e80 100644 --- a/target/avr/cpu.c +++ b/target/avr/cpu.c @@ -184,6 +184,19 @@ static void avr_cpu_dump_state(CPUState *cs, FILE *f, = int flags) qemu_fprintf(f, "\n"); } =20 +#include "hw/core/tcg-cpu-ops.h" + +static struct TCGCPUOps avr_tcg_ops =3D { + .initialize =3D avr_cpu_tcg_init, + .synchronize_from_tb =3D avr_cpu_synchronize_from_tb, + .cpu_exec_interrupt =3D avr_cpu_exec_interrupt, + .tlb_fill =3D avr_cpu_tlb_fill, + +#ifndef CONFIG_USER_ONLY + .do_interrupt =3D avr_cpu_do_interrupt, +#endif /* !CONFIG_USER_ONLY */ +}; + static void avr_cpu_class_init(ObjectClass *oc, void *data) { DeviceClass *dc =3D DEVICE_CLASS(oc); @@ -198,21 +211,17 @@ static void avr_cpu_class_init(ObjectClass *oc, void = *data) cc->class_by_name =3D avr_cpu_class_by_name; =20 cc->has_work =3D avr_cpu_has_work; - cc->tcg_ops.do_interrupt =3D avr_cpu_do_interrupt; - cc->tcg_ops.cpu_exec_interrupt =3D avr_cpu_exec_interrupt; cc->dump_state =3D avr_cpu_dump_state; cc->set_pc =3D avr_cpu_set_pc; cc->memory_rw_debug =3D avr_cpu_memory_rw_debug; cc->get_phys_page_debug =3D avr_cpu_get_phys_page_debug; - cc->tcg_ops.tlb_fill =3D avr_cpu_tlb_fill; cc->vmsd =3D &vms_avr_cpu; cc->disas_set_info =3D avr_cpu_disas_set_info; - cc->tcg_ops.initialize =3D avr_cpu_tcg_init; - cc->tcg_ops.synchronize_from_tb =3D avr_cpu_synchronize_from_tb; cc->gdb_read_register =3D avr_cpu_gdb_read_register; cc->gdb_write_register =3D avr_cpu_gdb_write_register; cc->gdb_num_core_regs =3D 35; cc->gdb_core_xml_file =3D "avr-cpu.xml"; + cc->tcg_ops =3D &avr_tcg_ops; } =20 /* diff --git a/target/avr/helper.c b/target/avr/helper.c index 69d3b6181f..65880b9928 100644 --- a/target/avr/helper.c +++ b/target/avr/helper.c @@ -20,6 +20,7 @@ =20 #include "qemu/osdep.h" #include "cpu.h" +#include "hw/core/tcg-cpu-ops.h" #include "exec/exec-all.h" #include "exec/address-spaces.h" #include "exec/helper-proto.h" @@ -34,7 +35,7 @@ bool avr_cpu_exec_interrupt(CPUState *cs, int interrupt_r= equest) if (interrupt_request & CPU_INTERRUPT_RESET) { if (cpu_interrupts_enabled(env)) { cs->exception_index =3D EXCP_RESET; - cc->tcg_ops.do_interrupt(cs); + cc->tcg_ops->do_interrupt(cs); =20 cs->interrupt_request &=3D ~CPU_INTERRUPT_RESET; =20 @@ -45,7 +46,7 @@ bool avr_cpu_exec_interrupt(CPUState *cs, int interrupt_r= equest) if (cpu_interrupts_enabled(env) && env->intsrc !=3D 0) { int index =3D ctz32(env->intsrc); cs->exception_index =3D EXCP_INT(index); - cc->tcg_ops.do_interrupt(cs); + cc->tcg_ops->do_interrupt(cs); =20 env->intsrc &=3D env->intsrc - 1; /* clear the interrupt */ cs->interrupt_request &=3D ~CPU_INTERRUPT_HARD; diff --git a/target/cris/cpu.c b/target/cris/cpu.c index b65743e8ca..ed983380fc 100644 --- a/target/cris/cpu.c +++ b/target/cris/cpu.c @@ -193,15 +193,36 @@ static void cris_cpu_initfn(Object *obj) #endif } =20 +#include "hw/core/tcg-cpu-ops.h" + +static struct TCGCPUOps crisv10_tcg_ops =3D { + .initialize =3D cris_initialize_crisv10_tcg, + .cpu_exec_interrupt =3D cris_cpu_exec_interrupt, + .tlb_fill =3D cris_cpu_tlb_fill, + +#ifndef CONFIG_USER_ONLY + .do_interrupt =3D crisv10_cpu_do_interrupt, +#endif /* !CONFIG_USER_ONLY */ +}; + +static struct TCGCPUOps crisv32_tcg_ops =3D { + .initialize =3D cris_initialize_tcg, + .cpu_exec_interrupt =3D cris_cpu_exec_interrupt, + .tlb_fill =3D cris_cpu_tlb_fill, + +#ifndef CONFIG_USER_ONLY + .do_interrupt =3D cris_cpu_do_interrupt, +#endif /* !CONFIG_USER_ONLY */ +}; + static void crisv8_cpu_class_init(ObjectClass *oc, void *data) { CPUClass *cc =3D CPU_CLASS(oc); CRISCPUClass *ccc =3D CRIS_CPU_CLASS(oc); =20 ccc->vr =3D 8; - cc->tcg_ops.do_interrupt =3D crisv10_cpu_do_interrupt; cc->gdb_read_register =3D crisv10_cpu_gdb_read_register; - cc->tcg_ops.initialize =3D cris_initialize_crisv10_tcg; + cc->tcg_ops =3D &crisv10_tcg_ops; } =20 static void crisv9_cpu_class_init(ObjectClass *oc, void *data) @@ -210,9 +231,8 @@ static void crisv9_cpu_class_init(ObjectClass *oc, void= *data) CRISCPUClass *ccc =3D CRIS_CPU_CLASS(oc); =20 ccc->vr =3D 9; - cc->tcg_ops.do_interrupt =3D crisv10_cpu_do_interrupt; cc->gdb_read_register =3D crisv10_cpu_gdb_read_register; - cc->tcg_ops.initialize =3D cris_initialize_crisv10_tcg; + cc->tcg_ops =3D &crisv10_tcg_ops; } =20 static void crisv10_cpu_class_init(ObjectClass *oc, void *data) @@ -221,9 +241,8 @@ static void crisv10_cpu_class_init(ObjectClass *oc, voi= d *data) CRISCPUClass *ccc =3D CRIS_CPU_CLASS(oc); =20 ccc->vr =3D 10; - cc->tcg_ops.do_interrupt =3D crisv10_cpu_do_interrupt; cc->gdb_read_register =3D crisv10_cpu_gdb_read_register; - cc->tcg_ops.initialize =3D cris_initialize_crisv10_tcg; + cc->tcg_ops =3D &crisv10_tcg_ops; } =20 static void crisv11_cpu_class_init(ObjectClass *oc, void *data) @@ -232,9 +251,8 @@ static void crisv11_cpu_class_init(ObjectClass *oc, voi= d *data) CRISCPUClass *ccc =3D CRIS_CPU_CLASS(oc); =20 ccc->vr =3D 11; - cc->tcg_ops.do_interrupt =3D crisv10_cpu_do_interrupt; cc->gdb_read_register =3D crisv10_cpu_gdb_read_register; - cc->tcg_ops.initialize =3D cris_initialize_crisv10_tcg; + cc->tcg_ops =3D &crisv10_tcg_ops; } =20 static void crisv17_cpu_class_init(ObjectClass *oc, void *data) @@ -243,16 +261,17 @@ static void crisv17_cpu_class_init(ObjectClass *oc, v= oid *data) CRISCPUClass *ccc =3D CRIS_CPU_CLASS(oc); =20 ccc->vr =3D 17; - cc->tcg_ops.do_interrupt =3D crisv10_cpu_do_interrupt; cc->gdb_read_register =3D crisv10_cpu_gdb_read_register; - cc->tcg_ops.initialize =3D cris_initialize_crisv10_tcg; + cc->tcg_ops =3D &crisv10_tcg_ops; } =20 static void crisv32_cpu_class_init(ObjectClass *oc, void *data) { + CPUClass *cc =3D CPU_CLASS(oc); CRISCPUClass *ccc =3D CRIS_CPU_CLASS(oc); =20 ccc->vr =3D 32; + cc->tcg_ops =3D &crisv32_tcg_ops; } =20 static void cris_cpu_class_init(ObjectClass *oc, void *data) @@ -268,13 +287,10 @@ static void cris_cpu_class_init(ObjectClass *oc, void= *data) =20 cc->class_by_name =3D cris_cpu_class_by_name; cc->has_work =3D cris_cpu_has_work; - cc->tcg_ops.do_interrupt =3D cris_cpu_do_interrupt; - cc->tcg_ops.cpu_exec_interrupt =3D cris_cpu_exec_interrupt; cc->dump_state =3D cris_cpu_dump_state; cc->set_pc =3D cris_cpu_set_pc; cc->gdb_read_register =3D cris_cpu_gdb_read_register; cc->gdb_write_register =3D cris_cpu_gdb_write_register; - cc->tcg_ops.tlb_fill =3D cris_cpu_tlb_fill; #ifndef CONFIG_USER_ONLY cc->get_phys_page_debug =3D cris_cpu_get_phys_page_debug; dc->vmsd =3D &vmstate_cris_cpu; @@ -284,7 +300,6 @@ static void cris_cpu_class_init(ObjectClass *oc, void *= data) cc->gdb_stop_before_watchpoint =3D true; =20 cc->disas_set_info =3D cris_disas_set_info; - cc->tcg_ops.initialize =3D cris_initialize_tcg; } =20 #define DEFINE_CRIS_CPU_TYPE(cpu_model, initfn) \ diff --git a/target/cris/helper.c b/target/cris/helper.c index 1f4d6f7d45..7e3bb58fe1 100644 --- a/target/cris/helper.c +++ b/target/cris/helper.c @@ -20,6 +20,7 @@ =20 #include "qemu/osdep.h" #include "cpu.h" +#include "hw/core/tcg-cpu-ops.h" #include "mmu.h" #include "qemu/host-utils.h" #include "exec/exec-all.h" @@ -299,7 +300,7 @@ bool cris_cpu_exec_interrupt(CPUState *cs, int interrup= t_request) && (env->pregs[PR_CCS] & I_FLAG) && !env->locked_irq) { cs->exception_index =3D EXCP_IRQ; - cc->tcg_ops.do_interrupt(cs); + cc->tcg_ops->do_interrupt(cs); ret =3D true; } if (interrupt_request & CPU_INTERRUPT_NMI) { @@ -311,7 +312,7 @@ bool cris_cpu_exec_interrupt(CPUState *cs, int interrup= t_request) } if ((env->pregs[PR_CCS] & m_flag_archval)) { cs->exception_index =3D EXCP_NMI; - cc->tcg_ops.do_interrupt(cs); + cc->tcg_ops->do_interrupt(cs); ret =3D true; } } diff --git a/target/hppa/cpu.c b/target/hppa/cpu.c index fd7f849a1c..d8fad52d1f 100644 --- a/target/hppa/cpu.c +++ b/target/hppa/cpu.c @@ -131,6 +131,20 @@ static ObjectClass *hppa_cpu_class_by_name(const char = *cpu_model) return object_class_by_name(TYPE_HPPA_CPU); } =20 +#include "hw/core/tcg-cpu-ops.h" + +static struct TCGCPUOps hppa_tcg_ops =3D { + .initialize =3D hppa_translate_init, + .synchronize_from_tb =3D hppa_cpu_synchronize_from_tb, + .cpu_exec_interrupt =3D hppa_cpu_exec_interrupt, + .tlb_fill =3D hppa_cpu_tlb_fill, + +#ifndef CONFIG_USER_ONLY + .do_interrupt =3D hppa_cpu_do_interrupt, + .do_unaligned_access =3D hppa_cpu_do_unaligned_access, +#endif /* !CONFIG_USER_ONLY */ +}; + static void hppa_cpu_class_init(ObjectClass *oc, void *data) { DeviceClass *dc =3D DEVICE_CLASS(oc); @@ -142,23 +156,17 @@ static void hppa_cpu_class_init(ObjectClass *oc, void= *data) =20 cc->class_by_name =3D hppa_cpu_class_by_name; cc->has_work =3D hppa_cpu_has_work; - cc->tcg_ops.do_interrupt =3D hppa_cpu_do_interrupt; - cc->tcg_ops.cpu_exec_interrupt =3D hppa_cpu_exec_interrupt; cc->dump_state =3D hppa_cpu_dump_state; cc->set_pc =3D hppa_cpu_set_pc; - cc->tcg_ops.synchronize_from_tb =3D hppa_cpu_synchronize_from_tb; cc->gdb_read_register =3D hppa_cpu_gdb_read_register; cc->gdb_write_register =3D hppa_cpu_gdb_write_register; - cc->tcg_ops.tlb_fill =3D hppa_cpu_tlb_fill; #ifndef CONFIG_USER_ONLY cc->get_phys_page_debug =3D hppa_cpu_get_phys_page_debug; - cc->tcg_ops.do_unaligned_access =3D hppa_cpu_do_unaligned_access; dc->vmsd =3D &vmstate_hppa_cpu; #endif cc->disas_set_info =3D hppa_cpu_disas_set_info; - cc->tcg_ops.initialize =3D hppa_translate_init; - cc->gdb_num_core_regs =3D 128; + cc->tcg_ops =3D &hppa_tcg_ops; } =20 static const TypeInfo hppa_cpu_type_info =3D { diff --git a/target/i386/tcg/tcg-cpu.c b/target/i386/tcg/tcg-cpu.c index 4a53cd89e2..1e125d2175 100644 --- a/target/i386/tcg/tcg-cpu.c +++ b/target/i386/tcg/tcg-cpu.c @@ -57,16 +57,22 @@ static void x86_cpu_synchronize_from_tb(CPUState *cs, cpu->env.eip =3D tb->pc - tb->cs_base; } =20 -void tcg_cpu_common_class_init(CPUClass *cc) -{ - cc->tcg_ops.do_interrupt =3D x86_cpu_do_interrupt; - cc->tcg_ops.cpu_exec_interrupt =3D x86_cpu_exec_interrupt; - cc->tcg_ops.synchronize_from_tb =3D x86_cpu_synchronize_from_tb; - cc->tcg_ops.cpu_exec_enter =3D x86_cpu_exec_enter; - cc->tcg_ops.cpu_exec_exit =3D x86_cpu_exec_exit; - cc->tcg_ops.initialize =3D tcg_x86_init; - cc->tcg_ops.tlb_fill =3D x86_cpu_tlb_fill; +#include "hw/core/tcg-cpu-ops.h" + +static struct TCGCPUOps x86_tcg_ops =3D { + .initialize =3D tcg_x86_init, + .synchronize_from_tb =3D x86_cpu_synchronize_from_tb, + .cpu_exec_enter =3D x86_cpu_exec_enter, + .cpu_exec_exit =3D x86_cpu_exec_exit, + .cpu_exec_interrupt =3D x86_cpu_exec_interrupt, + .do_interrupt =3D x86_cpu_do_interrupt, + .tlb_fill =3D x86_cpu_tlb_fill, #ifndef CONFIG_USER_ONLY - cc->tcg_ops.debug_excp_handler =3D breakpoint_handler; -#endif + .debug_excp_handler =3D breakpoint_handler, +#endif /* !CONFIG_USER_ONLY */ +}; + +void tcg_cpu_common_class_init(CPUClass *cc) +{ + cc->tcg_ops =3D &x86_tcg_ops; } diff --git a/target/lm32/cpu.c b/target/lm32/cpu.c index fb3761b749..c23d72874c 100644 --- a/target/lm32/cpu.c +++ b/target/lm32/cpu.c @@ -210,6 +210,19 @@ static ObjectClass *lm32_cpu_class_by_name(const char = *cpu_model) return oc; } =20 +#include "hw/core/tcg-cpu-ops.h" + +static struct TCGCPUOps lm32_tcg_ops =3D { + .initialize =3D lm32_translate_init, + .cpu_exec_interrupt =3D lm32_cpu_exec_interrupt, + .tlb_fill =3D lm32_cpu_tlb_fill, + .debug_excp_handler =3D lm32_debug_excp_handler, + +#ifndef CONFIG_USER_ONLY + .do_interrupt =3D lm32_cpu_do_interrupt, +#endif /* !CONFIG_USER_ONLY */ +}; + static void lm32_cpu_class_init(ObjectClass *oc, void *data) { LM32CPUClass *lcc =3D LM32_CPU_CLASS(oc); @@ -222,22 +235,18 @@ static void lm32_cpu_class_init(ObjectClass *oc, void= *data) =20 cc->class_by_name =3D lm32_cpu_class_by_name; cc->has_work =3D lm32_cpu_has_work; - cc->tcg_ops.do_interrupt =3D lm32_cpu_do_interrupt; - cc->tcg_ops.cpu_exec_interrupt =3D lm32_cpu_exec_interrupt; cc->dump_state =3D lm32_cpu_dump_state; cc->set_pc =3D lm32_cpu_set_pc; cc->gdb_read_register =3D lm32_cpu_gdb_read_register; cc->gdb_write_register =3D lm32_cpu_gdb_write_register; - cc->tcg_ops.tlb_fill =3D lm32_cpu_tlb_fill; #ifndef CONFIG_USER_ONLY cc->get_phys_page_debug =3D lm32_cpu_get_phys_page_debug; cc->vmsd =3D &vmstate_lm32_cpu; #endif cc->gdb_num_core_regs =3D 32 + 7; cc->gdb_stop_before_watchpoint =3D true; - cc->tcg_ops.debug_excp_handler =3D lm32_debug_excp_handler; cc->disas_set_info =3D lm32_cpu_disas_set_info; - cc->tcg_ops.initialize =3D lm32_translate_init; + cc->tcg_ops =3D &lm32_tcg_ops; } =20 #define DEFINE_LM32_CPU_TYPE(cpu_model, initfn) \ diff --git a/target/m68k/cpu.c b/target/m68k/cpu.c index e68b933c84..c6fde8132b 100644 --- a/target/m68k/cpu.c +++ b/target/m68k/cpu.c @@ -453,6 +453,19 @@ static const VMStateDescription vmstate_m68k_cpu =3D { }; #endif =20 +#include "hw/core/tcg-cpu-ops.h" + +static struct TCGCPUOps m68k_tcg_ops =3D { + .initialize =3D m68k_tcg_init, + .cpu_exec_interrupt =3D m68k_cpu_exec_interrupt, + .tlb_fill =3D m68k_cpu_tlb_fill, + +#ifndef CONFIG_USER_ONLY + .do_interrupt =3D m68k_cpu_do_interrupt, + .do_transaction_failed =3D m68k_cpu_transaction_failed, +#endif /* !CONFIG_USER_ONLY */ +}; + static void m68k_cpu_class_init(ObjectClass *c, void *data) { M68kCPUClass *mcc =3D M68K_CPU_CLASS(c); @@ -465,22 +478,18 @@ static void m68k_cpu_class_init(ObjectClass *c, void = *data) =20 cc->class_by_name =3D m68k_cpu_class_by_name; cc->has_work =3D m68k_cpu_has_work; - cc->tcg_ops.do_interrupt =3D m68k_cpu_do_interrupt; - cc->tcg_ops.cpu_exec_interrupt =3D m68k_cpu_exec_interrupt; cc->dump_state =3D m68k_cpu_dump_state; cc->set_pc =3D m68k_cpu_set_pc; cc->gdb_read_register =3D m68k_cpu_gdb_read_register; cc->gdb_write_register =3D m68k_cpu_gdb_write_register; - cc->tcg_ops.tlb_fill =3D m68k_cpu_tlb_fill; #if defined(CONFIG_SOFTMMU) - cc->tcg_ops.do_transaction_failed =3D m68k_cpu_transaction_failed; cc->get_phys_page_debug =3D m68k_cpu_get_phys_page_debug; dc->vmsd =3D &vmstate_m68k_cpu; #endif cc->disas_set_info =3D m68k_cpu_disas_set_info; - cc->tcg_ops.initialize =3D m68k_tcg_init; =20 cc->gdb_num_core_regs =3D 18; + cc->tcg_ops =3D &m68k_tcg_ops; } =20 static void m68k_cpu_class_init_cf_core(ObjectClass *c, void *data) diff --git a/target/microblaze/cpu.c b/target/microblaze/cpu.c index d84a374e75..af1528fcc5 100644 --- a/target/microblaze/cpu.c +++ b/target/microblaze/cpu.c @@ -306,6 +306,21 @@ static ObjectClass *mb_cpu_class_by_name(const char *c= pu_model) return object_class_by_name(TYPE_MICROBLAZE_CPU); } =20 +#include "hw/core/tcg-cpu-ops.h" + +static struct TCGCPUOps mb_tcg_ops =3D { + .initialize =3D mb_tcg_init, + .synchronize_from_tb =3D mb_cpu_synchronize_from_tb, + .cpu_exec_interrupt =3D mb_cpu_exec_interrupt, + .tlb_fill =3D mb_cpu_tlb_fill, + +#ifndef CONFIG_USER_ONLY + .do_interrupt =3D mb_cpu_do_interrupt, + .do_transaction_failed =3D mb_cpu_transaction_failed, + .do_unaligned_access =3D mb_cpu_do_unaligned_access, +#endif /* !CONFIG_USER_ONLY */ +}; + static void mb_cpu_class_init(ObjectClass *oc, void *data) { DeviceClass *dc =3D DEVICE_CLASS(oc); @@ -318,17 +333,13 @@ static void mb_cpu_class_init(ObjectClass *oc, void *= data) =20 cc->class_by_name =3D mb_cpu_class_by_name; cc->has_work =3D mb_cpu_has_work; - cc->tcg_ops.do_interrupt =3D mb_cpu_do_interrupt; - cc->tcg_ops.cpu_exec_interrupt =3D mb_cpu_exec_interrupt; + cc->dump_state =3D mb_cpu_dump_state; cc->set_pc =3D mb_cpu_set_pc; - cc->tcg_ops.synchronize_from_tb =3D mb_cpu_synchronize_from_tb; cc->gdb_read_register =3D mb_cpu_gdb_read_register; cc->gdb_write_register =3D mb_cpu_gdb_write_register; - cc->tcg_ops.tlb_fill =3D mb_cpu_tlb_fill; + #ifndef CONFIG_USER_ONLY - cc->tcg_ops.do_transaction_failed =3D mb_cpu_transaction_failed; - cc->tcg_ops.do_unaligned_access =3D mb_cpu_do_unaligned_access; cc->get_phys_page_debug =3D mb_cpu_get_phys_page_debug; dc->vmsd =3D &vmstate_mb_cpu; #endif @@ -336,7 +347,7 @@ static void mb_cpu_class_init(ObjectClass *oc, void *da= ta) cc->gdb_num_core_regs =3D 32 + 27; =20 cc->disas_set_info =3D mb_disas_set_info; - cc->tcg_ops.initialize =3D mb_tcg_init; + cc->tcg_ops =3D &mb_tcg_ops; } =20 static const TypeInfo mb_cpu_type_info =3D { diff --git a/target/mips/cpu.c b/target/mips/cpu.c index 12c12b1ada..840150e08e 100644 --- a/target/mips/cpu.c +++ b/target/mips/cpu.c @@ -464,6 +464,26 @@ static Property mips_cpu_properties[] =3D { DEFINE_PROP_END_OF_LIST() }; =20 +#ifdef CONFIG_TCG +#include "hw/core/tcg-cpu-ops.h" +/* + * NB: cannot be const, as some elements are changed for specific + * mips hardware (see hw/mips/jazz.c). + */ +static struct TCGCPUOps mips_tcg_ops =3D { + .initialize =3D mips_tcg_init, + .synchronize_from_tb =3D mips_cpu_synchronize_from_tb, + .cpu_exec_interrupt =3D mips_cpu_exec_interrupt, + .tlb_fill =3D mips_cpu_tlb_fill, + +#if !defined(CONFIG_USER_ONLY) + .do_interrupt =3D mips_cpu_do_interrupt, + .do_transaction_failed =3D mips_cpu_do_transaction_failed, + .do_unaligned_access =3D mips_cpu_do_unaligned_access, +#endif /* !CONFIG_USER_ONLY */ +}; +#endif /* CONFIG_TCG */ + static void mips_cpu_class_init(ObjectClass *c, void *data) { MIPSCPUClass *mcc =3D MIPS_CPU_CLASS(c); @@ -486,21 +506,11 @@ static void mips_cpu_class_init(ObjectClass *c, void = *data) cc->vmsd =3D &vmstate_mips_cpu; #endif cc->disas_set_info =3D mips_cpu_disas_set_info; -#ifdef CONFIG_TCG - cc->tcg_ops.initialize =3D mips_tcg_init; - cc->tcg_ops.do_interrupt =3D mips_cpu_do_interrupt; - cc->tcg_ops.cpu_exec_interrupt =3D mips_cpu_exec_interrupt; - cc->tcg_ops.synchronize_from_tb =3D mips_cpu_synchronize_from_tb; - cc->tcg_ops.tlb_fill =3D mips_cpu_tlb_fill; -#ifndef CONFIG_USER_ONLY - cc->tcg_ops.do_transaction_failed =3D mips_cpu_do_transaction_failed; - cc->tcg_ops.do_unaligned_access =3D mips_cpu_do_unaligned_access; - -#endif /* CONFIG_USER_ONLY */ -#endif /* CONFIG_TCG */ - cc->gdb_num_core_regs =3D 73; cc->gdb_stop_before_watchpoint =3D true; +#ifdef CONFIG_TCG + cc->tcg_ops =3D &mips_tcg_ops; +#endif /* CONFIG_TCG */ } =20 static const TypeInfo mips_cpu_type_info =3D { diff --git a/target/moxie/cpu.c b/target/moxie/cpu.c index 36bef4d357..83bec34d36 100644 --- a/target/moxie/cpu.c +++ b/target/moxie/cpu.c @@ -94,6 +94,17 @@ static ObjectClass *moxie_cpu_class_by_name(const char *= cpu_model) return oc; } =20 +#include "hw/core/tcg-cpu-ops.h" + +static struct TCGCPUOps moxie_tcg_ops =3D { + .initialize =3D moxie_translate_init, + .tlb_fill =3D moxie_cpu_tlb_fill, + +#ifndef CONFIG_USER_ONLY + .do_interrupt =3D moxie_cpu_do_interrupt, +#endif /* !CONFIG_USER_ONLY */ +}; + static void moxie_cpu_class_init(ObjectClass *oc, void *data) { DeviceClass *dc =3D DEVICE_CLASS(oc); @@ -107,16 +118,14 @@ static void moxie_cpu_class_init(ObjectClass *oc, voi= d *data) cc->class_by_name =3D moxie_cpu_class_by_name; =20 cc->has_work =3D moxie_cpu_has_work; - cc->tcg_ops.do_interrupt =3D moxie_cpu_do_interrupt; cc->dump_state =3D moxie_cpu_dump_state; cc->set_pc =3D moxie_cpu_set_pc; - cc->tcg_ops.tlb_fill =3D moxie_cpu_tlb_fill; #ifndef CONFIG_USER_ONLY cc->get_phys_page_debug =3D moxie_cpu_get_phys_page_debug; cc->vmsd =3D &vmstate_moxie_cpu; #endif cc->disas_set_info =3D moxie_cpu_disas_set_info; - cc->tcg_ops.initialize =3D moxie_translate_init; + cc->tcg_ops =3D &moxie_tcg_ops; } =20 static void moxielite_initfn(Object *obj) diff --git a/target/nios2/cpu.c b/target/nios2/cpu.c index c43aa3d4c4..e9c9fc3a38 100644 --- a/target/nios2/cpu.c +++ b/target/nios2/cpu.c @@ -207,6 +207,18 @@ static Property nios2_properties[] =3D { DEFINE_PROP_END_OF_LIST(), }; =20 +#include "hw/core/tcg-cpu-ops.h" + +static struct TCGCPUOps nios2_tcg_ops =3D { + .initialize =3D nios2_tcg_init, + .cpu_exec_interrupt =3D nios2_cpu_exec_interrupt, + .tlb_fill =3D nios2_cpu_tlb_fill, + +#ifndef CONFIG_USER_ONLY + .do_interrupt =3D nios2_cpu_do_interrupt, + .do_unaligned_access =3D nios2_cpu_do_unaligned_access, +#endif /* !CONFIG_USER_ONLY */ +}; =20 static void nios2_cpu_class_init(ObjectClass *oc, void *data) { @@ -221,20 +233,16 @@ static void nios2_cpu_class_init(ObjectClass *oc, voi= d *data) =20 cc->class_by_name =3D nios2_cpu_class_by_name; cc->has_work =3D nios2_cpu_has_work; - cc->tcg_ops.do_interrupt =3D nios2_cpu_do_interrupt; - cc->tcg_ops.cpu_exec_interrupt =3D nios2_cpu_exec_interrupt; cc->dump_state =3D nios2_cpu_dump_state; cc->set_pc =3D nios2_cpu_set_pc; cc->disas_set_info =3D nios2_cpu_disas_set_info; - cc->tcg_ops.tlb_fill =3D nios2_cpu_tlb_fill; #ifndef CONFIG_USER_ONLY - cc->tcg_ops.do_unaligned_access =3D nios2_cpu_do_unaligned_access; cc->get_phys_page_debug =3D nios2_cpu_get_phys_page_debug; #endif cc->gdb_read_register =3D nios2_cpu_gdb_read_register; cc->gdb_write_register =3D nios2_cpu_gdb_write_register; cc->gdb_num_core_regs =3D 49; - cc->tcg_ops.initialize =3D nios2_tcg_init; + cc->tcg_ops =3D &nios2_tcg_ops; } =20 static const TypeInfo nios2_cpu_type_info =3D { diff --git a/target/openrisc/cpu.c b/target/openrisc/cpu.c index 1a31f7564f..2c64842f46 100644 --- a/target/openrisc/cpu.c +++ b/target/openrisc/cpu.c @@ -174,6 +174,18 @@ static void openrisc_any_initfn(Object *obj) | (IMMUCFGR_NTS & (ctz32(TLB_SIZE) << 2)); } =20 +#include "hw/core/tcg-cpu-ops.h" + +static struct TCGCPUOps openrisc_tcg_ops =3D { + .initialize =3D openrisc_translate_init, + .cpu_exec_interrupt =3D openrisc_cpu_exec_interrupt, + .tlb_fill =3D openrisc_cpu_tlb_fill, + +#ifndef CONFIG_USER_ONLY + .do_interrupt =3D openrisc_cpu_do_interrupt, +#endif /* !CONFIG_USER_ONLY */ +}; + static void openrisc_cpu_class_init(ObjectClass *oc, void *data) { OpenRISCCPUClass *occ =3D OPENRISC_CPU_CLASS(oc); @@ -186,20 +198,17 @@ static void openrisc_cpu_class_init(ObjectClass *oc, = void *data) =20 cc->class_by_name =3D openrisc_cpu_class_by_name; cc->has_work =3D openrisc_cpu_has_work; - cc->tcg_ops.do_interrupt =3D openrisc_cpu_do_interrupt; - cc->tcg_ops.cpu_exec_interrupt =3D openrisc_cpu_exec_interrupt; cc->dump_state =3D openrisc_cpu_dump_state; cc->set_pc =3D openrisc_cpu_set_pc; cc->gdb_read_register =3D openrisc_cpu_gdb_read_register; cc->gdb_write_register =3D openrisc_cpu_gdb_write_register; - cc->tcg_ops.tlb_fill =3D openrisc_cpu_tlb_fill; #ifndef CONFIG_USER_ONLY cc->get_phys_page_debug =3D openrisc_cpu_get_phys_page_debug; dc->vmsd =3D &vmstate_openrisc_cpu; #endif cc->gdb_num_core_regs =3D 32 + 3; - cc->tcg_ops.initialize =3D openrisc_translate_init; cc->disas_set_info =3D openrisc_disas_set_info; + cc->tcg_ops =3D &openrisc_tcg_ops; } =20 /* Sort alphabetically by type name, except for "any". */ diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 7238a33b7b..e649cab2c1 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -557,6 +557,21 @@ static Property riscv_cpu_properties[] =3D { DEFINE_PROP_END_OF_LIST(), }; =20 +#include "hw/core/tcg-cpu-ops.h" + +static struct TCGCPUOps riscv_tcg_ops =3D { + .initialize =3D riscv_translate_init, + .synchronize_from_tb =3D riscv_cpu_synchronize_from_tb, + .cpu_exec_interrupt =3D riscv_cpu_exec_interrupt, + .tlb_fill =3D riscv_cpu_tlb_fill, + +#ifndef CONFIG_USER_ONLY + .do_interrupt =3D riscv_cpu_do_interrupt, + .do_transaction_failed =3D riscv_cpu_do_transaction_failed, + .do_unaligned_access =3D riscv_cpu_do_unaligned_access, +#endif /* !CONFIG_USER_ONLY */ +}; + static void riscv_cpu_class_init(ObjectClass *c, void *data) { RISCVCPUClass *mcc =3D RISCV_CPU_CLASS(c); @@ -570,11 +585,8 @@ static void riscv_cpu_class_init(ObjectClass *c, void = *data) =20 cc->class_by_name =3D riscv_cpu_class_by_name; cc->has_work =3D riscv_cpu_has_work; - cc->tcg_ops.do_interrupt =3D riscv_cpu_do_interrupt; - cc->tcg_ops.cpu_exec_interrupt =3D riscv_cpu_exec_interrupt; cc->dump_state =3D riscv_cpu_dump_state; cc->set_pc =3D riscv_cpu_set_pc; - cc->tcg_ops.synchronize_from_tb =3D riscv_cpu_synchronize_from_tb; cc->gdb_read_register =3D riscv_cpu_gdb_read_register; cc->gdb_write_register =3D riscv_cpu_gdb_write_register; cc->gdb_num_core_regs =3D 33; @@ -586,14 +598,11 @@ static void riscv_cpu_class_init(ObjectClass *c, void= *data) cc->gdb_stop_before_watchpoint =3D true; cc->disas_set_info =3D riscv_cpu_disas_set_info; #ifndef CONFIG_USER_ONLY - cc->tcg_ops.do_transaction_failed =3D riscv_cpu_do_transaction_failed; - cc->tcg_ops.do_unaligned_access =3D riscv_cpu_do_unaligned_access; cc->get_phys_page_debug =3D riscv_cpu_get_phys_page_debug; /* For now, mark unmigratable: */ cc->vmsd =3D &vmstate_riscv_cpu; #endif - cc->tcg_ops.initialize =3D riscv_translate_init; - cc->tcg_ops.tlb_fill =3D riscv_cpu_tlb_fill; + cc->tcg_ops =3D &riscv_tcg_ops; =20 device_class_set_props(dc, riscv_cpu_properties); } diff --git a/target/rx/cpu.c b/target/rx/cpu.c index e79f009cbd..7ac6618b26 100644 --- a/target/rx/cpu.c +++ b/target/rx/cpu.c @@ -173,6 +173,19 @@ static void rx_cpu_init(Object *obj) qdev_init_gpio_in(DEVICE(cpu), rx_cpu_set_irq, 2); } =20 +#include "hw/core/tcg-cpu-ops.h" + +static struct TCGCPUOps rx_tcg_ops =3D { + .initialize =3D rx_translate_init, + .synchronize_from_tb =3D rx_cpu_synchronize_from_tb, + .cpu_exec_interrupt =3D rx_cpu_exec_interrupt, + .tlb_fill =3D rx_cpu_tlb_fill, + +#ifndef CONFIG_USER_ONLY + .do_interrupt =3D rx_cpu_do_interrupt, +#endif /* !CONFIG_USER_ONLY */ +}; + static void rx_cpu_class_init(ObjectClass *klass, void *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); @@ -186,20 +199,17 @@ static void rx_cpu_class_init(ObjectClass *klass, voi= d *data) =20 cc->class_by_name =3D rx_cpu_class_by_name; cc->has_work =3D rx_cpu_has_work; - cc->tcg_ops.do_interrupt =3D rx_cpu_do_interrupt; - cc->tcg_ops.cpu_exec_interrupt =3D rx_cpu_exec_interrupt; cc->dump_state =3D rx_cpu_dump_state; cc->set_pc =3D rx_cpu_set_pc; - cc->tcg_ops.synchronize_from_tb =3D rx_cpu_synchronize_from_tb; + cc->gdb_read_register =3D rx_cpu_gdb_read_register; cc->gdb_write_register =3D rx_cpu_gdb_write_register; cc->get_phys_page_debug =3D rx_cpu_get_phys_page_debug; cc->disas_set_info =3D rx_cpu_disas_set_info; - cc->tcg_ops.initialize =3D rx_translate_init; - cc->tcg_ops.tlb_fill =3D rx_cpu_tlb_fill; =20 cc->gdb_num_core_regs =3D 26; cc->gdb_core_xml_file =3D "rx-core.xml"; + cc->tcg_ops =3D &rx_tcg_ops; } =20 static const TypeInfo rx_cpu_info =3D { diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c index a723ede8d1..d35eb39a1b 100644 --- a/target/s390x/cpu.c +++ b/target/s390x/cpu.c @@ -477,6 +477,22 @@ static void s390_cpu_reset_full(DeviceState *dev) return s390_cpu_reset(s, S390_CPU_RESET_CLEAR); } =20 +#ifdef CONFIG_TCG +#include "hw/core/tcg-cpu-ops.h" + +static struct TCGCPUOps s390_tcg_ops =3D { + .initialize =3D s390x_translate_init, + .tlb_fill =3D s390_cpu_tlb_fill, + +#if !defined(CONFIG_USER_ONLY) + .cpu_exec_interrupt =3D s390_cpu_exec_interrupt, + .do_interrupt =3D s390_cpu_do_interrupt, + .debug_excp_handler =3D s390x_cpu_debug_excp_handler, + .do_unaligned_access =3D s390x_cpu_do_unaligned_access, +#endif /* !CONFIG_USER_ONLY */ +}; +#endif /* CONFIG_TCG */ + static void s390_cpu_class_init(ObjectClass *oc, void *data) { S390CPUClass *scc =3D S390_CPU_CLASS(oc); @@ -495,9 +511,6 @@ static void s390_cpu_class_init(ObjectClass *oc, void *= data) scc->reset =3D s390_cpu_reset; cc->class_by_name =3D s390_cpu_class_by_name, cc->has_work =3D s390_cpu_has_work; -#ifdef CONFIG_TCG - cc->tcg_ops.do_interrupt =3D s390_cpu_do_interrupt; -#endif cc->dump_state =3D s390_cpu_dump_state; cc->set_pc =3D s390_cpu_set_pc; cc->gdb_read_register =3D s390_cpu_gdb_read_register; @@ -507,23 +520,17 @@ static void s390_cpu_class_init(ObjectClass *oc, void= *data) cc->vmsd =3D &vmstate_s390_cpu; cc->get_crash_info =3D s390_cpu_get_crash_info; cc->write_elf64_note =3D s390_cpu_write_elf64_note; -#ifdef CONFIG_TCG - cc->tcg_ops.cpu_exec_interrupt =3D s390_cpu_exec_interrupt; - cc->tcg_ops.debug_excp_handler =3D s390x_cpu_debug_excp_handler; - cc->tcg_ops.do_unaligned_access =3D s390x_cpu_do_unaligned_access; -#endif #endif cc->disas_set_info =3D s390_cpu_disas_set_info; -#ifdef CONFIG_TCG - cc->tcg_ops.initialize =3D s390x_translate_init; - cc->tcg_ops.tlb_fill =3D s390_cpu_tlb_fill; -#endif - cc->gdb_num_core_regs =3D S390_NUM_CORE_REGS; cc->gdb_core_xml_file =3D "s390x-core64.xml"; cc->gdb_arch_name =3D s390_gdb_arch_name; =20 s390_cpu_model_class_register_props(oc); + +#ifdef CONFIG_TCG + cc->tcg_ops =3D &s390_tcg_ops; +#endif /* CONFIG_TCG */ } =20 static const TypeInfo s390_cpu_type_info =3D { diff --git a/target/sh4/cpu.c b/target/sh4/cpu.c index 292152b562..a78d283bc8 100644 --- a/target/sh4/cpu.c +++ b/target/sh4/cpu.c @@ -206,6 +206,20 @@ static const VMStateDescription vmstate_sh_cpu =3D { .unmigratable =3D 1, }; =20 +#include "hw/core/tcg-cpu-ops.h" + +static struct TCGCPUOps superh_tcg_ops =3D { + .initialize =3D sh4_translate_init, + .synchronize_from_tb =3D superh_cpu_synchronize_from_tb, + .cpu_exec_interrupt =3D superh_cpu_exec_interrupt, + .tlb_fill =3D superh_cpu_tlb_fill, + +#ifndef CONFIG_USER_ONLY + .do_interrupt =3D superh_cpu_do_interrupt, + .do_unaligned_access =3D superh_cpu_do_unaligned_access, +#endif /* !CONFIG_USER_ONLY */ +}; + static void superh_cpu_class_init(ObjectClass *oc, void *data) { DeviceClass *dc =3D DEVICE_CLASS(oc); @@ -219,24 +233,19 @@ static void superh_cpu_class_init(ObjectClass *oc, vo= id *data) =20 cc->class_by_name =3D superh_cpu_class_by_name; cc->has_work =3D superh_cpu_has_work; - cc->tcg_ops.do_interrupt =3D superh_cpu_do_interrupt; - cc->tcg_ops.cpu_exec_interrupt =3D superh_cpu_exec_interrupt; cc->dump_state =3D superh_cpu_dump_state; cc->set_pc =3D superh_cpu_set_pc; - cc->tcg_ops.synchronize_from_tb =3D superh_cpu_synchronize_from_tb; cc->gdb_read_register =3D superh_cpu_gdb_read_register; cc->gdb_write_register =3D superh_cpu_gdb_write_register; - cc->tcg_ops.tlb_fill =3D superh_cpu_tlb_fill; #ifndef CONFIG_USER_ONLY - cc->tcg_ops.do_unaligned_access =3D superh_cpu_do_unaligned_access; cc->get_phys_page_debug =3D superh_cpu_get_phys_page_debug; #endif cc->disas_set_info =3D superh_cpu_disas_set_info; - cc->tcg_ops.initialize =3D sh4_translate_init; =20 cc->gdb_num_core_regs =3D 59; =20 dc->vmsd =3D &vmstate_sh_cpu; + cc->tcg_ops =3D &superh_tcg_ops; } =20 #define DEFINE_SUPERH_CPU_TYPE(type_name, cinit, initfn) \ diff --git a/target/sparc/cpu.c b/target/sparc/cpu.c index 1b785f60df..aece2c7dc8 100644 --- a/target/sparc/cpu.c +++ b/target/sparc/cpu.c @@ -848,6 +848,23 @@ static Property sparc_cpu_properties[] =3D { DEFINE_PROP_END_OF_LIST() }; =20 +#ifdef CONFIG_TCG +#include "hw/core/tcg-cpu-ops.h" + +static struct TCGCPUOps sparc_tcg_ops =3D { + .initialize =3D sparc_tcg_init, + .synchronize_from_tb =3D sparc_cpu_synchronize_from_tb, + .cpu_exec_interrupt =3D sparc_cpu_exec_interrupt, + .tlb_fill =3D sparc_cpu_tlb_fill, + +#ifndef CONFIG_USER_ONLY + .do_interrupt =3D sparc_cpu_do_interrupt, + .do_transaction_failed =3D sparc_cpu_do_transaction_failed, + .do_unaligned_access =3D sparc_cpu_do_unaligned_access, +#endif /* !CONFIG_USER_ONLY */ +}; +#endif /* CONFIG_TCG */ + static void sparc_cpu_class_init(ObjectClass *oc, void *data) { SPARCCPUClass *scc =3D SPARC_CPU_CLASS(oc); @@ -863,31 +880,25 @@ static void sparc_cpu_class_init(ObjectClass *oc, voi= d *data) cc->class_by_name =3D sparc_cpu_class_by_name; cc->parse_features =3D sparc_cpu_parse_features; cc->has_work =3D sparc_cpu_has_work; - cc->tcg_ops.do_interrupt =3D sparc_cpu_do_interrupt; - cc->tcg_ops.cpu_exec_interrupt =3D sparc_cpu_exec_interrupt; cc->dump_state =3D sparc_cpu_dump_state; #if !defined(TARGET_SPARC64) && !defined(CONFIG_USER_ONLY) cc->memory_rw_debug =3D sparc_cpu_memory_rw_debug; #endif cc->set_pc =3D sparc_cpu_set_pc; - cc->tcg_ops.synchronize_from_tb =3D sparc_cpu_synchronize_from_tb; cc->gdb_read_register =3D sparc_cpu_gdb_read_register; cc->gdb_write_register =3D sparc_cpu_gdb_write_register; - cc->tcg_ops.tlb_fill =3D sparc_cpu_tlb_fill; #ifndef CONFIG_USER_ONLY - cc->tcg_ops.do_transaction_failed =3D sparc_cpu_do_transaction_failed; - cc->tcg_ops.do_unaligned_access =3D sparc_cpu_do_unaligned_access; cc->get_phys_page_debug =3D sparc_cpu_get_phys_page_debug; cc->vmsd =3D &vmstate_sparc_cpu; #endif cc->disas_set_info =3D cpu_sparc_disas_set_info; - cc->tcg_ops.initialize =3D sparc_tcg_init; =20 #if defined(TARGET_SPARC64) && !defined(TARGET_ABI32) cc->gdb_num_core_regs =3D 86; #else cc->gdb_num_core_regs =3D 72; #endif + cc->tcg_ops =3D &sparc_tcg_ops; } =20 static const TypeInfo sparc_cpu_type_info =3D { diff --git a/target/tilegx/cpu.c b/target/tilegx/cpu.c index 7d4ead4ef1..d969c2f133 100644 --- a/target/tilegx/cpu.c +++ b/target/tilegx/cpu.c @@ -134,6 +134,18 @@ static bool tilegx_cpu_exec_interrupt(CPUState *cs, in= t interrupt_request) return false; } =20 +#include "hw/core/tcg-cpu-ops.h" + +static struct TCGCPUOps tilegx_tcg_ops =3D { + .initialize =3D tilegx_tcg_init, + .cpu_exec_interrupt =3D tilegx_cpu_exec_interrupt, + .tlb_fill =3D tilegx_cpu_tlb_fill, + +#ifndef CONFIG_USER_ONLY + .do_interrupt =3D tilegx_cpu_do_interrupt, +#endif /* !CONFIG_USER_ONLY */ +}; + static void tilegx_cpu_class_init(ObjectClass *oc, void *data) { DeviceClass *dc =3D DEVICE_CLASS(oc); @@ -147,13 +159,10 @@ static void tilegx_cpu_class_init(ObjectClass *oc, vo= id *data) =20 cc->class_by_name =3D tilegx_cpu_class_by_name; cc->has_work =3D tilegx_cpu_has_work; - cc->tcg_ops.do_interrupt =3D tilegx_cpu_do_interrupt; - cc->tcg_ops.cpu_exec_interrupt =3D tilegx_cpu_exec_interrupt; cc->dump_state =3D tilegx_cpu_dump_state; cc->set_pc =3D tilegx_cpu_set_pc; - cc->tcg_ops.tlb_fill =3D tilegx_cpu_tlb_fill; cc->gdb_num_core_regs =3D 0; - cc->tcg_ops.initialize =3D tilegx_tcg_init; + cc->tcg_ops =3D &tilegx_tcg_ops; } =20 static const TypeInfo tilegx_cpu_type_info =3D { diff --git a/target/tricore/cpu.c b/target/tricore/cpu.c index 9b21b640e2..0b1e139bcb 100644 --- a/target/tricore/cpu.c +++ b/target/tricore/cpu.c @@ -142,6 +142,14 @@ static void tc27x_initfn(Object *obj) set_feature(&cpu->env, TRICORE_FEATURE_161); } =20 +#include "hw/core/tcg-cpu-ops.h" + +static struct TCGCPUOps tricore_tcg_ops =3D { + .initialize =3D tricore_tcg_init, + .synchronize_from_tb =3D tricore_cpu_synchronize_from_tb, + .tlb_fill =3D tricore_cpu_tlb_fill, +}; + static void tricore_cpu_class_init(ObjectClass *c, void *data) { TriCoreCPUClass *mcc =3D TRICORE_CPU_CLASS(c); @@ -162,10 +170,8 @@ static void tricore_cpu_class_init(ObjectClass *c, voi= d *data) =20 cc->dump_state =3D tricore_cpu_dump_state; cc->set_pc =3D tricore_cpu_set_pc; - cc->tcg_ops.synchronize_from_tb =3D tricore_cpu_synchronize_from_tb; cc->get_phys_page_debug =3D tricore_cpu_get_phys_page_debug; - cc->tcg_ops.initialize =3D tricore_tcg_init; - cc->tcg_ops.tlb_fill =3D tricore_cpu_tlb_fill; + cc->tcg_ops =3D &tricore_tcg_ops; } =20 #define DEFINE_TRICORE_CPU_TYPE(cpu_model, initfn) \ diff --git a/target/unicore32/cpu.c b/target/unicore32/cpu.c index e27ffc571a..0258884f84 100644 --- a/target/unicore32/cpu.c +++ b/target/unicore32/cpu.c @@ -120,6 +120,18 @@ static const VMStateDescription vmstate_uc32_cpu =3D { .unmigratable =3D 1, }; =20 +#include "hw/core/tcg-cpu-ops.h" + +static struct TCGCPUOps uc32_tcg_ops =3D { + .initialize =3D uc32_translate_init, + .cpu_exec_interrupt =3D uc32_cpu_exec_interrupt, + .tlb_fill =3D uc32_cpu_tlb_fill, + +#ifndef CONFIG_USER_ONLY + .do_interrupt =3D uc32_cpu_do_interrupt, +#endif /* !CONFIG_USER_ONLY */ +}; + static void uc32_cpu_class_init(ObjectClass *oc, void *data) { DeviceClass *dc =3D DEVICE_CLASS(oc); @@ -131,14 +143,11 @@ static void uc32_cpu_class_init(ObjectClass *oc, void= *data) =20 cc->class_by_name =3D uc32_cpu_class_by_name; cc->has_work =3D uc32_cpu_has_work; - cc->tcg_ops.do_interrupt =3D uc32_cpu_do_interrupt; - cc->tcg_ops.cpu_exec_interrupt =3D uc32_cpu_exec_interrupt; cc->dump_state =3D uc32_cpu_dump_state; cc->set_pc =3D uc32_cpu_set_pc; - cc->tcg_ops.tlb_fill =3D uc32_cpu_tlb_fill; cc->get_phys_page_debug =3D uc32_cpu_get_phys_page_debug; - cc->tcg_ops.initialize =3D uc32_translate_init; dc->vmsd =3D &vmstate_uc32_cpu; + cc->tcg_ops =3D &uc32_tcg_ops; } =20 #define DEFINE_UNICORE32_CPU_TYPE(cpu_model, initfn) \ diff --git a/target/xtensa/cpu.c b/target/xtensa/cpu.c index 4b6381569f..e2b2c7a71c 100644 --- a/target/xtensa/cpu.c +++ b/target/xtensa/cpu.c @@ -181,6 +181,21 @@ static const VMStateDescription vmstate_xtensa_cpu =3D= { .unmigratable =3D 1, }; =20 +#include "hw/core/tcg-cpu-ops.h" + +static struct TCGCPUOps xtensa_tcg_ops =3D { + .initialize =3D xtensa_translate_init, + .cpu_exec_interrupt =3D xtensa_cpu_exec_interrupt, + .tlb_fill =3D xtensa_cpu_tlb_fill, + .debug_excp_handler =3D xtensa_breakpoint_handler, + +#ifndef CONFIG_USER_ONLY + .do_interrupt =3D xtensa_cpu_do_interrupt, + .do_transaction_failed =3D xtensa_cpu_do_transaction_failed, + .do_unaligned_access =3D xtensa_cpu_do_unaligned_access, +#endif /* !CONFIG_USER_ONLY */ +}; + static void xtensa_cpu_class_init(ObjectClass *oc, void *data) { DeviceClass *dc =3D DEVICE_CLASS(oc); @@ -194,23 +209,17 @@ static void xtensa_cpu_class_init(ObjectClass *oc, vo= id *data) =20 cc->class_by_name =3D xtensa_cpu_class_by_name; cc->has_work =3D xtensa_cpu_has_work; - cc->tcg_ops.do_interrupt =3D xtensa_cpu_do_interrupt; - cc->tcg_ops.cpu_exec_interrupt =3D xtensa_cpu_exec_interrupt; cc->dump_state =3D xtensa_cpu_dump_state; cc->set_pc =3D xtensa_cpu_set_pc; cc->gdb_read_register =3D xtensa_cpu_gdb_read_register; cc->gdb_write_register =3D xtensa_cpu_gdb_write_register; cc->gdb_stop_before_watchpoint =3D true; - cc->tcg_ops.tlb_fill =3D xtensa_cpu_tlb_fill; #ifndef CONFIG_USER_ONLY - cc->tcg_ops.do_unaligned_access =3D xtensa_cpu_do_unaligned_access; cc->get_phys_page_debug =3D xtensa_cpu_get_phys_page_debug; - cc->tcg_ops.do_transaction_failed =3D xtensa_cpu_do_transaction_failed; #endif - cc->tcg_ops.debug_excp_handler =3D xtensa_breakpoint_handler; cc->disas_set_info =3D xtensa_cpu_disas_set_info; - cc->tcg_ops.initialize =3D xtensa_translate_init; dc->vmsd =3D &vmstate_xtensa_cpu; + cc->tcg_ops =3D &xtensa_tcg_ops; } =20 static const TypeInfo xtensa_cpu_type_info =3D { diff --git a/target/ppc/translate_init.c.inc b/target/ppc/translate_init.c.= inc index 27ab243c6e..9867d0a6e4 100644 --- a/target/ppc/translate_init.c.inc +++ b/target/ppc/translate_init.c.inc @@ -10827,6 +10827,23 @@ static Property ppc_cpu_properties[] =3D { DEFINE_PROP_END_OF_LIST(), }; =20 +#ifdef CONFIG_TCG +#include "hw/core/tcg-cpu-ops.h" + +static struct TCGCPUOps ppc_tcg_ops =3D { + .initialize =3D ppc_translate_init, + .cpu_exec_interrupt =3D ppc_cpu_exec_interrupt, + .tlb_fill =3D ppc_cpu_tlb_fill, + +#ifndef CONFIG_USER_ONLY + .do_interrupt =3D ppc_cpu_do_interrupt, + .cpu_exec_enter =3D ppc_cpu_exec_enter, + .cpu_exec_exit =3D ppc_cpu_exec_exit, + .do_unaligned_access =3D ppc_cpu_do_unaligned_access, +#endif /* !CONFIG_USER_ONLY */ +}; +#endif /* CONFIG_TCG */ + static void ppc_cpu_class_init(ObjectClass *oc, void *data) { PowerPCCPUClass *pcc =3D POWERPC_CPU_CLASS(oc); @@ -10878,21 +10895,13 @@ static void ppc_cpu_class_init(ObjectClass *oc, v= oid *data) #ifndef CONFIG_USER_ONLY cc->virtio_is_big_endian =3D ppc_cpu_is_big_endian; #endif -#ifdef CONFIG_TCG - cc->tcg_ops.initialize =3D ppc_translate_init; - cc->tcg_ops.cpu_exec_interrupt =3D ppc_cpu_exec_interrupt; - cc->tcg_ops.do_interrupt =3D ppc_cpu_do_interrupt; - cc->tcg_ops.tlb_fill =3D ppc_cpu_tlb_fill; -#ifndef CONFIG_USER_ONLY - cc->tcg_ops.cpu_exec_enter =3D ppc_cpu_exec_enter; - cc->tcg_ops.cpu_exec_exit =3D ppc_cpu_exec_exit; - cc->tcg_ops.do_unaligned_access =3D ppc_cpu_do_unaligned_access; -#endif /* !CONFIG_USER_ONLY */ -#endif /* CONFIG_TCG */ - cc->disas_set_info =3D ppc_disas_set_info; =20 dc->fw_name =3D "PowerPC,UNKNOWN"; + +#ifdef CONFIG_TCG + cc->tcg_ops =3D &ppc_tcg_ops; +#endif /* CONFIG_TCG */ } =20 static const TypeInfo ppc_cpu_type_info =3D { diff --git a/MAINTAINERS b/MAINTAINERS index 4be087b88e..fd052e92ff 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -129,6 +129,7 @@ F: include/exec/helper*.h F: include/exec/tb-hash.h F: include/sysemu/cpus.h F: include/sysemu/tcg.h +F: include/hw/core/tcg-cpu-ops.h =20 FPU emulation M: Aurelien Jarno --=20 2.26.2 From nobody Thu Apr 25 18:08:54 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=1610475531; cv=none; d=zohomail.com; s=zohoarc; b=GSXFeG4Bzf2wW/HoMqOZ62G70ja1OhrjbZ3eMB1cWoGAy4Vard7WWirAPwykH4LWSzwXDMfIUEt+GHUWt165Yv4Tm5qUWBe9sCP79qwen/x90lgnF8aw6cqn/UMfnfYjt9sHQDQeuUQfS9I5vQCWCNXXt34vV5Kmd7SN0UmjPJo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610475531; h=Content-Type: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=QW7sY4cDgElImdVt90GpIojeQNDcYsETy+JSJn3s1tY=; b=DUxoLJpK39mt8CJFs0P7UnwaXfwocGIN8frGP5y1yLlroL0kdB//talT0e7WLvlwolWXUDMJn0olQ/JEg6a0SnGTFbBZEQ3tSMDRdx7izQ+/oDNEVNAojHFHRYet6Wh94RNELrik6Kbanohx61BNgSAPH4EvrQk0GNcrS0IHyBo= 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 1610475531502303.98060886398787; Tue, 12 Jan 2021 10:18:51 -0800 (PST) Received: from localhost ([::1]:59722 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kzOFl-0005KY-Rr for importer@patchew.org; Tue, 12 Jan 2021 13:18:49 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48190) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kzO1L-0005V5-Ue for qemu-devel@nongnu.org; Tue, 12 Jan 2021 13:03:55 -0500 Received: from mx2.suse.de ([195.135.220.15]:33920) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kzO19-0004wx-PO for qemu-devel@nongnu.org; Tue, 12 Jan 2021 13:03:55 -0500 Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 7CD6FAD62; Tue, 12 Jan 2021 18:03:32 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Claudio Fontana To: Paolo Bonzini , Thomas Huth , Richard Henderson , Stefano Stabellini , Wenchao Wang , Roman Bolshakov , Sunil Muthuswamy , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v12 16/22] accel: extend AccelState and AccelClass to user-mode Date: Tue, 12 Jan 2021 19:03:06 +0100 Message-Id: <20210112180312.26043-17-cfontana@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210112180312.26043-1-cfontana@suse.de> References: <20210112180312.26043-1-cfontana@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 , Peter Maydell , Eduardo Habkost , Paul Durrant , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Jason Wang , Marcelo Tosatti , qemu-devel@nongnu.org, Peter Xu , Dario Faggioli , Cameron Esfahani , haxm-team@intel.com, Claudio Fontana , Anthony Perard , Bruce Rogers , Olaf Hering , "Emilio G . Cota" , Colin Xu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Claudio Fontana Reviewed-by: Alex Benn=C3=A9e [claudio: rebased on Richard's splitwx work] Signed-off-by: Claudio Fontana --- include/hw/boards.h | 2 +- include/{sysemu =3D> qemu}/accel.h | 14 +++++---- include/sysemu/hvf.h | 2 +- include/sysemu/kvm.h | 2 +- include/sysemu/kvm_int.h | 2 +- target/i386/hvf/hvf-i386.h | 2 +- accel/accel-common.c | 50 ++++++++++++++++++++++++++++++ accel/{accel.c =3D> accel-softmmu.c} | 27 ++-------------- accel/accel-user.c | 24 ++++++++++++++ accel/qtest/qtest.c | 2 +- accel/tcg/tcg-all.c | 15 +++++++-- accel/xen/xen-all.c | 2 +- bsd-user/main.c | 6 +++- linux-user/main.c | 6 +++- softmmu/memory.c | 2 +- softmmu/qtest.c | 2 +- softmmu/vl.c | 2 +- target/i386/hax/hax-all.c | 2 +- target/i386/hvf/hvf.c | 2 +- target/i386/hvf/x86_task.c | 2 +- target/i386/whpx/whpx-all.c | 2 +- MAINTAINERS | 2 +- accel/meson.build | 4 ++- accel/tcg/meson.build | 2 +- 24 files changed, 125 insertions(+), 53 deletions(-) rename include/{sysemu =3D> qemu}/accel.h (95%) create mode 100644 accel/accel-common.c rename accel/{accel.c =3D> accel-softmmu.c} (75%) create mode 100644 accel/accel-user.c diff --git a/include/hw/boards.h b/include/hw/boards.h index 17b1f3f0b9..85af4faf76 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -6,7 +6,7 @@ #include "exec/memory.h" #include "sysemu/hostmem.h" #include "sysemu/blockdev.h" -#include "sysemu/accel.h" +#include "qemu/accel.h" #include "qapi/qapi-types-machine.h" #include "qemu/module.h" #include "qom/object.h" diff --git a/include/sysemu/accel.h b/include/qemu/accel.h similarity index 95% rename from include/sysemu/accel.h rename to include/qemu/accel.h index e08b8ab8fa..fac4a18703 100644 --- a/include/sysemu/accel.h +++ b/include/qemu/accel.h @@ -20,8 +20,8 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS = IN * THE SOFTWARE. */ -#ifndef HW_ACCEL_H -#define HW_ACCEL_H +#ifndef QEMU_ACCEL_H +#define QEMU_ACCEL_H =20 #include "qom/object.h" #include "exec/hwaddr.h" @@ -37,8 +37,8 @@ typedef struct AccelClass { /*< public >*/ =20 const char *name; -#ifndef CONFIG_USER_ONLY int (*init_machine)(MachineState *ms); +#ifndef CONFIG_USER_ONLY void (*setup_post)(MachineState *ms, AccelState *accel); bool (*has_memory)(MachineState *ms, AddressSpace *as, hwaddr start_addr, hwaddr size); @@ -67,11 +67,13 @@ typedef struct AccelClass { OBJECT_GET_CLASS(AccelClass, (obj), TYPE_ACCEL) =20 AccelClass *accel_find(const char *opt_name); +AccelState *current_accel(void); + +#ifndef CONFIG_USER_ONLY int accel_init_machine(AccelState *accel, MachineState *ms); =20 /* Called just before os_setup_post (ie just before drop OS privs) */ void accel_setup_post(MachineState *ms); +#endif /* !CONFIG_USER_ONLY */ =20 -AccelState *current_accel(void); - -#endif +#endif /* QEMU_ACCEL_H */ diff --git a/include/sysemu/hvf.h b/include/sysemu/hvf.h index f893768df9..c98636bc81 100644 --- a/include/sysemu/hvf.h +++ b/include/sysemu/hvf.h @@ -13,7 +13,7 @@ #ifndef HVF_H #define HVF_H =20 -#include "sysemu/accel.h" +#include "qemu/accel.h" #include "qom/object.h" =20 #ifdef CONFIG_HVF diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h index bb5d5cf497..739682f3c3 100644 --- a/include/sysemu/kvm.h +++ b/include/sysemu/kvm.h @@ -17,7 +17,7 @@ #include "qemu/queue.h" #include "hw/core/cpu.h" #include "exec/memattrs.h" -#include "sysemu/accel.h" +#include "qemu/accel.h" #include "qom/object.h" =20 #ifdef NEED_CPU_H diff --git a/include/sysemu/kvm_int.h b/include/sysemu/kvm_int.h index 65740806da..ccb8869f01 100644 --- a/include/sysemu/kvm_int.h +++ b/include/sysemu/kvm_int.h @@ -10,7 +10,7 @@ #define QEMU_KVM_INT_H =20 #include "exec/memory.h" -#include "sysemu/accel.h" +#include "qemu/accel.h" #include "sysemu/kvm.h" =20 typedef struct KVMSlot diff --git a/target/i386/hvf/hvf-i386.h b/target/i386/hvf/hvf-i386.h index e0edffd077..50b914fd67 100644 --- a/target/i386/hvf/hvf-i386.h +++ b/target/i386/hvf/hvf-i386.h @@ -16,7 +16,7 @@ #ifndef HVF_I386_H #define HVF_I386_H =20 -#include "sysemu/accel.h" +#include "qemu/accel.h" #include "sysemu/hvf.h" #include "cpu.h" #include "x86.h" diff --git a/accel/accel-common.c b/accel/accel-common.c new file mode 100644 index 0000000000..ddec8cb5ae --- /dev/null +++ b/accel/accel-common.c @@ -0,0 +1,50 @@ +/* + * QEMU accel class, components common to system emulation and user mode + * + * Copyright (c) 2003-2008 Fabrice Bellard + * Copyright (c) 2014 Red Hat Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a= copy + * of this software and associated documentation files (the "Software"), t= o deal + * in the Software without restriction, including without limitation the r= ights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or se= ll + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included= in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS= OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OT= HER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING= FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS = IN + * THE SOFTWARE. + */ + +#include "qemu/osdep.h" +#include "qemu/accel.h" + +static const TypeInfo accel_type =3D { + .name =3D TYPE_ACCEL, + .parent =3D TYPE_OBJECT, + .class_size =3D sizeof(AccelClass), + .instance_size =3D sizeof(AccelState), +}; + +/* Lookup AccelClass from opt_name. Returns NULL if not found */ +AccelClass *accel_find(const char *opt_name) +{ + char *class_name =3D g_strdup_printf(ACCEL_CLASS_NAME("%s"), opt_name); + AccelClass *ac =3D ACCEL_CLASS(object_class_by_name(class_name)); + g_free(class_name); + return ac; +} + +static void register_accel_types(void) +{ + type_register_static(&accel_type); +} + +type_init(register_accel_types); diff --git a/accel/accel.c b/accel/accel-softmmu.c similarity index 75% rename from accel/accel.c rename to accel/accel-softmmu.c index cb555e3b06..f89da8f9d1 100644 --- a/accel/accel.c +++ b/accel/accel-softmmu.c @@ -1,5 +1,5 @@ /* - * QEMU System Emulator, accelerator interfaces + * QEMU accel class, system emulation components * * Copyright (c) 2003-2008 Fabrice Bellard * Copyright (c) 2014 Red Hat Inc. @@ -24,28 +24,12 @@ */ =20 #include "qemu/osdep.h" -#include "sysemu/accel.h" +#include "qemu/accel.h" #include "hw/boards.h" #include "sysemu/arch_init.h" #include "sysemu/sysemu.h" #include "qom/object.h" =20 -static const TypeInfo accel_type =3D { - .name =3D TYPE_ACCEL, - .parent =3D TYPE_OBJECT, - .class_size =3D sizeof(AccelClass), - .instance_size =3D sizeof(AccelState), -}; - -/* Lookup AccelClass from opt_name. Returns NULL if not found */ -AccelClass *accel_find(const char *opt_name) -{ - char *class_name =3D g_strdup_printf(ACCEL_CLASS_NAME("%s"), opt_name); - AccelClass *ac =3D ACCEL_CLASS(object_class_by_name(class_name)); - g_free(class_name); - return ac; -} - int accel_init_machine(AccelState *accel, MachineState *ms) { AccelClass *acc =3D ACCEL_GET_CLASS(accel); @@ -76,10 +60,3 @@ void accel_setup_post(MachineState *ms) acc->setup_post(ms, accel); } } - -static void register_accel_types(void) -{ - type_register_static(&accel_type); -} - -type_init(register_accel_types); diff --git a/accel/accel-user.c b/accel/accel-user.c new file mode 100644 index 0000000000..26bdda6236 --- /dev/null +++ b/accel/accel-user.c @@ -0,0 +1,24 @@ +/* + * QEMU accel class, user-mode components + * + * Copyright 2020 SUSE LLC + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" +#include "qemu/accel.h" + +AccelState *current_accel(void) +{ + static AccelState *accel; + + if (!accel) { + AccelClass *ac =3D accel_find("tcg"); + + g_assert(ac !=3D NULL); + accel =3D ACCEL(object_new_with_class(OBJECT_CLASS(ac))); + } + return accel; +} diff --git a/accel/qtest/qtest.c b/accel/qtest/qtest.c index b282cea5cf..b4e731cb2b 100644 --- a/accel/qtest/qtest.c +++ b/accel/qtest/qtest.c @@ -17,7 +17,7 @@ #include "qemu/module.h" #include "qemu/option.h" #include "qemu/config-file.h" -#include "sysemu/accel.h" +#include "qemu/accel.h" #include "sysemu/qtest.h" #include "sysemu/cpus.h" #include "sysemu/cpu-timers.h" diff --git a/accel/tcg/tcg-all.c b/accel/tcg/tcg-all.c index 2eea8c32ee..642a7b94a7 100644 --- a/accel/tcg/tcg-all.c +++ b/accel/tcg/tcg-all.c @@ -30,9 +30,12 @@ #include "tcg/tcg.h" #include "qapi/error.h" #include "qemu/error-report.h" -#include "hw/boards.h" +#include "qemu/accel.h" #include "qapi/qapi-builtin-visit.h" + +#ifndef CONFIG_USER_ONLY #include "tcg-cpus.h" +#endif /* CONFIG_USER_ONLY */ =20 struct TCGState { AccelState parent_obj; @@ -97,7 +100,7 @@ static void tcg_accel_instance_init(Object *obj) s->mttcg_enabled =3D default_mttcg_enabled(); =20 /* If debugging enabled, default "auto on", otherwise off. */ -#ifdef CONFIG_DEBUG_TCG +#if defined(CONFIG_DEBUG_TCG) && !defined(CONFIG_USER_ONLY) s->splitwx_enabled =3D -1; #else s->splitwx_enabled =3D 0; @@ -114,8 +117,12 @@ static int tcg_init(MachineState *ms) mttcg_enabled =3D s->mttcg_enabled; =20 /* - * Initialize TCG regions + * Initialize TCG regions only for softmmu. + * + * This needs to be done later for user mode, because the prologue + * generation needs to be delayed so that GUEST_BASE is already set. */ +#ifndef CONFIG_USER_ONLY tcg_region_init(); =20 if (mttcg_enabled) { @@ -125,6 +132,8 @@ static int tcg_init(MachineState *ms) } else { cpus_register_accel(&tcg_cpus_rr); } +#endif /* !CONFIG_USER_ONLY */ + return 0; } =20 diff --git a/accel/xen/xen-all.c b/accel/xen/xen-all.c index 878a4089d9..594aaf6b49 100644 --- a/accel/xen/xen-all.c +++ b/accel/xen/xen-all.c @@ -15,7 +15,7 @@ #include "hw/xen/xen-legacy-backend.h" #include "hw/xen/xen_pt.h" #include "chardev/char.h" -#include "sysemu/accel.h" +#include "qemu/accel.h" #include "sysemu/cpus.h" #include "sysemu/xen.h" #include "sysemu/runstate.h" diff --git a/bsd-user/main.c b/bsd-user/main.c index 65163e1396..6501164e05 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -20,6 +20,7 @@ #include "qemu/osdep.h" #include "qemu-common.h" #include "qemu/units.h" +#include "qemu/accel.h" #include "sysemu/tcg.h" #include "qemu-version.h" #include @@ -909,8 +910,11 @@ int main(int argc, char **argv) } =20 /* init tcg before creating CPUs and to get qemu_host_page_size */ - tcg_exec_init(0, false); + { + AccelClass *ac =3D ACCEL_GET_CLASS(current_accel()); =20 + ac->init_machine(NULL); + } cpu_type =3D parse_cpu_option(cpu_model); cpu =3D cpu_create(cpu_type); env =3D cpu->env_ptr; diff --git a/linux-user/main.c b/linux-user/main.c index bb4e55e8fc..7ed23d9a29 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -20,6 +20,7 @@ #include "qemu/osdep.h" #include "qemu-common.h" #include "qemu/units.h" +#include "qemu/accel.h" #include "sysemu/tcg.h" #include "qemu-version.h" #include @@ -701,8 +702,11 @@ int main(int argc, char **argv, char **envp) cpu_type =3D parse_cpu_option(cpu_model); =20 /* init tcg before creating CPUs and to get qemu_host_page_size */ - tcg_exec_init(0, false); + { + AccelClass *ac =3D ACCEL_GET_CLASS(current_accel()); =20 + ac->init_machine(NULL); + } cpu =3D cpu_create(cpu_type); env =3D cpu->env_ptr; cpu_reset(cpu); diff --git a/softmmu/memory.c b/softmmu/memory.c index 333e1ed7b0..3381cfe308 100644 --- a/softmmu/memory.c +++ b/softmmu/memory.c @@ -32,7 +32,7 @@ #include "sysemu/kvm.h" #include "sysemu/runstate.h" #include "sysemu/tcg.h" -#include "sysemu/accel.h" +#include "qemu/accel.h" #include "hw/boards.h" #include "migration/vmstate.h" =20 diff --git a/softmmu/qtest.c b/softmmu/qtest.c index 7965dc9a16..130c366615 100644 --- a/softmmu/qtest.c +++ b/softmmu/qtest.c @@ -20,7 +20,7 @@ #include "exec/ioport.h" #include "exec/memory.h" #include "hw/irq.h" -#include "sysemu/accel.h" +#include "qemu/accel.h" #include "sysemu/cpu-timers.h" #include "qemu/config-file.h" #include "qemu/option.h" diff --git a/softmmu/vl.c b/softmmu/vl.c index 7ddf405d76..7514194132 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -44,7 +44,7 @@ =20 #include "qemu/error-report.h" #include "qemu/sockets.h" -#include "sysemu/accel.h" +#include "qemu/accel.h" #include "hw/usb.h" #include "hw/isa/isa.h" #include "hw/scsi/scsi.h" diff --git a/target/i386/hax/hax-all.c b/target/i386/hax/hax-all.c index fecfe8cd6e..d7f4bb44a7 100644 --- a/target/i386/hax/hax-all.c +++ b/target/i386/hax/hax-all.c @@ -28,7 +28,7 @@ #include "exec/address-spaces.h" =20 #include "qemu-common.h" -#include "sysemu/accel.h" +#include "qemu/accel.h" #include "sysemu/reset.h" #include "sysemu/runstate.h" #include "hw/boards.h" diff --git a/target/i386/hvf/hvf.c b/target/i386/hvf/hvf.c index ed9356565c..ffc9efa40f 100644 --- a/target/i386/hvf/hvf.c +++ b/target/i386/hvf/hvf.c @@ -69,7 +69,7 @@ #include "exec/address-spaces.h" #include "hw/i386/apic_internal.h" #include "qemu/main-loop.h" -#include "sysemu/accel.h" +#include "qemu/accel.h" #include "target/i386/cpu.h" =20 #include "hvf-cpus.h" diff --git a/target/i386/hvf/x86_task.c b/target/i386/hvf/x86_task.c index 6f04478b3a..d66dfd7669 100644 --- a/target/i386/hvf/x86_task.c +++ b/target/i386/hvf/x86_task.c @@ -28,7 +28,7 @@ =20 #include "hw/i386/apic_internal.h" #include "qemu/main-loop.h" -#include "sysemu/accel.h" +#include "qemu/accel.h" #include "target/i386/cpu.h" =20 // TODO: taskswitch handling diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c index 3b824fc9d7..b568eb5f1d 100644 --- a/target/i386/whpx/whpx-all.c +++ b/target/i386/whpx/whpx-all.c @@ -13,7 +13,7 @@ #include "exec/address-spaces.h" #include "exec/ioport.h" #include "qemu-common.h" -#include "sysemu/accel.h" +#include "qemu/accel.h" #include "sysemu/whpx.h" #include "sysemu/cpus.h" #include "sysemu/runstate.h" diff --git a/MAINTAINERS b/MAINTAINERS index fd052e92ff..485594eea9 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -438,7 +438,7 @@ Overall M: Richard Henderson R: Paolo Bonzini S: Maintained -F: include/sysemu/accel.h +F: include/qemu/accel.h F: accel/accel.c F: accel/Makefile.objs F: accel/stubs/Makefile.objs diff --git a/accel/meson.build b/accel/meson.build index b26cca227a..b44ba30c86 100644 --- a/accel/meson.build +++ b/accel/meson.build @@ -1,4 +1,6 @@ -softmmu_ss.add(files('accel.c')) +specific_ss.add(files('accel-common.c')) +softmmu_ss.add(files('accel-softmmu.c')) +user_ss.add(files('accel-user.c')) =20 subdir('qtest') subdir('kvm') diff --git a/accel/tcg/meson.build b/accel/tcg/meson.build index f39aab0a0c..424d9bb1fc 100644 --- a/accel/tcg/meson.build +++ b/accel/tcg/meson.build @@ -1,5 +1,6 @@ tcg_ss =3D ss.source_set() tcg_ss.add(files( + 'tcg-all.c', 'cpu-exec-common.c', 'cpu-exec.c', 'tcg-runtime-gvec.c', @@ -13,7 +14,6 @@ tcg_ss.add(when: 'CONFIG_PLUGIN', if_true: [files('plugin= -gen.c'), libdl]) specific_ss.add_all(when: 'CONFIG_TCG', if_true: tcg_ss) =20 specific_ss.add(when: ['CONFIG_SOFTMMU', 'CONFIG_TCG'], if_true: files( - 'tcg-all.c', 'cputlb.c', 'tcg-cpus.c', 'tcg-cpus-mttcg.c', --=20 2.26.2 From nobody Thu Apr 25 18:08:54 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=1610475418; cv=none; d=zohomail.com; s=zohoarc; b=ZLHNznxgi6Y5DRHrwRjo+4/O/SOTh489CDVZ0pmhMCTsc/QvbPrSNKUQeUefloYuS7n9nsKbRngYdfHr4Fyijw7S3JOLzIIA+XNKr/2GJOCDQM5pty0tEkspV8IEWTmgtuEGgN8b3xO41SaIzfaGEuZZ+DLK74DIWjHMJj5sSEs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610475418; 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=zrBPQfUHE+g1a0RL2z5YpJ8LyEz1R09qLBpVEJO05nA=; b=foUSGoywJWz4qWuI0pkgaRk0vZMfpvmFnHV+7ulBjmus2xofqyY3Ihn0A4idNUENeGAozRvJWrXTtMPFFYDw31e2AC7wWdYP3puLOVZlZOey5LzGwQA53Jxxzpy2fkvATKopAVLGyN61qkYJ5G2mYP/4agKUnQk+42G1xPlGgko= 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 1610475418185822.1829944010595; Tue, 12 Jan 2021 10:16:58 -0800 (PST) Received: from localhost ([::1]:54760 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kzODw-0003Gn-LF for importer@patchew.org; Tue, 12 Jan 2021 13:16:56 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48230) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kzO1P-0005d5-5r for qemu-devel@nongnu.org; Tue, 12 Jan 2021 13:03:59 -0500 Received: from mx2.suse.de ([195.135.220.15]:33950) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kzO1A-0004x4-PP for qemu-devel@nongnu.org; Tue, 12 Jan 2021 13:03:58 -0500 Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 7F864AD6A; Tue, 12 Jan 2021 18:03:33 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Claudio Fontana To: Paolo Bonzini , Thomas Huth , Richard Henderson , Stefano Stabellini , Wenchao Wang , Roman Bolshakov , Sunil Muthuswamy , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v12 17/22] accel: replace struct CpusAccel with AccelOpsClass Date: Tue, 12 Jan 2021 19:03:07 +0100 Message-Id: <20210112180312.26043-18-cfontana@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210112180312.26043-1-cfontana@suse.de> References: <20210112180312.26043-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 , Peter Maydell , Eduardo Habkost , Paul Durrant , Jason Wang , Marcelo Tosatti , qemu-devel@nongnu.org, Peter Xu , Dario Faggioli , Cameron Esfahani , haxm-team@intel.com, Claudio Fontana , Anthony Perard , Bruce Rogers , Olaf Hering , "Emilio G . Cota" , Colin Xu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" also centralize the registration of the cpus.c module accelerator operations in accel/accel-softmmu.c Consequently, rename all tcg-cpus.c, kvm-cpus.c etc to tcg-accel-ops.c, kvm-accel-ops.c etc, also matching the object type names. Signed-off-by: Claudio Fontana --- accel/accel-softmmu.h | 15 ++++++ accel/kvm/kvm-cpus.h | 2 - ...g-cpus-icount.h =3D> tcg-accel-ops-icount.h} | 2 + accel/tcg/tcg-accel-ops-mttcg.h | 19 ++++++++ .../tcg/{tcg-cpus-rr.h =3D> tcg-accel-ops-rr.h} | 0 accel/tcg/{tcg-cpus.h =3D> tcg-accel-ops.h} | 6 +-- include/qemu/accel.h | 2 + include/sysemu/accel-ops.h | 45 ++++++++++++++++++ include/sysemu/cpus.h | 26 ++-------- .../i386/hax/{hax-cpus.h =3D> hax-accel-ops.h} | 2 - target/i386/hax/hax-windows.h | 2 +- .../i386/hvf/{hvf-cpus.h =3D> hvf-accel-ops.h} | 2 - .../whpx/{whpx-cpus.h =3D> whpx-accel-ops.h} | 2 - accel/accel-common.c | 11 +++++ accel/accel-softmmu.c | 43 +++++++++++++++-- accel/kvm/{kvm-cpus.c =3D> kvm-accel-ops.c} | 26 +++++++--- accel/kvm/kvm-all.c | 2 - accel/qtest/qtest.c | 23 ++++++--- ...g-cpus-icount.c =3D> tcg-accel-ops-icount.c} | 21 +++------ ...tcg-cpus-mttcg.c =3D> tcg-accel-ops-mttcg.c} | 14 ++---- .../tcg/{tcg-cpus-rr.c =3D> tcg-accel-ops-rr.c} | 13 ++--- accel/tcg/{tcg-cpus.c =3D> tcg-accel-ops.c} | 47 ++++++++++++++++++- accel/tcg/tcg-all.c | 12 ----- accel/xen/xen-all.c | 22 ++++++--- bsd-user/main.c | 3 +- linux-user/main.c | 1 + softmmu/cpus.c | 12 ++--- softmmu/vl.c | 7 ++- .../i386/hax/{hax-cpus.c =3D> hax-accel-ops.c} | 31 ++++++++---- target/i386/hax/hax-all.c | 5 +- target/i386/hax/hax-mem.c | 2 +- target/i386/hax/hax-posix.c | 2 +- target/i386/hax/hax-windows.c | 2 +- .../i386/hvf/{hvf-cpus.c =3D> hvf-accel-ops.c} | 29 +++++++++--- target/i386/hvf/hvf.c | 3 +- target/i386/hvf/x86hvf.c | 2 +- .../whpx/{whpx-cpus.c =3D> whpx-accel-ops.c} | 31 ++++++++---- target/i386/whpx/whpx-all.c | 4 +- MAINTAINERS | 3 +- accel/kvm/meson.build | 2 +- accel/tcg/meson.build | 8 ++-- target/i386/hax/meson.build | 2 +- target/i386/hvf/meson.build | 2 +- target/i386/whpx/meson.build | 2 +- 44 files changed, 350 insertions(+), 162 deletions(-) create mode 100644 accel/accel-softmmu.h rename accel/tcg/{tcg-cpus-icount.h =3D> tcg-accel-ops-icount.h} (88%) create mode 100644 accel/tcg/tcg-accel-ops-mttcg.h rename accel/tcg/{tcg-cpus-rr.h =3D> tcg-accel-ops-rr.h} (100%) rename accel/tcg/{tcg-cpus.h =3D> tcg-accel-ops.h} (72%) create mode 100644 include/sysemu/accel-ops.h rename target/i386/hax/{hax-cpus.h =3D> hax-accel-ops.h} (95%) rename target/i386/hvf/{hvf-cpus.h =3D> hvf-accel-ops.h} (94%) rename target/i386/whpx/{whpx-cpus.h =3D> whpx-accel-ops.h} (96%) rename accel/kvm/{kvm-cpus.c =3D> kvm-accel-ops.c} (72%) rename accel/tcg/{tcg-cpus-icount.c =3D> tcg-accel-ops-icount.c} (89%) rename accel/tcg/{tcg-cpus-mttcg.c =3D> tcg-accel-ops-mttcg.c} (92%) rename accel/tcg/{tcg-cpus-rr.c =3D> tcg-accel-ops-rr.c} (97%) rename accel/tcg/{tcg-cpus.c =3D> tcg-accel-ops.c} (63%) rename target/i386/hax/{hax-cpus.c =3D> hax-accel-ops.c} (69%) rename target/i386/hvf/{hvf-cpus.c =3D> hvf-accel-ops.c} (84%) rename target/i386/whpx/{whpx-cpus.c =3D> whpx-accel-ops.c} (72%) diff --git a/accel/accel-softmmu.h b/accel/accel-softmmu.h new file mode 100644 index 0000000000..2877b5c234 --- /dev/null +++ b/accel/accel-softmmu.h @@ -0,0 +1,15 @@ +/* + * QEMU System Emulation accel internal functions + * + * Copyright 2020 SUSE LLC + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#ifndef ACCEL_SOFTMMU_H +#define ACCEL_SOFTMMU_H + +void accel_init_ops_interfaces(AccelClass *ac); + +#endif /* ACCEL_SOFTMMU_H */ diff --git a/accel/kvm/kvm-cpus.h b/accel/kvm/kvm-cpus.h index 3df732b816..bf0bd1bee4 100644 --- a/accel/kvm/kvm-cpus.h +++ b/accel/kvm/kvm-cpus.h @@ -12,8 +12,6 @@ =20 #include "sysemu/cpus.h" =20 -extern const CpusAccel kvm_cpus; - int kvm_init_vcpu(CPUState *cpu, Error **errp); int kvm_cpu_exec(CPUState *cpu); void kvm_destroy_vcpu(CPUState *cpu); diff --git a/accel/tcg/tcg-cpus-icount.h b/accel/tcg/tcg-accel-ops-icount.h similarity index 88% rename from accel/tcg/tcg-cpus-icount.h rename to accel/tcg/tcg-accel-ops-icount.h index b695939dfa..d884aa2aaa 100644 --- a/accel/tcg/tcg-cpus-icount.h +++ b/accel/tcg/tcg-accel-ops-icount.h @@ -14,4 +14,6 @@ void icount_handle_deadline(void); void icount_prepare_for_run(CPUState *cpu); void icount_process_data(CPUState *cpu); =20 +void icount_handle_interrupt(CPUState *cpu, int mask); + #endif /* TCG_CPUS_ICOUNT_H */ diff --git a/accel/tcg/tcg-accel-ops-mttcg.h b/accel/tcg/tcg-accel-ops-mttc= g.h new file mode 100644 index 0000000000..0af91dd3b3 --- /dev/null +++ b/accel/tcg/tcg-accel-ops-mttcg.h @@ -0,0 +1,19 @@ +/* + * QEMU TCG Multi Threaded vCPUs implementation + * + * Copyright 2020 SUSE LLC + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#ifndef TCG_CPUS_MTTCG_H +#define TCG_CPUS_MTTCG_H + +/* kick MTTCG vCPU thread */ +void mttcg_kick_vcpu_thread(CPUState *cpu); + +/* start an mttcg vCPU thread */ +void mttcg_start_vcpu_thread(CPUState *cpu); + +#endif /* TCG_CPUS_MTTCG_H */ diff --git a/accel/tcg/tcg-cpus-rr.h b/accel/tcg/tcg-accel-ops-rr.h similarity index 100% rename from accel/tcg/tcg-cpus-rr.h rename to accel/tcg/tcg-accel-ops-rr.h diff --git a/accel/tcg/tcg-cpus.h b/accel/tcg/tcg-accel-ops.h similarity index 72% rename from accel/tcg/tcg-cpus.h rename to accel/tcg/tcg-accel-ops.h index d6893a32f8..48130006de 100644 --- a/accel/tcg/tcg-cpus.h +++ b/accel/tcg/tcg-accel-ops.h @@ -14,12 +14,8 @@ =20 #include "sysemu/cpus.h" =20 -extern const CpusAccel tcg_cpus_mttcg; -extern const CpusAccel tcg_cpus_icount; -extern const CpusAccel tcg_cpus_rr; - void tcg_cpus_destroy(CPUState *cpu); int tcg_cpus_exec(CPUState *cpu); -void tcg_cpus_handle_interrupt(CPUState *cpu, int mask); +void tcg_handle_interrupt(CPUState *cpu, int mask); =20 #endif /* TCG_CPUS_H */ diff --git a/include/qemu/accel.h b/include/qemu/accel.h index fac4a18703..b9d6d69eb8 100644 --- a/include/qemu/accel.h +++ b/include/qemu/accel.h @@ -69,6 +69,8 @@ typedef struct AccelClass { AccelClass *accel_find(const char *opt_name); AccelState *current_accel(void); =20 +void accel_init_interfaces(AccelClass *ac); + #ifndef CONFIG_USER_ONLY int accel_init_machine(AccelState *accel, MachineState *ms); =20 diff --git a/include/sysemu/accel-ops.h b/include/sysemu/accel-ops.h new file mode 100644 index 0000000000..6102d2f80d --- /dev/null +++ b/include/sysemu/accel-ops.h @@ -0,0 +1,45 @@ +/* + * Accelerator OPS, used for cpus.c module + * + * Copyright 2020 SUSE LLC + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#ifndef ACCEL_OPS_H +#define ACCEL_OPS_H + +#include "qom/object.h" + +#define ACCEL_OPS_SUFFIX "-ops" +#define TYPE_ACCEL_OPS "accel" ACCEL_OPS_SUFFIX +#define ACCEL_OPS_NAME(name) (name "-" TYPE_ACCEL_OPS) + +typedef struct AccelOpsClass AccelOpsClass; +DECLARE_CLASS_CHECKERS(AccelOpsClass, ACCEL_OPS, TYPE_ACCEL_OPS) + +/* cpus.c operations interface */ +struct AccelOpsClass { + /*< private >*/ + ObjectClass parent_class; + /*< public >*/ + + /* initialization function called when accel is chosen */ + void (*ops_init)(AccelOpsClass *ops); + + void (*create_vcpu_thread)(CPUState *cpu); /* MANDATORY NON-NULL */ + void (*kick_vcpu_thread)(CPUState *cpu); + + void (*synchronize_post_reset)(CPUState *cpu); + void (*synchronize_post_init)(CPUState *cpu); + void (*synchronize_state)(CPUState *cpu); + void (*synchronize_pre_loadvm)(CPUState *cpu); + + void (*handle_interrupt)(CPUState *cpu, int mask); + + int64_t (*get_virtual_clock)(void); + int64_t (*get_elapsed_ticks)(void); +}; + +#endif /* ACCEL_OPS_H */ diff --git a/include/sysemu/cpus.h b/include/sysemu/cpus.h index e8156728c6..2cd74392e0 100644 --- a/include/sysemu/cpus.h +++ b/include/sysemu/cpus.h @@ -2,30 +2,14 @@ #define QEMU_CPUS_H =20 #include "qemu/timer.h" +#include "sysemu/accel-ops.h" =20 -/* cpus.c */ +/* register accel-specific operations */ +void cpus_register_accel(const AccelOpsClass *i); =20 -/* CPU execution threads */ +/* accel/dummy-cpus.c */ =20 -typedef struct CpusAccel { - void (*create_vcpu_thread)(CPUState *cpu); /* MANDATORY */ - void (*kick_vcpu_thread)(CPUState *cpu); - - void (*synchronize_post_reset)(CPUState *cpu); - void (*synchronize_post_init)(CPUState *cpu); - void (*synchronize_state)(CPUState *cpu); - void (*synchronize_pre_loadvm)(CPUState *cpu); - - void (*handle_interrupt)(CPUState *cpu, int mask); - - int64_t (*get_virtual_clock)(void); - int64_t (*get_elapsed_ticks)(void); -} CpusAccel; - -/* register accel-specific cpus interface implementation */ -void cpus_register_accel(const CpusAccel *i); - -/* Create a dummy vcpu for CpusAccel->create_vcpu_thread */ +/* Create a dummy vcpu for AccelOpsClass->create_vcpu_thread */ void dummy_start_vcpu_thread(CPUState *); =20 /* interface available for cpus accelerator threads */ diff --git a/target/i386/hax/hax-cpus.h b/target/i386/hax/hax-accel-ops.h similarity index 95% rename from target/i386/hax/hax-cpus.h rename to target/i386/hax/hax-accel-ops.h index ee8ab7a631..c7698519cd 100644 --- a/target/i386/hax/hax-cpus.h +++ b/target/i386/hax/hax-accel-ops.h @@ -12,8 +12,6 @@ =20 #include "sysemu/cpus.h" =20 -extern const CpusAccel hax_cpus; - #include "hax-interface.h" #include "hax-i386.h" =20 diff --git a/target/i386/hax/hax-windows.h b/target/i386/hax/hax-windows.h index a5ce12d663..b1f5d4f32f 100644 --- a/target/i386/hax/hax-windows.h +++ b/target/i386/hax/hax-windows.h @@ -23,7 +23,7 @@ #include #include =20 -#include "hax-cpus.h" +#include "hax-accel-ops.h" =20 #define HAX_INVALID_FD INVALID_HANDLE_VALUE =20 diff --git a/target/i386/hvf/hvf-cpus.h b/target/i386/hvf/hvf-accel-ops.h similarity index 94% rename from target/i386/hvf/hvf-cpus.h rename to target/i386/hvf/hvf-accel-ops.h index ced31b82c0..8f992da168 100644 --- a/target/i386/hvf/hvf-cpus.h +++ b/target/i386/hvf/hvf-accel-ops.h @@ -12,8 +12,6 @@ =20 #include "sysemu/cpus.h" =20 -extern const CpusAccel hvf_cpus; - int hvf_init_vcpu(CPUState *); int hvf_vcpu_exec(CPUState *); void hvf_cpu_synchronize_state(CPUState *); diff --git a/target/i386/whpx/whpx-cpus.h b/target/i386/whpx/whpx-accel-ops= .h similarity index 96% rename from target/i386/whpx/whpx-cpus.h rename to target/i386/whpx/whpx-accel-ops.h index bdb367d1d0..2dee6d61ea 100644 --- a/target/i386/whpx/whpx-cpus.h +++ b/target/i386/whpx/whpx-accel-ops.h @@ -12,8 +12,6 @@ =20 #include "sysemu/cpus.h" =20 -extern const CpusAccel whpx_cpus; - int whpx_init_vcpu(CPUState *cpu); int whpx_vcpu_exec(CPUState *cpu); void whpx_destroy_vcpu(CPUState *cpu); diff --git a/accel/accel-common.c b/accel/accel-common.c index ddec8cb5ae..6b59873419 100644 --- a/accel/accel-common.c +++ b/accel/accel-common.c @@ -26,6 +26,10 @@ #include "qemu/osdep.h" #include "qemu/accel.h" =20 +#ifndef CONFIG_USER_ONLY +#include "accel-softmmu.h" +#endif /* !CONFIG_USER_ONLY */ + static const TypeInfo accel_type =3D { .name =3D TYPE_ACCEL, .parent =3D TYPE_OBJECT, @@ -42,6 +46,13 @@ AccelClass *accel_find(const char *opt_name) return ac; } =20 +void accel_init_interfaces(AccelClass *ac) +{ +#ifndef CONFIG_USER_ONLY + accel_init_ops_interfaces(ac); +#endif /* !CONFIG_USER_ONLY */ +} + static void register_accel_types(void) { type_register_static(&accel_type); diff --git a/accel/accel-softmmu.c b/accel/accel-softmmu.c index f89da8f9d1..2d15d3f2f4 100644 --- a/accel/accel-softmmu.c +++ b/accel/accel-softmmu.c @@ -26,9 +26,9 @@ #include "qemu/osdep.h" #include "qemu/accel.h" #include "hw/boards.h" -#include "sysemu/arch_init.h" -#include "sysemu/sysemu.h" -#include "qom/object.h" +#include "sysemu/cpus.h" + +#include "accel-softmmu.h" =20 int accel_init_machine(AccelState *accel, MachineState *ms) { @@ -60,3 +60,40 @@ void accel_setup_post(MachineState *ms) acc->setup_post(ms, accel); } } + +/* initialize the arch-independent accel operation interfaces */ +void accel_init_ops_interfaces(AccelClass *ac) +{ + const char *ac_name; + char *ops_name; + AccelOpsClass *ops; + + ac_name =3D object_class_get_name(OBJECT_CLASS(ac)); + g_assert(ac_name !=3D NULL); + + ops_name =3D g_strdup_printf("%s" ACCEL_OPS_SUFFIX, ac_name); + ops =3D ACCEL_OPS_CLASS(object_class_by_name(ops_name)); + g_free(ops_name); + + /* + * all accelerators need to define ops, providing at least a mandatory + * non-NULL create_vcpu_thread operation. + */ + g_assert(ops !=3D NULL); + if (ops->ops_init) { + ops->ops_init(ops); + } + cpus_register_accel(ops); +} + +static const TypeInfo accel_ops_type_info =3D { + .name =3D TYPE_ACCEL_OPS, + .parent =3D TYPE_OBJECT, + .abstract =3D true, + .class_size =3D sizeof(AccelOpsClass), +}; +static void accel_softmmu_register_types(void) +{ + type_register_static(&accel_ops_type_info); +} +type_init(accel_softmmu_register_types); diff --git a/accel/kvm/kvm-cpus.c b/accel/kvm/kvm-accel-ops.c similarity index 72% rename from accel/kvm/kvm-cpus.c rename to accel/kvm/kvm-accel-ops.c index d809b1e74c..430d09de03 100644 --- a/accel/kvm/kvm-cpus.c +++ b/accel/kvm/kvm-accel-ops.c @@ -74,11 +74,25 @@ static void kvm_start_vcpu_thread(CPUState *cpu) cpu, QEMU_THREAD_JOINABLE); } =20 -const CpusAccel kvm_cpus =3D { - .create_vcpu_thread =3D kvm_start_vcpu_thread, +static void kvm_accel_ops_class_init(ObjectClass *oc, void *data) +{ + AccelOpsClass *ops =3D ACCEL_OPS_CLASS(oc); =20 - .synchronize_post_reset =3D kvm_cpu_synchronize_post_reset, - .synchronize_post_init =3D kvm_cpu_synchronize_post_init, - .synchronize_state =3D kvm_cpu_synchronize_state, - .synchronize_pre_loadvm =3D kvm_cpu_synchronize_pre_loadvm, + ops->create_vcpu_thread =3D kvm_start_vcpu_thread; + ops->synchronize_post_reset =3D kvm_cpu_synchronize_post_reset; + ops->synchronize_post_init =3D kvm_cpu_synchronize_post_init; + ops->synchronize_state =3D kvm_cpu_synchronize_state; + ops->synchronize_pre_loadvm =3D kvm_cpu_synchronize_pre_loadvm; }; +static const TypeInfo kvm_accel_ops_type =3D { + .name =3D ACCEL_OPS_NAME("kvm"), + + .parent =3D TYPE_ACCEL_OPS, + .class_init =3D kvm_accel_ops_class_init, + .abstract =3D true, +}; +static void kvm_accel_ops_register_types(void) +{ + type_register_static(&kvm_accel_ops_type); +} +type_init(kvm_accel_ops_register_types); diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index 389eaace72..d79302833d 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -2253,8 +2253,6 @@ static int kvm_init(MachineState *ms) ret =3D ram_block_discard_disable(true); assert(!ret); } - - cpus_register_accel(&kvm_cpus); return 0; =20 err: diff --git a/accel/qtest/qtest.c b/accel/qtest/qtest.c index b4e731cb2b..edb29f6fa4 100644 --- a/accel/qtest/qtest.c +++ b/accel/qtest/qtest.c @@ -25,14 +25,8 @@ #include "qemu/main-loop.h" #include "hw/core/cpu.h" =20 -const CpusAccel qtest_cpus =3D { - .create_vcpu_thread =3D dummy_start_vcpu_thread, - .get_virtual_clock =3D qtest_get_virtual_clock, -}; - static int qtest_init_accel(MachineState *ms) { - cpus_register_accel(&qtest_cpus); return 0; } =20 @@ -52,9 +46,26 @@ static const TypeInfo qtest_accel_type =3D { .class_init =3D qtest_accel_class_init, }; =20 +static void qtest_accel_ops_class_init(ObjectClass *oc, void *data) +{ + AccelOpsClass *ops =3D ACCEL_OPS_CLASS(oc); + + ops->create_vcpu_thread =3D dummy_start_vcpu_thread; + ops->get_virtual_clock =3D qtest_get_virtual_clock; +}; + +static const TypeInfo qtest_accel_ops_type =3D { + .name =3D ACCEL_OPS_NAME("qtest"), + + .parent =3D TYPE_ACCEL_OPS, + .class_init =3D qtest_accel_ops_class_init, + .abstract =3D true, +}; + static void qtest_type_init(void) { type_register_static(&qtest_accel_type); + type_register_static(&qtest_accel_ops_type); } =20 type_init(qtest_type_init); diff --git a/accel/tcg/tcg-cpus-icount.c b/accel/tcg/tcg-accel-ops-icount.c similarity index 89% rename from accel/tcg/tcg-cpus-icount.c rename to accel/tcg/tcg-accel-ops-icount.c index 9f45432275..87762b469c 100644 --- a/accel/tcg/tcg-cpus-icount.c +++ b/accel/tcg/tcg-accel-ops-icount.c @@ -32,9 +32,9 @@ #include "exec/exec-all.h" #include "hw/boards.h" =20 -#include "tcg-cpus.h" -#include "tcg-cpus-icount.h" -#include "tcg-cpus-rr.h" +#include "tcg-accel-ops.h" +#include "tcg-accel-ops-icount.h" +#include "tcg-accel-ops-rr.h" =20 static int64_t icount_get_limit(void) { @@ -93,7 +93,7 @@ void icount_prepare_for_run(CPUState *cpu) /* * These should always be cleared by icount_process_data after * each vCPU execution. However u16.high can be raised - * asynchronously by cpu_exit/cpu_interrupt/tcg_cpus_handle_interrupt + * asynchronously by cpu_exit/cpu_interrupt/tcg_handle_interrupt */ g_assert(cpu_neg(cpu)->icount_decr.u16.low =3D=3D 0); g_assert(cpu->icount_extra =3D=3D 0); @@ -125,23 +125,14 @@ void icount_process_data(CPUState *cpu) replay_mutex_unlock(); } =20 -static void icount_handle_interrupt(CPUState *cpu, int mask) +void icount_handle_interrupt(CPUState *cpu, int mask) { int old_mask =3D cpu->interrupt_request; =20 - tcg_cpus_handle_interrupt(cpu, mask); + tcg_handle_interrupt(cpu, mask); if (qemu_cpu_is_self(cpu) && !cpu->can_do_io && (mask & ~old_mask) !=3D 0) { cpu_abort(cpu, "Raised interrupt while not in I/O function"); } } - -const CpusAccel tcg_cpus_icount =3D { - .create_vcpu_thread =3D rr_start_vcpu_thread, - .kick_vcpu_thread =3D rr_kick_vcpu_thread, - - .handle_interrupt =3D icount_handle_interrupt, - .get_virtual_clock =3D icount_get, - .get_elapsed_ticks =3D icount_get, -}; diff --git a/accel/tcg/tcg-cpus-mttcg.c b/accel/tcg/tcg-accel-ops-mttcg.c similarity index 92% rename from accel/tcg/tcg-cpus-mttcg.c rename to accel/tcg/tcg-accel-ops-mttcg.c index 9c3767d260..42973fb062 100644 --- a/accel/tcg/tcg-cpus-mttcg.c +++ b/accel/tcg/tcg-accel-ops-mttcg.c @@ -32,7 +32,8 @@ #include "exec/exec-all.h" #include "hw/boards.h" =20 -#include "tcg-cpus.h" +#include "tcg-accel-ops.h" +#include "tcg-accel-ops-mttcg.h" =20 /* * In the multi-threaded case each vCPU has its own thread. The TLS @@ -103,12 +104,12 @@ static void *mttcg_cpu_thread_fn(void *arg) return NULL; } =20 -static void mttcg_kick_vcpu_thread(CPUState *cpu) +void mttcg_kick_vcpu_thread(CPUState *cpu) { cpu_exit(cpu); } =20 -static void mttcg_start_vcpu_thread(CPUState *cpu) +void mttcg_start_vcpu_thread(CPUState *cpu) { char thread_name[VCPU_THREAD_NAME_SIZE]; =20 @@ -131,10 +132,3 @@ static void mttcg_start_vcpu_thread(CPUState *cpu) cpu->hThread =3D qemu_thread_get_handle(cpu->thread); #endif } - -const CpusAccel tcg_cpus_mttcg =3D { - .create_vcpu_thread =3D mttcg_start_vcpu_thread, - .kick_vcpu_thread =3D mttcg_kick_vcpu_thread, - - .handle_interrupt =3D tcg_cpus_handle_interrupt, -}; diff --git a/accel/tcg/tcg-cpus-rr.c b/accel/tcg/tcg-accel-ops-rr.c similarity index 97% rename from accel/tcg/tcg-cpus-rr.c rename to accel/tcg/tcg-accel-ops-rr.c index 0181d2e4eb..4a66055e0d 100644 --- a/accel/tcg/tcg-cpus-rr.c +++ b/accel/tcg/tcg-accel-ops-rr.c @@ -32,9 +32,9 @@ #include "exec/exec-all.h" #include "hw/boards.h" =20 -#include "tcg-cpus.h" -#include "tcg-cpus-rr.h" -#include "tcg-cpus-icount.h" +#include "tcg-accel-ops.h" +#include "tcg-accel-ops-rr.h" +#include "tcg-accel-ops-icount.h" =20 /* Kick all RR vCPUs */ void rr_kick_vcpu_thread(CPUState *unused) @@ -296,10 +296,3 @@ void rr_start_vcpu_thread(CPUState *cpu) cpu->created =3D true; } } - -const CpusAccel tcg_cpus_rr =3D { - .create_vcpu_thread =3D rr_start_vcpu_thread, - .kick_vcpu_thread =3D rr_kick_vcpu_thread, - - .handle_interrupt =3D tcg_cpus_handle_interrupt, -}; diff --git a/accel/tcg/tcg-cpus.c b/accel/tcg/tcg-accel-ops.c similarity index 63% rename from accel/tcg/tcg-cpus.c rename to accel/tcg/tcg-accel-ops.c index e335f9f155..3017f66dd7 100644 --- a/accel/tcg/tcg-cpus.c +++ b/accel/tcg/tcg-accel-ops.c @@ -34,7 +34,10 @@ #include "exec/exec-all.h" #include "hw/boards.h" =20 -#include "tcg-cpus.h" +#include "tcg-accel-ops.h" +#include "tcg-accel-ops-mttcg.h" +#include "tcg-accel-ops-rr.h" +#include "tcg-accel-ops-icount.h" =20 /* common functionality among all TCG variants */ =20 @@ -64,7 +67,7 @@ int tcg_cpus_exec(CPUState *cpu) } =20 /* mask must never be zero, except for A20 change call */ -void tcg_cpus_handle_interrupt(CPUState *cpu, int mask) +void tcg_handle_interrupt(CPUState *cpu, int mask) { g_assert(qemu_mutex_iothread_locked()); =20 @@ -80,3 +83,43 @@ void tcg_cpus_handle_interrupt(CPUState *cpu, int mask) qatomic_set(&cpu_neg(cpu)->icount_decr.u16.high, -1); } } + +static void tcg_accel_ops_init(AccelOpsClass *ops) +{ + if (qemu_tcg_mttcg_enabled()) { + ops->create_vcpu_thread =3D mttcg_start_vcpu_thread; + ops->kick_vcpu_thread =3D mttcg_kick_vcpu_thread; + ops->handle_interrupt =3D tcg_handle_interrupt; + + } else if (icount_enabled()) { + ops->create_vcpu_thread =3D rr_start_vcpu_thread; + ops->kick_vcpu_thread =3D rr_kick_vcpu_thread; + ops->handle_interrupt =3D icount_handle_interrupt; + ops->get_virtual_clock =3D icount_get; + ops->get_elapsed_ticks =3D icount_get; + + } else { + ops->create_vcpu_thread =3D rr_start_vcpu_thread; + ops->kick_vcpu_thread =3D rr_kick_vcpu_thread; + ops->handle_interrupt =3D tcg_handle_interrupt; + } +} + +static void tcg_accel_ops_class_init(ObjectClass *oc, void *data) +{ + AccelOpsClass *ops =3D ACCEL_OPS_CLASS(oc); + + ops->ops_init =3D tcg_accel_ops_init; +}; +static const TypeInfo tcg_accel_ops_type =3D { + .name =3D ACCEL_OPS_NAME("tcg"), + + .parent =3D TYPE_ACCEL_OPS, + .class_init =3D tcg_accel_ops_class_init, + .abstract =3D true, +}; +static void tcg_accel_ops_register_types(void) +{ + type_register_static(&tcg_accel_ops_type); +} +type_init(tcg_accel_ops_register_types); diff --git a/accel/tcg/tcg-all.c b/accel/tcg/tcg-all.c index 642a7b94a7..e378c2db73 100644 --- a/accel/tcg/tcg-all.c +++ b/accel/tcg/tcg-all.c @@ -33,10 +33,6 @@ #include "qemu/accel.h" #include "qapi/qapi-builtin-visit.h" =20 -#ifndef CONFIG_USER_ONLY -#include "tcg-cpus.h" -#endif /* CONFIG_USER_ONLY */ - struct TCGState { AccelState parent_obj; =20 @@ -124,14 +120,6 @@ static int tcg_init(MachineState *ms) */ #ifndef CONFIG_USER_ONLY tcg_region_init(); - - if (mttcg_enabled) { - cpus_register_accel(&tcg_cpus_mttcg); - } else if (icount_enabled()) { - cpus_register_accel(&tcg_cpus_icount); - } else { - cpus_register_accel(&tcg_cpus_rr); - } #endif /* !CONFIG_USER_ONLY */ =20 return 0; diff --git a/accel/xen/xen-all.c b/accel/xen/xen-all.c index 594aaf6b49..82fc21f1ce 100644 --- a/accel/xen/xen-all.c +++ b/accel/xen/xen-all.c @@ -154,10 +154,6 @@ static void xen_setup_post(MachineState *ms, AccelStat= e *accel) } } =20 -const CpusAccel xen_cpus =3D { - .create_vcpu_thread =3D dummy_start_vcpu_thread, -}; - static int xen_init(MachineState *ms) { MachineClass *mc =3D MACHINE_GET_CLASS(ms); @@ -185,9 +181,6 @@ static int xen_init(MachineState *ms) * opt out of system RAM being allocated by generic code */ mc->default_ram_id =3D NULL; - - cpus_register_accel(&xen_cpus); - return 0; } =20 @@ -222,9 +215,24 @@ static const TypeInfo xen_accel_type =3D { .class_init =3D xen_accel_class_init, }; =20 +static void xen_accel_ops_class_init(ObjectClass *oc, void *data) +{ + AccelOpsClass *ops =3D ACCEL_OPS_CLASS(oc); + + ops->create_vcpu_thread =3D dummy_start_vcpu_thread; +}; +static const TypeInfo xen_accel_ops_type =3D { + .name =3D ACCEL_OPS_NAME("xen"), + + .parent =3D TYPE_ACCEL_OPS, + .class_init =3D xen_accel_ops_class_init, + .abstract =3D true, +}; + static void xen_type_init(void) { type_register_static(&xen_accel_type); + type_register_static(&xen_accel_ops_type); } =20 type_init(xen_type_init); diff --git a/bsd-user/main.c b/bsd-user/main.c index 6501164e05..7cc08024e3 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -909,13 +909,14 @@ int main(int argc, char **argv) #endif } =20 + cpu_type =3D parse_cpu_option(cpu_model); /* init tcg before creating CPUs and to get qemu_host_page_size */ { AccelClass *ac =3D ACCEL_GET_CLASS(current_accel()); =20 ac->init_machine(NULL); + accel_init_interfaces(ac); } - cpu_type =3D parse_cpu_option(cpu_model); cpu =3D cpu_create(cpu_type); env =3D cpu->env_ptr; #if defined(TARGET_SPARC) || defined(TARGET_PPC) diff --git a/linux-user/main.c b/linux-user/main.c index 7ed23d9a29..2e3c169878 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -706,6 +706,7 @@ int main(int argc, char **argv, char **envp) AccelClass *ac =3D ACCEL_GET_CLASS(current_accel()); =20 ac->init_machine(NULL); + accel_init_interfaces(ac); } cpu =3D cpu_create(cpu_type); env =3D cpu->env_ptr; diff --git a/softmmu/cpus.c b/softmmu/cpus.c index 1dc20b9dc3..112eba9d54 100644 --- a/softmmu/cpus.c +++ b/softmmu/cpus.c @@ -128,7 +128,7 @@ void hw_error(const char *fmt, ...) /* * The chosen accelerator is supposed to register this. */ -static const CpusAccel *cpus_accel; +static const AccelOpsClass *cpus_accel; =20 void cpu_synchronize_all_states(void) { @@ -594,11 +594,11 @@ void cpu_remove_sync(CPUState *cpu) qemu_mutex_lock_iothread(); } =20 -void cpus_register_accel(const CpusAccel *ca) +void cpus_register_accel(const AccelOpsClass *ops) { - assert(ca !=3D NULL); - assert(ca->create_vcpu_thread !=3D NULL); /* mandatory */ - cpus_accel =3D ca; + assert(ops !=3D NULL); + assert(ops->create_vcpu_thread !=3D NULL); /* mandatory */ + cpus_accel =3D ops; } =20 void qemu_init_vcpu(CPUState *cpu) @@ -618,7 +618,7 @@ void qemu_init_vcpu(CPUState *cpu) cpu_address_space_init(cpu, 0, "cpu-memory", cpu->memory); } =20 - /* accelerators all implement the CpusAccel interface */ + /* accelerators all implement the AccelOpsClass */ g_assert(cpus_accel !=3D NULL && cpus_accel->create_vcpu_thread !=3D N= ULL); cpus_accel->create_vcpu_thread(cpu); =20 diff --git a/softmmu/vl.c b/softmmu/vl.c index 7514194132..0c438ab1a8 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -1726,7 +1726,8 @@ static bool object_create_early(const char *type, Qem= uOpts *opts) return false; } =20 - /* Allocation of large amounts of memory may delay + /* + * Allocation of large amounts of memory may delay * chardev initialization for too long, and trigger timeouts * on software that waits for a monitor socket to be created * (e.g. libvirt). @@ -3497,7 +3498,7 @@ void qemu_init(int argc, char **argv, char **envp) * * Machine compat properties: object_set_machine_compat_props(). * Accelerator compat props: object_set_accelerator_compat_props(), - * called from configure_accelerator(). + * called from do_configure_accelerator(). */ =20 machine_class =3D MACHINE_GET_CLASS(current_machine); @@ -3519,6 +3520,8 @@ void qemu_init(int argc, char **argv, char **envp) if (cpu_option) { current_machine->cpu_type =3D parse_cpu_option(cpu_option); } + /* NB: for machine none cpu_type could STILL be NULL here! */ + accel_init_interfaces(ACCEL_GET_CLASS(current_machine->accelerator)); =20 qemu_resolve_machine_memdev(); parse_numa_opts(current_machine); diff --git a/target/i386/hax/hax-cpus.c b/target/i386/hax/hax-accel-ops.c similarity index 69% rename from target/i386/hax/hax-cpus.c rename to target/i386/hax/hax-accel-ops.c index f72c85bd49..f66042c61e 100644 --- a/target/i386/hax/hax-cpus.c +++ b/target/i386/hax/hax-accel-ops.c @@ -26,7 +26,7 @@ #include "sysemu/cpus.h" #include "qemu/guest-random.h" =20 -#include "hax-cpus.h" +#include "hax-accel-ops.h" =20 static void *hax_cpu_thread_fn(void *arg) { @@ -74,12 +74,27 @@ static void hax_start_vcpu_thread(CPUState *cpu) #endif } =20 -const CpusAccel hax_cpus =3D { - .create_vcpu_thread =3D hax_start_vcpu_thread, - .kick_vcpu_thread =3D hax_kick_vcpu_thread, +static void hax_accel_ops_class_init(ObjectClass *oc, void *data) +{ + AccelOpsClass *ops =3D ACCEL_OPS_CLASS(oc); =20 - .synchronize_post_reset =3D hax_cpu_synchronize_post_reset, - .synchronize_post_init =3D hax_cpu_synchronize_post_init, - .synchronize_state =3D hax_cpu_synchronize_state, - .synchronize_pre_loadvm =3D hax_cpu_synchronize_pre_loadvm, + ops->create_vcpu_thread =3D hax_start_vcpu_thread; + ops->kick_vcpu_thread =3D hax_kick_vcpu_thread; + + ops->synchronize_post_reset =3D hax_cpu_synchronize_post_reset; + ops->synchronize_post_init =3D hax_cpu_synchronize_post_init; + ops->synchronize_state =3D hax_cpu_synchronize_state; + ops->synchronize_pre_loadvm =3D hax_cpu_synchronize_pre_loadvm; +}; +static const TypeInfo hax_accel_ops_type =3D { + .name =3D ACCEL_OPS_NAME("hax"), + + .parent =3D TYPE_ACCEL_OPS, + .class_init =3D hax_accel_ops_class_init, + .abstract =3D true, }; +static void hax_accel_ops_register_types(void) +{ + type_register_static(&hax_accel_ops_type); +} +type_init(hax_accel_ops_register_types); diff --git a/target/i386/hax/hax-all.c b/target/i386/hax/hax-all.c index d7f4bb44a7..bf65ed6fa9 100644 --- a/target/i386/hax/hax-all.c +++ b/target/i386/hax/hax-all.c @@ -33,7 +33,7 @@ #include "sysemu/runstate.h" #include "hw/boards.h" =20 -#include "hax-cpus.h" +#include "hax-accel-ops.h" =20 #define DEBUG_HAX 0 =20 @@ -364,9 +364,6 @@ static int hax_accel_init(MachineState *ms) !ret ? "working" : "not working", !ret ? "fast virt" : "emulation"); } - if (ret =3D=3D 0) { - cpus_register_accel(&hax_cpus); - } return ret; } =20 diff --git a/target/i386/hax/hax-mem.c b/target/i386/hax/hax-mem.c index 71e637cf16..35495f5e82 100644 --- a/target/i386/hax/hax-mem.c +++ b/target/i386/hax/hax-mem.c @@ -13,7 +13,7 @@ #include "exec/address-spaces.h" #include "qemu/error-report.h" =20 -#include "hax-cpus.h" +#include "hax-accel-ops.h" #include "qemu/queue.h" =20 #define DEBUG_HAX_MEM 0 diff --git a/target/i386/hax/hax-posix.c b/target/i386/hax/hax-posix.c index 735a749d4b..ac1a51096e 100644 --- a/target/i386/hax/hax-posix.c +++ b/target/i386/hax/hax-posix.c @@ -15,7 +15,7 @@ #include =20 #include "sysemu/cpus.h" -#include "hax-cpus.h" +#include "hax-accel-ops.h" =20 hax_fd hax_mod_open(void) { diff --git a/target/i386/hax/hax-windows.c b/target/i386/hax/hax-windows.c index 6c82dfb54f..59afa213a6 100644 --- a/target/i386/hax/hax-windows.c +++ b/target/i386/hax/hax-windows.c @@ -12,7 +12,7 @@ =20 #include "qemu/osdep.h" #include "cpu.h" -#include "hax-cpus.h" +#include "hax-accel-ops.h" =20 /* * return 0 when success, -1 when driver not loaded, diff --git a/target/i386/hvf/hvf-cpus.c b/target/i386/hvf/hvf-accel-ops.c similarity index 84% rename from target/i386/hvf/hvf-cpus.c rename to target/i386/hvf/hvf-accel-ops.c index 817b3d7452..cbaad238e0 100644 --- a/target/i386/hvf/hvf-cpus.c +++ b/target/i386/hvf/hvf-accel-ops.c @@ -55,7 +55,7 @@ #include "target/i386/cpu.h" #include "qemu/guest-random.h" =20 -#include "hvf-cpus.h" +#include "hvf-accel-ops.h" =20 /* * The HVF-specific vCPU thread function. This one should only run when th= e host @@ -121,11 +121,26 @@ static void hvf_start_vcpu_thread(CPUState *cpu) cpu, QEMU_THREAD_JOINABLE); } =20 -const CpusAccel hvf_cpus =3D { - .create_vcpu_thread =3D hvf_start_vcpu_thread, +static void hvf_accel_ops_class_init(ObjectClass *oc, void *data) +{ + AccelOpsClass *ops =3D ACCEL_OPS_CLASS(oc); =20 - .synchronize_post_reset =3D hvf_cpu_synchronize_post_reset, - .synchronize_post_init =3D hvf_cpu_synchronize_post_init, - .synchronize_state =3D hvf_cpu_synchronize_state, - .synchronize_pre_loadvm =3D hvf_cpu_synchronize_pre_loadvm, + ops->create_vcpu_thread =3D hvf_start_vcpu_thread; + + ops->synchronize_post_reset =3D hvf_cpu_synchronize_post_reset; + ops->synchronize_post_init =3D hvf_cpu_synchronize_post_init; + ops->synchronize_state =3D hvf_cpu_synchronize_state; + ops->synchronize_pre_loadvm =3D hvf_cpu_synchronize_pre_loadvm; +}; +static const TypeInfo hvf_accel_ops_type =3D { + .name =3D ACCEL_OPS_NAME("hvf"), + + .parent =3D TYPE_ACCEL_OPS, + .class_init =3D hvf_accel_ops_class_init, + .abstract =3D true, }; +static void hvf_accel_ops_register_types(void) +{ + type_register_static(&hvf_accel_ops_type); +} +type_init(hvf_accel_ops_register_types); diff --git a/target/i386/hvf/hvf.c b/target/i386/hvf/hvf.c index ffc9efa40f..5b90dcdf88 100644 --- a/target/i386/hvf/hvf.c +++ b/target/i386/hvf/hvf.c @@ -72,7 +72,7 @@ #include "qemu/accel.h" #include "target/i386/cpu.h" =20 -#include "hvf-cpus.h" +#include "hvf-accel-ops.h" =20 HVFState *hvf_state; =20 @@ -887,7 +887,6 @@ static int hvf_accel_init(MachineState *ms) =20 hvf_state =3D s; memory_listener_register(&hvf_memory_listener, &address_space_memory); - cpus_register_accel(&hvf_cpus); return 0; } =20 diff --git a/target/i386/hvf/x86hvf.c b/target/i386/hvf/x86hvf.c index bbec412b6c..0d7533742e 100644 --- a/target/i386/hvf/x86hvf.c +++ b/target/i386/hvf/x86hvf.c @@ -32,7 +32,7 @@ #include #include =20 -#include "hvf-cpus.h" +#include "hvf-accel-ops.h" =20 void hvf_set_segment(struct CPUState *cpu, struct vmx_segment *vmx_seg, SegmentCache *qseg, bool is_tr) diff --git a/target/i386/whpx/whpx-cpus.c b/target/i386/whpx/whpx-accel-ops= .c similarity index 72% rename from target/i386/whpx/whpx-cpus.c rename to target/i386/whpx/whpx-accel-ops.c index d9bd5a2d36..b880947cc2 100644 --- a/target/i386/whpx/whpx-cpus.c +++ b/target/i386/whpx/whpx-accel-ops.c @@ -15,7 +15,7 @@ #include "qemu/guest-random.h" =20 #include "sysemu/whpx.h" -#include "whpx-cpus.h" +#include "whpx-accel-ops.h" =20 #include #include @@ -85,12 +85,27 @@ static void whpx_kick_vcpu_thread(CPUState *cpu) } } =20 -const CpusAccel whpx_cpus =3D { - .create_vcpu_thread =3D whpx_start_vcpu_thread, - .kick_vcpu_thread =3D whpx_kick_vcpu_thread, +static void whpx_accel_ops_class_init(ObjectClass *oc, void *data) +{ + AccelOpsClass *ops =3D ACCEL_OPS_CLASS(oc); =20 - .synchronize_post_reset =3D whpx_cpu_synchronize_post_reset, - .synchronize_post_init =3D whpx_cpu_synchronize_post_init, - .synchronize_state =3D whpx_cpu_synchronize_state, - .synchronize_pre_loadvm =3D whpx_cpu_synchronize_pre_loadvm, + ops->create_vcpu_thread =3D whpx_start_vcpu_thread; + ops->kick_vcpu_thread =3D whpx_kick_vcpu_thread; + + ops->synchronize_post_reset =3D whpx_cpu_synchronize_post_reset; + ops->synchronize_post_init =3D whpx_cpu_synchronize_post_init; + ops->synchronize_state =3D whpx_cpu_synchronize_state; + ops->synchronize_pre_loadvm =3D whpx_cpu_synchronize_pre_loadvm; +}; +static const TypeInfo whpx_accel_ops_type =3D { + .name =3D ACCEL_OPS_NAME("whpx"), + + .parent =3D TYPE_ACCEL_OPS, + .class_init =3D whpx_accel_ops_class_init, + .abstract =3D true, }; +static void whpx_accel_ops_register_types(void) +{ + type_register_static(&whpx_accel_ops_type); +} +type_init(whpx_accel_ops_register_types); diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c index b568eb5f1d..89ccba43c9 100644 --- a/target/i386/whpx/whpx-all.c +++ b/target/i386/whpx/whpx-all.c @@ -29,7 +29,7 @@ #include "whp-dispatch.h" #include =20 -#include "whpx-cpus.h" +#include "whpx-accel-ops.h" =20 #include #include @@ -1849,8 +1849,6 @@ static int whpx_accel_init(MachineState *ms) =20 whpx_memory_init(); =20 - cpus_register_accel(&whpx_cpus); - printf("Windows Hypervisor Platform accelerator is operational\n"); return 0; =20 diff --git a/MAINTAINERS b/MAINTAINERS index 485594eea9..05ddf0a004 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -439,7 +439,8 @@ M: Richard Henderson R: Paolo Bonzini S: Maintained F: include/qemu/accel.h -F: accel/accel.c +F: include/sysemu/accel-ops.h +F: accel/accel-*.c F: accel/Makefile.objs F: accel/stubs/Makefile.objs =20 diff --git a/accel/kvm/meson.build b/accel/kvm/meson.build index 7e9dafe24c..8d219bea50 100644 --- a/accel/kvm/meson.build +++ b/accel/kvm/meson.build @@ -1,7 +1,7 @@ kvm_ss =3D ss.source_set() kvm_ss.add(files( 'kvm-all.c', - 'kvm-cpus.c', + 'kvm-accel-ops.c', )) kvm_ss.add(when: 'CONFIG_SEV', if_false: files('sev-stub.c')) =20 diff --git a/accel/tcg/meson.build b/accel/tcg/meson.build index 424d9bb1fc..1236ac7b91 100644 --- a/accel/tcg/meson.build +++ b/accel/tcg/meson.build @@ -15,8 +15,8 @@ specific_ss.add_all(when: 'CONFIG_TCG', if_true: tcg_ss) =20 specific_ss.add(when: ['CONFIG_SOFTMMU', 'CONFIG_TCG'], if_true: files( 'cputlb.c', - 'tcg-cpus.c', - 'tcg-cpus-mttcg.c', - 'tcg-cpus-icount.c', - 'tcg-cpus-rr.c' + 'tcg-accel-ops.c', + 'tcg-accel-ops-mttcg.c', + 'tcg-accel-ops-icount.c', + 'tcg-accel-ops-rr.c' )) diff --git a/target/i386/hax/meson.build b/target/i386/hax/meson.build index 77ea431b30..d6c520fb6b 100644 --- a/target/i386/hax/meson.build +++ b/target/i386/hax/meson.build @@ -1,7 +1,7 @@ i386_softmmu_ss.add(when: 'CONFIG_HAX', if_true: files( 'hax-all.c', 'hax-mem.c', - 'hax-cpus.c', + 'hax-accel-ops.c', )) i386_softmmu_ss.add(when: ['CONFIG_HAX', 'CONFIG_POSIX'], if_true: files('= hax-posix.c')) i386_softmmu_ss.add(when: ['CONFIG_HAX', 'CONFIG_WIN32'], if_true: files('= hax-windows.c')) diff --git a/target/i386/hvf/meson.build b/target/i386/hvf/meson.build index 409c9a3f14..e9eb5a5da8 100644 --- a/target/i386/hvf/meson.build +++ b/target/i386/hvf/meson.build @@ -1,6 +1,6 @@ i386_softmmu_ss.add(when: [hvf, 'CONFIG_HVF'], if_true: files( 'hvf.c', - 'hvf-cpus.c', + 'hvf-accel-ops.c', 'x86.c', 'x86_cpuid.c', 'x86_decode.c', diff --git a/target/i386/whpx/meson.build b/target/i386/whpx/meson.build index d8aa683999..95fc31eb81 100644 --- a/target/i386/whpx/meson.build +++ b/target/i386/whpx/meson.build @@ -1,5 +1,5 @@ i386_softmmu_ss.add(when: 'CONFIG_WHPX', if_true: files( 'whpx-all.c', 'whpx-apic.c', - 'whpx-cpus.c', + 'whpx-accel-ops.c', )) --=20 2.26.2 From nobody Thu Apr 25 18:08:54 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=1610475547; cv=none; d=zohomail.com; s=zohoarc; b=Y5+Mob68AAk0YWi9FisEmt2uzJQHymEASarhtzmpzFQyvN6iJ4hNEx8E3recPhkIno12pes822qishL0OZ87Dlk3qkC+3QKonywxo4Qcq51AxvRzMimii8ZdHS+jghLNgLCWF60E6vDZ6n3izhBCxNjMM14s/QkBcW0qAFgfQC4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610475547; 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=aAjIAXa+rq9yDcv6hhtSknLOxdQAIzSZT9hB5CZtoCU=; b=W6zCmjJdUpqV4Vm3RbfhyGBMsY8EGZ0xe0vjUKSplJp8EUaH0b+nJsqjZIKrzwe888qt1b2xENfebdKgGPldo2g2W7TvnnibKUSb/BODmgi9eZF8VY42Dn1U8JXzXMD5xkYq+1yu12kyzGrLxQAO7wD37CABdb7ccNqLzIEQWlA= 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 1610475547197592.0196049770447; Tue, 12 Jan 2021 10:19:07 -0800 (PST) Received: from localhost ([::1]:60102 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kzOG1-0005Tv-RH for importer@patchew.org; Tue, 12 Jan 2021 13:19:05 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48204) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kzO1N-0005Ym-4F for qemu-devel@nongnu.org; Tue, 12 Jan 2021 13:03:57 -0500 Received: from mx2.suse.de ([195.135.220.15]:33990) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kzO1B-0004xT-S7 for qemu-devel@nongnu.org; Tue, 12 Jan 2021 13:03:56 -0500 Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 7F1D0ADE0; Tue, 12 Jan 2021 18:03:34 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Claudio Fontana To: Paolo Bonzini , Thomas Huth , Richard Henderson , Stefano Stabellini , Wenchao Wang , Roman Bolshakov , Sunil Muthuswamy , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v12 18/22] accel: introduce AccelCPUClass extending CPUClass Date: Tue, 12 Jan 2021 19:03:08 +0100 Message-Id: <20210112180312.26043-19-cfontana@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210112180312.26043-1-cfontana@suse.de> References: <20210112180312.26043-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 , Peter Maydell , Eduardo Habkost , Paul Durrant , Jason Wang , Marcelo Tosatti , qemu-devel@nongnu.org, Peter Xu , Dario Faggioli , Cameron Esfahani , haxm-team@intel.com, Claudio Fontana , Anthony Perard , Bruce Rogers , Olaf Hering , "Emilio G . Cota" , Colin Xu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" add a new optional interface to CPUClass, which allows accelerators to extend the CPUClass with additional accelerator-specific initializations. Add the field before tcg_ops, and mark tcg_ops as needing to be last in the struct until we rework this further in a later patch. Signed-off-by: Claudio Fontana --- include/hw/core/accel-cpu.h | 35 +++++++++++++++++++++++++++++ include/hw/core/cpu.h | 1 + accel/accel-common.c | 44 +++++++++++++++++++++++++++++++++++++ MAINTAINERS | 1 + 4 files changed, 81 insertions(+) create mode 100644 include/hw/core/accel-cpu.h diff --git a/include/hw/core/accel-cpu.h b/include/hw/core/accel-cpu.h new file mode 100644 index 0000000000..246b3e2fcb --- /dev/null +++ b/include/hw/core/accel-cpu.h @@ -0,0 +1,35 @@ +/* + * Accelerator interface, specializes CPUClass + * + * Copyright 2020 SUSE LLC + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#ifndef ACCEL_CPU_H +#define ACCEL_CPU_H + +/* + * these defines cannot be in cpu.h, because we are using + * CPU_RESOLVING_TYPE here. + * Use this header to define your accelerator-specific + * cpu-specific accelerator interfaces. + */ + +#define TYPE_ACCEL_CPU "accel-" CPU_RESOLVING_TYPE +#define ACCEL_CPU_NAME(name) (name "-" TYPE_ACCEL_CPU) +typedef struct AccelCPUClass AccelCPUClass; +DECLARE_CLASS_CHECKERS(AccelCPUClass, ACCEL_CPU, TYPE_ACCEL_CPU) + +typedef struct AccelCPUClass { + /*< private >*/ + ObjectClass parent_class; + /*< public >*/ + + void (*cpu_class_init)(CPUClass *cc); + void (*cpu_instance_init)(CPUState *cpu); + void (*cpu_realizefn)(CPUState *cpu, Error **errp); +} AccelCPUClass; + +#endif /* ACCEL_CPU_H */ diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index 500e2c4fce..81153c349f 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -190,6 +190,7 @@ struct CPUClass { /* Keep non-pointer data at the end to minimize holes. */ int gdb_num_core_regs; bool gdb_stop_before_watchpoint; + struct AccelCPUClass *accel_cpu; =20 /* * NB: this should be covered by CONFIG_TCG, but it is unsafe to do it= here, diff --git a/accel/accel-common.c b/accel/accel-common.c index 6b59873419..9901b0531c 100644 --- a/accel/accel-common.c +++ b/accel/accel-common.c @@ -26,6 +26,9 @@ #include "qemu/osdep.h" #include "qemu/accel.h" =20 +#include "cpu.h" +#include "hw/core/accel-cpu.h" + #ifndef CONFIG_USER_ONLY #include "accel-softmmu.h" #endif /* !CONFIG_USER_ONLY */ @@ -46,16 +49,57 @@ AccelClass *accel_find(const char *opt_name) return ac; } =20 +static void accel_init_cpu_int_aux(ObjectClass *klass, void *opaque) +{ + CPUClass *cc =3D CPU_CLASS(klass); + AccelCPUClass *accel_cpu =3D opaque; + + cc->accel_cpu =3D 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 */ + + ac_name =3D object_class_get_name(OBJECT_CLASS(ac)); + g_assert(ac_name !=3D NULL); + + acc_name =3D g_strdup_printf("%s-%s", ac_name, CPU_RESOLVING_TYPE); + acc =3D 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) { #ifndef CONFIG_USER_ONLY accel_init_ops_interfaces(ac); #endif /* !CONFIG_USER_ONLY */ + + accel_init_cpu_interfaces(ac); } =20 +static const TypeInfo accel_cpu_type =3D { + .name =3D TYPE_ACCEL_CPU, + .parent =3D TYPE_OBJECT, + .abstract =3D true, + .class_size =3D sizeof(AccelCPUClass), +}; + static void register_accel_types(void) { type_register_static(&accel_type); + type_register_static(&accel_cpu_type); } =20 type_init(register_accel_types); diff --git a/MAINTAINERS b/MAINTAINERS index 05ddf0a004..2724a0102e 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -440,6 +440,7 @@ R: Paolo Bonzini S: Maintained F: include/qemu/accel.h F: include/sysemu/accel-ops.h +F: include/hw/core/accel-cpu.h F: accel/accel-*.c F: accel/Makefile.objs F: accel/stubs/Makefile.objs --=20 2.26.2 From nobody Thu Apr 25 18:08:54 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=1610475749; cv=none; d=zohomail.com; s=zohoarc; b=D+fNfB60PibJesENk6fJWNyooCyjOkyHZGNaJJa9jFLf1/Cbgnz7Hgr5BP+aN6mf8ZawE0RsvaMrRidmtgbIXLImFvLm52yR6Gc1BTr+Xo9sUSOIFrfrveozmWianyeePRrrwx1bcdAUKYqkntBN4gGJRcP8FhvnvH9uNQqnuRw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610475749; 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=Vg55PAWt4LjBzrbXodEAVdY37IIO0BEDJWhaWZDMKb4=; b=SRkGTk6AJ3sDyC0xSVNklVS4ooWJl0PtxEhlPex4ypSWzSToAotE8MuzEzdLVLxVUwI8P5HjUCLD6n+0NkiHPFQyjvvqDs3LHyjktLI0PpgPbJB0kjYr8YD7W3VR6FmkLlCdFzvY3LMQrhxtvCaOeyBHl2mrVEMUQE2V3DRIomU= 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 161047574967983.4375205521061; Tue, 12 Jan 2021 10:22:29 -0800 (PST) Received: from localhost ([::1]:40180 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kzOJI-00010z-Bj for importer@patchew.org; Tue, 12 Jan 2021 13:22:28 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48252) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kzO1Q-0005gE-GM for qemu-devel@nongnu.org; Tue, 12 Jan 2021 13:04:00 -0500 Received: from mx2.suse.de ([195.135.220.15]:34088) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kzO1D-0004y6-RJ for qemu-devel@nongnu.org; Tue, 12 Jan 2021 13:04:00 -0500 Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 86799AED7; Tue, 12 Jan 2021 18:03:35 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Claudio Fontana To: Paolo Bonzini , Thomas Huth , Richard Henderson , Stefano Stabellini , Wenchao Wang , Roman Bolshakov , Sunil Muthuswamy , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v12 19/22] i386: split cpu accelerators from cpu.c, using AccelCPUClass Date: Tue, 12 Jan 2021 19:03:09 +0100 Message-Id: <20210112180312.26043-20-cfontana@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210112180312.26043-1-cfontana@suse.de> References: <20210112180312.26043-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 , Peter Maydell , Eduardo Habkost , Paul Durrant , Jason Wang , Marcelo Tosatti , qemu-devel@nongnu.org, Peter Xu , Dario Faggioli , Cameron Esfahani , haxm-team@intel.com, Claudio Fontana , Anthony Perard , Bruce Rogers , Olaf Hering , "Emilio G . Cota" , Colin Xu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" i386 is the first user of AccelCPUClass, allowing to split cpu.c into: cpu.c cpuid and common x86 cpu functionality host-cpu.c host x86 cpu functions and "host" cpu type kvm/kvm-cpu.c KVM x86 AccelCPUClass hvf/hvf-cpu.c HVF x86 AccelCPUClass tcg/tcg-cpu.c TCG x86 AccelCPUClass Signed-off-by: Claudio Fontana --- target/i386/cpu.h | 20 +- target/i386/host-cpu.h | 19 ++ target/i386/kvm/kvm-cpu.h | 41 ++++ target/i386/tcg/tcg-cpu.h | 15 -- hw/i386/pc_piix.c | 1 + target/i386/cpu.c | 389 ++++-------------------------------- target/i386/host-cpu.c | 198 ++++++++++++++++++ target/i386/hvf/hvf-cpu.c | 65 ++++++ target/i386/kvm/kvm-cpu.c | 151 ++++++++++++++ target/i386/kvm/kvm.c | 3 +- target/i386/tcg/tcg-cpu.c | 113 ++++++++++- MAINTAINERS | 2 +- target/i386/hvf/meson.build | 1 + target/i386/kvm/meson.build | 7 +- target/i386/meson.build | 6 +- 15 files changed, 645 insertions(+), 386 deletions(-) create mode 100644 target/i386/host-cpu.h create mode 100644 target/i386/kvm/kvm-cpu.h delete mode 100644 target/i386/tcg/tcg-cpu.h create mode 100644 target/i386/host-cpu.c create mode 100644 target/i386/hvf/hvf-cpu.c create mode 100644 target/i386/kvm/kvm-cpu.c diff --git a/target/i386/cpu.h b/target/i386/cpu.h index af130512e2..38ef631701 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1909,13 +1909,20 @@ int cpu_x86_signal_handler(int host_signum, void *p= info, void *puc); =20 /* cpu.c */ +void x86_cpu_vendor_words2str(char *dst, uint32_t vendor1, + uint32_t vendor2, uint32_t vendor3); +typedef struct PropValue { + const char *prop, *value; +} PropValue; +void x86_cpu_apply_props(X86CPU *cpu, PropValue *props); + +/* cpu.c other functions (cpuid) */ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count, uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx); void cpu_clear_apic_feature(CPUX86State *env); void host_cpuid(uint32_t function, uint32_t count, uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx= ); -void host_vendor_fms(char *vendor, int *family, int *model, int *stepping); =20 /* helper.c */ void x86_cpu_set_a20(X86CPU *cpu, int a20_state); @@ -2120,17 +2127,6 @@ void cpu_report_tpr_access(CPUX86State *env, TPRAcce= ss access); void apic_handle_tpr_access_report(DeviceState *d, target_ulong ip, TPRAccess access); =20 - -/* Change the value of a KVM-specific default - * - * If value is NULL, no default will be set and the original - * value from the CPU model table will be kept. - * - * It is valid to call this function only for properties that - * are already present in the kvm_default_props table. - */ -void x86_cpu_change_kvm_default(const char *prop, const char *value); - /* Special values for X86CPUVersion: */ =20 /* Resolve to latest CPU version */ diff --git a/target/i386/host-cpu.h b/target/i386/host-cpu.h new file mode 100644 index 0000000000..d1f2644422 --- /dev/null +++ b/target/i386/host-cpu.h @@ -0,0 +1,19 @@ +/* + * x86 host CPU type initialization and host CPU functions + * + * Copyright 2020 SUSE LLC + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#ifndef HOST_CPU_H +#define HOST_CPU_H + +void host_cpu_instance_init(X86CPU *cpu); +void host_cpu_max_instance_init(X86CPU *cpu); +void host_cpu_realizefn(CPUState *cs, Error **errp); + +void host_cpu_vendor_fms(char *vendor, int *family, int *model, int *stepp= ing); + +#endif /* HOST_CPU_H */ diff --git a/target/i386/kvm/kvm-cpu.h b/target/i386/kvm/kvm-cpu.h new file mode 100644 index 0000000000..e858ca21e5 --- /dev/null +++ b/target/i386/kvm/kvm-cpu.h @@ -0,0 +1,41 @@ +/* + * i386 KVM CPU type and functions + * + * Copyright (c) 2003 Fabrice Bellard + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +#ifndef KVM_CPU_H +#define KVM_CPU_H + +#ifdef CONFIG_KVM +/* + * Change the value of a KVM-specific default + * + * If value is NULL, no default will be set and the original + * value from the CPU model table will be kept. + * + * It is valid to call this function only for properties that + * are already present in the kvm_default_props table. + */ +void x86_cpu_change_kvm_default(const char *prop, const char *value); + +#else /* !CONFIG_KVM */ + +#define x86_cpu_change_kvm_default(a, b) + +#endif /* CONFIG_KVM */ + +#endif /* KVM_CPU_H */ diff --git a/target/i386/tcg/tcg-cpu.h b/target/i386/tcg/tcg-cpu.h deleted file mode 100644 index 81f02e562e..0000000000 --- a/target/i386/tcg/tcg-cpu.h +++ /dev/null @@ -1,15 +0,0 @@ -/* - * i386 TCG CPU class initialization - * - * Copyright 2020 SUSE LLC - * - * This work is licensed under the terms of the GNU GPL, version 2 or late= r. - * See the COPYING file in the top-level directory. - */ - -#ifndef TCG_CPU_H -#define TCG_CPU_H - -void tcg_cpu_common_class_init(CPUClass *cc); - -#endif /* TCG_CPU_H */ diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index 6188c3e97e..3abcb425bb 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -64,6 +64,7 @@ #include "hw/hyperv/vmbus-bridge.h" #include "hw/mem/nvdimm.h" #include "hw/i386/acpi-build.h" +#include "kvm/kvm-cpu.h" =20 #define MAX_IDE_BUS 2 =20 diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 35459a38bb..56a299ef14 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -22,38 +22,25 @@ #include "qemu/cutils.h" #include "qemu/bitops.h" #include "qemu/qemu-print.h" - #include "cpu.h" -#include "tcg/tcg-cpu.h" #include "tcg/helper-tcg.h" #include "exec/exec-all.h" #include "sysemu/kvm.h" #include "sysemu/reset.h" #include "sysemu/hvf.h" -#include "sysemu/cpus.h" +#include "hw/core/accel-cpu.h" #include "sysemu/xen.h" #include "sysemu/whpx.h" #include "kvm/kvm_i386.h" #include "sev_i386.h" - -#include "qemu/error-report.h" #include "qemu/module.h" -#include "qemu/option.h" -#include "qemu/config-file.h" -#include "qapi/error.h" #include "qapi/qapi-visit-machine.h" #include "qapi/qapi-visit-run-state.h" #include "qapi/qmp/qdict.h" #include "qapi/qmp/qerror.h" -#include "qapi/visitor.h" #include "qom/qom-qobject.h" -#include "sysemu/arch_init.h" #include "qapi/qapi-commands-machine-target.h" - #include "standard-headers/asm-x86/kvm_para.h" - -#include "sysemu/sysemu.h" -#include "sysemu/tcg.h" #include "hw/qdev-properties.h" #include "hw/i386/topology.h" #ifndef CONFIG_USER_ONLY @@ -595,8 +582,8 @@ static CPUCacheInfo legacy_l3_cache =3D { #define INTEL_PT_CYCLE_BITMAP 0x1fff /* Support 0,2^(0~11) */ #define INTEL_PT_PSB_BITMAP (0x003f << 16) /* Support 2K,4K,8K,16K,32= K,64K */ =20 -static void x86_cpu_vendor_words2str(char *dst, uint32_t vendor1, - uint32_t vendor2, uint32_t vendor3) +void x86_cpu_vendor_words2str(char *dst, uint32_t vendor1, + uint32_t vendor2, uint32_t vendor3) { int i; for (i =3D 0; i < 4; i++) { @@ -1589,25 +1576,6 @@ void host_cpuid(uint32_t function, uint32_t count, *edx =3D vec[3]; } =20 -void host_vendor_fms(char *vendor, int *family, int *model, int *stepping) -{ - uint32_t eax, ebx, ecx, edx; - - host_cpuid(0x0, 0, &eax, &ebx, &ecx, &edx); - x86_cpu_vendor_words2str(vendor, ebx, edx, ecx); - - host_cpuid(0x1, 0, &eax, &ebx, &ecx, &edx); - if (family) { - *family =3D ((eax >> 8) & 0x0F) + ((eax >> 20) & 0xFF); - } - if (model) { - *model =3D ((eax >> 4) & 0x0F) | ((eax & 0xF0000) >> 12); - } - if (stepping) { - *stepping =3D eax & 0x0F; - } -} - /* CPU class name definitions: */ =20 /* Return type name for a given CPU model name @@ -1632,10 +1600,6 @@ static char *x86_cpu_class_get_model_name(X86CPUClas= s *cc) strlen(class_name) - strlen(X86_CPU_TYPE_SUFFIX)); } =20 -typedef struct PropValue { - const char *prop, *value; -} PropValue; - typedef struct X86CPUVersionDefinition { X86CPUVersion version; const char *alias; @@ -4132,32 +4096,6 @@ static X86CPUDefinition builtin_x86_defs[] =3D { }, }; =20 -/* KVM-specific features that are automatically added/removed - * from all CPU models when KVM is enabled. - */ -static PropValue kvm_default_props[] =3D { - { "kvmclock", "on" }, - { "kvm-nopiodelay", "on" }, - { "kvm-asyncpf", "on" }, - { "kvm-steal-time", "on" }, - { "kvm-pv-eoi", "on" }, - { "kvmclock-stable-bit", "on" }, - { "x2apic", "on" }, - { "kvm-msi-ext-dest-id", "off" }, - { "acpi", "off" }, - { "monitor", "off" }, - { "svm", "off" }, - { NULL, NULL }, -}; - -/* TCG-specific defaults that override all CPU models when using TCG - */ -static PropValue tcg_default_props[] =3D { - { "vme", "off" }, - { NULL, NULL }, -}; - - /* * We resolve CPU model aliases using -v1 when using "-machine * none", but this is just for compatibility while libvirt isn't @@ -4199,61 +4137,6 @@ static X86CPUVersion x86_cpu_model_resolve_version(c= onst X86CPUModel *model) return v; } =20 -void x86_cpu_change_kvm_default(const char *prop, const char *value) -{ - PropValue *pv; - for (pv =3D kvm_default_props; pv->prop; pv++) { - if (!strcmp(pv->prop, prop)) { - pv->value =3D value; - break; - } - } - - /* It is valid to call this function only for properties that - * are already present in the kvm_default_props table. - */ - assert(pv->prop); -} - -static bool lmce_supported(void) -{ - uint64_t mce_cap =3D 0; - -#ifdef CONFIG_KVM - if (kvm_ioctl(kvm_state, KVM_X86_GET_MCE_CAP_SUPPORTED, &mce_cap) < 0)= { - return false; - } -#endif - - return !!(mce_cap & MCG_LMCE_P); -} - -#define CPUID_MODEL_ID_SZ 48 - -/** - * cpu_x86_fill_model_id: - * Get CPUID model ID string from host CPU. - * - * @str should have at least CPUID_MODEL_ID_SZ bytes - * - * The function does NOT add a null terminator to the string - * automatically. - */ -static int cpu_x86_fill_model_id(char *str) -{ - uint32_t eax =3D 0, ebx =3D 0, ecx =3D 0, edx =3D 0; - int i; - - for (i =3D 0; i < 3; i++) { - host_cpuid(0x80000002 + i, 0, &eax, &ebx, &ecx, &edx); - memcpy(str + i * 16 + 0, &eax, 4); - memcpy(str + i * 16 + 4, &ebx, 4); - memcpy(str + i * 16 + 8, &ecx, 4); - memcpy(str + i * 16 + 12, &edx, 4); - } - return 0; -} - static Property max_x86_cpu_properties[] =3D { DEFINE_PROP_BOOL("migratable", X86CPU, migratable, true), DEFINE_PROP_BOOL("host-cache-info", X86CPU, cache_info_passthrough, fa= lse), @@ -4276,61 +4159,25 @@ static void max_x86_cpu_class_init(ObjectClass *oc,= void *data) static void max_x86_cpu_initfn(Object *obj) { X86CPU *cpu =3D X86_CPU(obj); - CPUX86State *env =3D &cpu->env; - KVMState *s =3D kvm_state; =20 /* We can't fill the features array here because we don't know yet if * "migratable" is true or false. */ cpu->max_features =3D true; - - if (accel_uses_host_cpuid()) { - char vendor[CPUID_VENDOR_SZ + 1] =3D { 0 }; - char model_id[CPUID_MODEL_ID_SZ + 1] =3D { 0 }; - int family, model, stepping; - - host_vendor_fms(vendor, &family, &model, &stepping); - cpu_x86_fill_model_id(model_id); - - object_property_set_str(OBJECT(cpu), "vendor", vendor, &error_abor= t); - object_property_set_int(OBJECT(cpu), "family", family, &error_abor= t); - object_property_set_int(OBJECT(cpu), "model", model, &error_abort); - object_property_set_int(OBJECT(cpu), "stepping", stepping, - &error_abort); - object_property_set_str(OBJECT(cpu), "model-id", model_id, - &error_abort); - - if (kvm_enabled()) { - env->cpuid_min_level =3D - kvm_arch_get_supported_cpuid(s, 0x0, 0, R_EAX); - env->cpuid_min_xlevel =3D - kvm_arch_get_supported_cpuid(s, 0x80000000, 0, R_EAX); - env->cpuid_min_xlevel2 =3D - kvm_arch_get_supported_cpuid(s, 0xC0000000, 0, R_EAX); - } else { - env->cpuid_min_level =3D - hvf_get_supported_cpuid(0x0, 0, R_EAX); - env->cpuid_min_xlevel =3D - hvf_get_supported_cpuid(0x80000000, 0, R_EAX); - env->cpuid_min_xlevel2 =3D - hvf_get_supported_cpuid(0xC0000000, 0, R_EAX); - } - - if (lmce_supported()) { - object_property_set_bool(OBJECT(cpu), "lmce", true, &error_abo= rt); - } - } else { - object_property_set_str(OBJECT(cpu), "vendor", CPUID_VENDOR_AMD, - &error_abort); - object_property_set_int(OBJECT(cpu), "family", 6, &error_abort); - object_property_set_int(OBJECT(cpu), "model", 6, &error_abort); - object_property_set_int(OBJECT(cpu), "stepping", 3, &error_abort); - object_property_set_str(OBJECT(cpu), "model-id", - "QEMU TCG CPU version " QEMU_HW_VERSION, - &error_abort); - } - object_property_set_bool(OBJECT(cpu), "pmu", true, &error_abort); + + /* + * these defaults are used for TCG and all other accelerators + * besides KVM and HVF, which overwrite these values + */ + object_property_set_str(OBJECT(cpu), "vendor", CPUID_VENDOR_AMD, + &error_abort); + object_property_set_int(OBJECT(cpu), "family", 6, &error_abort); + object_property_set_int(OBJECT(cpu), "model", 6, &error_abort); + object_property_set_int(OBJECT(cpu), "stepping", 3, &error_abort); + object_property_set_str(OBJECT(cpu), "model-id", + "QEMU TCG CPU version " QEMU_HW_VERSION, + &error_abort); } =20 static const TypeInfo max_x86_cpu_type_info =3D { @@ -4340,31 +4187,6 @@ static const TypeInfo max_x86_cpu_type_info =3D { .class_init =3D max_x86_cpu_class_init, }; =20 -#if defined(CONFIG_KVM) || defined(CONFIG_HVF) -static void host_x86_cpu_class_init(ObjectClass *oc, void *data) -{ - X86CPUClass *xcc =3D X86_CPU_CLASS(oc); - - xcc->host_cpuid_required =3D true; - xcc->ordering =3D 8; - -#if defined(CONFIG_KVM) - xcc->model_description =3D - "KVM processor with all supported host features "; -#elif defined(CONFIG_HVF) - xcc->model_description =3D - "HVF processor with all supported host features "; -#endif -} - -static const TypeInfo host_x86_cpu_type_info =3D { - .name =3D X86_CPU_TYPE_NAME("host"), - .parent =3D X86_CPU_TYPE_NAME("max"), - .class_init =3D host_x86_cpu_class_init, -}; - -#endif - static char *feature_word_description(FeatureWordInfo *f, uint32_t bit) { assert(f->type =3D=3D CPUID_FEATURE_WORD || f->type =3D=3D MSR_FEATURE= _WORD); @@ -5086,7 +4908,7 @@ static uint64_t x86_cpu_get_supported_feature_word(Fe= atureWord w, return r; } =20 -static void x86_cpu_apply_props(X86CPU *cpu, PropValue *props) +void x86_cpu_apply_props(X86CPU *cpu, PropValue *props) { PropValue *pv; for (pv =3D props; pv->prop; pv++) { @@ -5133,8 +4955,6 @@ static void x86_cpu_load_model(X86CPU *cpu, X86CPUMod= el *model) { X86CPUDefinition *def =3D model->cpudef; CPUX86State *env =3D &cpu->env; - const char *vendor; - char host_vendor[CPUID_VENDOR_SZ + 1]; FeatureWord w; =20 /*NOTE: any property set by this function should be returned by @@ -5161,20 +4981,6 @@ static void x86_cpu_load_model(X86CPU *cpu, X86CPUMo= del *model) /* legacy-cache defaults to 'off' if CPU model provides cache info */ cpu->legacy_cache =3D !def->cache_info; =20 - /* Special cases not set in the X86CPUDefinition structs: */ - /* TODO: in-kernel irqchip for hvf */ - if (kvm_enabled()) { - if (!kvm_irqchip_in_kernel()) { - x86_cpu_change_kvm_default("x2apic", "off"); - } else if (kvm_irqchip_is_split() && kvm_enable_x2apic()) { - x86_cpu_change_kvm_default("kvm-msi-ext-dest-id", "on"); - } - - x86_cpu_apply_props(cpu, kvm_default_props); - } else if (tcg_enabled()) { - x86_cpu_apply_props(cpu, tcg_default_props); - } - env->features[FEAT_1_ECX] |=3D CPUID_EXT_HYPERVISOR; =20 /* sysenter isn't supported in compatibility mode on AMD, @@ -5184,15 +4990,12 @@ static void x86_cpu_load_model(X86CPU *cpu, X86CPUM= odel *model) * KVM's sysenter/syscall emulation in compatibility mode and * when doing cross vendor migration */ - vendor =3D def->vendor; - if (accel_uses_host_cpuid()) { - uint32_t ebx =3D 0, ecx =3D 0, edx =3D 0; - host_cpuid(0, 0, NULL, &ebx, &ecx, &edx); - x86_cpu_vendor_words2str(host_vendor, ebx, edx, ecx); - vendor =3D host_vendor; - } =20 - object_property_set_str(OBJECT(cpu), "vendor", vendor, &error_abort); + /* + * vendor property is set here but then overloaded with the + * host cpu vendor for KVM and HVF. + */ + object_property_set_str(OBJECT(cpu), "vendor", def->vendor, &error_abo= rt); =20 x86_cpu_apply_version_props(cpu, model); =20 @@ -6222,53 +6025,12 @@ static void x86_cpu_apic_realize(X86CPU *cpu, Error= **errp) apic_mmio_map_once =3D true; } } - -static void x86_cpu_machine_done(Notifier *n, void *unused) -{ - X86CPU *cpu =3D container_of(n, X86CPU, machine_done); - MemoryRegion *smram =3D - (MemoryRegion *) object_resolve_path("/machine/smram", NULL); - - if (smram) { - cpu->smram =3D g_new(MemoryRegion, 1); - memory_region_init_alias(cpu->smram, OBJECT(cpu), "smram", - smram, 0, 4 * GiB); - memory_region_set_enabled(cpu->smram, true); - memory_region_add_subregion_overlap(cpu->cpu_as_root, 0, cpu->smra= m, 1); - } -} #else static void x86_cpu_apic_realize(X86CPU *cpu, Error **errp) { } #endif =20 -/* Note: Only safe for use on x86(-64) hosts */ -static uint32_t x86_host_phys_bits(void) -{ - uint32_t eax; - uint32_t host_phys_bits; - - host_cpuid(0x80000000, 0, &eax, NULL, NULL, NULL); - if (eax >=3D 0x80000008) { - host_cpuid(0x80000008, 0, &eax, NULL, NULL, NULL); - /* Note: According to AMD doc 25481 rev 2.34 they have a field - * at 23:16 that can specify a maximum physical address bits for - * the guest that can override this value; but I've not seen - * anything with that set. - */ - host_phys_bits =3D eax & 0xff; - } else { - /* It's an odd 64 bit machine that doesn't have the leaf for - * physical address bits; fall back to 36 that's most older - * Intel. - */ - host_phys_bits =3D 36; - } - - return host_phys_bits; -} - static void x86_cpu_adjust_level(X86CPU *cpu, uint32_t *min, uint32_t valu= e) { if (*min < value) { @@ -6580,33 +6342,22 @@ static void x86_cpu_hyperv_realize(X86CPU *cpu) static void x86_cpu_realizefn(DeviceState *dev, Error **errp) { CPUState *cs =3D CPU(dev); + CPUClass *cc =3D CPU_GET_CLASS(cs); X86CPU *cpu =3D X86_CPU(dev); X86CPUClass *xcc =3D X86_CPU_GET_CLASS(dev); CPUX86State *env =3D &cpu->env; Error *local_err =3D NULL; static bool ht_warned; =20 - if (xcc->host_cpuid_required) { - if (!accel_uses_host_cpuid()) { - g_autofree char *name =3D x86_cpu_class_get_model_name(xcc); - error_setg(&local_err, "CPU model '%s' requires KVM", name); - goto out; - } + /* The accelerator realizefn needs to be called first. */ + if (cc->accel_cpu) { + cc->accel_cpu->cpu_realizefn(cs, errp); } =20 - if (cpu->max_features && accel_uses_host_cpuid()) { - if (enable_cpu_pm) { - host_cpuid(5, 0, &cpu->mwait.eax, &cpu->mwait.ebx, - &cpu->mwait.ecx, &cpu->mwait.edx); - env->features[FEAT_1_ECX] |=3D CPUID_EXT_MONITOR; - if (kvm_enabled() && kvm_has_waitpkg()) { - env->features[FEAT_7_0_ECX] |=3D CPUID_7_0_ECX_WAITPKG; - } - } - if (kvm_enabled() && cpu->ucode_rev =3D=3D 0) { - cpu->ucode_rev =3D kvm_arch_get_supported_msr_feature(kvm_stat= e, - MSR_IA32_U= CODE_REV); - } + if (xcc->host_cpuid_required && !accel_uses_host_cpuid()) { + g_autofree char *name =3D x86_cpu_class_get_model_name(xcc); + error_setg(&local_err, "CPU model '%s' requires KVM or HVF", name); + goto out; } =20 if (cpu->ucode_rev =3D=3D 0) { @@ -6658,39 +6409,7 @@ static void x86_cpu_realizefn(DeviceState *dev, Erro= r **errp) * consumer AMD devices but nothing else. */ if (env->features[FEAT_8000_0001_EDX] & CPUID_EXT2_LM) { - if (accel_uses_host_cpuid()) { - uint32_t host_phys_bits =3D x86_host_phys_bits(); - static bool warned; - - /* Print a warning if the user set it to a value that's not the - * host value. - */ - if (cpu->phys_bits !=3D host_phys_bits && cpu->phys_bits !=3D = 0 && - !warned) { - warn_report("Host physical bits (%u)" - " does not match phys-bits property (%u)", - host_phys_bits, cpu->phys_bits); - warned =3D true; - } - - if (cpu->host_phys_bits) { - /* The user asked for us to use the host physical bits */ - cpu->phys_bits =3D host_phys_bits; - if (cpu->host_phys_bits_limit && - cpu->phys_bits > cpu->host_phys_bits_limit) { - cpu->phys_bits =3D cpu->host_phys_bits_limit; - } - } - - if (cpu->phys_bits && - (cpu->phys_bits > TARGET_PHYS_ADDR_SPACE_BITS || - cpu->phys_bits < 32)) { - error_setg(errp, "phys-bits should be between 32 and %u " - " (but is %u)", - TARGET_PHYS_ADDR_SPACE_BITS, cpu->phys_bi= ts); - return; - } - } else { + if (!accel_uses_host_cpuid()) { if (cpu->phys_bits && cpu->phys_bits !=3D TCG_PHYS_ADDR_BITS) { error_setg(errp, "TCG only supports phys-bits=3D%u", TCG_PHYS_ADDR_BITS); @@ -6698,8 +6417,8 @@ static void x86_cpu_realizefn(DeviceState *dev, Error= **errp) } } /* 0 means it was not explicitly set by the user (or by machine - * compat_props or by the host code above). In this case, the defa= ult - * is the value used by TCG (40). + * compat_props or by the host code in host-cpu.c). + * In this case, the default is the value used by TCG (40). */ if (cpu->phys_bits =3D=3D 0) { cpu->phys_bits =3D TCG_PHYS_ADDR_BITS; @@ -6771,33 +6490,6 @@ static void x86_cpu_realizefn(DeviceState *dev, Erro= r **errp) =20 mce_init(cpu); =20 -#ifndef CONFIG_USER_ONLY - if (tcg_enabled()) { - cpu->cpu_as_mem =3D g_new(MemoryRegion, 1); - cpu->cpu_as_root =3D g_new(MemoryRegion, 1); - - /* Outer container... */ - memory_region_init(cpu->cpu_as_root, OBJECT(cpu), "memory", ~0ull); - memory_region_set_enabled(cpu->cpu_as_root, true); - - /* ... with two regions inside: normal system memory with low - * priority, and... - */ - memory_region_init_alias(cpu->cpu_as_mem, OBJECT(cpu), "memory", - get_system_memory(), 0, ~0ull); - memory_region_add_subregion_overlap(cpu->cpu_as_root, 0, cpu->cpu_= as_mem, 0); - memory_region_set_enabled(cpu->cpu_as_mem, true); - - cs->num_ases =3D 2; - cpu_address_space_init(cs, 0, "cpu-memory", cs->memory); - cpu_address_space_init(cs, 1, "cpu-smm", cpu->cpu_as_root); - - /* ... SMRAM with higher priority, linked from /machine/smram. */ - cpu->machine_done.notify =3D x86_cpu_machine_done; - qemu_add_machine_init_done_notifier(&cpu->machine_done); - } -#endif - qemu_init_vcpu(cs); =20 /* @@ -6997,6 +6689,8 @@ static void x86_cpu_initfn(Object *obj) { X86CPU *cpu =3D X86_CPU(obj); X86CPUClass *xcc =3D X86_CPU_GET_CLASS(obj); + CPUClass *cc =3D CPU_CLASS(xcc); + CPUX86State *env =3D &cpu->env; =20 env->nr_dies =3D 1; @@ -7044,6 +6738,11 @@ static void x86_cpu_initfn(Object *obj) if (xcc->model) { x86_cpu_load_model(cpu, xcc->model); } + + /* if required, do the accelerator-specific cpu initialization */ + if (cc->accel_cpu) { + cc->accel_cpu->cpu_instance_init(CPU(obj)); + } } =20 static int64_t x86_cpu_get_arch_id(CPUState *cs) @@ -7301,11 +7000,6 @@ static void x86_cpu_common_class_init(ObjectClass *o= c, void *data) cc->class_by_name =3D x86_cpu_class_by_name; cc->parse_features =3D x86_cpu_parse_featurestr; cc->has_work =3D x86_cpu_has_work; - -#ifdef CONFIG_TCG - tcg_cpu_common_class_init(cc); -#endif /* CONFIG_TCG */ - cc->dump_state =3D x86_cpu_dump_state; cc->set_pc =3D x86_cpu_set_pc; cc->gdb_read_register =3D x86_cpu_gdb_read_register; @@ -7416,9 +7110,6 @@ static void x86_cpu_register_types(void) } type_register_static(&max_x86_cpu_type_info); type_register_static(&x86_base_cpu_type_info); -#if defined(CONFIG_KVM) || defined(CONFIG_HVF) - type_register_static(&host_x86_cpu_type_info); -#endif } =20 type_init(x86_cpu_register_types) diff --git a/target/i386/host-cpu.c b/target/i386/host-cpu.c new file mode 100644 index 0000000000..3ce2bc9a84 --- /dev/null +++ b/target/i386/host-cpu.c @@ -0,0 +1,198 @@ +/* + * x86 host CPU functions, and "host" cpu type initialization + * + * Copyright 2020 SUSE LLC + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" +#include "cpu.h" +#include "host-cpu.h" +#include "qapi/error.h" +#include "sysemu/sysemu.h" + +/* Note: Only safe for use on x86(-64) hosts */ +static uint32_t host_cpu_phys_bits(void) +{ + uint32_t eax; + uint32_t host_phys_bits; + + host_cpuid(0x80000000, 0, &eax, NULL, NULL, NULL); + if (eax >=3D 0x80000008) { + host_cpuid(0x80000008, 0, &eax, NULL, NULL, NULL); + /* + * Note: According to AMD doc 25481 rev 2.34 they have a field + * at 23:16 that can specify a maximum physical address bits for + * the guest that can override this value; but I've not seen + * anything with that set. + */ + host_phys_bits =3D eax & 0xff; + } else { + /* + * It's an odd 64 bit machine that doesn't have the leaf for + * physical address bits; fall back to 36 that's most older + * Intel. + */ + host_phys_bits =3D 36; + } + + return host_phys_bits; +} + +static void host_cpu_enable_cpu_pm(X86CPU *cpu) +{ + CPUX86State *env =3D &cpu->env; + + host_cpuid(5, 0, &cpu->mwait.eax, &cpu->mwait.ebx, + &cpu->mwait.ecx, &cpu->mwait.edx); + env->features[FEAT_1_ECX] |=3D CPUID_EXT_MONITOR; +} + +static uint32_t host_cpu_adjust_phys_bits(X86CPU *cpu, Error **errp) +{ + uint32_t host_phys_bits =3D host_cpu_phys_bits(); + uint32_t phys_bits =3D cpu->phys_bits; + static bool warned; + + /* + * Print a warning if the user set it to a value that's not the + * host value. + */ + if (phys_bits !=3D host_phys_bits && phys_bits !=3D 0 && + !warned) { + warn_report("Host physical bits (%u)" + " does not match phys-bits property (%u)", + host_phys_bits, phys_bits); + warned =3D true; + } + + if (cpu->host_phys_bits) { + /* The user asked for us to use the host physical bits */ + phys_bits =3D host_phys_bits; + if (cpu->host_phys_bits_limit && + phys_bits > cpu->host_phys_bits_limit) { + phys_bits =3D cpu->host_phys_bits_limit; + } + } + + if (phys_bits && + (phys_bits > TARGET_PHYS_ADDR_SPACE_BITS || + phys_bits < 32)) { + error_setg(errp, "phys-bits should be between 32 and %u " + " (but is %u)", + TARGET_PHYS_ADDR_SPACE_BITS, phys_bits); + } + + return phys_bits; +} + +void host_cpu_realizefn(CPUState *cs, Error **errp) +{ + X86CPU *cpu =3D X86_CPU(cs); + CPUX86State *env =3D &cpu->env; + + if (cpu->max_features && enable_cpu_pm) { + host_cpu_enable_cpu_pm(cpu); + } + if (env->features[FEAT_8000_0001_EDX] & CPUID_EXT2_LM) { + cpu->phys_bits =3D host_cpu_adjust_phys_bits(cpu, errp); + } +} + +#define CPUID_MODEL_ID_SZ 48 +/** + * cpu_x86_fill_model_id: + * Get CPUID model ID string from host CPU. + * + * @str should have at least CPUID_MODEL_ID_SZ bytes + * + * The function does NOT add a null terminator to the string + * automatically. + */ +static int host_cpu_fill_model_id(char *str) +{ + uint32_t eax =3D 0, ebx =3D 0, ecx =3D 0, edx =3D 0; + int i; + + for (i =3D 0; i < 3; i++) { + host_cpuid(0x80000002 + i, 0, &eax, &ebx, &ecx, &edx); + memcpy(str + i * 16 + 0, &eax, 4); + memcpy(str + i * 16 + 4, &ebx, 4); + memcpy(str + i * 16 + 8, &ecx, 4); + memcpy(str + i * 16 + 12, &edx, 4); + } + return 0; +} + +void host_cpu_vendor_fms(char *vendor, int *family, int *model, int *stepp= ing) +{ + uint32_t eax, ebx, ecx, edx; + + host_cpuid(0x0, 0, &eax, &ebx, &ecx, &edx); + x86_cpu_vendor_words2str(vendor, ebx, edx, ecx); + + host_cpuid(0x1, 0, &eax, &ebx, &ecx, &edx); + if (family) { + *family =3D ((eax >> 8) & 0x0F) + ((eax >> 20) & 0xFF); + } + if (model) { + *model =3D ((eax >> 4) & 0x0F) | ((eax & 0xF0000) >> 12); + } + if (stepping) { + *stepping =3D eax & 0x0F; + } +} + +void host_cpu_instance_init(X86CPU *cpu) +{ + uint32_t ebx =3D 0, ecx =3D 0, edx =3D 0; + char vendor[CPUID_VENDOR_SZ + 1]; + + host_cpuid(0, 0, NULL, &ebx, &ecx, &edx); + x86_cpu_vendor_words2str(vendor, ebx, edx, ecx); + + object_property_set_str(OBJECT(cpu), "vendor", vendor, &error_abort); +} + +void host_cpu_max_instance_init(X86CPU *cpu) +{ + char vendor[CPUID_VENDOR_SZ + 1] =3D { 0 }; + char model_id[CPUID_MODEL_ID_SZ + 1] =3D { 0 }; + int family, model, stepping; + + host_cpu_vendor_fms(vendor, &family, &model, &stepping); + host_cpu_fill_model_id(model_id); + + object_property_set_str(OBJECT(cpu), "vendor", vendor, &error_abort); + object_property_set_int(OBJECT(cpu), "family", family, &error_abort); + object_property_set_int(OBJECT(cpu), "model", model, &error_abort); + object_property_set_int(OBJECT(cpu), "stepping", stepping, + &error_abort); + object_property_set_str(OBJECT(cpu), "model-id", model_id, + &error_abort); +} + +static void host_cpu_class_init(ObjectClass *oc, void *data) +{ + X86CPUClass *xcc =3D X86_CPU_CLASS(oc); + + xcc->host_cpuid_required =3D true; + xcc->ordering =3D 8; + xcc->model_description =3D + g_strdup_printf("processor with all supported host features "); +} + +static const TypeInfo host_cpu_type_info =3D { + .name =3D X86_CPU_TYPE_NAME("host"), + .parent =3D X86_CPU_TYPE_NAME("max"), + .class_init =3D host_cpu_class_init, +}; + +static void host_cpu_type_init(void) +{ + type_register_static(&host_cpu_type_info); +} + +type_init(host_cpu_type_init); diff --git a/target/i386/hvf/hvf-cpu.c b/target/i386/hvf/hvf-cpu.c new file mode 100644 index 0000000000..d6579571f1 --- /dev/null +++ b/target/i386/hvf/hvf-cpu.c @@ -0,0 +1,65 @@ +/* + * x86 HVF CPU type initialization + * + * Copyright 2020 SUSE LLC + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" +#include "cpu.h" +#include "host-cpu.h" +#include "qapi/error.h" +#include "sysemu/sysemu.h" +#include "hw/boards.h" +#include "sysemu/hvf.h" +#include "hw/core/accel-cpu.h" + +static void hvf_cpu_max_instance_init(X86CPU *cpu) +{ + CPUX86State *env =3D &cpu->env; + + host_cpu_max_instance_init(cpu); + + env->cpuid_min_level =3D + hvf_get_supported_cpuid(0x0, 0, R_EAX); + env->cpuid_min_xlevel =3D + hvf_get_supported_cpuid(0x80000000, 0, R_EAX); + env->cpuid_min_xlevel2 =3D + hvf_get_supported_cpuid(0xC0000000, 0, R_EAX); +} + +static void hvf_cpu_instance_init(CPUState *cs) +{ + X86CPU *cpu =3D X86_CPU(cs); + + host_cpu_instance_init(cpu); + + /* Special cases not set in the X86CPUDefinition structs: */ + /* TODO: in-kernel irqchip for hvf */ + + if (cpu->max_features) { + hvf_cpu_max_instance_init(cpu); + } +} + +static void hvf_cpu_accel_class_init(ObjectClass *oc, void *data) +{ + AccelCPUClass *acc =3D ACCEL_CPU_CLASS(oc); + + acc->cpu_realizefn =3D host_cpu_realizefn; + acc->cpu_instance_init =3D hvf_cpu_instance_init; +}; +static const TypeInfo hvf_cpu_accel_type_info =3D { + .name =3D ACCEL_CPU_NAME("hvf"), + + .parent =3D TYPE_ACCEL_CPU, + .class_init =3D hvf_cpu_accel_class_init, + .abstract =3D true, +}; +static void hvf_cpu_accel_register_types(void) +{ + type_register_static(&hvf_cpu_accel_type_info); +} +type_init(hvf_cpu_accel_register_types); diff --git a/target/i386/kvm/kvm-cpu.c b/target/i386/kvm/kvm-cpu.c new file mode 100644 index 0000000000..78758780ec --- /dev/null +++ b/target/i386/kvm/kvm-cpu.c @@ -0,0 +1,151 @@ +/* + * x86 KVM CPU type initialization + * + * Copyright 2020 SUSE LLC + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" +#include "cpu.h" +#include "host-cpu.h" +#include "kvm-cpu.h" +#include "qapi/error.h" +#include "sysemu/sysemu.h" +#include "hw/boards.h" + +#include "kvm_i386.h" +#include "hw/core/accel-cpu.h" + +static void kvm_cpu_realizefn(CPUState *cs, Error **errp) +{ + X86CPU *cpu =3D X86_CPU(cs); + CPUX86State *env =3D &cpu->env; + + /* + * The realize order is important, since x86_cpu_realize() checks if + * nothing else has been set by the user (or by accelerators) in + * cpu->ucode_rev and cpu->phys_bits. + * + * realize order: + * kvm_cpu -> host_cpu -> x86_cpu + */ + if (cpu->max_features) { + if (enable_cpu_pm && kvm_has_waitpkg()) { + env->features[FEAT_7_0_ECX] |=3D CPUID_7_0_ECX_WAITPKG; + } + if (cpu->ucode_rev =3D=3D 0) { + cpu->ucode_rev =3D + kvm_arch_get_supported_msr_feature(kvm_state, + MSR_IA32_UCODE_REV); + } + } + host_cpu_realizefn(cs, errp); +} + +/* + * KVM-specific features that are automatically added/removed + * from all CPU models when KVM is enabled. + */ +static PropValue kvm_default_props[] =3D { + { "kvmclock", "on" }, + { "kvm-nopiodelay", "on" }, + { "kvm-asyncpf", "on" }, + { "kvm-steal-time", "on" }, + { "kvm-pv-eoi", "on" }, + { "kvmclock-stable-bit", "on" }, + { "x2apic", "on" }, + { "kvm-msi-ext-dest-id", "off" }, + { "acpi", "off" }, + { "monitor", "off" }, + { "svm", "off" }, + { NULL, NULL }, +}; + +void x86_cpu_change_kvm_default(const char *prop, const char *value) +{ + PropValue *pv; + for (pv =3D kvm_default_props; pv->prop; pv++) { + if (!strcmp(pv->prop, prop)) { + pv->value =3D value; + break; + } + } + + /* + * It is valid to call this function only for properties that + * are already present in the kvm_default_props table. + */ + assert(pv->prop); +} + +static bool lmce_supported(void) +{ + uint64_t mce_cap =3D 0; + + if (kvm_ioctl(kvm_state, KVM_X86_GET_MCE_CAP_SUPPORTED, &mce_cap) < 0)= { + return false; + } + return !!(mce_cap & MCG_LMCE_P); +} + +static void kvm_cpu_max_instance_init(X86CPU *cpu) +{ + CPUX86State *env =3D &cpu->env; + KVMState *s =3D kvm_state; + + host_cpu_max_instance_init(cpu); + + if (lmce_supported()) { + object_property_set_bool(OBJECT(cpu), "lmce", true, &error_abort); + } + + env->cpuid_min_level =3D + kvm_arch_get_supported_cpuid(s, 0x0, 0, R_EAX); + env->cpuid_min_xlevel =3D + kvm_arch_get_supported_cpuid(s, 0x80000000, 0, R_EAX); + env->cpuid_min_xlevel2 =3D + kvm_arch_get_supported_cpuid(s, 0xC0000000, 0, R_EAX); +} + +static void kvm_cpu_instance_init(CPUState *cs) +{ + X86CPU *cpu =3D X86_CPU(cs); + + host_cpu_instance_init(cpu); + + if (!kvm_irqchip_in_kernel()) { + x86_cpu_change_kvm_default("x2apic", "off"); + } else if (kvm_irqchip_is_split() && kvm_enable_x2apic()) { + x86_cpu_change_kvm_default("kvm-msi-ext-dest-id", "on"); + } + + /* Special cases not set in the X86CPUDefinition structs: */ + + x86_cpu_apply_props(cpu, kvm_default_props); + + if (cpu->max_features) { + kvm_cpu_max_instance_init(cpu); + } +} + +static void kvm_cpu_accel_class_init(ObjectClass *oc, void *data) +{ + AccelCPUClass *acc =3D ACCEL_CPU_CLASS(oc); + + acc->cpu_realizefn =3D kvm_cpu_realizefn; + acc->cpu_instance_init =3D kvm_cpu_instance_init; +} +static const TypeInfo kvm_cpu_accel_type_info =3D { + .name =3D ACCEL_CPU_NAME("kvm"), + + .parent =3D TYPE_ACCEL_CPU, + .class_init =3D kvm_cpu_accel_class_init, + .abstract =3D true, +}; +static void kvm_cpu_accel_register_types(void) +{ + type_register_static(&kvm_cpu_accel_type_info); +} +type_init(kvm_cpu_accel_register_types); diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index 6dc1ee052d..052de11915 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -22,6 +22,7 @@ #include "standard-headers/asm-x86/kvm_para.h" =20 #include "cpu.h" +#include "host-cpu.h" #include "sysemu/sysemu.h" #include "sysemu/hw_accel.h" #include "sysemu/kvm_int.h" @@ -285,7 +286,7 @@ static bool host_tsx_broken(void) int family, model, stepping;\ char vendor[CPUID_VENDOR_SZ + 1]; =20 - host_vendor_fms(vendor, &family, &model, &stepping); + host_cpu_vendor_fms(vendor, &family, &model, &stepping); =20 /* Check if we are running on a Haswell host known to have broken TSX = */ return !strcmp(vendor, CPUID_VENDOR_INTEL) && diff --git a/target/i386/tcg/tcg-cpu.c b/target/i386/tcg/tcg-cpu.c index 1e125d2175..1d3d6d1c6a 100644 --- a/target/i386/tcg/tcg-cpu.c +++ b/target/i386/tcg/tcg-cpu.c @@ -19,13 +19,14 @@ =20 #include "qemu/osdep.h" #include "cpu.h" -#include "tcg-cpu.h" -#include "exec/exec-all.h" -#include "sysemu/runstate.h" #include "helper-tcg.h" +#include "qemu/accel.h" +#include "hw/core/accel-cpu.h" =20 -#if !defined(CONFIG_USER_ONLY) -#include "hw/i386/apic.h" +#ifndef CONFIG_USER_ONLY +#include "sysemu/sysemu.h" +#include "qemu/units.h" +#include "exec/address-spaces.h" #endif =20 /* Frob eflags into and out of the CPU temporary format. */ @@ -72,7 +73,107 @@ static struct TCGCPUOps x86_tcg_ops =3D { #endif /* !CONFIG_USER_ONLY */ }; =20 -void tcg_cpu_common_class_init(CPUClass *cc) +static void tcg_cpu_class_init(CPUClass *cc) { cc->tcg_ops =3D &x86_tcg_ops; } + +#ifndef CONFIG_USER_ONLY + +static void x86_cpu_machine_done(Notifier *n, void *unused) +{ + X86CPU *cpu =3D container_of(n, X86CPU, machine_done); + MemoryRegion *smram =3D + (MemoryRegion *) object_resolve_path("/machine/smram", NULL); + + if (smram) { + cpu->smram =3D g_new(MemoryRegion, 1); + memory_region_init_alias(cpu->smram, OBJECT(cpu), "smram", + smram, 0, 4 * GiB); + memory_region_set_enabled(cpu->smram, true); + memory_region_add_subregion_overlap(cpu->cpu_as_root, 0, + cpu->smram, 1); + } +} + +static void tcg_cpu_realizefn(CPUState *cs, Error **errp) +{ + X86CPU *cpu =3D X86_CPU(cs); + + /* + * The realize order is important, since x86_cpu_realize() checks if + * nothing else has been set by the user (or by accelerators) in + * cpu->ucode_rev and cpu->phys_bits, and the memory regions + * initialized here are needed for the vcpu initialization. + * + * realize order: + * tcg_cpu -> host_cpu -> x86_cpu + */ + cpu->cpu_as_mem =3D g_new(MemoryRegion, 1); + cpu->cpu_as_root =3D g_new(MemoryRegion, 1); + + /* Outer container... */ + memory_region_init(cpu->cpu_as_root, OBJECT(cpu), "memory", ~0ull); + memory_region_set_enabled(cpu->cpu_as_root, true); + + /* + * ... with two regions inside: normal system memory with low + * priority, and... + */ + memory_region_init_alias(cpu->cpu_as_mem, OBJECT(cpu), "memory", + get_system_memory(), 0, ~0ull); + memory_region_add_subregion_overlap(cpu->cpu_as_root, 0, cpu->cpu_as_m= em, 0); + memory_region_set_enabled(cpu->cpu_as_mem, true); + + cs->num_ases =3D 2; + cpu_address_space_init(cs, 0, "cpu-memory", cs->memory); + cpu_address_space_init(cs, 1, "cpu-smm", cpu->cpu_as_root); + + /* ... SMRAM with higher priority, linked from /machine/smram. */ + cpu->machine_done.notify =3D x86_cpu_machine_done; + qemu_add_machine_init_done_notifier(&cpu->machine_done); +} + +#else /* CONFIG_USER_ONLY */ + +static void tcg_cpu_realizefn(CPUState *cs, Error **errp) +{ +} + +#endif /* !CONFIG_USER_ONLY */ + +/* + * TCG-specific defaults that override all CPU models when using TCG + */ +static PropValue tcg_default_props[] =3D { + { "vme", "off" }, + { NULL, NULL }, +}; + +static void tcg_cpu_instance_init(CPUState *cs) +{ + X86CPU *cpu =3D X86_CPU(cs); + /* Special cases not set in the X86CPUDefinition structs: */ + x86_cpu_apply_props(cpu, tcg_default_props); +} + +static void tcg_cpu_accel_class_init(ObjectClass *oc, void *data) +{ + AccelCPUClass *acc =3D ACCEL_CPU_CLASS(oc); + + acc->cpu_realizefn =3D tcg_cpu_realizefn; + acc->cpu_class_init =3D tcg_cpu_class_init; + acc->cpu_instance_init =3D tcg_cpu_instance_init; +} +static const TypeInfo tcg_cpu_accel_type_info =3D { + .name =3D ACCEL_CPU_NAME("tcg"), + + .parent =3D TYPE_ACCEL_CPU, + .class_init =3D tcg_cpu_accel_class_init, + .abstract =3D true, +}; +static void tcg_cpu_accel_register_types(void) +{ + type_register_static(&tcg_cpu_accel_type_info); +} +type_init(tcg_cpu_accel_register_types); diff --git a/MAINTAINERS b/MAINTAINERS index 2724a0102e..d3caca4b2d 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -340,7 +340,7 @@ M: Paolo Bonzini M: Richard Henderson M: Eduardo Habkost S: Maintained -F: target/i386/ +F: target/i386/tcg/ F: tests/tcg/i386/ F: tests/tcg/x86_64/ F: hw/i386/ diff --git a/target/i386/hvf/meson.build b/target/i386/hvf/meson.build index e9eb5a5da8..d253d5fd10 100644 --- a/target/i386/hvf/meson.build +++ b/target/i386/hvf/meson.build @@ -10,4 +10,5 @@ i386_softmmu_ss.add(when: [hvf, 'CONFIG_HVF'], if_true: f= iles( 'x86_mmu.c', 'x86_task.c', 'x86hvf.c', + 'hvf-cpu.c', )) diff --git a/target/i386/kvm/meson.build b/target/i386/kvm/meson.build index 1d66559187..0a533411ca 100644 --- a/target/i386/kvm/meson.build +++ b/target/i386/kvm/meson.build @@ -1,3 +1,8 @@ i386_ss.add(when: 'CONFIG_KVM', if_false: files('kvm-stub.c')) -i386_softmmu_ss.add(when: 'CONFIG_KVM', if_true: files('kvm.c')) + +i386_softmmu_ss.add(when: 'CONFIG_KVM', if_true: files( + 'kvm.c', + 'kvm-cpu.c', +)) + i386_softmmu_ss.add(when: 'CONFIG_HYPERV', if_true: files('hyperv.c'), if_= false: files('hyperv-stub.c')) diff --git a/target/i386/meson.build b/target/i386/meson.build index c4bf20b319..fd24479590 100644 --- a/target/i386/meson.build +++ b/target/i386/meson.build @@ -6,7 +6,11 @@ i386_ss.add(files( 'xsave_helper.c', 'cpu-dump.c', )) -i386_ss.add(when: 'CONFIG_SEV', if_true: files('sev.c'), if_false: files('= sev-stub.c')) +i386_ss.add(when: 'CONFIG_SEV', if_true: files('host-cpu.c', 'sev.c'), if_= false: files('sev-stub.c')) + +# x86 cpu type +i386_ss.add(when: 'CONFIG_KVM', if_true: files('host-cpu.c')) +i386_ss.add(when: 'CONFIG_HVF', if_true: files('host-cpu.c')) =20 i386_softmmu_ss =3D ss.source_set() i386_softmmu_ss.add(files( --=20 2.26.2 From nobody Thu Apr 25 18:08:54 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=1610475749; cv=none; d=zohomail.com; s=zohoarc; b=R5mBOZPD6hwaxzryVAwKspF5G7xmH3ILiEyPrKnD1kwwq4mTkcpJxreC/Zgzb5AMXSKb99tQZlVvquV4OVxcqTtp4TD+0raLABLGQeNUd4oeId7wWnluAEVUz8lEq2/DQFAHaO1E4/wRSBNqqIoIwyKmac4bmYvxPLLxn47M8BU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610475749; 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=Q2XN25D4GUwUZRDZp+cn+yS8Av1D+dqSd0aQ6UtyztI=; b=VHyCvoIm/TLa4OoJF0FJXJ7aZRQeEW9JCHDvTvYVL9xVeeJgWZ9tqm+kamH4CiInDPM0ANGNVS6+rb/Pn40dQSoYAanP09PSgnna5F/ikyfpNf4rtMIo4xQjipJulbAqZkbedZ0HhOAOe4Rondmr91qD1REMmqT+a/oPXeRIR9A= 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 1610475749398590.077309200758; Tue, 12 Jan 2021 10:22:29 -0800 (PST) Received: from localhost ([::1]:40168 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kzOJG-00010j-5r for importer@patchew.org; Tue, 12 Jan 2021 13:22:26 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48240) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kzO1P-0005ef-TR for qemu-devel@nongnu.org; Tue, 12 Jan 2021 13:03:59 -0500 Received: from mx2.suse.de ([195.135.220.15]:34128) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kzO1D-0004yA-Sg for qemu-devel@nongnu.org; Tue, 12 Jan 2021 13:03:59 -0500 Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 9257BAF2B; Tue, 12 Jan 2021 18:03:36 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Claudio Fontana To: Paolo Bonzini , Thomas Huth , Richard Henderson , Stefano Stabellini , Wenchao Wang , Roman Bolshakov , Sunil Muthuswamy , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v12 20/22] cpu: call AccelCPUClass::cpu_realizefn in cpu_exec_realizefn Date: Tue, 12 Jan 2021 19:03:10 +0100 Message-Id: <20210112180312.26043-21-cfontana@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210112180312.26043-1-cfontana@suse.de> References: <20210112180312.26043-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 , Peter Maydell , Eduardo Habkost , Paul Durrant , Jason Wang , Marcelo Tosatti , qemu-devel@nongnu.org, Peter Xu , Dario Faggioli , Cameron Esfahani , haxm-team@intel.com, Claudio Fontana , Anthony Perard , Bruce Rogers , Olaf Hering , "Emilio G . Cota" , Colin Xu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" move the call to accel_cpu->cpu_realizefn to the general cpu_exec_realizefn from target/i386, so it does not need to be called for every target explicitly as we enable more targets. Signed-off-by: Claudio Fontana --- cpu.c | 6 ++++++ target/i386/cpu.c | 20 +++++++------------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/cpu.c b/cpu.c index bfbe5a66f9..ba5d272c1e 100644 --- a/cpu.c +++ b/cpu.c @@ -36,6 +36,7 @@ #include "sysemu/replay.h" #include "exec/translate-all.h" #include "exec/log.h" +#include "hw/core/accel-cpu.h" =20 uintptr_t qemu_host_page_size; intptr_t qemu_host_page_mask; @@ -130,6 +131,11 @@ void cpu_exec_realizefn(CPUState *cpu, Error **errp) =20 cpu_list_add(cpu); =20 + if (cc->accel_cpu) { + /* NB: errp parameter is unused currently */ + cc->accel_cpu->cpu_realizefn(cpu, errp); + } + #ifdef CONFIG_TCG /* NB: errp parameter is unused currently */ if (tcg_enabled()) { diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 56a299ef14..9bfbf19a71 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -6342,16 +6342,19 @@ static void x86_cpu_hyperv_realize(X86CPU *cpu) static void x86_cpu_realizefn(DeviceState *dev, Error **errp) { CPUState *cs =3D CPU(dev); - CPUClass *cc =3D CPU_GET_CLASS(cs); X86CPU *cpu =3D X86_CPU(dev); X86CPUClass *xcc =3D X86_CPU_GET_CLASS(dev); CPUX86State *env =3D &cpu->env; Error *local_err =3D NULL; static bool ht_warned; =20 - /* The accelerator realizefn needs to be called first. */ - if (cc->accel_cpu) { - cc->accel_cpu->cpu_realizefn(cs, errp); + /* Process Hyper-V enlightenments */ + x86_cpu_hyperv_realize(cpu); + + cpu_exec_realizefn(cs, &local_err); + if (local_err !=3D NULL) { + error_propagate(errp, local_err); + return; } =20 if (xcc->host_cpuid_required && !accel_uses_host_cpuid()) { @@ -6467,15 +6470,6 @@ static void x86_cpu_realizefn(DeviceState *dev, Erro= r **errp) env->cache_info_amd.l3_cache =3D &legacy_l3_cache; } =20 - /* Process Hyper-V enlightenments */ - x86_cpu_hyperv_realize(cpu); - - cpu_exec_realizefn(cs, &local_err); - if (local_err !=3D NULL) { - error_propagate(errp, local_err); - return; - } - #ifndef CONFIG_USER_ONLY MachineState *ms =3D MACHINE(qdev_get_machine()); qemu_register_reset(x86_cpu_machine_reset_cb, cpu); --=20 2.26.2 From nobody Thu Apr 25 18:08:54 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=1610475879; cv=none; d=zohomail.com; s=zohoarc; b=J6D9VE1Iy086vYbCzN5JJfwdgMijW2oBcpY1ZJQf+v/3dMCJvhFQpbgAPN0927Q5nfOrl5/izDTBggCdkDlNdYO5W15+LoFTI3LcBAmPLgL7gHtHYVGVdJYVub+L+6Ti/Fnmf5ARTfzHdTbP4z25UgPf1RNNSbshHJLDWSbKx7c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610475879; 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=qqDx86JpKGWK1CA0/B4dP1oQzfG+aIj6XNdrrxrXojY=; b=PVkUmmA4YwMHkL2VsgIspnMyCEsZgm+BaDpudbjyn5I8voGyqoJ/rF7dogW+iIZfTMVpJYo0qRk/yjDNYZboM4G6czLxlrhev+J8I2KX2mxZifunc85+pKdU4hzPHfFVcYk0RkxUZ2z8QzE65rIpFmgLPrB+U2KTp6usVt6GLbE= 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 1610475879501482.44577656088063; Tue, 12 Jan 2021 10:24:39 -0800 (PST) Received: from localhost ([::1]:48546 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kzOLN-0005BH-RH for importer@patchew.org; Tue, 12 Jan 2021 13:24:37 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48262) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kzO1R-0005ii-Ep for qemu-devel@nongnu.org; Tue, 12 Jan 2021 13:04:01 -0500 Received: from mx2.suse.de ([195.135.220.15]:34170) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kzO1F-0004yJ-QI for qemu-devel@nongnu.org; Tue, 12 Jan 2021 13:04:01 -0500 Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 9514BAF37; Tue, 12 Jan 2021 18:03:37 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Claudio Fontana To: Paolo Bonzini , Thomas Huth , Richard Henderson , Stefano Stabellini , Wenchao Wang , Roman Bolshakov , Sunil Muthuswamy , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v12 21/22] hw/core/cpu: call qemu_init_vcpu in cpu_common_realizefn Date: Tue, 12 Jan 2021 19:03:11 +0100 Message-Id: <20210112180312.26043-22-cfontana@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210112180312.26043-1-cfontana@suse.de> References: <20210112180312.26043-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 , Peter Maydell , Eduardo Habkost , Paul Durrant , Jason Wang , Marcelo Tosatti , qemu-devel@nongnu.org, Peter Xu , Dario Faggioli , Cameron Esfahani , haxm-team@intel.com, Claudio Fontana , Anthony Perard , Bruce Rogers , Olaf Hering , "Emilio G . Cota" , Colin Xu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" move the call to qemu_init_vcpu inside cpu_common_realizefn, so it does not need to be done explicitly in each target cpu. Despite this, the way cpu realize is done continues to be not ideal; ideally the cpu_list_add would be done in common_cpu, and in this case we could avoid even more redundant open coded additional calls in target/xxx/cpu.c, but this cannot happen because target cpu code, plugins, etc now all came to rely on cpu->index (which is updated in cpu_list_add), since no particular order was defined previously, so we are stuck with the freak call order for the target cpu realizefn. After this patch the target/xxx/cpu.c realizefn body becomes: void mycpu_realizefn(DeviceState *dev, Error **errp) { /* ... */ cpu_exec_realizefn(CPU_STATE(dev), errp); /* ... anything that needs done pre-qemu_vcpu_init */ xcc->parent_realize(dev, errp); /* does qemu_vcpu_init */ /* ... anything that needs to be done after qemu_vcpu_init */ } Signed-off-by: Claudio Fontana --- hw/core/cpu.c | 2 ++ target/alpha/cpu.c | 5 +---- target/arm/cpu.c | 4 +--- target/avr/cpu.c | 3 +-- target/cris/cpu.c | 2 -- target/hppa/cpu.c | 1 - target/i386/cpu.c | 5 +---- target/lm32/cpu.c | 3 --- target/m68k/cpu.c | 2 -- target/microblaze/cpu.c | 9 +++------ target/mips/cpu.c | 2 -- target/moxie/cpu.c | 4 +--- target/nios2/cpu.c | 4 +--- target/openrisc/cpu.c | 4 +--- target/riscv/cpu.c | 8 +++----- target/rx/cpu.c | 8 +++----- target/s390x/cpu.c | 3 +-- target/sh4/cpu.c | 2 -- target/sparc/cpu.c | 4 +--- target/tilegx/cpu.c | 2 -- target/tricore/cpu.c | 2 -- target/unicore32/cpu.c | 6 +----- target/xtensa/cpu.c | 2 -- target/ppc/translate_init.c.inc | 5 ++--- 24 files changed, 23 insertions(+), 69 deletions(-) diff --git a/hw/core/cpu.c b/hw/core/cpu.c index 00330ba07d..2d8103167b 100644 --- a/hw/core/cpu.c +++ b/hw/core/cpu.c @@ -310,6 +310,8 @@ static void cpu_common_realizefn(DeviceState *dev, Erro= r **errp) CPUState *cpu =3D CPU(dev); Object *machine =3D qdev_get_machine(); =20 + qemu_init_vcpu(cpu); + /* qdev_get_machine() can return something that's not TYPE_MACHINE * if this is one of the user-only emulators; in that case there's * no need to check the ignore_memory_transaction_failures board flag. diff --git a/target/alpha/cpu.c b/target/alpha/cpu.c index 27192b62e2..07406d5e38 100644 --- a/target/alpha/cpu.c +++ b/target/alpha/cpu.c @@ -56,18 +56,15 @@ static void alpha_cpu_disas_set_info(CPUState *cpu, dis= assemble_info *info) =20 static void alpha_cpu_realizefn(DeviceState *dev, Error **errp) { - CPUState *cs =3D CPU(dev); AlphaCPUClass *acc =3D ALPHA_CPU_GET_CLASS(dev); Error *local_err =3D NULL; =20 - cpu_exec_realizefn(cs, &local_err); + cpu_exec_realizefn(CPU(dev), &local_err); if (local_err !=3D NULL) { error_propagate(errp, local_err); return; } =20 - qemu_init_vcpu(cs); - acc->parent_realize(dev, errp); } =20 diff --git a/target/arm/cpu.c b/target/arm/cpu.c index b8b34f1b3a..b0cf0b3261 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -1864,10 +1864,8 @@ static void arm_cpu_realizefn(DeviceState *dev, Erro= r **errp) } } =20 - qemu_init_vcpu(cs); - cpu_reset(cs); - acc->parent_realize(dev, errp); + cpu_reset(cs); } =20 static ObjectClass *arm_cpu_class_by_name(const char *cpu_model) diff --git a/target/avr/cpu.c b/target/avr/cpu.c index fa0f8e0e80..b1ffeac72d 100644 --- a/target/avr/cpu.c +++ b/target/avr/cpu.c @@ -98,10 +98,9 @@ static void avr_cpu_realizefn(DeviceState *dev, Error **= errp) error_propagate(errp, local_err); return; } - qemu_init_vcpu(cs); - cpu_reset(cs); =20 mcc->parent_realize(dev, errp); + cpu_reset(cs); } =20 static void avr_cpu_set_int(void *opaque, int irq, int level) diff --git a/target/cris/cpu.c b/target/cris/cpu.c index ed983380fc..da161dae1b 100644 --- a/target/cris/cpu.c +++ b/target/cris/cpu.c @@ -135,8 +135,6 @@ static void cris_cpu_realizefn(DeviceState *dev, Error = **errp) } =20 cpu_reset(cs); - qemu_init_vcpu(cs); - ccc->parent_realize(dev, errp); } =20 diff --git a/target/hppa/cpu.c b/target/hppa/cpu.c index d8fad52d1f..2724f731b8 100644 --- a/target/hppa/cpu.c +++ b/target/hppa/cpu.c @@ -102,7 +102,6 @@ static void hppa_cpu_realizefn(DeviceState *dev, Error = **errp) return; } =20 - qemu_init_vcpu(cs); acc->parent_realize(dev, errp); =20 #ifndef CONFIG_USER_ONLY diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 9bfbf19a71..83c474e270 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -6484,8 +6484,7 @@ static void x86_cpu_realizefn(DeviceState *dev, Error= **errp) =20 mce_init(cpu); =20 - qemu_init_vcpu(cs); - + xcc->parent_realize(dev, &local_err); /* * Most Intel and certain AMD CPUs support hyperthreading. Even though= QEMU * fixes this issue by adjusting CPUID_0000_0001_EBX and CPUID_8000_00= 08_ECX @@ -6512,8 +6511,6 @@ static void x86_cpu_realizefn(DeviceState *dev, Error= **errp) } cpu_reset(cs); =20 - xcc->parent_realize(dev, &local_err); - out: if (local_err !=3D NULL) { error_propagate(errp, local_err); diff --git a/target/lm32/cpu.c b/target/lm32/cpu.c index c23d72874c..3c9987709e 100644 --- a/target/lm32/cpu.c +++ b/target/lm32/cpu.c @@ -133,9 +133,6 @@ static void lm32_cpu_realizefn(DeviceState *dev, Error = **errp) } =20 cpu_reset(cs); - - qemu_init_vcpu(cs); - lcc->parent_realize(dev, errp); } =20 diff --git a/target/m68k/cpu.c b/target/m68k/cpu.c index c6fde8132b..180ad04bd8 100644 --- a/target/m68k/cpu.c +++ b/target/m68k/cpu.c @@ -248,8 +248,6 @@ static void m68k_cpu_realizefn(DeviceState *dev, Error = **errp) m68k_cpu_init_gdb(cpu); =20 cpu_reset(cs); - qemu_init_vcpu(cs); - mcc->parent_realize(dev, errp); } =20 diff --git a/target/microblaze/cpu.c b/target/microblaze/cpu.c index af1528fcc5..829ab9875e 100644 --- a/target/microblaze/cpu.c +++ b/target/microblaze/cpu.c @@ -146,15 +146,14 @@ static void mb_disas_set_info(CPUState *cpu, disassem= ble_info *info) =20 static void mb_cpu_realizefn(DeviceState *dev, Error **errp) { - CPUState *cs =3D CPU(dev); MicroBlazeCPUClass *mcc =3D MICROBLAZE_CPU_GET_CLASS(dev); - MicroBlazeCPU *cpu =3D MICROBLAZE_CPU(cs); + MicroBlazeCPU *cpu =3D MICROBLAZE_CPU(dev); uint8_t version_code =3D 0; const char *version; int i =3D 0; Error *local_err =3D NULL; =20 - cpu_exec_realizefn(cs, &local_err); + cpu_exec_realizefn(CPU(dev), &local_err); if (local_err !=3D NULL) { error_propagate(errp, local_err); return; @@ -166,7 +165,7 @@ static void mb_cpu_realizefn(DeviceState *dev, Error **= errp) return; } =20 - qemu_init_vcpu(cs); + mcc->parent_realize(dev, errp); =20 version =3D cpu->cfg.version ? cpu->cfg.version : DEFAULT_CPU_VERSION; for (i =3D 0; mb_cpu_lookup[i].name && version; i++) { @@ -232,8 +231,6 @@ static void mb_cpu_realizefn(DeviceState *dev, Error **= errp) cpu->cfg.mmu_tlb_access =3D 3; cpu->cfg.mmu_zones =3D 16; cpu->cfg.addr_mask =3D MAKE_64BIT_MASK(0, cpu->cfg.addr_size); - - mcc->parent_realize(dev, errp); } =20 static void mb_cpu_initfn(Object *obj) diff --git a/target/mips/cpu.c b/target/mips/cpu.c index 840150e08e..348911ba9c 100644 --- a/target/mips/cpu.c +++ b/target/mips/cpu.c @@ -425,8 +425,6 @@ static void mips_cpu_realizefn(DeviceState *dev, Error = **errp) mvp_init(env); =20 cpu_reset(cs); - qemu_init_vcpu(cs); - mcc->parent_realize(dev, errp); } =20 diff --git a/target/moxie/cpu.c b/target/moxie/cpu.c index 83bec34d36..f3284e730d 100644 --- a/target/moxie/cpu.c +++ b/target/moxie/cpu.c @@ -66,10 +66,8 @@ static void moxie_cpu_realizefn(DeviceState *dev, Error = **errp) return; } =20 - qemu_init_vcpu(cs); - cpu_reset(cs); - mcc->parent_realize(dev, errp); + cpu_reset(cs); } =20 static void moxie_cpu_initfn(Object *obj) diff --git a/target/nios2/cpu.c b/target/nios2/cpu.c index e9c9fc3a38..e59ed9e135 100644 --- a/target/nios2/cpu.c +++ b/target/nios2/cpu.c @@ -121,10 +121,8 @@ static void nios2_cpu_realizefn(DeviceState *dev, Erro= r **errp) return; } =20 - qemu_init_vcpu(cs); - cpu_reset(cs); - ncc->parent_realize(dev, errp); + cpu_reset(cs); } =20 static bool nios2_cpu_exec_interrupt(CPUState *cs, int interrupt_request) diff --git a/target/openrisc/cpu.c b/target/openrisc/cpu.c index 2c64842f46..d7877ecfdd 100644 --- a/target/openrisc/cpu.c +++ b/target/openrisc/cpu.c @@ -105,10 +105,8 @@ static void openrisc_cpu_realizefn(DeviceState *dev, E= rror **errp) return; } =20 - qemu_init_vcpu(cs); - cpu_reset(cs); - occ->parent_realize(dev, errp); + cpu_reset(cs); } =20 static void openrisc_cpu_initfn(Object *obj) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index e649cab2c1..72f6a9d157 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -372,7 +372,7 @@ static void riscv_cpu_disas_set_info(CPUState *s, disas= semble_info *info) } } =20 -static void riscv_cpu_realize(DeviceState *dev, Error **errp) +static void riscv_cpu_realizefn(DeviceState *dev, Error **errp) { CPUState *cs =3D CPU(dev); RISCVCPU *cpu =3D RISCV_CPU(dev); @@ -517,10 +517,8 @@ static void riscv_cpu_realize(DeviceState *dev, Error = **errp) =20 riscv_cpu_register_gdb_regs_for_features(cs); =20 - qemu_init_vcpu(cs); - cpu_reset(cs); - mcc->parent_realize(dev, errp); + cpu_reset(cs); } =20 static void riscv_cpu_init(Object *obj) @@ -578,7 +576,7 @@ static void riscv_cpu_class_init(ObjectClass *c, void *= data) CPUClass *cc =3D CPU_CLASS(c); DeviceClass *dc =3D DEVICE_CLASS(c); =20 - device_class_set_parent_realize(dc, riscv_cpu_realize, + device_class_set_parent_realize(dc, riscv_cpu_realizefn, &mcc->parent_realize); =20 device_class_set_parent_reset(dc, riscv_cpu_reset, &mcc->parent_reset); diff --git a/target/rx/cpu.c b/target/rx/cpu.c index 7ac6618b26..3dd2e649d3 100644 --- a/target/rx/cpu.c +++ b/target/rx/cpu.c @@ -106,7 +106,7 @@ static ObjectClass *rx_cpu_class_by_name(const char *cp= u_model) return oc; } =20 -static void rx_cpu_realize(DeviceState *dev, Error **errp) +static void rx_cpu_realizefn(DeviceState *dev, Error **errp) { CPUState *cs =3D CPU(dev); RXCPUClass *rcc =3D RX_CPU_GET_CLASS(dev); @@ -118,10 +118,8 @@ static void rx_cpu_realize(DeviceState *dev, Error **e= rrp) return; } =20 - qemu_init_vcpu(cs); - cpu_reset(cs); - rcc->parent_realize(dev, errp); + cpu_reset(cs); } =20 static void rx_cpu_set_irq(void *opaque, int no, int request) @@ -192,7 +190,7 @@ static void rx_cpu_class_init(ObjectClass *klass, void = *data) CPUClass *cc =3D CPU_CLASS(klass); RXCPUClass *rcc =3D RX_CPU_CLASS(klass); =20 - device_class_set_parent_realize(dc, rx_cpu_realize, + device_class_set_parent_realize(dc, rx_cpu_realizefn, &rcc->parent_realize); device_class_set_parent_reset(dc, rx_cpu_reset, &rcc->parent_reset); diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c index d35eb39a1b..303932d51a 100644 --- a/target/s390x/cpu.c +++ b/target/s390x/cpu.c @@ -232,8 +232,8 @@ static void s390_cpu_realizefn(DeviceState *dev, Error = **errp) qemu_register_reset(s390_cpu_machine_reset_cb, cpu); #endif s390_cpu_gdb_init(cs); - qemu_init_vcpu(cs); =20 + scc->parent_realize(dev, &err); /* * KVM requires the initial CPU reset ioctl to be executed on the targ= et * CPU thread. CPU hotplug under single-threaded TCG will not work with @@ -246,7 +246,6 @@ static void s390_cpu_realizefn(DeviceState *dev, Error = **errp) cpu_reset(cs); } =20 - scc->parent_realize(dev, &err); out: error_propagate(errp, err); } diff --git a/target/sh4/cpu.c b/target/sh4/cpu.c index a78d283bc8..5ee540c6c5 100644 --- a/target/sh4/cpu.c +++ b/target/sh4/cpu.c @@ -186,8 +186,6 @@ static void superh_cpu_realizefn(DeviceState *dev, Erro= r **errp) } =20 cpu_reset(cs); - qemu_init_vcpu(cs); - scc->parent_realize(dev, errp); } =20 diff --git a/target/sparc/cpu.c b/target/sparc/cpu.c index aece2c7dc8..82ed3c0152 100644 --- a/target/sparc/cpu.c +++ b/target/sparc/cpu.c @@ -739,9 +739,9 @@ static void sparc_cpu_realizefn(DeviceState *dev, Error= **errp) { CPUState *cs =3D CPU(dev); SPARCCPUClass *scc =3D SPARC_CPU_GET_CLASS(dev); - Error *local_err =3D NULL; SPARCCPU *cpu =3D SPARC_CPU(dev); CPUSPARCState *env =3D &cpu->env; + Error *local_err =3D NULL; =20 #if defined(CONFIG_USER_ONLY) if ((env->def.features & CPU_FEATURE_FLOAT)) { @@ -769,8 +769,6 @@ static void sparc_cpu_realizefn(DeviceState *dev, Error= **errp) return; } =20 - qemu_init_vcpu(cs); - scc->parent_realize(dev, errp); } =20 diff --git a/target/tilegx/cpu.c b/target/tilegx/cpu.c index d969c2f133..ae490bb9cd 100644 --- a/target/tilegx/cpu.c +++ b/target/tilegx/cpu.c @@ -93,8 +93,6 @@ static void tilegx_cpu_realizefn(DeviceState *dev, Error = **errp) } =20 cpu_reset(cs); - qemu_init_vcpu(cs); - tcc->parent_realize(dev, errp); } =20 diff --git a/target/tricore/cpu.c b/target/tricore/cpu.c index 0b1e139bcb..56cae72fa3 100644 --- a/target/tricore/cpu.c +++ b/target/tricore/cpu.c @@ -93,8 +93,6 @@ static void tricore_cpu_realizefn(DeviceState *dev, Error= **errp) set_feature(env, TRICORE_FEATURE_13); } cpu_reset(cs); - qemu_init_vcpu(cs); - tcc->parent_realize(dev, errp); } =20 diff --git a/target/unicore32/cpu.c b/target/unicore32/cpu.c index 0258884f84..04fc657ecb 100644 --- a/target/unicore32/cpu.c +++ b/target/unicore32/cpu.c @@ -84,18 +84,14 @@ static void uc32_any_cpu_initfn(Object *obj) =20 static void uc32_cpu_realizefn(DeviceState *dev, Error **errp) { - CPUState *cs =3D CPU(dev); UniCore32CPUClass *ucc =3D UNICORE32_CPU_GET_CLASS(dev); Error *local_err =3D NULL; =20 - cpu_exec_realizefn(cs, &local_err); + cpu_exec_realizefn(CPU(dev), &local_err); if (local_err !=3D NULL) { error_propagate(errp, local_err); return; } - - qemu_init_vcpu(cs); - ucc->parent_realize(dev, errp); } =20 diff --git a/target/xtensa/cpu.c b/target/xtensa/cpu.c index e2b2c7a71c..ebe5dc2090 100644 --- a/target/xtensa/cpu.c +++ b/target/xtensa/cpu.c @@ -153,8 +153,6 @@ static void xtensa_cpu_realizefn(DeviceState *dev, Erro= r **errp) =20 cs->gdb_num_regs =3D xcc->config->gdb_regmap.num_regs; =20 - qemu_init_vcpu(cs); - xcc->parent_realize(dev, errp); } =20 diff --git a/target/ppc/translate_init.c.inc b/target/ppc/translate_init.c.= inc index 9867d0a6e4..e99106bc1c 100644 --- a/target/ppc/translate_init.c.inc +++ b/target/ppc/translate_init.c.inc @@ -10093,7 +10093,7 @@ static int ppc_fixup_cpu(PowerPCCPU *cpu) return 0; } =20 -static void ppc_cpu_realize(DeviceState *dev, Error **errp) +static void ppc_cpu_realizefn(DeviceState *dev, Error **errp) { CPUState *cs =3D CPU(dev); PowerPCCPU *cpu =3D POWERPC_CPU(dev); @@ -10143,7 +10143,6 @@ static void ppc_cpu_realize(DeviceState *dev, Error= **errp) gdb_register_coprocessor(cs, gdb_get_spr_reg, gdb_set_spr_reg, pcc->gdb_num_sprs, "power-spr.xml", 0); #endif - qemu_init_vcpu(cs); =20 pcc->parent_realize(dev, errp); =20 @@ -10850,7 +10849,7 @@ static void ppc_cpu_class_init(ObjectClass *oc, voi= d *data) CPUClass *cc =3D CPU_CLASS(oc); DeviceClass *dc =3D DEVICE_CLASS(oc); =20 - device_class_set_parent_realize(dc, ppc_cpu_realize, + device_class_set_parent_realize(dc, ppc_cpu_realizefn, &pcc->parent_realize); device_class_set_parent_unrealize(dc, ppc_cpu_unrealize, &pcc->parent_unrealize); --=20 2.26.2 From nobody Thu Apr 25 18:08:54 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=1610475578; cv=none; d=zohomail.com; s=zohoarc; b=bMKzRUjzCD9PKIykGA6di5s9W0XBhFNPmdnQL9PnWQjDzgqcJseDoSlSgjvWVXfPcCIExw0MGATHtCMgvaoYBM8oLy9oJSmIk6+rO8ykwvwCdhrE/V1kGcVRmJ2HHTMikT8RBvnPdSgF3x5MObX+mrd6hx/biAnRcOoPyzXpgxE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610475578; 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=3yN84LGdNg6yvKllqOdcfe9gXdNrZTSWwWfszqFQ+UU=; b=Aeg9wVJ9pda7svslLt21btlFgHJAI4LojWsIBPaUvUmlfWKE9IivF0dgPXNvE6bZYuj+9mu1fDcRe4MbTfFPnLMelE/tSiP+ROWPWStmdwIwtJCTlMGIjDb1tylvLyf0PmtbHMr0nTSOiEppGpegkJLC1UUQUZ6TUPeQ0LKI7/c= 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 1610475578635483.4433422710605; Tue, 12 Jan 2021 10:19:38 -0800 (PST) Received: from localhost ([::1]:35170 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kzOGX-0006uf-GN for importer@patchew.org; Tue, 12 Jan 2021 13:19:37 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48256) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kzO1Q-0005h2-QL for qemu-devel@nongnu.org; Tue, 12 Jan 2021 13:04:00 -0500 Received: from mx2.suse.de ([195.135.220.15]:34286) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kzO1L-0004zY-Ok for qemu-devel@nongnu.org; Tue, 12 Jan 2021 13:04:00 -0500 Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 9E693AF80; Tue, 12 Jan 2021 18:03:38 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Claudio Fontana To: Paolo Bonzini , Thomas Huth , Richard Henderson , Stefano Stabellini , Wenchao Wang , Roman Bolshakov , Sunil Muthuswamy , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v12 22/22] accel: introduce new accessor functions Date: Tue, 12 Jan 2021 19:03:12 +0100 Message-Id: <20210112180312.26043-23-cfontana@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210112180312.26043-1-cfontana@suse.de> References: <20210112180312.26043-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 , Peter Maydell , Eduardo Habkost , Paul Durrant , Jason Wang , Marcelo Tosatti , qemu-devel@nongnu.org, Peter Xu , Dario Faggioli , Cameron Esfahani , haxm-team@intel.com, Claudio Fontana , Anthony Perard , Bruce Rogers , Olaf Hering , "Emilio G . Cota" , Colin Xu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" avoid open coding the accesses to cpu->accel_cpu interfaces, and instead introduce: accel_cpu_instance_init, accel_cpu_realizefn to be used by the targets/ initfn code, and by cpu_exec_realizefn respectively. Add warnings about the use of target-specific headers. Signed-off-by: Claudio Fontana --- include/hw/core/accel-cpu.h | 11 +++++++---- include/qemu/accel.h | 13 +++++++++++++ accel/accel-common.c | 19 +++++++++++++++++++ cpu.c | 6 +----- target/i386/cpu.c | 9 ++------- 5 files changed, 42 insertions(+), 16 deletions(-) diff --git a/include/hw/core/accel-cpu.h b/include/hw/core/accel-cpu.h index 246b3e2fcb..2edecd026a 100644 --- a/include/hw/core/accel-cpu.h +++ b/include/hw/core/accel-cpu.h @@ -1,5 +1,6 @@ /* * Accelerator interface, specializes CPUClass + * This header is used only by target-specific code. * * Copyright 2020 SUSE LLC * @@ -11,10 +12,12 @@ #define ACCEL_CPU_H =20 /* - * these defines cannot be in cpu.h, because we are using - * CPU_RESOLVING_TYPE here. - * Use this header to define your accelerator-specific - * cpu-specific accelerator interfaces. + * 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/ */ =20 #define TYPE_ACCEL_CPU "accel-" CPU_RESOLVING_TYPE diff --git a/include/qemu/accel.h b/include/qemu/accel.h index b9d6d69eb8..da0c8ab523 100644 --- a/include/qemu/accel.h +++ b/include/qemu/accel.h @@ -78,4 +78,17 @@ int accel_init_machine(AccelState *accel, MachineState *= ms); void accel_setup_post(MachineState *ms); #endif /* !CONFIG_USER_ONLY */ =20 +/** + * accel_cpu_instance_init: + * @cpu: The CPU that needs to do accel-specific object initializations. + */ +void accel_cpu_instance_init(CPUState *cpu); + +/** + * accel_cpu_realizefn: + * @cpu: The CPU that needs to call accel-specific cpu realization. + * @errp: currently unused. + */ +void accel_cpu_realizefn(CPUState *cpu, Error **errp); + #endif /* QEMU_ACCEL_H */ diff --git a/accel/accel-common.c b/accel/accel-common.c index 9901b0531c..0f6fb4fb66 100644 --- a/accel/accel-common.c +++ b/accel/accel-common.c @@ -89,6 +89,25 @@ void accel_init_interfaces(AccelClass *ac) accel_init_cpu_interfaces(ac); } =20 +void accel_cpu_instance_init(CPUState *cpu) +{ + CPUClass *cc =3D CPU_GET_CLASS(cpu); + + if (cc->accel_cpu && cc->accel_cpu->cpu_instance_init) { + cc->accel_cpu->cpu_instance_init(cpu); + } +} + +void accel_cpu_realizefn(CPUState *cpu, Error **errp) +{ + CPUClass *cc =3D CPU_GET_CLASS(cpu); + + if (cc->accel_cpu && cc->accel_cpu->cpu_realizefn) { + /* NB: errp parameter is unused currently */ + cc->accel_cpu->cpu_realizefn(cpu, errp); + } +} + static const TypeInfo accel_cpu_type =3D { .name =3D TYPE_ACCEL_CPU, .parent =3D TYPE_OBJECT, diff --git a/cpu.c b/cpu.c index ba5d272c1e..25e6fbfa2c 100644 --- a/cpu.c +++ b/cpu.c @@ -130,11 +130,7 @@ void cpu_exec_realizefn(CPUState *cpu, Error **errp) CPUClass *cc =3D CPU_GET_CLASS(cpu); =20 cpu_list_add(cpu); - - if (cc->accel_cpu) { - /* NB: errp parameter is unused currently */ - cc->accel_cpu->cpu_realizefn(cpu, errp); - } + accel_cpu_realizefn(cpu, errp); =20 #ifdef CONFIG_TCG /* NB: errp parameter is unused currently */ diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 83c474e270..c79123811f 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 "sysemu/whpx.h" #include "kvm/kvm_i386.h" @@ -6680,8 +6679,6 @@ static void x86_cpu_initfn(Object *obj) { X86CPU *cpu =3D X86_CPU(obj); X86CPUClass *xcc =3D X86_CPU_GET_CLASS(obj); - CPUClass *cc =3D CPU_CLASS(xcc); - CPUX86State *env =3D &cpu->env; =20 env->nr_dies =3D 1; @@ -6730,10 +6727,8 @@ static void x86_cpu_initfn(Object *obj) x86_cpu_load_model(cpu, xcc->model); } =20 - /* if required, do the accelerator-specific cpu initialization */ - if (cc->accel_cpu) { - cc->accel_cpu->cpu_instance_init(CPU(obj)); - } + /* if required, do accelerator-specific cpu initializations */ + accel_cpu_instance_init(CPU(obj)); } =20 static int64_t x86_cpu_get_arch_id(CPUState *cs) --=20 2.26.2