From nobody Sun Apr 6 22:16:00 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=quarantine dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1735515766; cv=none; d=zohomail.com; s=zohoarc; b=CFLQvLk8Uih/3zzvE8si0bPgoPELy3l+7BIO/wVBBP5eXjtKMH/wHQ+5IsODtAakjzV8+sXo5lTAMU8Jl2+jgwxbxURREAWz/GYmGn71s5k6rwS5lGOxGSlN1XcXSNpMes/vH3lE8cbAzEZ0DAo/tKuBqLBpHfQU/w/uGJ2o2o8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1735515766; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=M6lNxiKdfRQkCuimqbj0zox6bMsRablBZ37dSfV793s=; b=doRO5/pbEmuh6r4aTd+8zjiWyhhOrRHZ1rMN23wO1VMG6Rm09wO4pAUj9bVunXWPwoD3seoo8p+cOcg3IBZzR0sy4Z8uMhzFH6bBBcGgD+Hg7kATKenhtob9krccVrcNoFyw9JOcMkQrb1bAq1ZvSDvuyjMcjL2oEXcaIgz/enI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1735515766650935.5256615632042; Sun, 29 Dec 2024 15:42:46 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tS2vN-0003tK-3M; Sun, 29 Dec 2024 18:42:21 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tS2vC-0003ro-G4 for qemu-devel@nongnu.org; Sun, 29 Dec 2024 18:42:13 -0500 Received: from nyc.source.kernel.org ([147.75.193.91]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tS2vA-0001ew-Nx for qemu-devel@nongnu.org; Sun, 29 Dec 2024 18:42:10 -0500 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id C375AA40157; Sun, 29 Dec 2024 23:40:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 028ADC4CED1; Sun, 29 Dec 2024 23:41:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1735515719; bh=3/NpwClqbsROPze7xbpqnoulOTvLNUQ3RzivWGlikH8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rOH6688HjuY+oIQ1s6KIUMpp2p5XN7I8OccTDR1FgOGUgvnI/NqwRVy7spsMF9DJq 0lCSFUX4/LkV/Ex82FXpi1AUUn7wKMGI9JWNUNocOjaUgT2pAKaTAdTM/r0Z/w6CgX 3T55dof9wJW3jCMv2nxrvp4B3qraGAvI+gWXGaV2Mn3fA51L0ilbQxgm+XZEKMT8m4 6j1GGeL/FZUzqDdffxXpuuvtxO3/paNeINm5taiTdX3JMWDG0T8NbocCX6fq9uUKIS 9vlbBI//Z2yOHwc4qlF52Xb55YsCFoqMeRX18J1Pv6jjhDvB4s1cYaTob66TmKfiTB 8do78HoInELsg== From: deller@kernel.org To: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org, Richard Henderson Cc: Helge Deller Subject: [PATCH 1/2] target/hppa: Add CPU reset method Date: Mon, 30 Dec 2024 00:41:53 +0100 Message-ID: <20241229234154.32250-2-deller@kernel.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241229234154.32250-1-deller@kernel.org> References: <20241229234154.32250-1-deller@kernel.org> 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=147.75.193.91; envelope-from=deller@kernel.org; helo=nyc.source.kernel.org X-Spam_score_int: -65 X-Spam_score: -6.6 X-Spam_bar: ------ X-Spam_report: (-6.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-2.187, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @kernel.org) X-ZM-MESSAGEID: 1735515769000116600 Content-Type: text/plain; charset="utf-8" From: Helge Deller Add the CPU reset method, which resets all CPU registers and the TLB to zero. Then the CPU will switch to 32-bit mode (PSW_W bit is not set) and start execution at address 0xf0000004. Although we currently want to zero out all values in the CPUHPPAState struct, add the end_reset_fields marker in case the state structs gets extended with other variables later on which should not be reset. Signed-off-by: Helge Deller Reviewed-by: Richard Henderson V4: - Drop initialization of exception_index in hppa_cpu_initfn() V3: - Call reset function from hppa_machine_reset() instead V2: - Add end_reset_fields marker - call reset function in hppa_cpu_initfn() --- hw/hppa/machine.c | 6 +++--- target/hppa/cpu.c | 26 ++++++++++++++++++++++++-- target/hppa/cpu.h | 5 +++++ 3 files changed, 32 insertions(+), 5 deletions(-) diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c index a31dc32a9f..05fd43ce9c 100644 --- a/hw/hppa/machine.c +++ b/hw/hppa/machine.c @@ -655,12 +655,12 @@ static void hppa_machine_reset(MachineState *ms, Rese= tType type) for (i =3D 0; i < smp_cpus; i++) { CPUState *cs =3D CPU(cpu[i]); =20 + /* reset CPU */ + resettable_reset(OBJECT(cs), RESET_TYPE_COLD); + cpu_set_pc(cs, firmware_entry); cpu[i]->env.psw =3D PSW_Q; cpu[i]->env.gr[5] =3D CPU_HPA + i * 0x1000; - - cs->exception_index =3D -1; - cs->halted =3D 0; } =20 /* already initialized by machine_hppa_init()? */ diff --git a/target/hppa/cpu.c b/target/hppa/cpu.c index c38439c180..cb1b5191a4 100644 --- a/target/hppa/cpu.c +++ b/target/hppa/cpu.c @@ -194,11 +194,9 @@ static void hppa_cpu_realizefn(DeviceState *dev, Error= **errp) =20 static void hppa_cpu_initfn(Object *obj) { - CPUState *cs =3D CPU(obj); HPPACPU *cpu =3D HPPA_CPU(obj); CPUHPPAState *env =3D &cpu->env; =20 - cs->exception_index =3D -1; cpu_hppa_loaded_fr0(env); cpu_hppa_put_psw(env, PSW_W); } @@ -235,15 +233,39 @@ static const TCGCPUOps hppa_tcg_ops =3D { #endif /* !CONFIG_USER_ONLY */ }; =20 +static void hppa_cpu_reset_hold(Object *obj, ResetType type) +{ + HPPACPU *cpu =3D HPPA_CPU(obj); + HPPACPUClass *scc =3D HPPA_CPU_GET_CLASS(cpu); + CPUHPPAState *env =3D &cpu->env; + CPUState *cs =3D CPU(cpu); + + if (scc->parent_phases.hold) { + scc->parent_phases.hold(obj, type); + } + + memset(env, 0, offsetof(CPUHPPAState, end_reset_fields)); + cpu_set_pc(cs, 0xf0000004); + cpu_hppa_put_psw(env, hppa_is_pa20(env) ? PSW_W : 0); + cpu_hppa_loaded_fr0(env); + + cs->exception_index =3D -1; + cs->halted =3D 0; +} + static void hppa_cpu_class_init(ObjectClass *oc, void *data) { DeviceClass *dc =3D DEVICE_CLASS(oc); CPUClass *cc =3D CPU_CLASS(oc); HPPACPUClass *acc =3D HPPA_CPU_CLASS(oc); + ResettableClass *rc =3D RESETTABLE_CLASS(oc); =20 device_class_set_parent_realize(dc, hppa_cpu_realizefn, &acc->parent_realize); =20 + resettable_class_set_parent_phases(rc, NULL, hppa_cpu_reset_hold, NULL, + &acc->parent_phases); + cc->class_by_name =3D hppa_cpu_class_by_name; cc->has_work =3D hppa_cpu_has_work; cc->mmu_index =3D hppa_cpu_mmu_index; diff --git a/target/hppa/cpu.h b/target/hppa/cpu.h index e45ba50a59..32a674a8b8 100644 --- a/target/hppa/cpu.h +++ b/target/hppa/cpu.h @@ -263,6 +263,9 @@ typedef struct CPUArchState { IntervalTreeRoot tlb_root; =20 HPPATLBEntry tlb[HPPA_TLB_ENTRIES]; + + /* Fields up to this point are cleared by a CPU reset */ + struct {} end_reset_fields; } CPUHPPAState; =20 /** @@ -281,6 +284,7 @@ struct ArchCPU { /** * HPPACPUClass: * @parent_realize: The parent class' realize handler. + * @parent_phases: The parent class' reset phase handlers. * * An HPPA CPU model. */ @@ -288,6 +292,7 @@ struct HPPACPUClass { CPUClass parent_class; =20 DeviceRealize parent_realize; + ResettablePhases parent_phases; }; =20 #include "exec/cpu-all.h" --=20 2.47.0 From nobody Sun Apr 6 22:16:00 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=quarantine dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1735515766; cv=none; d=zohomail.com; s=zohoarc; b=HnMsdS+8lfiueRtF7sXG+AE7RplssN2W7DnpgrNFN4Fteqihq+gkJdOmzR/SgG7IHpM5hHgKrMfNqJnXnnYf7VTZsZfY8wAMWjrNODtex/vnA/a2mrlgWxtLejQrHGk5O8I7RPbMkNz2jqEjQ57IPtsHC9URc/ynQKZeA/Qfnz8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1735515766; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=NJe0LqGY8MypnFf6GU1RAHoor8akbvykWqirDlXtx58=; b=PCFA6xm0tYmBw0VK4hC12hO/Tp6L5UROl2g+aD+GZOCDx72nPlDyyjb7YA9MrcG2w0HZJsT+pNG3/hvP84YMPpSK5tjZ/mvEKDeWqVjcr5bNU1mU3NwWkBCoXOavDbaA/Xqixd9eZLC4DzWAFXRauJ2CxvyLwc0HAgav2oDsWoE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1735515766696526.24242832961; Sun, 29 Dec 2024 15:42:46 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tS2vH-0003sQ-E5; Sun, 29 Dec 2024 18:42:15 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tS2vC-0003rn-CU for qemu-devel@nongnu.org; Sun, 29 Dec 2024 18:42:13 -0500 Received: from dfw.source.kernel.org ([139.178.84.217]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tS2vA-0001fR-O0 for qemu-devel@nongnu.org; Sun, 29 Dec 2024 18:42:10 -0500 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 43A845C110C; Sun, 29 Dec 2024 23:41:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 766C8C4CED7; Sun, 29 Dec 2024 23:41:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1735515720; bh=ZFuZeCs3Orq8OXoUrzXYPv+DEcb9GFUxfEBGQdRF4wg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vLBm77XAN+fsXPEAFbF2pI/KdwzxOkt8QhDCIyVUfuSlcROQu9BAr4kK2abKbkG7a guAO/FbKx+F2nZ2i98Qpwzg1sa8QO8SPdR2jeVfHay2aKUIQIlSBIEd96xwTEYfGux He0KJjdHcd4Q7H8lnMWaL8+Z6tbKFBFs407PLxKkTS+FOut+wO224JEZHSKmZhcDta 820UEzSVYHzM+/qsbXvs6xRP16SMFes/wrJBWCLakvFBlSXvxAoVpCRwZZRwV4rKkC F2yg5Xonkh8mb+EW/YHtwHcj/1IKDXvpoO7p5dNR9JTVyza7V9yKqxKvvZri9taU6M tSrBlGkdzYEXw== From: deller@kernel.org To: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org, Richard Henderson Cc: Helge Deller Subject: [PATCH 2/2] target/hppa: Speed up hppa_is_pa20() Date: Mon, 30 Dec 2024 00:41:54 +0100 Message-ID: <20241229234154.32250-3-deller@kernel.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241229234154.32250-1-deller@kernel.org> References: <20241229234154.32250-1-deller@kernel.org> 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=139.178.84.217; envelope-from=deller@kernel.org; helo=dfw.source.kernel.org X-Spam_score_int: -92 X-Spam_score: -9.3 X-Spam_bar: --------- X-Spam_report: (-9.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-2.187, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_HI=-5, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @kernel.org) X-ZM-MESSAGEID: 1735515768945116600 From: Helge Deller Although the hppa_is_pa20() helper is costly due to string comparisons in object_dynamic_cast(), it is called quite often during memory lookups and at each start of a block of instruction translations. Speed hppa_is_pa20() up by calling object_dynamic_cast() only once at CPU creation and store the result in the is_pa20 of struct CPUArchState. Signed-off-by: Helge Deller Reviewed-by: Philippe Mathieu-Daud=C3=A9 v3: - use !!object_dynamic_cast() - typo fix in commit message (feedback by Philippe Mathieu-Daud=C3=A9) v2: - moved init to hppa_cpu_initfn() and is_pa20 to end of CPUArchState struct (feedback by Richard Henderson) Reviewed-by: Richard Henderson --- target/hppa/cpu.c | 1 + target/hppa/cpu.h | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/target/hppa/cpu.c b/target/hppa/cpu.c index cb1b5191a4..64a762b410 100644 --- a/target/hppa/cpu.c +++ b/target/hppa/cpu.c @@ -197,6 +197,7 @@ static void hppa_cpu_initfn(Object *obj) HPPACPU *cpu =3D HPPA_CPU(obj); CPUHPPAState *env =3D &cpu->env; =20 + env->is_pa20 =3D !!object_dynamic_cast(obj, TYPE_HPPA64_CPU); cpu_hppa_loaded_fr0(env); cpu_hppa_put_psw(env, PSW_W); } diff --git a/target/hppa/cpu.h b/target/hppa/cpu.h index 32a674a8b8..288ce6d98a 100644 --- a/target/hppa/cpu.h +++ b/target/hppa/cpu.h @@ -266,6 +266,8 @@ typedef struct CPUArchState { =20 /* Fields up to this point are cleared by a CPU reset */ struct {} end_reset_fields; + + bool is_pa20; } CPUHPPAState; =20 /** @@ -299,7 +301,7 @@ struct HPPACPUClass { =20 static inline bool hppa_is_pa20(CPUHPPAState *env) { - return object_dynamic_cast(OBJECT(env_cpu(env)), TYPE_HPPA64_CPU) !=3D= NULL; + return env->is_pa20; } =20 static inline int HPPA_BTLB_ENTRIES(CPUHPPAState *env) --=20 2.47.0