From nobody Sat May 18 13:55:28 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=eik.bme.hu Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1713911716488625.011359395004; Tue, 23 Apr 2024 15:35:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rzOfr-0001Cy-LI; Tue, 23 Apr 2024 18:31:39 -0400 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 1rzOfc-00016w-79; Tue, 23 Apr 2024 18:31:25 -0400 Received: from zero.eik.bme.hu ([152.66.115.2]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rzOfY-0004aX-6a; Tue, 23 Apr 2024 18:31:23 -0400 Received: from zero.eik.bme.hu (localhost [127.0.0.1]) by zero.eik.bme.hu (Postfix) with ESMTP id A31FB4E6041; Wed, 24 Apr 2024 00:31:13 +0200 (CEST) Received: from zero.eik.bme.hu ([127.0.0.1]) by zero.eik.bme.hu (zero.eik.bme.hu [127.0.0.1]) (amavisd-new, port 10028) with ESMTP id n8DLTj_PkGSj; Wed, 24 Apr 2024 00:31:11 +0200 (CEST) Received: by zero.eik.bme.hu (Postfix, from userid 432) id ADED24E6031; Wed, 24 Apr 2024 00:31:11 +0200 (CEST) X-Virus-Scanned: amavisd-new at eik.bme.hu Message-Id: <124d7953cdea26b9c94d2f8f6345258177e5fb46.1713907038.git.balaton@eik.bme.hu> In-Reply-To: References: From: BALATON Zoltan Subject: [PATCH 01/24] target/ppc: Fix gen_sc to use correct nip MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable To: qemu-devel@nongnu.org, qemu-ppc@nongnu.org Cc: Nicholas Piggin , Daniel Henrique Barboza Date: Wed, 24 Apr 2024 00:31:11 +0200 (CEST) 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=152.66.115.2; envelope-from=balaton@eik.bme.hu; helo=zero.eik.bme.hu X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZM-MESSAGEID: 1713911717312100002 Content-Type: text/plain; charset="utf-8" Most exceptions are raised with nip pointing to the faulting instruction but the sc instruction generating a syscall exception leaves nip pointing to next instruction. Fix gen_sc to not use gen_exception_err() which sets nip back but correctly set nip to pc_next so we don't have to patch this in the exception handlers. Signed-off-by: BALATON Zoltan Reviewed-by: Nicholas Piggin --- target/ppc/excp_helper.c | 43 ++-------------------------------------- target/ppc/translate.c | 6 ++---- 2 files changed, 4 insertions(+), 45 deletions(-) diff --git a/target/ppc/excp_helper.c b/target/ppc/excp_helper.c index 674c05a2ce..b6a5241a4d 100644 --- a/target/ppc/excp_helper.c +++ b/target/ppc/excp_helper.c @@ -116,7 +116,7 @@ static void dump_syscall(CPUPPCState *env) ppc_dump_gpr(env, 0), ppc_dump_gpr(env, 3), ppc_dump_gpr(env, 4), ppc_dump_gpr(env, 5), ppc_dump_gpr(env, 6), ppc_dump_gpr(env, 7), - ppc_dump_gpr(env, 8), env->nip); + ppc_dump_gpr(env, 8), env->nip - 4); } =20 static void dump_hcall(CPUPPCState *env) @@ -131,7 +131,7 @@ static void dump_hcall(CPUPPCState *env) ppc_dump_gpr(env, 7), ppc_dump_gpr(env, 8), ppc_dump_gpr(env, 9), ppc_dump_gpr(env, 10), ppc_dump_gpr(env, 11), ppc_dump_gpr(env, 12), - env->nip); + env->nip - 4); } =20 #ifdef CONFIG_TCG @@ -516,12 +516,6 @@ static void powerpc_excp_40x(PowerPCCPU *cpu, int excp) break; case POWERPC_EXCP_SYSCALL: /* System call exception = */ dump_syscall(env); - - /* - * We need to correct the NIP which in this case is supposed - * to point to the next instruction - */ - env->nip +=3D 4; break; case POWERPC_EXCP_FIT: /* Fixed-interval timer interrupt = */ trace_ppc_excp_print("FIT"); @@ -632,12 +626,6 @@ static void powerpc_excp_6xx(PowerPCCPU *cpu, int excp) break; case POWERPC_EXCP_SYSCALL: /* System call exception = */ dump_syscall(env); - - /* - * We need to correct the NIP which in this case is supposed - * to point to the next instruction - */ - env->nip +=3D 4; break; case POWERPC_EXCP_FPU: /* Floating-point unavailable exception = */ case POWERPC_EXCP_DECR: /* Decrementer exception = */ @@ -780,13 +768,6 @@ static void powerpc_excp_7xx(PowerPCCPU *cpu, int excp) } else { dump_syscall(env); } - - /* - * We need to correct the NIP which in this case is supposed - * to point to the next instruction - */ - env->nip +=3D 4; - /* * The Virtual Open Firmware (VOF) relies on the 'sc 1' * instruction to communicate with QEMU. The pegasos2 machine @@ -932,13 +913,6 @@ static void powerpc_excp_74xx(PowerPCCPU *cpu, int exc= p) } else { dump_syscall(env); } - - /* - * We need to correct the NIP which in this case is supposed - * to point to the next instruction - */ - env->nip +=3D 4; - /* * The Virtual Open Firmware (VOF) relies on the 'sc 1' * instruction to communicate with QEMU. The pegasos2 machine @@ -1098,12 +1072,6 @@ static void powerpc_excp_booke(PowerPCCPU *cpu, int = excp) break; case POWERPC_EXCP_SYSCALL: /* System call exception = */ dump_syscall(env); - - /* - * We need to correct the NIP which in this case is supposed - * to point to the next instruction - */ - env->nip +=3D 4; break; case POWERPC_EXCP_FPU: /* Floating-point unavailable exception = */ case POWERPC_EXCP_APU: /* Auxiliary processor unavailable = */ @@ -1428,13 +1396,6 @@ static void powerpc_excp_books(PowerPCCPU *cpu, int = excp) } else { dump_syscall(env); } - - /* - * We need to correct the NIP which in this case is supposed - * to point to the next instruction - */ - env->nip +=3D 4; - /* "PAPR mode" built-in hypercall emulation */ if (lev =3D=3D 1 && books_vhyp_handles_hcall(cpu)) { PPCVirtualHypervisorClass *vhc =3D diff --git a/target/ppc/translate.c b/target/ppc/translate.c index 93ffec787c..fa72f17c3e 100644 --- a/target/ppc/translate.c +++ b/target/ppc/translate.c @@ -4479,15 +4479,13 @@ static void gen_hrfid(DisasContext *ctx) #endif static void gen_sc(DisasContext *ctx) { - uint32_t lev; - /* * LEV is a 7-bit field, but the top 6 bits are treated as a reserved * field (i.e., ignored). ISA v3.1 changes that to 5 bits, but that is * for Ultravisor which TCG does not support, so just ignore the top 6. */ - lev =3D (ctx->opcode >> 5) & 0x1; - gen_exception_err(ctx, POWERPC_SYSCALL, lev); + uint32_t lev =3D (ctx->opcode >> 5) & 0x1; + gen_exception_err_nip(ctx, POWERPC_SYSCALL, lev, ctx->base.pc_next); } =20 #if defined(TARGET_PPC64) --=20 2.30.9 From nobody Sat May 18 13:55:28 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=eik.bme.hu Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1713911589085187.49097642642812; Tue, 23 Apr 2024 15:33:09 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rzOfo-0001Aq-US; Tue, 23 Apr 2024 18:31:36 -0400 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 1rzOfb-00016u-Po; Tue, 23 Apr 2024 18:31:25 -0400 Received: from zero.eik.bme.hu ([2001:738:2001:2001::2001]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rzOfY-0004ac-6R; Tue, 23 Apr 2024 18:31:23 -0400 Received: from zero.eik.bme.hu (localhost [127.0.0.1]) by zero.eik.bme.hu (Postfix) with ESMTP id B0B5E4E603D; Wed, 24 Apr 2024 00:31:14 +0200 (CEST) Received: from zero.eik.bme.hu ([127.0.0.1]) by zero.eik.bme.hu (zero.eik.bme.hu [127.0.0.1]) (amavisd-new, port 10028) with ESMTP id eyjFkb3X6TUo; Wed, 24 Apr 2024 00:31:12 +0200 (CEST) Received: by zero.eik.bme.hu (Postfix, from userid 432) id BF03C4E6040; Wed, 24 Apr 2024 00:31:12 +0200 (CEST) X-Virus-Scanned: amavisd-new at eik.bme.hu Message-Id: In-Reply-To: References: From: BALATON Zoltan Subject: [PATCH 02/24] target/ppc: Move patching nip from exception handler to helper_scv MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable To: qemu-devel@nongnu.org, qemu-ppc@nongnu.org Cc: Nicholas Piggin , Daniel Henrique Barboza Date: Wed, 24 Apr 2024 00:31:12 +0200 (CEST) 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2001:738:2001:2001::2001; envelope-from=balaton@eik.bme.hu; helo=zero.eik.bme.hu X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZM-MESSAGEID: 1713911590736100005 Content-Type: text/plain; charset="utf-8" From: Nicholas Piggin Unlike sc, for scv a facility unavailable interrupt must be generated if FSCR[SCV]=3D0 so we can't raise the exception with nip set to next instruction but we can move advancing nip if the FSCR check passes to helper_scv so the exception handler does not need to change it. [balaton: added commit message] Signed-off-by: BALATON Zoltan --- target/ppc/excp_helper.c | 2 +- target/ppc/translate.c | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/target/ppc/excp_helper.c b/target/ppc/excp_helper.c index b6a5241a4d..fd145200dd 100644 --- a/target/ppc/excp_helper.c +++ b/target/ppc/excp_helper.c @@ -1415,7 +1415,6 @@ static void powerpc_excp_books(PowerPCCPU *cpu, int e= xcp) case POWERPC_EXCP_SYSCALL_VECTORED: /* scv exception = */ lev =3D env->error_code; dump_syscall(env); - env->nip +=3D 4; new_msr |=3D env->msr & ((target_ulong)1 << MSR_EE); new_msr |=3D env->msr & ((target_ulong)1 << MSR_RI); =20 @@ -2524,6 +2523,7 @@ void helper_ppc_maybe_interrupt(CPUPPCState *env) void helper_scv(CPUPPCState *env, uint32_t lev) { if (env->spr[SPR_FSCR] & (1ull << FSCR_SCV)) { + env->nip +=3D 4; raise_exception_err(env, POWERPC_EXCP_SYSCALL_VECTORED, lev); } else { raise_exception_err(env, POWERPC_EXCP_FU, FSCR_IC_SCV); diff --git a/target/ppc/translate.c b/target/ppc/translate.c index fa72f17c3e..0dbcf4b26f 100644 --- a/target/ppc/translate.c +++ b/target/ppc/translate.c @@ -4494,7 +4494,11 @@ static void gen_scv(DisasContext *ctx) { uint32_t lev =3D (ctx->opcode >> 5) & 0x7F; =20 - /* Set the PC back to the faulting instruction. */ + /* + * Set the PC back to the scv instruction (unlike sc), because a facil= ity + * unavailable interrupt must be generated if FSCR[SCV]=3D0. The helper + * advances nip if the FSCR check passes. + */ gen_update_nip(ctx, ctx->cia); gen_helper_scv(tcg_env, tcg_constant_i32(lev)); =20 --=20 2.30.9 From nobody Sat May 18 13:55:28 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=eik.bme.hu Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1713911700231119.45058059075313; Tue, 23 Apr 2024 15:35:00 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rzOfr-0001D0-Sh; Tue, 23 Apr 2024 18:31:39 -0400 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 1rzOfb-00016s-18; Tue, 23 Apr 2024 18:31:25 -0400 Received: from zero.eik.bme.hu ([2001:738:2001:2001::2001]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rzOfY-0004ah-6D; Tue, 23 Apr 2024 18:31:22 -0400 Received: from zero.eik.bme.hu (localhost [127.0.0.1]) by zero.eik.bme.hu (Postfix) with ESMTP id B683A4E6040; Wed, 24 Apr 2024 00:31:15 +0200 (CEST) Received: from zero.eik.bme.hu ([127.0.0.1]) by zero.eik.bme.hu (zero.eik.bme.hu [127.0.0.1]) (amavisd-new, port 10028) with ESMTP id 24oEFHn6xHgW; Wed, 24 Apr 2024 00:31:13 +0200 (CEST) Received: by zero.eik.bme.hu (Postfix, from userid 432) id CA44D4E6042; Wed, 24 Apr 2024 00:31:13 +0200 (CEST) X-Virus-Scanned: amavisd-new at eik.bme.hu Message-Id: In-Reply-To: References: From: BALATON Zoltan Subject: [PATCH 03/24] target/ppc: Simplify syscall exception handlers MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable To: qemu-devel@nongnu.org, qemu-ppc@nongnu.org Cc: Nicholas Piggin , Daniel Henrique Barboza Date: Wed, 24 Apr 2024 00:31:13 +0200 (CEST) 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2001:738:2001:2001::2001; envelope-from=balaton@eik.bme.hu; helo=zero.eik.bme.hu X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZM-MESSAGEID: 1713911701216100001 Content-Type: text/plain; charset="utf-8" After previous changes the hypercall handling in 7xx and 74xx exception handlers can be folded into one if statement to simplify this code. Also add "unlikely" to mark the less frequently used branch for the compiler. Signed-off-by: BALATON Zoltan Reviewed-by: Harsh Prateek Bora --- target/ppc/excp_helper.c | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/target/ppc/excp_helper.c b/target/ppc/excp_helper.c index fd145200dd..4c1375381d 100644 --- a/target/ppc/excp_helper.c +++ b/target/ppc/excp_helper.c @@ -762,26 +762,21 @@ static void powerpc_excp_7xx(PowerPCCPU *cpu, int exc= p) case POWERPC_EXCP_SYSCALL: /* System call exception = */ { int lev =3D env->error_code; - - if (lev =3D=3D 1 && cpu->vhyp) { - dump_hcall(env); - } else { - dump_syscall(env); - } /* * The Virtual Open Firmware (VOF) relies on the 'sc 1' * instruction to communicate with QEMU. The pegasos2 machine * uses VOF and the 7xx CPUs, so although the 7xx don't have * HV mode, we need to keep hypercall support. */ - if (lev =3D=3D 1 && cpu->vhyp) { + if (unlikely(lev =3D=3D 1 && cpu->vhyp)) { PPCVirtualHypervisorClass *vhc =3D PPC_VIRTUAL_HYPERVISOR_GET_CLASS(cpu->vhyp); + dump_hcall(env); vhc->hypercall(cpu->vhyp, cpu); powerpc_reset_excp_state(cpu); return; } - + dump_syscall(env); break; } case POWERPC_EXCP_FPU: /* Floating-point unavailable exception = */ @@ -907,26 +902,21 @@ static void powerpc_excp_74xx(PowerPCCPU *cpu, int ex= cp) case POWERPC_EXCP_SYSCALL: /* System call exception = */ { int lev =3D env->error_code; - - if (lev =3D=3D 1 && cpu->vhyp) { - dump_hcall(env); - } else { - dump_syscall(env); - } /* * The Virtual Open Firmware (VOF) relies on the 'sc 1' * instruction to communicate with QEMU. The pegasos2 machine * uses VOF and the 74xx CPUs, so although the 74xx don't have * HV mode, we need to keep hypercall support. */ - if (lev =3D=3D 1 && cpu->vhyp) { + if (unlikely(lev =3D=3D 1 && cpu->vhyp)) { PPCVirtualHypervisorClass *vhc =3D PPC_VIRTUAL_HYPERVISOR_GET_CLASS(cpu->vhyp); + dump_hcall(env); vhc->hypercall(cpu->vhyp, cpu); powerpc_reset_excp_state(cpu); return; } - + dump_syscall(env); break; } case POWERPC_EXCP_FPU: /* Floating-point unavailable exception = */ --=20 2.30.9 From nobody Sat May 18 13:55:28 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=eik.bme.hu Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1713911647377264.01404138134683; Tue, 23 Apr 2024 15:34:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rzOfo-0001Ao-SJ; Tue, 23 Apr 2024 18:31:36 -0400 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 1rzOfb-00016v-SG; Tue, 23 Apr 2024 18:31:25 -0400 Received: from zero.eik.bme.hu ([152.66.115.2]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rzOfY-0004an-6a; Tue, 23 Apr 2024 18:31:23 -0400 Received: from zero.eik.bme.hu (localhost [127.0.0.1]) by zero.eik.bme.hu (Postfix) with ESMTP id C161D4E6042; Wed, 24 Apr 2024 00:31:16 +0200 (CEST) Received: from zero.eik.bme.hu ([127.0.0.1]) by zero.eik.bme.hu (zero.eik.bme.hu [127.0.0.1]) (amavisd-new, port 10028) with ESMTP id wRP8tTGP9yDN; Wed, 24 Apr 2024 00:31:14 +0200 (CEST) Received: by zero.eik.bme.hu (Postfix, from userid 432) id D45FC4E6031; Wed, 24 Apr 2024 00:31:14 +0200 (CEST) X-Virus-Scanned: amavisd-new at eik.bme.hu Message-Id: <70bd4c106a5dd14eacf4b79131741c76accb9ad4.1713907038.git.balaton@eik.bme.hu> In-Reply-To: References: From: BALATON Zoltan Subject: [PATCH 04/24] target/ppc: Remove unused helper MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable To: qemu-devel@nongnu.org, qemu-ppc@nongnu.org Cc: Nicholas Piggin , Daniel Henrique Barboza Date: Wed, 24 Apr 2024 00:31:14 +0200 (CEST) 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=152.66.115.2; envelope-from=balaton@eik.bme.hu; helo=zero.eik.bme.hu X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZM-MESSAGEID: 1713911648988100001 Content-Type: text/plain; charset="utf-8" The helper_rac function is defined but not used, remove it. Fixes: 005b69fdcc (target/ppc: Remove PowerPC 601 CPUs) Signed-off-by: BALATON Zoltan --- target/ppc/helper.h | 2 -- target/ppc/mmu_helper.c | 24 ------------------------ 2 files changed, 26 deletions(-) diff --git a/target/ppc/helper.h b/target/ppc/helper.h index 86f97ee1e7..f769e01c3d 100644 --- a/target/ppc/helper.h +++ b/target/ppc/helper.h @@ -700,8 +700,6 @@ DEF_HELPER_2(book3s_msgclr, void, env, tl) =20 DEF_HELPER_4(dlmzb, tl, env, tl, tl, i32) #if !defined(CONFIG_USER_ONLY) -DEF_HELPER_2(rac, tl, env, tl) - DEF_HELPER_2(load_dcr, tl, env, tl) DEF_HELPER_3(store_dcr, void, env, tl, tl) #endif diff --git a/target/ppc/mmu_helper.c b/target/ppc/mmu_helper.c index c071b4d5e2..817836b731 100644 --- a/target/ppc/mmu_helper.c +++ b/target/ppc/mmu_helper.c @@ -595,30 +595,6 @@ void helper_6xx_tlbi(CPUPPCState *env, target_ulong EP= N) do_6xx_tlb(env, EPN, 1); } =20 -/*************************************************************************= ****/ -/* PowerPC 601 specific instructions (POWER bridge) */ - -target_ulong helper_rac(CPUPPCState *env, target_ulong addr) -{ - mmu_ctx_t ctx; - int nb_BATs; - target_ulong ret =3D 0; - - /* - * We don't have to generate many instances of this instruction, - * as rac is supervisor only. - * - * XXX: FIX THIS: Pretend we have no BAT - */ - nb_BATs =3D env->nb_BATs; - env->nb_BATs =3D 0; - if (get_physical_address_wtlb(env, &ctx, addr, 0, ACCESS_INT, 0) =3D= =3D 0) { - ret =3D ctx.raddr; - } - env->nb_BATs =3D nb_BATs; - return ret; -} - static inline target_ulong booke_tlb_to_page_size(int size) { return 1024 << (2 * size); --=20 2.30.9 From nobody Sat May 18 13:55:28 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=eik.bme.hu Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1713911572335242.41314805894956; Tue, 23 Apr 2024 15:32:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rzOfw-0001F9-Hx; Tue, 23 Apr 2024 18:31:44 -0400 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 1rzOfe-000175-26; Tue, 23 Apr 2024 18:31:29 -0400 Received: from zero.eik.bme.hu ([152.66.115.2]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rzOfc-0004bH-A5; Tue, 23 Apr 2024 18:31:25 -0400 Received: from zero.eik.bme.hu (localhost [127.0.0.1]) by zero.eik.bme.hu (Postfix) with ESMTP id CB5AD4E6031; Wed, 24 Apr 2024 00:31:17 +0200 (CEST) Received: from zero.eik.bme.hu ([127.0.0.1]) by zero.eik.bme.hu (zero.eik.bme.hu [127.0.0.1]) (amavisd-new, port 10028) with ESMTP id KZdOsRHPTW55; Wed, 24 Apr 2024 00:31:15 +0200 (CEST) Received: by zero.eik.bme.hu (Postfix, from userid 432) id DD7714E6054; Wed, 24 Apr 2024 00:31:15 +0200 (CEST) X-Virus-Scanned: amavisd-new at eik.bme.hu Message-Id: <60e5167ed91a2d98a08899e52b89d28bcd2d7d8d.1713907038.git.balaton@eik.bme.hu> In-Reply-To: References: From: BALATON Zoltan Subject: [PATCH 05/24] target/ppc/mmu_common.c: Move calculation of a value closer to its usage MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable To: qemu-devel@nongnu.org, qemu-ppc@nongnu.org Cc: Nicholas Piggin , Daniel Henrique Barboza Date: Wed, 24 Apr 2024 00:31:15 +0200 (CEST) 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=152.66.115.2; envelope-from=balaton@eik.bme.hu; helo=zero.eik.bme.hu X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZM-MESSAGEID: 1713911572671100001 Content-Type: text/plain; charset="utf-8" In mmubooke_check_tlb() prot2 is calculated first but only used after an unrelated check that can return before tha value is used. Move the calculation after the check, closer to where it is used, to keep them together and avoid computing it when not needed. Signed-off-by: BALATON Zoltan --- target/ppc/mmu_common.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/target/ppc/mmu_common.c b/target/ppc/mmu_common.c index 751403f1c8..168ff842a5 100644 --- a/target/ppc/mmu_common.c +++ b/target/ppc/mmu_common.c @@ -634,12 +634,6 @@ static int mmubooke_check_tlb(CPUPPCState *env, ppcemb= _tlb_t *tlb, return -1; } =20 - if (FIELD_EX64(env->msr, MSR, PR)) { - prot2 =3D tlb->prot & 0xF; - } else { - prot2 =3D (tlb->prot >> 4) & 0xF; - } - /* Check the address space */ if ((access_type =3D=3D MMU_INST_FETCH ? FIELD_EX64(env->msr, MSR, IR) : @@ -648,6 +642,11 @@ static int mmubooke_check_tlb(CPUPPCState *env, ppcemb= _tlb_t *tlb, return -1; } =20 + if (FIELD_EX64(env->msr, MSR, PR)) { + prot2 =3D tlb->prot & 0xF; + } else { + prot2 =3D (tlb->prot >> 4) & 0xF; + } *prot =3D prot2; if (prot2 & prot_for_access_type(access_type)) { qemu_log_mask(CPU_LOG_MMU, "%s: good TLB!\n", __func__); --=20 2.30.9 From nobody Sat May 18 13:55:28 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=eik.bme.hu Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 171391167339296.00529895100476; Tue, 23 Apr 2024 15:34:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rzOfq-0001CU-PE; Tue, 23 Apr 2024 18:31:38 -0400 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 1rzOff-000178-6B; Tue, 23 Apr 2024 18:31:29 -0400 Received: from zero.eik.bme.hu ([152.66.115.2]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rzOfc-0004bG-Co; Tue, 23 Apr 2024 18:31:26 -0400 Received: from zero.eik.bme.hu (localhost [127.0.0.1]) by zero.eik.bme.hu (Postfix) with ESMTP id D76564E6054; Wed, 24 Apr 2024 00:31:18 +0200 (CEST) Received: from zero.eik.bme.hu ([127.0.0.1]) by zero.eik.bme.hu (zero.eik.bme.hu [127.0.0.1]) (amavisd-new, port 10028) with ESMTP id Ax8IgTfEiaPk; Wed, 24 Apr 2024 00:31:16 +0200 (CEST) Received: by zero.eik.bme.hu (Postfix, from userid 432) id EC4D54E6055; Wed, 24 Apr 2024 00:31:16 +0200 (CEST) X-Virus-Scanned: amavisd-new at eik.bme.hu Message-Id: <69f0b11f0dcbc4ed8f9a89e7132c94a2e7e24c62.1713907038.git.balaton@eik.bme.hu> In-Reply-To: References: From: BALATON Zoltan Subject: [PATCH 06/24] target/ppc/mmu_common.c: Simplify checking for real mode MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable To: qemu-devel@nongnu.org, qemu-ppc@nongnu.org Cc: Nicholas Piggin , Daniel Henrique Barboza Date: Wed, 24 Apr 2024 00:31:16 +0200 (CEST) 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=152.66.115.2; envelope-from=balaton@eik.bme.hu; helo=zero.eik.bme.hu X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZM-MESSAGEID: 1713911675084100001 Content-Type: text/plain; charset="utf-8" In get_physical_address_wtlb() the real_mode flag depends on either the MSR[IR] or MSR[DR] bit depending on access_type. Extract just the needed bit in a more straight forward way instead of doing unnecessary computation. Signed-off-by: BALATON Zoltan --- target/ppc/mmu_common.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/target/ppc/mmu_common.c b/target/ppc/mmu_common.c index 168ff842a5..aa01469604 100644 --- a/target/ppc/mmu_common.c +++ b/target/ppc/mmu_common.c @@ -1188,8 +1188,10 @@ int get_physical_address_wtlb(CPUPPCState *env, mmu_= ctx_t *ctx, int mmu_idx) { int ret =3D -1; - bool real_mode =3D (type =3D=3D ACCESS_CODE && !FIELD_EX64(env->msr, M= SR, IR)) || - (type !=3D ACCESS_CODE && !FIELD_EX64(env->msr, MSR, = DR)); + bool real_mode; + + real_mode =3D (type =3D=3D ACCESS_CODE) ? !FIELD_EX64(env->msr, MSR, I= R) + : !FIELD_EX64(env->msr, MSR, DR); =20 switch (env->mmu_model) { case POWERPC_MMU_SOFT_6xx: --=20 2.30.9 From nobody Sat May 18 13:55:28 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=eik.bme.hu Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1713911796276711.3952315008984; Tue, 23 Apr 2024 15:36:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rzOfs-0001DO-Pm; Tue, 23 Apr 2024 18:31:40 -0400 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 1rzOfe-000174-20; Tue, 23 Apr 2024 18:31:29 -0400 Received: from zero.eik.bme.hu ([2001:738:2001:2001::2001]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rzOfc-0004bD-8g; Tue, 23 Apr 2024 18:31:25 -0400 Received: from zero.eik.bme.hu (localhost [127.0.0.1]) by zero.eik.bme.hu (Postfix) with ESMTP id E9DD84E6055; Wed, 24 Apr 2024 00:31:19 +0200 (CEST) Received: from zero.eik.bme.hu ([127.0.0.1]) by zero.eik.bme.hu (zero.eik.bme.hu [127.0.0.1]) (amavisd-new, port 10028) with ESMTP id CeLbiOELZJ5t; Wed, 24 Apr 2024 00:31:18 +0200 (CEST) Received: by zero.eik.bme.hu (Postfix, from userid 432) id 06FB74E6056; Wed, 24 Apr 2024 00:31:18 +0200 (CEST) X-Virus-Scanned: amavisd-new at eik.bme.hu Message-Id: <27222e10354fe1b22423f70a14301e02a7b0939d.1713907038.git.balaton@eik.bme.hu> In-Reply-To: References: From: BALATON Zoltan Subject: [PATCH 07/24] target/ppc/mmu_common.c: Drop cases for unimplemented MPC8xx MMU MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable To: qemu-devel@nongnu.org, qemu-ppc@nongnu.org Cc: Nicholas Piggin , Daniel Henrique Barboza Date: Wed, 24 Apr 2024 00:31:18 +0200 (CEST) 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2001:738:2001:2001::2001; envelope-from=balaton@eik.bme.hu; helo=zero.eik.bme.hu X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZM-MESSAGEID: 1713911796518100004 Content-Type: text/plain; charset="utf-8" The default case will catch this and abort the same way and there is still a warning about it in ppc_tlb_invalidate_all() so drop these from mmu_common.c to simplify this code. Signed-off-by: BALATON Zoltan --- target/ppc/mmu_common.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/target/ppc/mmu_common.c b/target/ppc/mmu_common.c index aa01469604..c4fafebbe3 100644 --- a/target/ppc/mmu_common.c +++ b/target/ppc/mmu_common.c @@ -1223,10 +1223,6 @@ int get_physical_address_wtlb(CPUPPCState *env, mmu_= ctx_t *ctx, ret =3D mmubooke206_get_physical_address(env, ctx, eaddr, access_t= ype, mmu_idx); break; - case POWERPC_MMU_MPC8xx: - /* XXX: TODO */ - cpu_abort(env_cpu(env), "MPC8xx MMU model is not implemented\n"); - break; case POWERPC_MMU_REAL: if (real_mode) { ret =3D check_physical(env, ctx, eaddr, access_type); @@ -1357,8 +1353,6 @@ static bool ppc_jumbo_xlate(PowerPCCPU *cpu, vaddr ea= ddr, env->spr[SPR_BOOKE_DEAR] =3D eaddr; env->spr[SPR_BOOKE_ESR] =3D mmubooke206_esr(mmu_idx, M= MU_DATA_LOAD); break; - case POWERPC_MMU_MPC8xx: - cpu_abort(cs, "MPC8xx MMU model is not implemented\n"); case POWERPC_MMU_REAL: cpu_abort(cs, "PowerPC in real mode should never raise= " "any MMU exceptions\n"); @@ -1431,9 +1425,6 @@ static bool ppc_jumbo_xlate(PowerPCCPU *cpu, vaddr ea= ddr, env->spr[SPR_40x_ESR] =3D 0x00000000; } break; - case POWERPC_MMU_MPC8xx: - /* XXX: TODO */ - cpu_abort(cs, "MPC8xx MMU model is not implemented\n"); case POWERPC_MMU_BOOKE206: booke206_update_mas_tlb_miss(env, eaddr, access_type, = mmu_idx); /* fall through */ --=20 2.30.9 From nobody Sat May 18 13:55:28 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=eik.bme.hu Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1713911669964860.2777373285172; Tue, 23 Apr 2024 15:34:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rzOfo-00019s-8n; Tue, 23 Apr 2024 18:31:36 -0400 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 1rzOff-000177-6N; Tue, 23 Apr 2024 18:31:29 -0400 Received: from zero.eik.bme.hu ([2001:738:2001:2001::2001]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rzOfc-0004bI-Ab; Tue, 23 Apr 2024 18:31:26 -0400 Received: from zero.eik.bme.hu (localhost [127.0.0.1]) by zero.eik.bme.hu (Postfix) with ESMTP id 03CDA4E6056; Wed, 24 Apr 2024 00:31:21 +0200 (CEST) Received: from zero.eik.bme.hu ([127.0.0.1]) by zero.eik.bme.hu (zero.eik.bme.hu [127.0.0.1]) (amavisd-new, port 10028) with ESMTP id DbhUbOu9borS; Wed, 24 Apr 2024 00:31:19 +0200 (CEST) Received: by zero.eik.bme.hu (Postfix, from userid 432) id 15D614E6057; Wed, 24 Apr 2024 00:31:19 +0200 (CEST) X-Virus-Scanned: amavisd-new at eik.bme.hu Message-Id: In-Reply-To: References: From: BALATON Zoltan Subject: [PATCH 08/24] target/ppc/mmu_common.c: Introduce mmu6xx_get_physical_address() MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable To: qemu-devel@nongnu.org, qemu-ppc@nongnu.org Cc: Nicholas Piggin , Daniel Henrique Barboza Date: Wed, 24 Apr 2024 00:31:19 +0200 (CEST) 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2001:738:2001:2001::2001; envelope-from=balaton@eik.bme.hu; helo=zero.eik.bme.hu X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZM-MESSAGEID: 1713911671073100002 Content-Type: text/plain; charset="utf-8" Repurpose get_segment_6xx_tlb() to do the whole address translation for POWERPC_MMU_SOFT_6xx MMU model by moving the BAT check there and renaming it to match other similar functions. These are only called once together so no need to keep these separate functions and combining them simplifies the caller allowing further restructuring. Signed-off-by: BALATON Zoltan --- target/ppc/mmu_common.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/target/ppc/mmu_common.c b/target/ppc/mmu_common.c index c4fafebbe3..47346adb88 100644 --- a/target/ppc/mmu_common.c +++ b/target/ppc/mmu_common.c @@ -359,19 +359,25 @@ static int get_bat_6xx_tlb(CPUPPCState *env, mmu_ctx_= t *ctx, return ret; } =20 -/* Perform segment based translation */ -static int get_segment_6xx_tlb(CPUPPCState *env, mmu_ctx_t *ctx, - target_ulong eaddr, MMUAccessType access_ty= pe, - int type) +static int mmu6xx_get_physical_address(CPUPPCState *env, mmu_ctx_t *ctx, + target_ulong eaddr, + MMUAccessType access_type, int type) { PowerPCCPU *cpu =3D env_archcpu(env); hwaddr hash; - target_ulong vsid; - int ds, target_page_bits; + target_ulong vsid, sr, pgidx; bool pr; - int ret; - target_ulong sr, pgidx; + int ds, target_page_bits, ret =3D -1; =20 + /* First try to find a BAT entry if there are any */ + if (env->nb_BATs !=3D 0) { + ret =3D get_bat_6xx_tlb(env, ctx, eaddr, access_type); + } + if (ret >=3D 0) { + return ret; + } + + /* Perform segment based translation when no BATs matched */ pr =3D FIELD_EX64(env->msr, MSR, PR); ctx->eaddr =3D eaddr; =20 @@ -1198,14 +1204,8 @@ int get_physical_address_wtlb(CPUPPCState *env, mmu_= ctx_t *ctx, if (real_mode) { ret =3D check_physical(env, ctx, eaddr, access_type); } else { - /* Try to find a BAT */ - if (env->nb_BATs !=3D 0) { - ret =3D get_bat_6xx_tlb(env, ctx, eaddr, access_type); - } - if (ret < 0) { - /* We didn't match any BAT entry or don't have BATs */ - ret =3D get_segment_6xx_tlb(env, ctx, eaddr, access_type, = type); - } + ret =3D mmu6xx_get_physical_address(env, ctx, eaddr, access_ty= pe, + type); } break; =20 --=20 2.30.9 From nobody Sat May 18 13:55:28 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=eik.bme.hu Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 171391179517774.95721477712266; Tue, 23 Apr 2024 15:36:35 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rzOfs-0001DM-Oj; Tue, 23 Apr 2024 18:31:40 -0400 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 1rzOfg-00017B-4c; Tue, 23 Apr 2024 18:31:29 -0400 Received: from zero.eik.bme.hu ([152.66.115.2]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rzOfd-0004bh-3D; Tue, 23 Apr 2024 18:31:27 -0400 Received: from zero.eik.bme.hu (localhost [127.0.0.1]) by zero.eik.bme.hu (Postfix) with ESMTP id 0BBCF4E6057; Wed, 24 Apr 2024 00:31:22 +0200 (CEST) Received: from zero.eik.bme.hu ([127.0.0.1]) by zero.eik.bme.hu (zero.eik.bme.hu [127.0.0.1]) (amavisd-new, port 10028) with ESMTP id 8DETRj6QtMcY; Wed, 24 Apr 2024 00:31:20 +0200 (CEST) Received: by zero.eik.bme.hu (Postfix, from userid 432) id 20B384E6058; Wed, 24 Apr 2024 00:31:20 +0200 (CEST) X-Virus-Scanned: amavisd-new at eik.bme.hu Message-Id: <64bf7f88c46bd5ce63e73247fffa82c9cf7586ac.1713907038.git.balaton@eik.bme.hu> In-Reply-To: References: From: BALATON Zoltan Subject: [PATCH 09/24] target/ppc/mmu_common.c: Rename get_bat_6xx_tlb() MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable To: qemu-devel@nongnu.org, qemu-ppc@nongnu.org Cc: Nicholas Piggin , Daniel Henrique Barboza Date: Wed, 24 Apr 2024 00:31:20 +0200 (CEST) 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=152.66.115.2; envelope-from=balaton@eik.bme.hu; helo=zero.eik.bme.hu X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZM-MESSAGEID: 1713911796516100003 Content-Type: text/plain; charset="utf-8" Rename to ppc6xx_tlb_get_bat() to match other similar names in the same file. Signed-off-by: BALATON Zoltan --- target/ppc/mmu_common.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/target/ppc/mmu_common.c b/target/ppc/mmu_common.c index 47346adb88..1fbf5a1bb0 100644 --- a/target/ppc/mmu_common.c +++ b/target/ppc/mmu_common.c @@ -288,8 +288,8 @@ static inline void bat_size_prot(CPUPPCState *env, targ= et_ulong *blp, *protp =3D prot; } =20 -static int get_bat_6xx_tlb(CPUPPCState *env, mmu_ctx_t *ctx, - target_ulong virtual, MMUAccessType access_type) +static int ppc6xx_tlb_get_bat(CPUPPCState *env, mmu_ctx_t *ctx, + target_ulong virtual, MMUAccessType access_t= ype) { target_ulong *BATlt, *BATut, *BATu, *BATl; target_ulong BEPIl, BEPIu, bl; @@ -371,7 +371,7 @@ static int mmu6xx_get_physical_address(CPUPPCState *env= , mmu_ctx_t *ctx, =20 /* First try to find a BAT entry if there are any */ if (env->nb_BATs !=3D 0) { - ret =3D get_bat_6xx_tlb(env, ctx, eaddr, access_type); + ret =3D ppc6xx_tlb_get_bat(env, ctx, eaddr, access_type); } if (ret >=3D 0) { return ret; --=20 2.30.9 From nobody Sat May 18 13:55:28 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=eik.bme.hu Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17139117549094.679864101746489; Tue, 23 Apr 2024 15:35:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rzOfs-0001D7-G4; Tue, 23 Apr 2024 18:31:40 -0400 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 1rzOff-000179-8c; Tue, 23 Apr 2024 18:31:29 -0400 Received: from zero.eik.bme.hu ([2001:738:2001:2001::2001]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rzOfd-0004bg-07; Tue, 23 Apr 2024 18:31:27 -0400 Received: from zero.eik.bme.hu (localhost [127.0.0.1]) by zero.eik.bme.hu (Postfix) with ESMTP id 1B4714E6058; Wed, 24 Apr 2024 00:31:23 +0200 (CEST) Received: from zero.eik.bme.hu ([127.0.0.1]) by zero.eik.bme.hu (zero.eik.bme.hu [127.0.0.1]) (amavisd-new, port 10028) with ESMTP id d18_P6lfAXCJ; Wed, 24 Apr 2024 00:31:21 +0200 (CEST) Received: by zero.eik.bme.hu (Postfix, from userid 432) id 31AA14E6059; Wed, 24 Apr 2024 00:31:21 +0200 (CEST) X-Virus-Scanned: amavisd-new at eik.bme.hu Message-Id: <062ade878f5dde2834ae81db7f6a388955ce77d4.1713907038.git.balaton@eik.bme.hu> In-Reply-To: References: From: BALATON Zoltan Subject: [PATCH 10/24] target/ppc/mmu_common.c: Split out BookE cases before checking real mode MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable To: qemu-devel@nongnu.org, qemu-ppc@nongnu.org Cc: Nicholas Piggin , Daniel Henrique Barboza Date: Wed, 24 Apr 2024 00:31:21 +0200 (CEST) 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2001:738:2001:2001::2001; envelope-from=balaton@eik.bme.hu; helo=zero.eik.bme.hu X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZM-MESSAGEID: 1713911756400100001 Content-Type: text/plain; charset="utf-8" BookE does not have real mode so split off and handle it first in get_physical_address_wtlb() before checking for real mode for other MMU models. Signed-off-by: BALATON Zoltan --- target/ppc/mmu_common.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/target/ppc/mmu_common.c b/target/ppc/mmu_common.c index 1fbf5a1bb0..68c367e6ad 100644 --- a/target/ppc/mmu_common.c +++ b/target/ppc/mmu_common.c @@ -1196,6 +1196,13 @@ int get_physical_address_wtlb(CPUPPCState *env, mmu_= ctx_t *ctx, int ret =3D -1; bool real_mode; =20 + if (env->mmu_model =3D=3D POWERPC_MMU_BOOKE) { + return mmubooke_get_physical_address(env, ctx, eaddr, access_type); + } else if (env->mmu_model =3D=3D POWERPC_MMU_BOOKE206) { + return mmubooke206_get_physical_address(env, ctx, eaddr, access_ty= pe, + mmu_idx); + } + real_mode =3D (type =3D=3D ACCESS_CODE) ? !FIELD_EX64(env->msr, MSR, I= R) : !FIELD_EX64(env->msr, MSR, DR); =20 @@ -1216,13 +1223,6 @@ int get_physical_address_wtlb(CPUPPCState *env, mmu_= ctx_t *ctx, ret =3D mmu40x_get_physical_address(env, ctx, eaddr, access_ty= pe); } break; - case POWERPC_MMU_BOOKE: - ret =3D mmubooke_get_physical_address(env, ctx, eaddr, access_type= ); - break; - case POWERPC_MMU_BOOKE206: - ret =3D mmubooke206_get_physical_address(env, ctx, eaddr, access_t= ype, - mmu_idx); - break; case POWERPC_MMU_REAL: if (real_mode) { ret =3D check_physical(env, ctx, eaddr, access_type); --=20 2.30.9 From nobody Sat May 18 13:55:28 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=eik.bme.hu Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1713911678581991.9876070730754; Tue, 23 Apr 2024 15:34:38 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rzOft-0001Du-Me; Tue, 23 Apr 2024 18:31:41 -0400 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 1rzOfg-00017C-Ap; Tue, 23 Apr 2024 18:31:29 -0400 Received: from zero.eik.bme.hu ([2001:738:2001:2001::2001]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rzOfe-0004c1-5S; Tue, 23 Apr 2024 18:31:28 -0400 Received: from zero.eik.bme.hu (localhost [127.0.0.1]) by zero.eik.bme.hu (Postfix) with ESMTP id 2AC064E6040; Wed, 24 Apr 2024 00:31:24 +0200 (CEST) Received: from zero.eik.bme.hu ([127.0.0.1]) by zero.eik.bme.hu (zero.eik.bme.hu [127.0.0.1]) (amavisd-new, port 10028) with ESMTP id JivpVkijRgHu; Wed, 24 Apr 2024 00:31:22 +0200 (CEST) Received: by zero.eik.bme.hu (Postfix, from userid 432) id 3E88E4E605A; Wed, 24 Apr 2024 00:31:22 +0200 (CEST) X-Virus-Scanned: amavisd-new at eik.bme.hu Message-Id: <895d38984367425cbdc85ff3bf2facf467838496.1713907038.git.balaton@eik.bme.hu> In-Reply-To: References: From: BALATON Zoltan Subject: [PATCH 11/24] target/ppc/mmu_common.c: Split off real mode cases in get_physical_address_wtlb() MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable To: qemu-devel@nongnu.org, qemu-ppc@nongnu.org Cc: Nicholas Piggin , Daniel Henrique Barboza Date: Wed, 24 Apr 2024 00:31:22 +0200 (CEST) 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2001:738:2001:2001::2001; envelope-from=balaton@eik.bme.hu; helo=zero.eik.bme.hu X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZM-MESSAGEID: 1713911679133100001 Content-Type: text/plain; charset="utf-8" The real mode handling is identical in the remaining switch cases. Split off these common real mode cases into a separate conditional to leave only the else branches in the switch that are different. Signed-off-by: BALATON Zoltan --- target/ppc/mmu_common.c | 34 +++++++++------------------------- 1 file changed, 9 insertions(+), 25 deletions(-) diff --git a/target/ppc/mmu_common.c b/target/ppc/mmu_common.c index 68c367e6ad..fb66468d34 100644 --- a/target/ppc/mmu_common.c +++ b/target/ppc/mmu_common.c @@ -1193,7 +1193,6 @@ int get_physical_address_wtlb(CPUPPCState *env, mmu_c= tx_t *ctx, MMUAccessType access_type, int type, int mmu_idx) { - int ret =3D -1; bool real_mode; =20 if (env->mmu_model =3D=3D POWERPC_MMU_BOOKE) { @@ -1205,38 +1204,23 @@ int get_physical_address_wtlb(CPUPPCState *env, mmu= _ctx_t *ctx, =20 real_mode =3D (type =3D=3D ACCESS_CODE) ? !FIELD_EX64(env->msr, MSR, I= R) : !FIELD_EX64(env->msr, MSR, DR); + if (real_mode && (env->mmu_model =3D=3D POWERPC_MMU_SOFT_6xx || + env->mmu_model =3D=3D POWERPC_MMU_SOFT_4xx || + env->mmu_model =3D=3D POWERPC_MMU_REAL)) { + return check_physical(env, ctx, eaddr, access_type); + } =20 switch (env->mmu_model) { case POWERPC_MMU_SOFT_6xx: - if (real_mode) { - ret =3D check_physical(env, ctx, eaddr, access_type); - } else { - ret =3D mmu6xx_get_physical_address(env, ctx, eaddr, access_ty= pe, - type); - } - break; - + return mmu6xx_get_physical_address(env, ctx, eaddr, access_type, t= ype); case POWERPC_MMU_SOFT_4xx: - if (real_mode) { - ret =3D check_physical(env, ctx, eaddr, access_type); - } else { - ret =3D mmu40x_get_physical_address(env, ctx, eaddr, access_ty= pe); - } - break; + return mmu40x_get_physical_address(env, ctx, eaddr, access_type); case POWERPC_MMU_REAL: - if (real_mode) { - ret =3D check_physical(env, ctx, eaddr, access_type); - } else { - cpu_abort(env_cpu(env), - "PowerPC in real mode do not do any translation\n"); - } - return -1; + cpu_abort(env_cpu(env), + "PowerPC in real mode do not do any translation\n"); default: cpu_abort(env_cpu(env), "Unknown or invalid MMU model\n"); - return -1; } - - return ret; } =20 static void booke206_update_mas_tlb_miss(CPUPPCState *env, target_ulong ad= dress, --=20 2.30.9 From nobody Sat May 18 13:55:28 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=eik.bme.hu Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1713911649263285.1815863292584; Tue, 23 Apr 2024 15:34:09 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rzOfr-0001Cz-QV; Tue, 23 Apr 2024 18:31:39 -0400 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 1rzOfh-00017E-BI; Tue, 23 Apr 2024 18:31:29 -0400 Received: from zero.eik.bme.hu ([2001:738:2001:2001::2001]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rzOff-0004cF-7v; Tue, 23 Apr 2024 18:31:29 -0400 Received: from zero.eik.bme.hu (localhost [127.0.0.1]) by zero.eik.bme.hu (Postfix) with ESMTP id 340CA4E6041; Wed, 24 Apr 2024 00:31:25 +0200 (CEST) Received: from zero.eik.bme.hu ([127.0.0.1]) by zero.eik.bme.hu (zero.eik.bme.hu [127.0.0.1]) (amavisd-new, port 10028) with ESMTP id bLvPjQN-Squc; Wed, 24 Apr 2024 00:31:23 +0200 (CEST) Received: by zero.eik.bme.hu (Postfix, from userid 432) id 4A0D24E603E; Wed, 24 Apr 2024 00:31:23 +0200 (CEST) X-Virus-Scanned: amavisd-new at eik.bme.hu Message-Id: In-Reply-To: References: From: BALATON Zoltan Subject: [PATCH 12/24] target/ppc/mmu_common.c: Inline and remove check_physical() MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable To: qemu-devel@nongnu.org, qemu-ppc@nongnu.org Cc: Nicholas Piggin , Daniel Henrique Barboza Date: Wed, 24 Apr 2024 00:31:23 +0200 (CEST) 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2001:738:2001:2001::2001; envelope-from=balaton@eik.bme.hu; helo=zero.eik.bme.hu X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZM-MESSAGEID: 1713911651036100009 Content-Type: text/plain; charset="utf-8" This function just does two assignments and and unnecessary check that is always true so inline it in the only caller left and remove it. Signed-off-by: BALATON Zoltan --- target/ppc/mmu_common.c | 26 +++----------------------- 1 file changed, 3 insertions(+), 23 deletions(-) diff --git a/target/ppc/mmu_common.c b/target/ppc/mmu_common.c index fb66468d34..843f909619 100644 --- a/target/ppc/mmu_common.c +++ b/target/ppc/mmu_common.c @@ -1166,28 +1166,6 @@ void dump_mmu(CPUPPCState *env) } } =20 -static int check_physical(CPUPPCState *env, mmu_ctx_t *ctx, target_ulong e= addr, - MMUAccessType access_type) -{ - ctx->raddr =3D eaddr; - ctx->prot =3D PAGE_READ | PAGE_EXEC; - - switch (env->mmu_model) { - case POWERPC_MMU_SOFT_6xx: - case POWERPC_MMU_SOFT_4xx: - case POWERPC_MMU_REAL: - case POWERPC_MMU_BOOKE: - ctx->prot |=3D PAGE_WRITE; - break; - - default: - /* Caller's checks mean we should never get here for other models = */ - g_assert_not_reached(); - } - - return 0; -} - int get_physical_address_wtlb(CPUPPCState *env, mmu_ctx_t *ctx, target_ulong eaddr, MMUAccessType access_type, int type, @@ -1207,7 +1185,9 @@ int get_physical_address_wtlb(CPUPPCState *env, mmu_c= tx_t *ctx, if (real_mode && (env->mmu_model =3D=3D POWERPC_MMU_SOFT_6xx || env->mmu_model =3D=3D POWERPC_MMU_SOFT_4xx || env->mmu_model =3D=3D POWERPC_MMU_REAL)) { - return check_physical(env, ctx, eaddr, access_type); + ctx->raddr =3D eaddr; + ctx->prot =3D PAGE_READ | PAGE_WRITE | PAGE_EXEC; + return 0; } =20 switch (env->mmu_model) { --=20 2.30.9 From nobody Sat May 18 13:55:28 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=eik.bme.hu Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1713911637236533.6770624510493; Tue, 23 Apr 2024 15:33:57 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rzOfy-0001HA-EG; Tue, 23 Apr 2024 18:31:46 -0400 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 1rzOfh-000181-Sk; Tue, 23 Apr 2024 18:31:31 -0400 Received: from zero.eik.bme.hu ([2001:738:2001:2001::2001]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rzOfg-0004cc-6p; Tue, 23 Apr 2024 18:31:29 -0400 Received: from zero.eik.bme.hu (localhost [127.0.0.1]) by zero.eik.bme.hu (Postfix) with ESMTP id 4AB494E603E; Wed, 24 Apr 2024 00:31:26 +0200 (CEST) Received: from zero.eik.bme.hu ([127.0.0.1]) by zero.eik.bme.hu (zero.eik.bme.hu [127.0.0.1]) (amavisd-new, port 10028) with ESMTP id SuFV9X7D57eU; Wed, 24 Apr 2024 00:31:24 +0200 (CEST) Received: by zero.eik.bme.hu (Postfix, from userid 432) id 5D7F44E603D; Wed, 24 Apr 2024 00:31:24 +0200 (CEST) X-Virus-Scanned: amavisd-new at eik.bme.hu Message-Id: In-Reply-To: References: From: BALATON Zoltan Subject: [PATCH 13/24] target/ppc/mmu_common.c: Simplify mmubooke_get_physical_address() MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable To: qemu-devel@nongnu.org, qemu-ppc@nongnu.org Cc: Nicholas Piggin , Daniel Henrique Barboza Date: Wed, 24 Apr 2024 00:31:24 +0200 (CEST) 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2001:738:2001:2001::2001; envelope-from=balaton@eik.bme.hu; helo=zero.eik.bme.hu X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZM-MESSAGEID: 1713911638974100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: BALATON Zoltan --- target/ppc/mmu_common.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/target/ppc/mmu_common.c b/target/ppc/mmu_common.c index 843f909619..d40ddb6fc3 100644 --- a/target/ppc/mmu_common.c +++ b/target/ppc/mmu_common.c @@ -668,31 +668,24 @@ static int mmubooke_get_physical_address(CPUPPCState = *env, mmu_ctx_t *ctx, MMUAccessType access_type) { ppcemb_tlb_t *tlb; - hwaddr raddr; - int i, ret; + hwaddr raddr =3D (hwaddr)-1ULL; + int i, ret =3D -1; =20 - ret =3D -1; - raddr =3D (hwaddr)-1ULL; for (i =3D 0; i < env->nb_tlb; i++) { tlb =3D &env->tlb.tlbe[i]; ret =3D mmubooke_check_tlb(env, tlb, &raddr, &ctx->prot, address, access_type, i); if (ret !=3D -1) { + if (ret >=3D 0) { + ctx->raddr =3D raddr; + } break; } } - - if (ret >=3D 0) { - ctx->raddr =3D raddr; - qemu_log_mask(CPU_LOG_MMU, "%s: access granted " TARGET_FMT_lx - " =3D> " HWADDR_FMT_plx " %d %d\n", __func__, - address, ctx->raddr, ctx->prot, ret); - } else { - qemu_log_mask(CPU_LOG_MMU, "%s: access refused " TARGET_FMT_lx - " =3D> " HWADDR_FMT_plx " %d %d\n", __func__, - address, raddr, ctx->prot, ret); - } - + qemu_log_mask(CPU_LOG_MMU, + "%s: access %s " TARGET_FMT_lx " =3D> " HWADDR_FMT_plx + " %d %d\n", __func__, ret < 0 ? "refused" : "granted", + address, raddr, ctx->prot, ret); return ret; } =20 --=20 2.30.9 From nobody Sat May 18 13:55:28 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=eik.bme.hu Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1713911660141177.36983304521607; Tue, 23 Apr 2024 15:34:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rzOfu-0001EQ-M3; Tue, 23 Apr 2024 18:31:42 -0400 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 1rzOfi-00018b-Cb; Tue, 23 Apr 2024 18:31:31 -0400 Received: from zero.eik.bme.hu ([152.66.115.2]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rzOfg-0004d0-QF; Tue, 23 Apr 2024 18:31:30 -0400 Received: from zero.eik.bme.hu (localhost [127.0.0.1]) by zero.eik.bme.hu (Postfix) with ESMTP id 56F064E603D; Wed, 24 Apr 2024 00:31:27 +0200 (CEST) Received: from zero.eik.bme.hu ([127.0.0.1]) by zero.eik.bme.hu (zero.eik.bme.hu [127.0.0.1]) (amavisd-new, port 10028) with ESMTP id eN86juZ7Q2SW; Wed, 24 Apr 2024 00:31:25 +0200 (CEST) Received: by zero.eik.bme.hu (Postfix, from userid 432) id 6ACF04E6042; Wed, 24 Apr 2024 00:31:25 +0200 (CEST) X-Virus-Scanned: amavisd-new at eik.bme.hu Message-Id: <6735e4d6a048c4a14aed8a20e2ea66c00e44c847.1713907038.git.balaton@eik.bme.hu> In-Reply-To: References: From: BALATON Zoltan Subject: [PATCH 14/24] target/ppc/mmu_common.c: Simplify mmubooke206_get_physical_address() MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable To: qemu-devel@nongnu.org, qemu-ppc@nongnu.org Cc: Nicholas Piggin , Daniel Henrique Barboza Date: Wed, 24 Apr 2024 00:31:25 +0200 (CEST) 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=152.66.115.2; envelope-from=balaton@eik.bme.hu; helo=zero.eik.bme.hu X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZM-MESSAGEID: 1713911661040100001 Content-Type: text/plain; charset="utf-8" This function is similar to mmubooke_get_physical_address() and can be simplified the same way. Signed-off-by: BALATON Zoltan --- target/ppc/mmu_common.c | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/target/ppc/mmu_common.c b/target/ppc/mmu_common.c index d40ddb6fc3..5cb550da7e 100644 --- a/target/ppc/mmu_common.c +++ b/target/ppc/mmu_common.c @@ -877,15 +877,11 @@ static int mmubooke206_get_physical_address(CPUPPCSta= te *env, mmu_ctx_t *ctx, int mmu_idx) { ppcmas_tlb_t *tlb; - hwaddr raddr; - int i, j, ret; - - ret =3D -1; - raddr =3D (hwaddr)-1ULL; + hwaddr raddr =3D (hwaddr)-1ULL; + int i, j, ways, ret =3D -1; =20 for (i =3D 0; i < BOOKE206_MAX_TLBN; i++) { - int ways =3D booke206_tlb_ways(env, i); - + ways =3D booke206_tlb_ways(env, i); for (j =3D 0; j < ways; j++) { tlb =3D booke206_get_tlbm(env, i, address, j); if (!tlb) { @@ -894,6 +890,9 @@ static int mmubooke206_get_physical_address(CPUPPCState= *env, mmu_ctx_t *ctx, ret =3D mmubooke206_check_tlb(env, tlb, &raddr, &ctx->prot, ad= dress, access_type, mmu_idx); if (ret !=3D -1) { + if (ret >=3D 0) { + ctx->raddr =3D raddr; + } goto found_tlb; } } @@ -901,17 +900,10 @@ static int mmubooke206_get_physical_address(CPUPPCSta= te *env, mmu_ctx_t *ctx, =20 found_tlb: =20 - if (ret >=3D 0) { - ctx->raddr =3D raddr; - qemu_log_mask(CPU_LOG_MMU, "%s: access granted " TARGET_FMT_lx - " =3D> " HWADDR_FMT_plx " %d %d\n", __func__, addre= ss, - ctx->raddr, ctx->prot, ret); - } else { - qemu_log_mask(CPU_LOG_MMU, "%s: access refused " TARGET_FMT_lx - " =3D> " HWADDR_FMT_plx " %d %d\n", __func__, addre= ss, - raddr, ctx->prot, ret); - } - + qemu_log_mask(CPU_LOG_MMU, "%s: access %s " TARGET_FMT_lx " =3D> " + HWADDR_FMT_plx " %d %d\n", __func__, + ret < 0 ? "refused" : "granted", address, raddr, + ctx->prot, ret); return ret; } =20 --=20 2.30.9 From nobody Sat May 18 13:55:28 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=eik.bme.hu Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1713911688519825.8523715679751; Tue, 23 Apr 2024 15:34:48 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rzOfq-0001CA-J2; Tue, 23 Apr 2024 18:31:38 -0400 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 1rzOfj-00018f-P1; Tue, 23 Apr 2024 18:31:33 -0400 Received: from zero.eik.bme.hu ([2001:738:2001:2001::2001]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rzOfi-0004dI-0Y; Tue, 23 Apr 2024 18:31:31 -0400 Received: from zero.eik.bme.hu (localhost [127.0.0.1]) by zero.eik.bme.hu (Postfix) with ESMTP id 669BF4E6042; Wed, 24 Apr 2024 00:31:28 +0200 (CEST) Received: from zero.eik.bme.hu ([127.0.0.1]) by zero.eik.bme.hu (zero.eik.bme.hu [127.0.0.1]) (amavisd-new, port 10028) with ESMTP id Ml8MWfTR5fXj; Wed, 24 Apr 2024 00:31:26 +0200 (CEST) Received: by zero.eik.bme.hu (Postfix, from userid 432) id 775894E6031; Wed, 24 Apr 2024 00:31:26 +0200 (CEST) X-Virus-Scanned: amavisd-new at eik.bme.hu Message-Id: <11cb8b749d64cb1e0ef9e73da101d41a50da8909.1713907038.git.balaton@eik.bme.hu> In-Reply-To: References: From: BALATON Zoltan Subject: [PATCH 15/24] target/ppc/mmu_common.c: Fix misindented qemu_log_mask() calls MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable To: qemu-devel@nongnu.org, qemu-ppc@nongnu.org Cc: Nicholas Piggin , Daniel Henrique Barboza Date: Wed, 24 Apr 2024 00:31:26 +0200 (CEST) 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2001:738:2001:2001::2001; envelope-from=balaton@eik.bme.hu; helo=zero.eik.bme.hu X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZM-MESSAGEID: 1713911689231100001 Content-Type: text/plain; charset="utf-8" Fix several qemu_log_mask() calls that are misindented. Signed-off-by: BALATON Zoltan --- target/ppc/mmu_common.c | 42 ++++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/target/ppc/mmu_common.c b/target/ppc/mmu_common.c index 5cb550da7e..80c8fb0bf5 100644 --- a/target/ppc/mmu_common.c +++ b/target/ppc/mmu_common.c @@ -297,8 +297,8 @@ static int ppc6xx_tlb_get_bat(CPUPPCState *env, mmu_ctx= _t *ctx, int ret =3D -1; bool ifetch =3D access_type =3D=3D MMU_INST_FETCH; =20 - qemu_log_mask(CPU_LOG_MMU, "%s: %cBAT v " TARGET_FMT_lx "\n", __func_= _, - ifetch ? 'I' : 'D', virtual); + qemu_log_mask(CPU_LOG_MMU, "%s: %cBAT v " TARGET_FMT_lx "\n", __func__, + ifetch ? 'I' : 'D', virtual); if (ifetch) { BATlt =3D env->IBAT[1]; BATut =3D env->IBAT[0]; @@ -312,9 +312,9 @@ static int ppc6xx_tlb_get_bat(CPUPPCState *env, mmu_ctx= _t *ctx, BEPIu =3D *BATu & 0xF0000000; BEPIl =3D *BATu & 0x0FFE0000; bat_size_prot(env, &bl, &valid, &prot, BATu, BATl); - qemu_log_mask(CPU_LOG_MMU, "%s: %cBAT%d v " TARGET_FMT_lx " BATu " - TARGET_FMT_lx " BATl " TARGET_FMT_lx "\n", __func__, - ifetch ? 'I' : 'D', i, virtual, *BATu, *BATl); + qemu_log_mask(CPU_LOG_MMU, "%s: %cBAT%d v " TARGET_FMT_lx " BATu " + TARGET_FMT_lx " BATl " TARGET_FMT_lx "\n", __func__, + ifetch ? 'I' : 'D', i, virtual, *BATu, *BATl); if ((virtual & 0xF0000000) =3D=3D BEPIu && ((virtual & 0x0FFE0000) & ~bl) =3D=3D BEPIl) { /* BAT matches */ @@ -346,12 +346,11 @@ static int ppc6xx_tlb_get_bat(CPUPPCState *env, mmu_c= tx_t *ctx, BEPIu =3D *BATu & 0xF0000000; BEPIl =3D *BATu & 0x0FFE0000; bl =3D (*BATu & 0x00001FFC) << 15; - qemu_log_mask(CPU_LOG_MMU, "%s: %cBAT%d v " - TARGET_FMT_lx " BATu " TARGET_FMT_lx - " BATl " TARGET_FMT_lx "\n\t" TARGET_FMT_lx= " " - TARGET_FMT_lx " " TARGET_FMT_lx "\n", - __func__, ifetch ? 'I' : 'D', i, virtual, - *BATu, *BATl, BEPIu, BEPIl, bl); + qemu_log_mask(CPU_LOG_MMU, "%s: %cBAT%d v " TARGET_FMT_lx + " BATu " TARGET_FMT_lx " BATl " TARGET_FMT_lx + "\n\t" TARGET_FMT_lx " " TARGET_FMT_lx " " + TARGET_FMT_lx "\n", __func__, ifetch ? 'I' := 'D', + i, virtual, *BATu, *BATl, BEPIu, BEPIl, bl); } } } @@ -400,9 +399,8 @@ static int mmu6xx_get_physical_address(CPUPPCState *env= , mmu_ctx_t *ctx, hash =3D vsid ^ pgidx; ctx->ptem =3D (vsid << 7) | (pgidx >> 10); =20 - qemu_log_mask(CPU_LOG_MMU, - "pte segment: key=3D%d ds %d nx %d vsid " TARGET_FMT_lx "\n", - ctx->key, ds, ctx->nx, vsid); + qemu_log_mask(CPU_LOG_MMU, "pte segment: key=3D%d ds %d nx %d vsid " + TARGET_FMT_lx "\n", ctx->key, ds, ctx->nx, vsid); ret =3D -1; if (!ds) { /* Check if instruction fetch is allowed, if needed */ @@ -599,9 +597,9 @@ static int mmu40x_get_physical_address(CPUPPCState *env= , mmu_ctx_t *ctx, return 0; } } - qemu_log_mask(CPU_LOG_MMU, "%s: access refused " TARGET_FMT_lx - " =3D> " HWADDR_FMT_plx - " %d %d\n", __func__, address, raddr, ctx->prot, ret); + qemu_log_mask(CPU_LOG_MMU, "%s: access refused " TARGET_FMT_lx + " =3D> " HWADDR_FMT_plx " %d %d\n", + __func__, address, raddr, ctx->prot, ret); =20 return ret; } @@ -716,11 +714,11 @@ int ppcmas_tlb_check(CPUPPCState *env, ppcmas_tlb_t *= tlb, hwaddr *raddrp, } =20 mask =3D ~(booke206_tlb_to_page_size(env, tlb) - 1); - qemu_log_mask(CPU_LOG_MMU, "%s: TLB ADDR=3D0x" TARGET_FMT_lx - " PID=3D0x%x MAS1=3D0x%x MAS2=3D0x%" PRIx64 " mask=3D0x= %" - HWADDR_PRIx " MAS7_3=3D0x%" PRIx64 " MAS8=3D0x%" PRIx32= "\n", - __func__, address, pid, tlb->mas1, tlb->mas2, mask, - tlb->mas7_3, tlb->mas8); + qemu_log_mask(CPU_LOG_MMU, "%s: TLB ADDR=3D0x" TARGET_FMT_lx + " PID=3D0x%x MAS1=3D0x%x MAS2=3D0x%" PRIx64 " mask=3D0x%" + HWADDR_PRIx " MAS7_3=3D0x%" PRIx64 " MAS8=3D0x%" PRIx32 = "\n", + __func__, address, pid, tlb->mas1, tlb->mas2, mask, + tlb->mas7_3, tlb->mas8); =20 /* Check PID */ tlb_pid =3D (tlb->mas1 & MAS1_TID_MASK) >> MAS1_TID_SHIFT; --=20 2.30.9 From nobody Sat May 18 13:55:28 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=eik.bme.hu Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1713911648076100.45466238595293; Tue, 23 Apr 2024 15:34:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rzOfu-0001EU-Uz; Tue, 23 Apr 2024 18:31:43 -0400 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 1rzOfl-00019M-Rm; Tue, 23 Apr 2024 18:31:35 -0400 Received: from zero.eik.bme.hu ([152.66.115.2]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rzOfj-0004dd-1A; Tue, 23 Apr 2024 18:31:33 -0400 Received: from zero.eik.bme.hu (localhost [127.0.0.1]) by zero.eik.bme.hu (Postfix) with ESMTP id 7E0304E6031; Wed, 24 Apr 2024 00:31:29 +0200 (CEST) Received: from zero.eik.bme.hu ([127.0.0.1]) by zero.eik.bme.hu (zero.eik.bme.hu [127.0.0.1]) (amavisd-new, port 10028) with ESMTP id mherrP4JMhzz; Wed, 24 Apr 2024 00:31:27 +0200 (CEST) Received: by zero.eik.bme.hu (Postfix, from userid 432) id 89D4C4E6054; Wed, 24 Apr 2024 00:31:27 +0200 (CEST) X-Virus-Scanned: amavisd-new at eik.bme.hu Message-Id: <90a82679fbe5c850175f71cf7bc29b3efe6356ce.1713907038.git.balaton@eik.bme.hu> In-Reply-To: References: From: BALATON Zoltan Subject: [PATCH 16/24] target/ppc/mmu_common.c: Deindent ppc_jumbo_xlate() MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable To: qemu-devel@nongnu.org, qemu-ppc@nongnu.org Cc: Nicholas Piggin , Daniel Henrique Barboza Date: Wed, 24 Apr 2024 00:31:27 +0200 (CEST) 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=152.66.115.2; envelope-from=balaton@eik.bme.hu; helo=zero.eik.bme.hu X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZM-MESSAGEID: 1713911649039100003 Content-Type: text/plain; charset="utf-8" Instead of putting a large block of code in an if, invert the condition and return early to be able to deindent the code block. Signed-off-by: BALATON Zoltan --- target/ppc/mmu_common.c | 319 ++++++++++++++++++++-------------------- 1 file changed, 159 insertions(+), 160 deletions(-) diff --git a/target/ppc/mmu_common.c b/target/ppc/mmu_common.c index 80c8fb0bf5..34d8576905 100644 --- a/target/ppc/mmu_common.c +++ b/target/ppc/mmu_common.c @@ -1270,187 +1270,186 @@ static bool ppc_jumbo_xlate(PowerPCCPU *cpu, vadd= r eaddr, *protp =3D ctx.prot; *psizep =3D TARGET_PAGE_BITS; return true; + } else if (!guest_visible) { + return false; } =20 - if (guest_visible) { - log_cpu_state_mask(CPU_LOG_MMU, cs, 0); - if (type =3D=3D ACCESS_CODE) { - switch (ret) { - case -1: - /* No matches in page tables or TLB */ - switch (env->mmu_model) { - case POWERPC_MMU_SOFT_6xx: - cs->exception_index =3D POWERPC_EXCP_IFTLB; - env->error_code =3D 1 << 18; - env->spr[SPR_IMISS] =3D eaddr; - env->spr[SPR_ICMP] =3D 0x80000000 | ctx.ptem; - goto tlb_miss; - case POWERPC_MMU_SOFT_4xx: - cs->exception_index =3D POWERPC_EXCP_ITLB; - env->error_code =3D 0; - env->spr[SPR_40x_DEAR] =3D eaddr; - env->spr[SPR_40x_ESR] =3D 0x00000000; - break; - case POWERPC_MMU_BOOKE206: - booke206_update_mas_tlb_miss(env, eaddr, 2, mmu_idx); - /* fall through */ - case POWERPC_MMU_BOOKE: - cs->exception_index =3D POWERPC_EXCP_ITLB; - env->error_code =3D 0; - env->spr[SPR_BOOKE_DEAR] =3D eaddr; - env->spr[SPR_BOOKE_ESR] =3D mmubooke206_esr(mmu_idx, M= MU_DATA_LOAD); - break; - case POWERPC_MMU_REAL: - cpu_abort(cs, "PowerPC in real mode should never raise= " - "any MMU exceptions\n"); - default: - cpu_abort(cs, "Unknown or invalid MMU model\n"); - } + log_cpu_state_mask(CPU_LOG_MMU, cs, 0); + if (type =3D=3D ACCESS_CODE) { + switch (ret) { + case -1: + /* No matches in page tables or TLB */ + switch (env->mmu_model) { + case POWERPC_MMU_SOFT_6xx: + cs->exception_index =3D POWERPC_EXCP_IFTLB; + env->error_code =3D 1 << 18; + env->spr[SPR_IMISS] =3D eaddr; + env->spr[SPR_ICMP] =3D 0x80000000 | ctx.ptem; + goto tlb_miss; + case POWERPC_MMU_SOFT_4xx: + cs->exception_index =3D POWERPC_EXCP_ITLB; + env->error_code =3D 0; + env->spr[SPR_40x_DEAR] =3D eaddr; + env->spr[SPR_40x_ESR] =3D 0x00000000; break; - case -2: - /* Access rights violation */ - cs->exception_index =3D POWERPC_EXCP_ISI; - if ((env->mmu_model =3D=3D POWERPC_MMU_BOOKE) || - (env->mmu_model =3D=3D POWERPC_MMU_BOOKE206)) { - env->error_code =3D 0; - } else { - env->error_code =3D 0x08000000; - } + case POWERPC_MMU_BOOKE206: + booke206_update_mas_tlb_miss(env, eaddr, 2, mmu_idx); + /* fall through */ + case POWERPC_MMU_BOOKE: + cs->exception_index =3D POWERPC_EXCP_ITLB; + env->error_code =3D 0; + env->spr[SPR_BOOKE_DEAR] =3D eaddr; + env->spr[SPR_BOOKE_ESR] =3D mmubooke206_esr(mmu_idx, MMU_D= ATA_LOAD); break; - case -3: - /* No execute protection violation */ - if ((env->mmu_model =3D=3D POWERPC_MMU_BOOKE) || - (env->mmu_model =3D=3D POWERPC_MMU_BOOKE206)) { - env->spr[SPR_BOOKE_ESR] =3D 0x00000000; - env->error_code =3D 0; + case POWERPC_MMU_REAL: + cpu_abort(cs, "PowerPC in real mode should never raise " + "any MMU exceptions\n"); + default: + cpu_abort(cs, "Unknown or invalid MMU model\n"); + } + break; + case -2: + /* Access rights violation */ + cs->exception_index =3D POWERPC_EXCP_ISI; + if ((env->mmu_model =3D=3D POWERPC_MMU_BOOKE) || + (env->mmu_model =3D=3D POWERPC_MMU_BOOKE206)) { + env->error_code =3D 0; + } else { + env->error_code =3D 0x08000000; + } + break; + case -3: + /* No execute protection violation */ + if ((env->mmu_model =3D=3D POWERPC_MMU_BOOKE) || + (env->mmu_model =3D=3D POWERPC_MMU_BOOKE206)) { + env->spr[SPR_BOOKE_ESR] =3D 0x00000000; + env->error_code =3D 0; + } else { + env->error_code =3D 0x10000000; + } + cs->exception_index =3D POWERPC_EXCP_ISI; + break; + case -4: + /* Direct store exception */ + /* No code fetch is allowed in direct-store areas */ + cs->exception_index =3D POWERPC_EXCP_ISI; + if ((env->mmu_model =3D=3D POWERPC_MMU_BOOKE) || + (env->mmu_model =3D=3D POWERPC_MMU_BOOKE206)) { + env->error_code =3D 0; + } else { + env->error_code =3D 0x10000000; + } + break; + } + } else { + switch (ret) { + case -1: + /* No matches in page tables or TLB */ + switch (env->mmu_model) { + case POWERPC_MMU_SOFT_6xx: + if (access_type =3D=3D MMU_DATA_STORE) { + cs->exception_index =3D POWERPC_EXCP_DSTLB; + env->error_code =3D 1 << 16; } else { - env->error_code =3D 0x10000000; + cs->exception_index =3D POWERPC_EXCP_DLTLB; + env->error_code =3D 0; } - cs->exception_index =3D POWERPC_EXCP_ISI; + env->spr[SPR_DMISS] =3D eaddr; + env->spr[SPR_DCMP] =3D 0x80000000 | ctx.ptem; + tlb_miss: + env->error_code |=3D ctx.key << 19; + env->spr[SPR_HASH1] =3D ppc_hash32_hpt_base(cpu) + + get_pteg_offset32(cpu, ctx.hash[0]); + env->spr[SPR_HASH2] =3D ppc_hash32_hpt_base(cpu) + + get_pteg_offset32(cpu, ctx.hash[1]); break; - case -4: - /* Direct store exception */ - /* No code fetch is allowed in direct-store areas */ - cs->exception_index =3D POWERPC_EXCP_ISI; - if ((env->mmu_model =3D=3D POWERPC_MMU_BOOKE) || - (env->mmu_model =3D=3D POWERPC_MMU_BOOKE206)) { - env->error_code =3D 0; + case POWERPC_MMU_SOFT_4xx: + cs->exception_index =3D POWERPC_EXCP_DTLB; + env->error_code =3D 0; + env->spr[SPR_40x_DEAR] =3D eaddr; + if (access_type =3D=3D MMU_DATA_STORE) { + env->spr[SPR_40x_ESR] =3D 0x00800000; } else { - env->error_code =3D 0x10000000; + env->spr[SPR_40x_ESR] =3D 0x00000000; } break; - } - } else { - switch (ret) { - case -1: - /* No matches in page tables or TLB */ - switch (env->mmu_model) { - case POWERPC_MMU_SOFT_6xx: - if (access_type =3D=3D MMU_DATA_STORE) { - cs->exception_index =3D POWERPC_EXCP_DSTLB; - env->error_code =3D 1 << 16; - } else { - cs->exception_index =3D POWERPC_EXCP_DLTLB; - env->error_code =3D 0; - } - env->spr[SPR_DMISS] =3D eaddr; - env->spr[SPR_DCMP] =3D 0x80000000 | ctx.ptem; - tlb_miss: - env->error_code |=3D ctx.key << 19; - env->spr[SPR_HASH1] =3D ppc_hash32_hpt_base(cpu) + - get_pteg_offset32(cpu, ctx.hash[0]); - env->spr[SPR_HASH2] =3D ppc_hash32_hpt_base(cpu) + - get_pteg_offset32(cpu, ctx.hash[1]); - break; - case POWERPC_MMU_SOFT_4xx: - cs->exception_index =3D POWERPC_EXCP_DTLB; - env->error_code =3D 0; - env->spr[SPR_40x_DEAR] =3D eaddr; - if (access_type =3D=3D MMU_DATA_STORE) { - env->spr[SPR_40x_ESR] =3D 0x00800000; - } else { - env->spr[SPR_40x_ESR] =3D 0x00000000; - } - break; - case POWERPC_MMU_BOOKE206: - booke206_update_mas_tlb_miss(env, eaddr, access_type, = mmu_idx); - /* fall through */ - case POWERPC_MMU_BOOKE: - cs->exception_index =3D POWERPC_EXCP_DTLB; - env->error_code =3D 0; - env->spr[SPR_BOOKE_DEAR] =3D eaddr; - env->spr[SPR_BOOKE_ESR] =3D mmubooke206_esr(mmu_idx, a= ccess_type); - break; - case POWERPC_MMU_REAL: - cpu_abort(cs, "PowerPC in real mode should never raise= " + case POWERPC_MMU_BOOKE206: + booke206_update_mas_tlb_miss(env, eaddr, access_type, mmu_= idx); + /* fall through */ + case POWERPC_MMU_BOOKE: + cs->exception_index =3D POWERPC_EXCP_DTLB; + env->error_code =3D 0; + env->spr[SPR_BOOKE_DEAR] =3D eaddr; + env->spr[SPR_BOOKE_ESR] =3D mmubooke206_esr(mmu_idx, acces= s_type); + break; + case POWERPC_MMU_REAL: + cpu_abort(cs, "PowerPC in real mode should never raise " "any MMU exceptions\n"); - default: - cpu_abort(cs, "Unknown or invalid MMU model\n"); + default: + cpu_abort(cs, "Unknown or invalid MMU model\n"); + } + break; + case -2: + /* Access rights violation */ + cs->exception_index =3D POWERPC_EXCP_DSI; + env->error_code =3D 0; + if (env->mmu_model =3D=3D POWERPC_MMU_SOFT_4xx) { + env->spr[SPR_40x_DEAR] =3D eaddr; + if (access_type =3D=3D MMU_DATA_STORE) { + env->spr[SPR_40x_ESR] |=3D 0x00800000; } + } else if ((env->mmu_model =3D=3D POWERPC_MMU_BOOKE) || + (env->mmu_model =3D=3D POWERPC_MMU_BOOKE206)) { + env->spr[SPR_BOOKE_DEAR] =3D eaddr; + env->spr[SPR_BOOKE_ESR] =3D mmubooke206_esr(mmu_idx, acces= s_type); + } else { + env->spr[SPR_DAR] =3D eaddr; + if (access_type =3D=3D MMU_DATA_STORE) { + env->spr[SPR_DSISR] =3D 0x0A000000; + } else { + env->spr[SPR_DSISR] =3D 0x08000000; + } + } + break; + case -4: + /* Direct store exception */ + switch (type) { + case ACCESS_FLOAT: + /* Floating point load/store */ + cs->exception_index =3D POWERPC_EXCP_ALIGN; + env->error_code =3D POWERPC_EXCP_ALIGN_FP; + env->spr[SPR_DAR] =3D eaddr; break; - case -2: - /* Access rights violation */ + case ACCESS_RES: + /* lwarx, ldarx or stwcx. */ cs->exception_index =3D POWERPC_EXCP_DSI; env->error_code =3D 0; - if (env->mmu_model =3D=3D POWERPC_MMU_SOFT_4xx) { - env->spr[SPR_40x_DEAR] =3D eaddr; - if (access_type =3D=3D MMU_DATA_STORE) { - env->spr[SPR_40x_ESR] |=3D 0x00800000; - } - } else if ((env->mmu_model =3D=3D POWERPC_MMU_BOOKE) || - (env->mmu_model =3D=3D POWERPC_MMU_BOOKE206)) { - env->spr[SPR_BOOKE_DEAR] =3D eaddr; - env->spr[SPR_BOOKE_ESR] =3D mmubooke206_esr(mmu_idx, a= ccess_type); + env->spr[SPR_DAR] =3D eaddr; + if (access_type =3D=3D MMU_DATA_STORE) { + env->spr[SPR_DSISR] =3D 0x06000000; } else { - env->spr[SPR_DAR] =3D eaddr; - if (access_type =3D=3D MMU_DATA_STORE) { - env->spr[SPR_DSISR] =3D 0x0A000000; - } else { - env->spr[SPR_DSISR] =3D 0x08000000; - } + env->spr[SPR_DSISR] =3D 0x04000000; } break; - case -4: - /* Direct store exception */ - switch (type) { - case ACCESS_FLOAT: - /* Floating point load/store */ - cs->exception_index =3D POWERPC_EXCP_ALIGN; - env->error_code =3D POWERPC_EXCP_ALIGN_FP; - env->spr[SPR_DAR] =3D eaddr; - break; - case ACCESS_RES: - /* lwarx, ldarx or stwcx. */ - cs->exception_index =3D POWERPC_EXCP_DSI; - env->error_code =3D 0; - env->spr[SPR_DAR] =3D eaddr; - if (access_type =3D=3D MMU_DATA_STORE) { - env->spr[SPR_DSISR] =3D 0x06000000; - } else { - env->spr[SPR_DSISR] =3D 0x04000000; - } - break; - case ACCESS_EXT: - /* eciwx or ecowx */ - cs->exception_index =3D POWERPC_EXCP_DSI; - env->error_code =3D 0; - env->spr[SPR_DAR] =3D eaddr; - if (access_type =3D=3D MMU_DATA_STORE) { - env->spr[SPR_DSISR] =3D 0x06100000; - } else { - env->spr[SPR_DSISR] =3D 0x04100000; - } - break; - default: - printf("DSI: invalid exception (%d)\n", ret); - cs->exception_index =3D POWERPC_EXCP_PROGRAM; - env->error_code =3D - POWERPC_EXCP_INVAL | POWERPC_EXCP_INVAL_INVAL; - env->spr[SPR_DAR] =3D eaddr; - break; + case ACCESS_EXT: + /* eciwx or ecowx */ + cs->exception_index =3D POWERPC_EXCP_DSI; + env->error_code =3D 0; + env->spr[SPR_DAR] =3D eaddr; + if (access_type =3D=3D MMU_DATA_STORE) { + env->spr[SPR_DSISR] =3D 0x06100000; + } else { + env->spr[SPR_DSISR] =3D 0x04100000; } break; + default: + printf("DSI: invalid exception (%d)\n", ret); + cs->exception_index =3D POWERPC_EXCP_PROGRAM; + env->error_code =3D POWERPC_EXCP_INVAL | POWERPC_EXCP_INVA= L_INVAL; + env->spr[SPR_DAR] =3D eaddr; + break; } + break; } } return false; --=20 2.30.9 From nobody Sat May 18 13:55:28 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=eik.bme.hu Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1713911661100890.1956988838081; Tue, 23 Apr 2024 15:34:21 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rzOfv-0001EX-K9; Tue, 23 Apr 2024 18:31:43 -0400 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 1rzOfn-00019n-SA; Tue, 23 Apr 2024 18:31:35 -0400 Received: from zero.eik.bme.hu ([152.66.115.2]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rzOfk-0004eE-17; Tue, 23 Apr 2024 18:31:34 -0400 Received: from zero.eik.bme.hu (localhost [127.0.0.1]) by zero.eik.bme.hu (Postfix) with ESMTP id 842F74E603E; Wed, 24 Apr 2024 00:31:30 +0200 (CEST) Received: from zero.eik.bme.hu ([127.0.0.1]) by zero.eik.bme.hu (zero.eik.bme.hu [127.0.0.1]) (amavisd-new, port 10028) with ESMTP id Vh9asA8xIOua; Wed, 24 Apr 2024 00:31:28 +0200 (CEST) Received: by zero.eik.bme.hu (Postfix, from userid 432) id 96F8B4E6040; Wed, 24 Apr 2024 00:31:28 +0200 (CEST) X-Virus-Scanned: amavisd-new at eik.bme.hu Message-Id: In-Reply-To: References: From: BALATON Zoltan Subject: [PATCH 17/24] target/ppc/mmu_common.c: Replace hard coded constants in ppc_jumbo_xlate() MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable To: qemu-devel@nongnu.org, qemu-ppc@nongnu.org Cc: Nicholas Piggin , Daniel Henrique Barboza Date: Wed, 24 Apr 2024 00:31:28 +0200 (CEST) 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=152.66.115.2; envelope-from=balaton@eik.bme.hu; helo=zero.eik.bme.hu X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZM-MESSAGEID: 1713911663054100005 Content-Type: text/plain; charset="utf-8" The "2" in booke206_update_mas_tlb_miss() call corresponds to MMU_INST_FETCH which is the value of access_type in this branch; mmubooke206_esr() only checks for MMU_DATA_STORE and it's called from code access so using MMU_DATA_LOAD here seems wrong so replace it with access_type here as well that yields the same result. This also makes these calls the same as the data access branch further down. Signed-off-by: BALATON Zoltan --- target/ppc/mmu_common.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/ppc/mmu_common.c b/target/ppc/mmu_common.c index 34d8576905..b64f8f79c3 100644 --- a/target/ppc/mmu_common.c +++ b/target/ppc/mmu_common.c @@ -1293,13 +1293,13 @@ static bool ppc_jumbo_xlate(PowerPCCPU *cpu, vaddr = eaddr, env->spr[SPR_40x_ESR] =3D 0x00000000; break; case POWERPC_MMU_BOOKE206: - booke206_update_mas_tlb_miss(env, eaddr, 2, mmu_idx); + booke206_update_mas_tlb_miss(env, eaddr, access_type, mmu_= idx); /* fall through */ case POWERPC_MMU_BOOKE: cs->exception_index =3D POWERPC_EXCP_ITLB; env->error_code =3D 0; env->spr[SPR_BOOKE_DEAR] =3D eaddr; - env->spr[SPR_BOOKE_ESR] =3D mmubooke206_esr(mmu_idx, MMU_D= ATA_LOAD); + env->spr[SPR_BOOKE_ESR] =3D mmubooke206_esr(mmu_idx, acces= s_type); break; case POWERPC_MMU_REAL: cpu_abort(cs, "PowerPC in real mode should never raise " --=20 2.30.9 From nobody Sat May 18 13:55:28 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=eik.bme.hu Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1713911537376910.7265965091598; Tue, 23 Apr 2024 15:32:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rzOfu-0001E3-6X; Tue, 23 Apr 2024 18:31:42 -0400 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 1rzOfn-00019o-Sd; Tue, 23 Apr 2024 18:31:35 -0400 Received: from zero.eik.bme.hu ([152.66.115.2]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rzOfl-0004eP-Ua; Tue, 23 Apr 2024 18:31:35 -0400 Received: from zero.eik.bme.hu (localhost [127.0.0.1]) by zero.eik.bme.hu (Postfix) with ESMTP id 8F4314E6040; Wed, 24 Apr 2024 00:31:31 +0200 (CEST) Received: from zero.eik.bme.hu ([127.0.0.1]) by zero.eik.bme.hu (zero.eik.bme.hu [127.0.0.1]) (amavisd-new, port 10028) with ESMTP id eUQSvwKp8pC0; Wed, 24 Apr 2024 00:31:29 +0200 (CEST) Received: by zero.eik.bme.hu (Postfix, from userid 432) id A37534E6041; Wed, 24 Apr 2024 00:31:29 +0200 (CEST) X-Virus-Scanned: amavisd-new at eik.bme.hu Message-Id: <6c1c60af648da158a329c2f94e04af2d1bbbb960.1713907038.git.balaton@eik.bme.hu> In-Reply-To: References: From: BALATON Zoltan Subject: [PATCH 18/24] target/ppc/mmu_common.c: Make get_physical_address_wtlb() static MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable To: qemu-devel@nongnu.org, qemu-ppc@nongnu.org Cc: Nicholas Piggin , Daniel Henrique Barboza Date: Wed, 24 Apr 2024 00:31:29 +0200 (CEST) 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=152.66.115.2; envelope-from=balaton@eik.bme.hu; helo=zero.eik.bme.hu X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZM-MESSAGEID: 1713911539434100001 Content-Type: text/plain; charset="utf-8" This function is not used from any other files so make it static and fix the maybe used uninitialised warnings this has uncovered. Signed-off-by: BALATON Zoltan --- target/ppc/internal.h | 5 +---- target/ppc/mmu_common.c | 5 ++++- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/target/ppc/internal.h b/target/ppc/internal.h index 5b20ecbd33..3e4423ce0d 100644 --- a/target/ppc/internal.h +++ b/target/ppc/internal.h @@ -260,10 +260,7 @@ typedef struct mmu_ctx_t mmu_ctx_t; bool ppc_xlate(PowerPCCPU *cpu, vaddr eaddr, MMUAccessType access_type, hwaddr *raddrp, int *psizep, int *protp, int mmu_idx, bool guest_visible); -int get_physical_address_wtlb(CPUPPCState *env, mmu_ctx_t *ctx, - target_ulong eaddr, - MMUAccessType access_type, int type, - int mmu_idx); + /* Software driven TLB helpers */ int ppc6xx_tlb_getnum(CPUPPCState *env, target_ulong eaddr, int way, int is_code); diff --git a/target/ppc/mmu_common.c b/target/ppc/mmu_common.c index b64f8f79c3..5ba8d2460d 100644 --- a/target/ppc/mmu_common.c +++ b/target/ppc/mmu_common.c @@ -669,6 +669,7 @@ static int mmubooke_get_physical_address(CPUPPCState *e= nv, mmu_ctx_t *ctx, hwaddr raddr =3D (hwaddr)-1ULL; int i, ret =3D -1; =20 + ctx->prot =3D 0; for (i =3D 0; i < env->nb_tlb; i++) { tlb =3D &env->tlb.tlbe[i]; ret =3D mmubooke_check_tlb(env, tlb, &raddr, &ctx->prot, address, @@ -878,6 +879,7 @@ static int mmubooke206_get_physical_address(CPUPPCState= *env, mmu_ctx_t *ctx, hwaddr raddr =3D (hwaddr)-1ULL; int i, j, ways, ret =3D -1; =20 + ctx->prot =3D 0; for (i =3D 0; i < BOOKE206_MAX_TLBN; i++) { ways =3D booke206_tlb_ways(env, i); for (j =3D 0; j < ways; j++) { @@ -1149,7 +1151,7 @@ void dump_mmu(CPUPPCState *env) } } =20 -int get_physical_address_wtlb(CPUPPCState *env, mmu_ctx_t *ctx, +static int get_physical_address_wtlb(CPUPPCState *env, mmu_ctx_t *ctx, target_ulong eaddr, MMUAccessType access_type, int type, int mmu_idx) @@ -1168,6 +1170,7 @@ int get_physical_address_wtlb(CPUPPCState *env, mmu_c= tx_t *ctx, if (real_mode && (env->mmu_model =3D=3D POWERPC_MMU_SOFT_6xx || env->mmu_model =3D=3D POWERPC_MMU_SOFT_4xx || env->mmu_model =3D=3D POWERPC_MMU_REAL)) { + memset(ctx, 0, sizeof(*ctx)); ctx->raddr =3D eaddr; ctx->prot =3D PAGE_READ | PAGE_WRITE | PAGE_EXEC; return 0; --=20 2.30.9 From nobody Sat May 18 13:55:28 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=eik.bme.hu Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1713911586851317.5745007596297; Tue, 23 Apr 2024 15:33:06 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rzOfw-0001FV-UB; Tue, 23 Apr 2024 18:31:44 -0400 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 1rzOfp-0001BC-3s; Tue, 23 Apr 2024 18:31:37 -0400 Received: from zero.eik.bme.hu ([152.66.115.2]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rzOfm-0004eV-6M; Tue, 23 Apr 2024 18:31:36 -0400 Received: from zero.eik.bme.hu (localhost [127.0.0.1]) by zero.eik.bme.hu (Postfix) with ESMTP id 9E3934E6041; Wed, 24 Apr 2024 00:31:32 +0200 (CEST) Received: from zero.eik.bme.hu ([127.0.0.1]) by zero.eik.bme.hu (zero.eik.bme.hu [127.0.0.1]) (amavisd-new, port 10028) with ESMTP id hFCN8lY1dhdw; Wed, 24 Apr 2024 00:31:30 +0200 (CEST) Received: by zero.eik.bme.hu (Postfix, from userid 432) id AFF044E603D; Wed, 24 Apr 2024 00:31:30 +0200 (CEST) X-Virus-Scanned: amavisd-new at eik.bme.hu Message-Id: In-Reply-To: References: From: BALATON Zoltan Subject: [PATCH 19/24] target/ppc: Move mmu_ctx_t definition to mmu_common.c MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable To: qemu-devel@nongnu.org, qemu-ppc@nongnu.org Cc: Nicholas Piggin , Daniel Henrique Barboza Date: Wed, 24 Apr 2024 00:31:30 +0200 (CEST) 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=152.66.115.2; envelope-from=balaton@eik.bme.hu; helo=zero.eik.bme.hu X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZM-MESSAGEID: 1713911588755100003 Content-Type: text/plain; charset="utf-8" This type is only used within mmu_common.c. Move its definition from internal.h to there. Signed-off-by: BALATON Zoltan --- target/ppc/internal.h | 12 ------------ target/ppc/mmu_common.c | 11 +++++++++++ 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/target/ppc/internal.h b/target/ppc/internal.h index 3e4423ce0d..b835b2cba0 100644 --- a/target/ppc/internal.h +++ b/target/ppc/internal.h @@ -255,8 +255,6 @@ static inline int prot_for_access_type(MMUAccessType ac= cess_type) =20 /* PowerPC MMU emulation */ =20 -typedef struct mmu_ctx_t mmu_ctx_t; - bool ppc_xlate(PowerPCCPU *cpu, vaddr eaddr, MMUAccessType access_type, hwaddr *raddrp, int *psizep, int *protp, int mmu_idx, bool guest_visible); @@ -264,16 +262,6 @@ bool ppc_xlate(PowerPCCPU *cpu, vaddr eaddr, MMUAccess= Type access_type, /* Software driven TLB helpers */ int ppc6xx_tlb_getnum(CPUPPCState *env, target_ulong eaddr, int way, int is_code); -/* Context used internally during MMU translations */ -struct mmu_ctx_t { - hwaddr raddr; /* Real address */ - hwaddr eaddr; /* Effective address */ - int prot; /* Protection bits */ - hwaddr hash[2]; /* Pagetable hash values */ - target_ulong ptem; /* Virtual segment ID | API */ - int key; /* Access key */ - int nx; /* Non-execute area */ -}; =20 #endif /* !CONFIG_USER_ONLY */ =20 diff --git a/target/ppc/mmu_common.c b/target/ppc/mmu_common.c index 5ba8d2460d..244830c196 100644 --- a/target/ppc/mmu_common.c +++ b/target/ppc/mmu_common.c @@ -35,6 +35,17 @@ =20 /* #define DUMP_PAGE_TABLES */ =20 +/* Context used internally during MMU translations */ +typedef struct { + hwaddr raddr; /* Real address */ + hwaddr eaddr; /* Effective address */ + int prot; /* Protection bits */ + hwaddr hash[2]; /* Pagetable hash values */ + target_ulong ptem; /* Virtual segment ID | API */ + int key; /* Access key */ + int nx; /* Non-execute area */ +} mmu_ctx_t; + void ppc_store_sdr1(CPUPPCState *env, target_ulong value) { PowerPCCPU *cpu =3D env_archcpu(env); --=20 2.30.9 From nobody Sat May 18 13:55:28 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=eik.bme.hu Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1713911654267494.88465826120853; Tue, 23 Apr 2024 15:34:14 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rzOfz-0001IG-3i; Tue, 23 Apr 2024 18:31:47 -0400 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 1rzOfp-0001Bi-MS; Tue, 23 Apr 2024 18:31:38 -0400 Received: from zero.eik.bme.hu ([2001:738:2001:2001::2001]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rzOfn-0004en-Tr; Tue, 23 Apr 2024 18:31:37 -0400 Received: from zero.eik.bme.hu (localhost [127.0.0.1]) by zero.eik.bme.hu (Postfix) with ESMTP id A998B4E603D; Wed, 24 Apr 2024 00:31:33 +0200 (CEST) Received: from zero.eik.bme.hu ([127.0.0.1]) by zero.eik.bme.hu (zero.eik.bme.hu [127.0.0.1]) (amavisd-new, port 10028) with ESMTP id t9O8ENAnXjn6; Wed, 24 Apr 2024 00:31:31 +0200 (CEST) Received: by zero.eik.bme.hu (Postfix, from userid 432) id B8CFD4E6042; Wed, 24 Apr 2024 00:31:31 +0200 (CEST) X-Virus-Scanned: amavisd-new at eik.bme.hu Message-Id: In-Reply-To: References: From: BALATON Zoltan Subject: [PATCH 20/24] target/ppc: Remove ppc_hash32_pp_prot() and reuse common function MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable To: qemu-devel@nongnu.org, qemu-ppc@nongnu.org Cc: Nicholas Piggin , Daniel Henrique Barboza Date: Wed, 24 Apr 2024 00:31:31 +0200 (CEST) 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2001:738:2001:2001::2001; envelope-from=balaton@eik.bme.hu; helo=zero.eik.bme.hu X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZM-MESSAGEID: 1713911655029100001 Content-Type: text/plain; charset="utf-8" The ppc_hash32_pp_prot() function in mmu-hash32.c is the same as pp_check() in mmu_common.c. Rename the latter to ppc_pte_prot() and merge with ppc_hash32_pp_prot() to remove duplicated code. Signed-off-by: BALATON Zoltan --- target/ppc/internal.h | 2 +- target/ppc/mmu-hash32.c | 47 +---------------------------------------- target/ppc/mmu_common.c | 19 +++++++++-------- 3 files changed, 12 insertions(+), 56 deletions(-) diff --git a/target/ppc/internal.h b/target/ppc/internal.h index b835b2cba0..2d95d406f6 100644 --- a/target/ppc/internal.h +++ b/target/ppc/internal.h @@ -254,7 +254,7 @@ static inline int prot_for_access_type(MMUAccessType ac= cess_type) #ifndef CONFIG_USER_ONLY =20 /* PowerPC MMU emulation */ - +int ppc_pte_prot(int key, int pp, int nx); bool ppc_xlate(PowerPCCPU *cpu, vaddr eaddr, MMUAccessType access_type, hwaddr *raddrp, int *psizep, int *protp, int mmu_idx, bool guest_visible); diff --git a/target/ppc/mmu-hash32.c b/target/ppc/mmu-hash32.c index 3976416840..ee9df351ae 100644 --- a/target/ppc/mmu-hash32.c +++ b/target/ppc/mmu-hash32.c @@ -42,51 +42,6 @@ struct mmu_ctx_hash32 { int key; /* Access key */ }; =20 -static int ppc_hash32_pp_prot(int key, int pp, int nx) -{ - int prot; - - if (key =3D=3D 0) { - switch (pp) { - case 0x0: - case 0x1: - case 0x2: - prot =3D PAGE_READ | PAGE_WRITE; - break; - - case 0x3: - prot =3D PAGE_READ; - break; - - default: - abort(); - } - } else { - switch (pp) { - case 0x0: - prot =3D 0; - break; - - case 0x1: - case 0x3: - prot =3D PAGE_READ; - break; - - case 0x2: - prot =3D PAGE_READ | PAGE_WRITE; - break; - - default: - abort(); - } - } - if (nx =3D=3D 0) { - prot |=3D PAGE_EXEC; - } - - return prot; -} - static int ppc_hash32_pte_prot(int mmu_idx, target_ulong sr, ppc_hash_pte32_t pte) { @@ -95,7 +50,7 @@ static int ppc_hash32_pte_prot(int mmu_idx, key =3D !!(mmuidx_pr(mmu_idx) ? (sr & SR32_KP) : (sr & SR32_KS)); pp =3D pte.pte1 & HPTE32_R_PP; =20 - return ppc_hash32_pp_prot(key, pp, !!(sr & SR32_NX)); + return ppc_pte_prot(key, pp, !!(sr & SR32_NX)); } =20 static target_ulong hash32_bat_size(int mmu_idx, diff --git a/target/ppc/mmu_common.c b/target/ppc/mmu_common.c index 244830c196..ca1cbba0f0 100644 --- a/target/ppc/mmu_common.c +++ b/target/ppc/mmu_common.c @@ -75,22 +75,23 @@ void ppc_store_sdr1(CPUPPCState *env, target_ulong valu= e) /*************************************************************************= ****/ /* PowerPC MMU emulation */ =20 -static int pp_check(int key, int pp, int nx) +int ppc_pte_prot(int key, int pp, int nx) { int access; =20 /* Compute access rights */ - access =3D 0; if (key =3D=3D 0) { switch (pp) { case 0x0: case 0x1: case 0x2: - access |=3D PAGE_WRITE; - /* fall through */ + access =3D PAGE_READ | PAGE_WRITE; + break; case 0x3: - access |=3D PAGE_READ; + access =3D PAGE_READ; break; + default: + g_assert_not_reached(); } } else { switch (pp) { @@ -104,6 +105,8 @@ static int pp_check(int key, int pp, int nx) case 0x2: access =3D PAGE_READ | PAGE_WRITE; break; + default: + g_assert_not_reached(); } } if (nx =3D=3D 0) { @@ -140,7 +143,7 @@ static int ppc6xx_tlb_pte_check(mmu_ctx_t *ctx, target_= ulong pte0, MMUAccessType access_type) { target_ulong ptem, mmask; - int access, ret, pteh, ptev, pp; + int ret, pteh, ptev, pp; =20 ret =3D -1; /* Check validity and table match */ @@ -159,11 +162,9 @@ static int ppc6xx_tlb_pte_check(mmu_ctx_t *ctx, target= _ulong pte0, return -3; } } - /* Compute access rights */ - access =3D pp_check(ctx->key, pp, ctx->nx); /* Keep the matching PTE information */ ctx->raddr =3D pte1; - ctx->prot =3D access; + ctx->prot =3D ppc_pte_prot(ctx->key, pp, ctx->nx); ret =3D check_prot(ctx->prot, access_type); if (ret =3D=3D 0) { /* Access granted */ --=20 2.30.9 From nobody Sat May 18 13:55:28 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=eik.bme.hu Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1713911653622783.0681872320074; Tue, 23 Apr 2024 15:34:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rzOfz-0001IP-67; Tue, 23 Apr 2024 18:31:47 -0400 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 1rzOfq-0001CW-Mg; Tue, 23 Apr 2024 18:31:38 -0400 Received: from zero.eik.bme.hu ([2001:738:2001:2001::2001]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rzOfo-0004ex-7q; Tue, 23 Apr 2024 18:31:38 -0400 Received: from zero.eik.bme.hu (localhost [127.0.0.1]) by zero.eik.bme.hu (Postfix) with ESMTP id B681B4E6042; Wed, 24 Apr 2024 00:31:34 +0200 (CEST) Received: from zero.eik.bme.hu ([127.0.0.1]) by zero.eik.bme.hu (zero.eik.bme.hu [127.0.0.1]) (amavisd-new, port 10028) with ESMTP id yewWdoztPhYZ; Wed, 24 Apr 2024 00:31:32 +0200 (CEST) Received: by zero.eik.bme.hu (Postfix, from userid 432) id C26994E6054; Wed, 24 Apr 2024 00:31:32 +0200 (CEST) X-Virus-Scanned: amavisd-new at eik.bme.hu Message-Id: <0e7de4e5d2b1c159ebb99b9d8e196e1ae15de087.1713907038.git.balaton@eik.bme.hu> In-Reply-To: References: From: BALATON Zoltan Subject: [PATCH 21/24] target/ppc/mmu_common.c: Split off BookE handling from ppc_jumbo_xlate() MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable To: qemu-devel@nongnu.org, qemu-ppc@nongnu.org Cc: Nicholas Piggin , Daniel Henrique Barboza Date: Wed, 24 Apr 2024 00:31:32 +0200 (CEST) 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2001:738:2001:2001::2001; envelope-from=balaton@eik.bme.hu; helo=zero.eik.bme.hu X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZM-MESSAGEID: 1713911655059100002 Content-Type: text/plain; charset="utf-8" Introduce ppc_booke_xlate() to handle BookE and BookE 2.06 cases to reduce ppc_jumbo_xlate() further. Signed-off-by: BALATON Zoltan --- target/ppc/mmu_common.c | 180 ++++++++++++++++++++++++++++++---------- 1 file changed, 138 insertions(+), 42 deletions(-) diff --git a/target/ppc/mmu_common.c b/target/ppc/mmu_common.c index ca1cbba0f0..b7803c1c26 100644 --- a/target/ppc/mmu_common.c +++ b/target/ppc/mmu_common.c @@ -1255,6 +1255,137 @@ static void booke206_update_mas_tlb_miss(CPUPPCStat= e *env, target_ulong address, env->spr[SPR_BOOKE_MAS0] |=3D env->last_way << MAS0_NV_SHIFT; } =20 +static bool ppc_booke_xlate(PowerPCCPU *cpu, vaddr eaddr, + MMUAccessType access_type, + hwaddr *raddrp, int *psizep, int *protp, + int mmu_idx, bool guest_visible) +{ + CPUState *cs =3D CPU(cpu); + CPUPPCState *env =3D &cpu->env; + mmu_ctx_t ctx; + int ret; + + if (env->mmu_model =3D=3D POWERPC_MMU_BOOKE206) { + ret =3D mmubooke206_get_physical_address(env, &ctx, eaddr, access_= type, + mmu_idx); + } else { + ret =3D mmubooke_get_physical_address(env, &ctx, eaddr, access_typ= e); + } + if (ret =3D=3D 0) { + *raddrp =3D ctx.raddr; + *protp =3D ctx.prot; + *psizep =3D TARGET_PAGE_BITS; + return true; + } else if (!guest_visible) { + return false; + } + + log_cpu_state_mask(CPU_LOG_MMU, cs, 0); + if (access_type =3D=3D MMU_INST_FETCH) { + switch (ret) { + case -1: + /* No matches in page tables or TLB */ + switch (env->mmu_model) { + case POWERPC_MMU_BOOKE206: + booke206_update_mas_tlb_miss(env, eaddr, access_type, mmu_= idx); + /* fall through */ + case POWERPC_MMU_BOOKE: + cs->exception_index =3D POWERPC_EXCP_ITLB; + env->error_code =3D 0; + env->spr[SPR_BOOKE_DEAR] =3D eaddr; + env->spr[SPR_BOOKE_ESR] =3D mmubooke206_esr(mmu_idx, acces= s_type); + break; + default: + g_assert_not_reached(); + } + break; + case -2: + /* Access rights violation */ + cs->exception_index =3D POWERPC_EXCP_ISI; + env->error_code =3D 0; + break; + case -3: + /* No execute protection violation */ + cs->exception_index =3D POWERPC_EXCP_ISI; + env->spr[SPR_BOOKE_ESR] =3D 0; + env->error_code =3D 0; + break; + case -4: + /* Direct store exception */ + /* No code fetch is allowed in direct-store areas */ + cs->exception_index =3D POWERPC_EXCP_ISI; + env->error_code =3D 0; + break; + } + } else { + switch (ret) { + case -1: + /* No matches in page tables or TLB */ + switch (env->mmu_model) { + case POWERPC_MMU_BOOKE206: + booke206_update_mas_tlb_miss(env, eaddr, access_type, mmu_= idx); + /* fall through */ + case POWERPC_MMU_BOOKE: + cs->exception_index =3D POWERPC_EXCP_DTLB; + env->error_code =3D 0; + env->spr[SPR_BOOKE_DEAR] =3D eaddr; + env->spr[SPR_BOOKE_ESR] =3D mmubooke206_esr(mmu_idx, acces= s_type); + break; + default: + g_assert_not_reached(); + } + break; + case -2: + /* Access rights violation */ + cs->exception_index =3D POWERPC_EXCP_DSI; + env->error_code =3D 0; + env->spr[SPR_BOOKE_DEAR] =3D eaddr; + env->spr[SPR_BOOKE_ESR] =3D mmubooke206_esr(mmu_idx, access_ty= pe); + break; + case -4: + /* Direct store exception */ + switch (env->access_type) { + case ACCESS_FLOAT: + /* Floating point load/store */ + cs->exception_index =3D POWERPC_EXCP_ALIGN; + env->error_code =3D POWERPC_EXCP_ALIGN_FP; + env->spr[SPR_DAR] =3D eaddr; + break; + case ACCESS_RES: + /* lwarx, ldarx or stwcx. */ + cs->exception_index =3D POWERPC_EXCP_DSI; + env->error_code =3D 0; + env->spr[SPR_DAR] =3D eaddr; + if (access_type =3D=3D MMU_DATA_STORE) { + env->spr[SPR_DSISR] =3D 0x06000000; + } else { + env->spr[SPR_DSISR] =3D 0x04000000; + } + break; + case ACCESS_EXT: + /* eciwx or ecowx */ + cs->exception_index =3D POWERPC_EXCP_DSI; + env->error_code =3D 0; + env->spr[SPR_DAR] =3D eaddr; + if (access_type =3D=3D MMU_DATA_STORE) { + env->spr[SPR_DSISR] =3D 0x06100000; + } else { + env->spr[SPR_DSISR] =3D 0x04100000; + } + break; + default: + printf("DSI: invalid exception (%d)\n", ret); + cs->exception_index =3D POWERPC_EXCP_PROGRAM; + env->error_code =3D POWERPC_EXCP_INVAL | POWERPC_EXCP_INVA= L_INVAL; + env->spr[SPR_DAR] =3D eaddr; + break; + } + break; + } + } + return false; +} + /* Perform address translation */ /* TODO: Split this by mmu_model. */ static bool ppc_jumbo_xlate(PowerPCCPU *cpu, vaddr eaddr, @@ -1307,15 +1438,6 @@ static bool ppc_jumbo_xlate(PowerPCCPU *cpu, vaddr e= addr, env->spr[SPR_40x_DEAR] =3D eaddr; env->spr[SPR_40x_ESR] =3D 0x00000000; break; - case POWERPC_MMU_BOOKE206: - booke206_update_mas_tlb_miss(env, eaddr, access_type, mmu_= idx); - /* fall through */ - case POWERPC_MMU_BOOKE: - cs->exception_index =3D POWERPC_EXCP_ITLB; - env->error_code =3D 0; - env->spr[SPR_BOOKE_DEAR] =3D eaddr; - env->spr[SPR_BOOKE_ESR] =3D mmubooke206_esr(mmu_idx, acces= s_type); - break; case POWERPC_MMU_REAL: cpu_abort(cs, "PowerPC in real mode should never raise " "any MMU exceptions\n"); @@ -1326,34 +1448,18 @@ static bool ppc_jumbo_xlate(PowerPCCPU *cpu, vaddr = eaddr, case -2: /* Access rights violation */ cs->exception_index =3D POWERPC_EXCP_ISI; - if ((env->mmu_model =3D=3D POWERPC_MMU_BOOKE) || - (env->mmu_model =3D=3D POWERPC_MMU_BOOKE206)) { - env->error_code =3D 0; - } else { - env->error_code =3D 0x08000000; - } + env->error_code =3D 0x08000000; break; case -3: /* No execute protection violation */ - if ((env->mmu_model =3D=3D POWERPC_MMU_BOOKE) || - (env->mmu_model =3D=3D POWERPC_MMU_BOOKE206)) { - env->spr[SPR_BOOKE_ESR] =3D 0x00000000; - env->error_code =3D 0; - } else { - env->error_code =3D 0x10000000; - } cs->exception_index =3D POWERPC_EXCP_ISI; + env->error_code =3D 0x10000000; break; case -4: /* Direct store exception */ /* No code fetch is allowed in direct-store areas */ cs->exception_index =3D POWERPC_EXCP_ISI; - if ((env->mmu_model =3D=3D POWERPC_MMU_BOOKE) || - (env->mmu_model =3D=3D POWERPC_MMU_BOOKE206)) { - env->error_code =3D 0; - } else { - env->error_code =3D 0x10000000; - } + env->error_code =3D 0x10000000; break; } } else { @@ -1388,15 +1494,6 @@ static bool ppc_jumbo_xlate(PowerPCCPU *cpu, vaddr e= addr, env->spr[SPR_40x_ESR] =3D 0x00000000; } break; - case POWERPC_MMU_BOOKE206: - booke206_update_mas_tlb_miss(env, eaddr, access_type, mmu_= idx); - /* fall through */ - case POWERPC_MMU_BOOKE: - cs->exception_index =3D POWERPC_EXCP_DTLB; - env->error_code =3D 0; - env->spr[SPR_BOOKE_DEAR] =3D eaddr; - env->spr[SPR_BOOKE_ESR] =3D mmubooke206_esr(mmu_idx, acces= s_type); - break; case POWERPC_MMU_REAL: cpu_abort(cs, "PowerPC in real mode should never raise " "any MMU exceptions\n"); @@ -1413,10 +1510,6 @@ static bool ppc_jumbo_xlate(PowerPCCPU *cpu, vaddr e= addr, if (access_type =3D=3D MMU_DATA_STORE) { env->spr[SPR_40x_ESR] |=3D 0x00800000; } - } else if ((env->mmu_model =3D=3D POWERPC_MMU_BOOKE) || - (env->mmu_model =3D=3D POWERPC_MMU_BOOKE206)) { - env->spr[SPR_BOOKE_DEAR] =3D eaddr; - env->spr[SPR_BOOKE_ESR] =3D mmubooke206_esr(mmu_idx, acces= s_type); } else { env->spr[SPR_DAR] =3D eaddr; if (access_type =3D=3D MMU_DATA_STORE) { @@ -1495,7 +1588,10 @@ bool ppc_xlate(PowerPCCPU *cpu, vaddr eaddr, MMUAcce= ssType access_type, case POWERPC_MMU_32B: return ppc_hash32_xlate(cpu, eaddr, access_type, raddrp, psizep, protp, mmu_idx, guest_visible); - + case POWERPC_MMU_BOOKE: + case POWERPC_MMU_BOOKE206: + return ppc_booke_xlate(cpu, eaddr, access_type, raddrp, + psizep, protp, mmu_idx, guest_visible); default: return ppc_jumbo_xlate(cpu, eaddr, access_type, raddrp, psizep, protp, mmu_idx, guest_visible); --=20 2.30.9 From nobody Sat May 18 13:55:28 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=eik.bme.hu Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1713911579099191.49805818380867; Tue, 23 Apr 2024 15:32:59 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rzOgD-0001T9-2E; Tue, 23 Apr 2024 18:32:01 -0400 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 1rzOgA-0001SC-QM; Tue, 23 Apr 2024 18:31:58 -0400 Received: from zero.eik.bme.hu ([2001:738:2001:2001::2001]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rzOg9-0004fD-5e; Tue, 23 Apr 2024 18:31:58 -0400 Received: from zero.eik.bme.hu (localhost [127.0.0.1]) by zero.eik.bme.hu (Postfix) with ESMTP id B2DC24E6054; Wed, 24 Apr 2024 00:31:35 +0200 (CEST) Received: from zero.eik.bme.hu ([127.0.0.1]) by zero.eik.bme.hu (zero.eik.bme.hu [127.0.0.1]) (amavisd-new, port 10028) with ESMTP id yEdFVZzD8MNB; Wed, 24 Apr 2024 00:31:33 +0200 (CEST) Received: by zero.eik.bme.hu (Postfix, from userid 432) id CB7C14E6031; Wed, 24 Apr 2024 00:31:33 +0200 (CEST) X-Virus-Scanned: amavisd-new at eik.bme.hu Message-Id: <517eaa380f883622276f34af2db9485bb00003a5.1713907038.git.balaton@eik.bme.hu> In-Reply-To: References: From: BALATON Zoltan Subject: [PATCH 22/24] target/ppc/mmu_common.c: Remove BookE handling from get_physical_address_wtlb() MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable To: qemu-devel@nongnu.org, qemu-ppc@nongnu.org Cc: Nicholas Piggin , Daniel Henrique Barboza Date: Wed, 24 Apr 2024 00:31:33 +0200 (CEST) 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2001:738:2001:2001::2001; envelope-from=balaton@eik.bme.hu; helo=zero.eik.bme.hu X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZM-MESSAGEID: 1713911581274100005 Content-Type: text/plain; charset="utf-8" This function is no longer called for BookE MMU model so remove parts related to it. This has uncovered a few may be used uninitialised warnings that are also fixed. Signed-off-by: BALATON Zoltan --- target/ppc/mmu_common.c | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/target/ppc/mmu_common.c b/target/ppc/mmu_common.c index b7803c1c26..ce1cf5cb77 100644 --- a/target/ppc/mmu_common.c +++ b/target/ppc/mmu_common.c @@ -687,12 +687,10 @@ static int mmubooke_get_physical_address(CPUPPCState = *env, mmu_ctx_t *ctx, ret =3D mmubooke_check_tlb(env, tlb, &raddr, &ctx->prot, address, access_type, i); if (ret !=3D -1) { - if (ret >=3D 0) { - ctx->raddr =3D raddr; - } break; } } + ctx->raddr =3D raddr; qemu_log_mask(CPU_LOG_MMU, "%s: access %s " TARGET_FMT_lx " =3D> " HWADDR_FMT_plx " %d %d\n", __func__, ret < 0 ? "refused" : "granted", @@ -902,9 +900,6 @@ static int mmubooke206_get_physical_address(CPUPPCState= *env, mmu_ctx_t *ctx, ret =3D mmubooke206_check_tlb(env, tlb, &raddr, &ctx->prot, ad= dress, access_type, mmu_idx); if (ret !=3D -1) { - if (ret >=3D 0) { - ctx->raddr =3D raddr; - } goto found_tlb; } } @@ -912,6 +907,7 @@ static int mmubooke206_get_physical_address(CPUPPCState= *env, mmu_ctx_t *ctx, =20 found_tlb: =20 + ctx->raddr =3D raddr; qemu_log_mask(CPU_LOG_MMU, "%s: access %s " TARGET_FMT_lx " =3D> " HWADDR_FMT_plx " %d %d\n", __func__, ret < 0 ? "refused" : "granted", address, raddr, @@ -1168,20 +1164,9 @@ static int get_physical_address_wtlb(CPUPPCState *en= v, mmu_ctx_t *ctx, MMUAccessType access_type, int type, int mmu_idx) { - bool real_mode; - - if (env->mmu_model =3D=3D POWERPC_MMU_BOOKE) { - return mmubooke_get_physical_address(env, ctx, eaddr, access_type); - } else if (env->mmu_model =3D=3D POWERPC_MMU_BOOKE206) { - return mmubooke206_get_physical_address(env, ctx, eaddr, access_ty= pe, - mmu_idx); - } - - real_mode =3D (type =3D=3D ACCESS_CODE) ? !FIELD_EX64(env->msr, MSR, I= R) - : !FIELD_EX64(env->msr, MSR, DR); - if (real_mode && (env->mmu_model =3D=3D POWERPC_MMU_SOFT_6xx || - env->mmu_model =3D=3D POWERPC_MMU_SOFT_4xx || - env->mmu_model =3D=3D POWERPC_MMU_REAL)) { + bool real_mode =3D (type =3D=3D ACCESS_CODE) ? !FIELD_EX64(env->msr, M= SR, IR) + : !FIELD_EX64(env->msr, MSR, DR= ); + if (real_mode) { memset(ctx, 0, sizeof(*ctx)); ctx->raddr =3D eaddr; ctx->prot =3D PAGE_READ | PAGE_WRITE | PAGE_EXEC; --=20 2.30.9 From nobody Sat May 18 13:55:28 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=eik.bme.hu Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1713911623869652.5187482876153; Tue, 23 Apr 2024 15:33:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rzOfy-0001Gt-4W; Tue, 23 Apr 2024 18:31:46 -0400 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 1rzOfs-0001D2-74; Tue, 23 Apr 2024 18:31:40 -0400 Received: from zero.eik.bme.hu ([152.66.115.2]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rzOfq-0004fS-9d; Tue, 23 Apr 2024 18:31:39 -0400 Received: from zero.eik.bme.hu (localhost [127.0.0.1]) by zero.eik.bme.hu (Postfix) with ESMTP id C03FB4E6031; Wed, 24 Apr 2024 00:31:36 +0200 (CEST) Received: from zero.eik.bme.hu ([127.0.0.1]) by zero.eik.bme.hu (zero.eik.bme.hu [127.0.0.1]) (amavisd-new, port 10028) with ESMTP id nlRCvHAgAnNf; Wed, 24 Apr 2024 00:31:34 +0200 (CEST) Received: by zero.eik.bme.hu (Postfix, from userid 432) id D60C64E6055; Wed, 24 Apr 2024 00:31:34 +0200 (CEST) X-Virus-Scanned: amavisd-new at eik.bme.hu Message-Id: <28edfcfcbad19d9b4d511126e37e1f9061b978b0.1713907038.git.balaton@eik.bme.hu> In-Reply-To: References: From: BALATON Zoltan Subject: [PATCH 23/24] target/ppc/mmu_common.c: Simplify ppc_booke_xlate() MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable To: qemu-devel@nongnu.org, qemu-ppc@nongnu.org Cc: Nicholas Piggin , Daniel Henrique Barboza Date: Wed, 24 Apr 2024 00:31:34 +0200 (CEST) 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=152.66.115.2; envelope-from=balaton@eik.bme.hu; helo=zero.eik.bme.hu X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZM-MESSAGEID: 1713911624936100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: BALATON Zoltan --- target/ppc/mmu_common.c | 147 +++++++++++++++------------------------- 1 file changed, 56 insertions(+), 91 deletions(-) diff --git a/target/ppc/mmu_common.c b/target/ppc/mmu_common.c index ce1cf5cb77..ad64ec1647 100644 --- a/target/ppc/mmu_common.c +++ b/target/ppc/mmu_common.c @@ -1266,106 +1266,71 @@ static bool ppc_booke_xlate(PowerPCCPU *cpu, vaddr= eaddr, } =20 log_cpu_state_mask(CPU_LOG_MMU, cs, 0); + env->error_code =3D 0; + if (env->mmu_model =3D=3D POWERPC_MMU_BOOKE206 && ret =3D=3D -1) { + booke206_update_mas_tlb_miss(env, eaddr, access_type, mmu_idx); + } if (access_type =3D=3D MMU_INST_FETCH) { - switch (ret) { - case -1: + if (ret =3D=3D -1) { /* No matches in page tables or TLB */ - switch (env->mmu_model) { - case POWERPC_MMU_BOOKE206: - booke206_update_mas_tlb_miss(env, eaddr, access_type, mmu_= idx); - /* fall through */ - case POWERPC_MMU_BOOKE: - cs->exception_index =3D POWERPC_EXCP_ITLB; - env->error_code =3D 0; - env->spr[SPR_BOOKE_DEAR] =3D eaddr; - env->spr[SPR_BOOKE_ESR] =3D mmubooke206_esr(mmu_idx, acces= s_type); - break; - default: - g_assert_not_reached(); - } - break; - case -2: - /* Access rights violation */ - cs->exception_index =3D POWERPC_EXCP_ISI; - env->error_code =3D 0; - break; - case -3: - /* No execute protection violation */ - cs->exception_index =3D POWERPC_EXCP_ISI; - env->spr[SPR_BOOKE_ESR] =3D 0; - env->error_code =3D 0; - break; - case -4: - /* Direct store exception */ - /* No code fetch is allowed in direct-store areas */ + cs->exception_index =3D POWERPC_EXCP_ITLB; + env->spr[SPR_BOOKE_DEAR] =3D eaddr; + env->spr[SPR_BOOKE_ESR] =3D mmubooke206_esr(mmu_idx, access_ty= pe); + } else { cs->exception_index =3D POWERPC_EXCP_ISI; - env->error_code =3D 0; - break; - } - } else { - switch (ret) { - case -1: - /* No matches in page tables or TLB */ - switch (env->mmu_model) { - case POWERPC_MMU_BOOKE206: - booke206_update_mas_tlb_miss(env, eaddr, access_type, mmu_= idx); - /* fall through */ - case POWERPC_MMU_BOOKE: - cs->exception_index =3D POWERPC_EXCP_DTLB; - env->error_code =3D 0; - env->spr[SPR_BOOKE_DEAR] =3D eaddr; - env->spr[SPR_BOOKE_ESR] =3D mmubooke206_esr(mmu_idx, acces= s_type); - break; - default: - g_assert_not_reached(); + if (ret =3D=3D -3) { + /* No execute protection violation */ + env->spr[SPR_BOOKE_ESR] =3D 0; } + } + return false; + } + + switch (ret) { + case -1: + /* No matches in page tables or TLB */ + cs->exception_index =3D POWERPC_EXCP_DTLB; + env->spr[SPR_BOOKE_DEAR] =3D eaddr; + env->spr[SPR_BOOKE_ESR] =3D mmubooke206_esr(mmu_idx, access_type); + break; + case -2: + /* Access rights violation */ + cs->exception_index =3D POWERPC_EXCP_DSI; + env->spr[SPR_BOOKE_DEAR] =3D eaddr; + env->spr[SPR_BOOKE_ESR] =3D mmubooke206_esr(mmu_idx, access_type); + break; + case -4: + /* Direct store exception */ + env->spr[SPR_DAR] =3D eaddr; + switch (env->access_type) { + case ACCESS_FLOAT: + /* Floating point load/store */ + cs->exception_index =3D POWERPC_EXCP_ALIGN; + env->error_code =3D POWERPC_EXCP_ALIGN_FP; break; - case -2: - /* Access rights violation */ + case ACCESS_RES: + /* lwarx, ldarx or stwcx. */ cs->exception_index =3D POWERPC_EXCP_DSI; - env->error_code =3D 0; - env->spr[SPR_BOOKE_DEAR] =3D eaddr; - env->spr[SPR_BOOKE_ESR] =3D mmubooke206_esr(mmu_idx, access_ty= pe); + if (access_type =3D=3D MMU_DATA_STORE) { + env->spr[SPR_DSISR] =3D 0x06000000; + } else { + env->spr[SPR_DSISR] =3D 0x04000000; + } break; - case -4: - /* Direct store exception */ - switch (env->access_type) { - case ACCESS_FLOAT: - /* Floating point load/store */ - cs->exception_index =3D POWERPC_EXCP_ALIGN; - env->error_code =3D POWERPC_EXCP_ALIGN_FP; - env->spr[SPR_DAR] =3D eaddr; - break; - case ACCESS_RES: - /* lwarx, ldarx or stwcx. */ - cs->exception_index =3D POWERPC_EXCP_DSI; - env->error_code =3D 0; - env->spr[SPR_DAR] =3D eaddr; - if (access_type =3D=3D MMU_DATA_STORE) { - env->spr[SPR_DSISR] =3D 0x06000000; - } else { - env->spr[SPR_DSISR] =3D 0x04000000; - } - break; - case ACCESS_EXT: - /* eciwx or ecowx */ - cs->exception_index =3D POWERPC_EXCP_DSI; - env->error_code =3D 0; - env->spr[SPR_DAR] =3D eaddr; - if (access_type =3D=3D MMU_DATA_STORE) { - env->spr[SPR_DSISR] =3D 0x06100000; - } else { - env->spr[SPR_DSISR] =3D 0x04100000; - } - break; - default: - printf("DSI: invalid exception (%d)\n", ret); - cs->exception_index =3D POWERPC_EXCP_PROGRAM; - env->error_code =3D POWERPC_EXCP_INVAL | POWERPC_EXCP_INVA= L_INVAL; - env->spr[SPR_DAR] =3D eaddr; - break; + case ACCESS_EXT: + /* eciwx or ecowx */ + cs->exception_index =3D POWERPC_EXCP_DSI; + if (access_type =3D=3D MMU_DATA_STORE) { + env->spr[SPR_DSISR] =3D 0x06100000; + } else { + env->spr[SPR_DSISR] =3D 0x04100000; } break; + default: + printf("DSI: invalid exception (%d)\n", ret); + cs->exception_index =3D POWERPC_EXCP_PROGRAM; + env->error_code =3D POWERPC_EXCP_INVAL | POWERPC_EXCP_INVAL_IN= VAL; + break; } } return false; --=20 2.30.9 From nobody Sat May 18 13:55:28 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=eik.bme.hu Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 171391157909427.86575594304213; Tue, 23 Apr 2024 15:32:59 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rzOg0-0001KV-JC; Tue, 23 Apr 2024 18:31:48 -0400 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 1rzOft-0001Dv-Jw; Tue, 23 Apr 2024 18:31:41 -0400 Received: from zero.eik.bme.hu ([152.66.115.2]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rzOfr-0004ff-B6; Tue, 23 Apr 2024 18:31:41 -0400 Received: from zero.eik.bme.hu (localhost [127.0.0.1]) by zero.eik.bme.hu (Postfix) with ESMTP id D0F6B4E6040; Wed, 24 Apr 2024 00:31:37 +0200 (CEST) Received: from zero.eik.bme.hu ([127.0.0.1]) by zero.eik.bme.hu (zero.eik.bme.hu [127.0.0.1]) (amavisd-new, port 10028) with ESMTP id mRNQp7u80-u7; Wed, 24 Apr 2024 00:31:35 +0200 (CEST) Received: by zero.eik.bme.hu (Postfix, from userid 432) id DFE404E603E; Wed, 24 Apr 2024 00:31:35 +0200 (CEST) X-Virus-Scanned: amavisd-new at eik.bme.hu Message-Id: In-Reply-To: References: From: BALATON Zoltan Subject: [PATCH 24/24] target/ppc/mmu_common.c: Move BookE MMU functions together MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable To: qemu-devel@nongnu.org, qemu-ppc@nongnu.org Cc: Nicholas Piggin , Daniel Henrique Barboza Date: Wed, 24 Apr 2024 00:31:35 +0200 (CEST) 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=152.66.115.2; envelope-from=balaton@eik.bme.hu; helo=zero.eik.bme.hu X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZM-MESSAGEID: 1713911580921100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: BALATON Zoltan --- target/ppc/mmu_common.c | 300 ++++++++++++++++++++-------------------- 1 file changed, 150 insertions(+), 150 deletions(-) diff --git a/target/ppc/mmu_common.c b/target/ppc/mmu_common.c index ad64ec1647..18e49aa2f1 100644 --- a/target/ppc/mmu_common.c +++ b/target/ppc/mmu_common.c @@ -915,6 +915,156 @@ found_tlb: return ret; } =20 +static void booke206_update_mas_tlb_miss(CPUPPCState *env, target_ulong ad= dress, + MMUAccessType access_type, int mm= u_idx) +{ + uint32_t epid; + bool as, pr; + uint32_t missed_tid =3D 0; + bool use_epid =3D mmubooke206_get_as(env, mmu_idx, &epid, &as, &pr); + + if (access_type =3D=3D MMU_INST_FETCH) { + as =3D FIELD_EX64(env->msr, MSR, IR); + } + env->spr[SPR_BOOKE_MAS0] =3D env->spr[SPR_BOOKE_MAS4] & MAS4_TLBSELD_M= ASK; + env->spr[SPR_BOOKE_MAS1] =3D env->spr[SPR_BOOKE_MAS4] & MAS4_TSIZED_MA= SK; + env->spr[SPR_BOOKE_MAS2] =3D env->spr[SPR_BOOKE_MAS4] & MAS4_WIMGED_MA= SK; + env->spr[SPR_BOOKE_MAS3] =3D 0; + env->spr[SPR_BOOKE_MAS6] =3D 0; + env->spr[SPR_BOOKE_MAS7] =3D 0; + + /* AS */ + if (as) { + env->spr[SPR_BOOKE_MAS1] |=3D MAS1_TS; + env->spr[SPR_BOOKE_MAS6] |=3D MAS6_SAS; + } + + env->spr[SPR_BOOKE_MAS1] |=3D MAS1_VALID; + env->spr[SPR_BOOKE_MAS2] |=3D address & MAS2_EPN_MASK; + + if (!use_epid) { + switch (env->spr[SPR_BOOKE_MAS4] & MAS4_TIDSELD_PIDZ) { + case MAS4_TIDSELD_PID0: + missed_tid =3D env->spr[SPR_BOOKE_PID]; + break; + case MAS4_TIDSELD_PID1: + missed_tid =3D env->spr[SPR_BOOKE_PID1]; + break; + case MAS4_TIDSELD_PID2: + missed_tid =3D env->spr[SPR_BOOKE_PID2]; + break; + } + env->spr[SPR_BOOKE_MAS6] |=3D env->spr[SPR_BOOKE_PID] << 16; + } else { + missed_tid =3D epid; + env->spr[SPR_BOOKE_MAS6] |=3D missed_tid << 16; + } + env->spr[SPR_BOOKE_MAS1] |=3D (missed_tid << MAS1_TID_SHIFT); + + + /* next victim logic */ + env->spr[SPR_BOOKE_MAS0] |=3D env->last_way << MAS0_ESEL_SHIFT; + env->last_way++; + env->last_way &=3D booke206_tlb_ways(env, 0) - 1; + env->spr[SPR_BOOKE_MAS0] |=3D env->last_way << MAS0_NV_SHIFT; +} + +static bool ppc_booke_xlate(PowerPCCPU *cpu, vaddr eaddr, + MMUAccessType access_type, + hwaddr *raddrp, int *psizep, int *protp, + int mmu_idx, bool guest_visible) +{ + CPUState *cs =3D CPU(cpu); + CPUPPCState *env =3D &cpu->env; + mmu_ctx_t ctx; + int ret; + + if (env->mmu_model =3D=3D POWERPC_MMU_BOOKE206) { + ret =3D mmubooke206_get_physical_address(env, &ctx, eaddr, access_= type, + mmu_idx); + } else { + ret =3D mmubooke_get_physical_address(env, &ctx, eaddr, access_typ= e); + } + if (ret =3D=3D 0) { + *raddrp =3D ctx.raddr; + *protp =3D ctx.prot; + *psizep =3D TARGET_PAGE_BITS; + return true; + } else if (!guest_visible) { + return false; + } + + log_cpu_state_mask(CPU_LOG_MMU, cs, 0); + env->error_code =3D 0; + if (env->mmu_model =3D=3D POWERPC_MMU_BOOKE206 && ret =3D=3D -1) { + booke206_update_mas_tlb_miss(env, eaddr, access_type, mmu_idx); + } + if (access_type =3D=3D MMU_INST_FETCH) { + if (ret =3D=3D -1) { + /* No matches in page tables or TLB */ + cs->exception_index =3D POWERPC_EXCP_ITLB; + env->spr[SPR_BOOKE_DEAR] =3D eaddr; + env->spr[SPR_BOOKE_ESR] =3D mmubooke206_esr(mmu_idx, access_ty= pe); + } else { + cs->exception_index =3D POWERPC_EXCP_ISI; + if (ret =3D=3D -3) { + /* No execute protection violation */ + env->spr[SPR_BOOKE_ESR] =3D 0; + } + } + return false; + } + + switch (ret) { + case -1: + /* No matches in page tables or TLB */ + cs->exception_index =3D POWERPC_EXCP_DTLB; + env->spr[SPR_BOOKE_DEAR] =3D eaddr; + env->spr[SPR_BOOKE_ESR] =3D mmubooke206_esr(mmu_idx, access_type); + break; + case -2: + /* Access rights violation */ + cs->exception_index =3D POWERPC_EXCP_DSI; + env->spr[SPR_BOOKE_DEAR] =3D eaddr; + env->spr[SPR_BOOKE_ESR] =3D mmubooke206_esr(mmu_idx, access_type); + break; + case -4: + /* Direct store exception */ + env->spr[SPR_DAR] =3D eaddr; + switch (env->access_type) { + case ACCESS_FLOAT: + /* Floating point load/store */ + cs->exception_index =3D POWERPC_EXCP_ALIGN; + env->error_code =3D POWERPC_EXCP_ALIGN_FP; + break; + case ACCESS_RES: + /* lwarx, ldarx or stwcx. */ + cs->exception_index =3D POWERPC_EXCP_DSI; + if (access_type =3D=3D MMU_DATA_STORE) { + env->spr[SPR_DSISR] =3D 0x06000000; + } else { + env->spr[SPR_DSISR] =3D 0x04000000; + } + break; + case ACCESS_EXT: + /* eciwx or ecowx */ + cs->exception_index =3D POWERPC_EXCP_DSI; + if (access_type =3D=3D MMU_DATA_STORE) { + env->spr[SPR_DSISR] =3D 0x06100000; + } else { + env->spr[SPR_DSISR] =3D 0x04100000; + } + break; + default: + printf("DSI: invalid exception (%d)\n", ret); + cs->exception_index =3D POWERPC_EXCP_PROGRAM; + env->error_code =3D POWERPC_EXCP_INVAL | POWERPC_EXCP_INVAL_IN= VAL; + break; + } + } + return false; +} + static const char *book3e_tsize_to_str[32] =3D { "1K", "2K", "4K", "8K", "16K", "32K", "64K", "128K", "256K", "512K", "1M", "2M", "4M", "8M", "16M", "32M", "64M", "128M", "256M", "512M", @@ -1186,156 +1336,6 @@ static int get_physical_address_wtlb(CPUPPCState *e= nv, mmu_ctx_t *ctx, } } =20 -static void booke206_update_mas_tlb_miss(CPUPPCState *env, target_ulong ad= dress, - MMUAccessType access_type, int mm= u_idx) -{ - uint32_t epid; - bool as, pr; - uint32_t missed_tid =3D 0; - bool use_epid =3D mmubooke206_get_as(env, mmu_idx, &epid, &as, &pr); - - if (access_type =3D=3D MMU_INST_FETCH) { - as =3D FIELD_EX64(env->msr, MSR, IR); - } - env->spr[SPR_BOOKE_MAS0] =3D env->spr[SPR_BOOKE_MAS4] & MAS4_TLBSELD_M= ASK; - env->spr[SPR_BOOKE_MAS1] =3D env->spr[SPR_BOOKE_MAS4] & MAS4_TSIZED_MA= SK; - env->spr[SPR_BOOKE_MAS2] =3D env->spr[SPR_BOOKE_MAS4] & MAS4_WIMGED_MA= SK; - env->spr[SPR_BOOKE_MAS3] =3D 0; - env->spr[SPR_BOOKE_MAS6] =3D 0; - env->spr[SPR_BOOKE_MAS7] =3D 0; - - /* AS */ - if (as) { - env->spr[SPR_BOOKE_MAS1] |=3D MAS1_TS; - env->spr[SPR_BOOKE_MAS6] |=3D MAS6_SAS; - } - - env->spr[SPR_BOOKE_MAS1] |=3D MAS1_VALID; - env->spr[SPR_BOOKE_MAS2] |=3D address & MAS2_EPN_MASK; - - if (!use_epid) { - switch (env->spr[SPR_BOOKE_MAS4] & MAS4_TIDSELD_PIDZ) { - case MAS4_TIDSELD_PID0: - missed_tid =3D env->spr[SPR_BOOKE_PID]; - break; - case MAS4_TIDSELD_PID1: - missed_tid =3D env->spr[SPR_BOOKE_PID1]; - break; - case MAS4_TIDSELD_PID2: - missed_tid =3D env->spr[SPR_BOOKE_PID2]; - break; - } - env->spr[SPR_BOOKE_MAS6] |=3D env->spr[SPR_BOOKE_PID] << 16; - } else { - missed_tid =3D epid; - env->spr[SPR_BOOKE_MAS6] |=3D missed_tid << 16; - } - env->spr[SPR_BOOKE_MAS1] |=3D (missed_tid << MAS1_TID_SHIFT); - - - /* next victim logic */ - env->spr[SPR_BOOKE_MAS0] |=3D env->last_way << MAS0_ESEL_SHIFT; - env->last_way++; - env->last_way &=3D booke206_tlb_ways(env, 0) - 1; - env->spr[SPR_BOOKE_MAS0] |=3D env->last_way << MAS0_NV_SHIFT; -} - -static bool ppc_booke_xlate(PowerPCCPU *cpu, vaddr eaddr, - MMUAccessType access_type, - hwaddr *raddrp, int *psizep, int *protp, - int mmu_idx, bool guest_visible) -{ - CPUState *cs =3D CPU(cpu); - CPUPPCState *env =3D &cpu->env; - mmu_ctx_t ctx; - int ret; - - if (env->mmu_model =3D=3D POWERPC_MMU_BOOKE206) { - ret =3D mmubooke206_get_physical_address(env, &ctx, eaddr, access_= type, - mmu_idx); - } else { - ret =3D mmubooke_get_physical_address(env, &ctx, eaddr, access_typ= e); - } - if (ret =3D=3D 0) { - *raddrp =3D ctx.raddr; - *protp =3D ctx.prot; - *psizep =3D TARGET_PAGE_BITS; - return true; - } else if (!guest_visible) { - return false; - } - - log_cpu_state_mask(CPU_LOG_MMU, cs, 0); - env->error_code =3D 0; - if (env->mmu_model =3D=3D POWERPC_MMU_BOOKE206 && ret =3D=3D -1) { - booke206_update_mas_tlb_miss(env, eaddr, access_type, mmu_idx); - } - if (access_type =3D=3D MMU_INST_FETCH) { - if (ret =3D=3D -1) { - /* No matches in page tables or TLB */ - cs->exception_index =3D POWERPC_EXCP_ITLB; - env->spr[SPR_BOOKE_DEAR] =3D eaddr; - env->spr[SPR_BOOKE_ESR] =3D mmubooke206_esr(mmu_idx, access_ty= pe); - } else { - cs->exception_index =3D POWERPC_EXCP_ISI; - if (ret =3D=3D -3) { - /* No execute protection violation */ - env->spr[SPR_BOOKE_ESR] =3D 0; - } - } - return false; - } - - switch (ret) { - case -1: - /* No matches in page tables or TLB */ - cs->exception_index =3D POWERPC_EXCP_DTLB; - env->spr[SPR_BOOKE_DEAR] =3D eaddr; - env->spr[SPR_BOOKE_ESR] =3D mmubooke206_esr(mmu_idx, access_type); - break; - case -2: - /* Access rights violation */ - cs->exception_index =3D POWERPC_EXCP_DSI; - env->spr[SPR_BOOKE_DEAR] =3D eaddr; - env->spr[SPR_BOOKE_ESR] =3D mmubooke206_esr(mmu_idx, access_type); - break; - case -4: - /* Direct store exception */ - env->spr[SPR_DAR] =3D eaddr; - switch (env->access_type) { - case ACCESS_FLOAT: - /* Floating point load/store */ - cs->exception_index =3D POWERPC_EXCP_ALIGN; - env->error_code =3D POWERPC_EXCP_ALIGN_FP; - break; - case ACCESS_RES: - /* lwarx, ldarx or stwcx. */ - cs->exception_index =3D POWERPC_EXCP_DSI; - if (access_type =3D=3D MMU_DATA_STORE) { - env->spr[SPR_DSISR] =3D 0x06000000; - } else { - env->spr[SPR_DSISR] =3D 0x04000000; - } - break; - case ACCESS_EXT: - /* eciwx or ecowx */ - cs->exception_index =3D POWERPC_EXCP_DSI; - if (access_type =3D=3D MMU_DATA_STORE) { - env->spr[SPR_DSISR] =3D 0x06100000; - } else { - env->spr[SPR_DSISR] =3D 0x04100000; - } - break; - default: - printf("DSI: invalid exception (%d)\n", ret); - cs->exception_index =3D POWERPC_EXCP_PROGRAM; - env->error_code =3D POWERPC_EXCP_INVAL | POWERPC_EXCP_INVAL_IN= VAL; - break; - } - } - return false; -} - /* Perform address translation */ /* TODO: Split this by mmu_model. */ static bool ppc_jumbo_xlate(PowerPCCPU *cpu, vaddr eaddr, --=20 2.30.9