From nobody Wed Oct 29 17:31:56 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1524822644964902.1495350805757; Fri, 27 Apr 2018 02:50:44 -0700 (PDT) Received: from localhost ([::1]:46847 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fC01b-0002b2-QJ for importer@patchew.org; Fri, 27 Apr 2018 05:50:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59663) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fBzaN-0001xm-HL for qemu-devel@nongnu.org; Fri, 27 Apr 2018 05:22:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fBzaM-0002Dr-8K for qemu-devel@nongnu.org; Fri, 27 Apr 2018 05:22:35 -0400 Received: from ozlabs.org ([203.11.71.1]:60661) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fBzaL-0002Bz-Js; Fri, 27 Apr 2018 05:22:34 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 40XT2t5yb3z9sXp; Fri, 27 Apr 2018 19:21:39 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1524820902; bh=Oc11+mHydWV++yFz1KC/LIwT9w14MNm/XGsgxGz0KlM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HLyE8sb958naOqeV8Phm6ZfGEPwoHq61rrso8cY4okyKNo2fe1TvMl46KLoB7ltFp 2uDi7QEJTPaN64wjlZLxqKbhIl0/eMnUnCD+ho12CQItcArIUS/kyoNZnuj59fS15e oZEWDbLlvkWeC1z1OWONj7R01Inednkaclj6l0F8= From: David Gibson To: peter.maydell@linaro.org Date: Fri, 27 Apr 2018 19:21:11 +1000 Message-Id: <20180427092126.24812-35-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180427092126.24812-1-david@gibson.dropbear.id.au> References: <20180427092126.24812-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 203.11.71.1 Subject: [Qemu-devel] [PULL 34/49] target/ppc: Avoid taking "env" parameter to mmu-hash64 functions X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Gibson , qemu-ppc@nongnu.org, groug@kaod.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" In most cases we prefer to pass a PowerPCCPU rather than the (embedded) CPUPPCState. For ppc_hash64_update_{rmls,vrma}() change to take "cpu" instead of "env". For ppc_hash64_set_{dsi,isi}() remove the redundant "env" parameter. In theory this makes more work for the functions, but since "cs", "cpu" and "env" are related by at most constant offsets, the compiler should be able to optimize out the difference at effectively zero cost. helper_*() functions are left alone - since they're more closely tied to the TCG generated code, passing "env" is still the standard there. While we're there, fix an incorrect indentation. Signed-off-by: David Gibson Reviewed-by: Greg Kurz Reviewed-by: C=C3=A9dric Le Goater --- target/ppc/mmu-hash64.c | 35 +++++++++++++++++++---------------- target/ppc/mmu-hash64.h | 4 ++-- target/ppc/translate_init.c | 4 ++-- 3 files changed, 23 insertions(+), 20 deletions(-) diff --git a/target/ppc/mmu-hash64.c b/target/ppc/mmu-hash64.c index c9b72b7429..a87fa7c83f 100644 --- a/target/ppc/mmu-hash64.c +++ b/target/ppc/mmu-hash64.c @@ -633,9 +633,9 @@ unsigned ppc_hash64_hpte_page_shift_noslb(PowerPCCPU *c= pu, return 0; } =20 -static void ppc_hash64_set_isi(CPUState *cs, CPUPPCState *env, - uint64_t error_code) +static void ppc_hash64_set_isi(CPUState *cs, uint64_t error_code) { + CPUPPCState *env =3D &POWERPC_CPU(cs)->env; bool vpm; =20 if (msr_ir) { @@ -659,9 +659,9 @@ static void ppc_hash64_set_isi(CPUState *cs, CPUPPCStat= e *env, env->error_code =3D error_code; } =20 -static void ppc_hash64_set_dsi(CPUState *cs, CPUPPCState *env, uint64_t da= r, - uint64_t dsisr) +static void ppc_hash64_set_dsi(CPUState *cs, uint64_t dar, uint64_t dsisr) { + CPUPPCState *env =3D &POWERPC_CPU(cs)->env; bool vpm; =20 if (msr_dr) { @@ -741,13 +741,13 @@ int ppc_hash64_handle_mmu_fault(PowerPCCPU *cpu, vadd= r eaddr, } else { /* The access failed, generate the approriate interrupt */ if (rwx =3D=3D 2) { - ppc_hash64_set_isi(cs, env, SRR1_PROTFAULT); + ppc_hash64_set_isi(cs, SRR1_PROTFAULT); } else { int dsisr =3D DSISR_PROTFAULT; if (rwx =3D=3D 1) { dsisr |=3D DSISR_ISSTORE; } - ppc_hash64_set_dsi(cs, env, eaddr, dsisr); + ppc_hash64_set_dsi(cs, eaddr, dsisr); } return 1; } @@ -783,7 +783,7 @@ skip_slb_search: =20 /* 3. Check for segment level no-execute violation */ if ((rwx =3D=3D 2) && (slb->vsid & SLB_VSID_N)) { - ppc_hash64_set_isi(cs, env, SRR1_NOEXEC_GUARD); + ppc_hash64_set_isi(cs, SRR1_NOEXEC_GUARD); return 1; } =20 @@ -791,13 +791,13 @@ skip_slb_search: ptex =3D ppc_hash64_htab_lookup(cpu, slb, eaddr, &pte, &apshift); if (ptex =3D=3D -1) { if (rwx =3D=3D 2) { - ppc_hash64_set_isi(cs, env, SRR1_NOPTE); + ppc_hash64_set_isi(cs, SRR1_NOPTE); } else { int dsisr =3D DSISR_NOPTE; if (rwx =3D=3D 1) { dsisr |=3D DSISR_ISSTORE; } - ppc_hash64_set_dsi(cs, env, eaddr, dsisr); + ppc_hash64_set_dsi(cs, eaddr, dsisr); } return 1; } @@ -824,7 +824,7 @@ skip_slb_search: if (PAGE_EXEC & ~amr_prot) { srr1 |=3D SRR1_IAMR; /* Access violates virt pg class key = prot */ } - ppc_hash64_set_isi(cs, env, srr1); + ppc_hash64_set_isi(cs, srr1); } else { int dsisr =3D 0; if (need_prot[rwx] & ~pp_prot) { @@ -836,7 +836,7 @@ skip_slb_search: if (need_prot[rwx] & ~amr_prot) { dsisr |=3D DSISR_AMR; } - ppc_hash64_set_dsi(cs, env, eaddr, dsisr); + ppc_hash64_set_dsi(cs, eaddr, dsisr); } return 1; } @@ -942,8 +942,9 @@ void ppc_hash64_tlb_flush_hpte(PowerPCCPU *cpu, target_= ulong ptex, cpu->env.tlb_need_flush =3D TLB_NEED_GLOBAL_FLUSH | TLB_NEED_LOCAL_FLU= SH; } =20 -void ppc_hash64_update_rmls(CPUPPCState *env) +void ppc_hash64_update_rmls(PowerPCCPU *cpu) { + CPUPPCState *env =3D &cpu->env; uint64_t lpcr =3D env->spr[SPR_LPCR]; =20 /* @@ -976,8 +977,9 @@ void ppc_hash64_update_rmls(CPUPPCState *env) } } =20 -void ppc_hash64_update_vrma(CPUPPCState *env) +void ppc_hash64_update_vrma(PowerPCCPU *cpu) { + CPUPPCState *env =3D &cpu->env; const struct ppc_one_seg_page_size *sps =3D NULL; target_ulong esid, vsid, lpcr; ppc_slb_t *slb =3D &env->vrma_slb; @@ -1002,7 +1004,7 @@ void ppc_hash64_update_vrma(CPUPPCState *env) vsid |=3D (vrmasd << 4) & (SLB_VSID_L | SLB_VSID_LP); esid =3D SLB_ESID_V; =20 - for (i =3D 0; i < PPC_PAGE_SIZES_MAX_SZ; i++) { + for (i =3D 0; i < PPC_PAGE_SIZES_MAX_SZ; i++) { const struct ppc_one_seg_page_size *sps1 =3D &env->sps.sps[i]; =20 if (!sps1->page_shift) { @@ -1028,6 +1030,7 @@ void ppc_hash64_update_vrma(CPUPPCState *env) =20 void helper_store_lpcr(CPUPPCState *env, target_ulong val) { + PowerPCCPU *cpu =3D ppc_env_get_cpu(env); uint64_t lpcr =3D 0; =20 /* Filter out bits */ @@ -1089,6 +1092,6 @@ void helper_store_lpcr(CPUPPCState *env, target_ulong= val) ; } env->spr[SPR_LPCR] =3D lpcr; - ppc_hash64_update_rmls(env); - ppc_hash64_update_vrma(env); + ppc_hash64_update_rmls(cpu); + ppc_hash64_update_vrma(cpu); } diff --git a/target/ppc/mmu-hash64.h b/target/ppc/mmu-hash64.h index d297b97d37..95a8c330d6 100644 --- a/target/ppc/mmu-hash64.h +++ b/target/ppc/mmu-hash64.h @@ -17,8 +17,8 @@ void ppc_hash64_tlb_flush_hpte(PowerPCCPU *cpu, target_ulong pte0, target_ulong pte1); unsigned ppc_hash64_hpte_page_shift_noslb(PowerPCCPU *cpu, uint64_t pte0, uint64_t pte1); -void ppc_hash64_update_vrma(CPUPPCState *env); -void ppc_hash64_update_rmls(CPUPPCState *env); +void ppc_hash64_update_vrma(PowerPCCPU *cpu); +void ppc_hash64_update_rmls(PowerPCCPU *cpu); #endif =20 /* diff --git a/target/ppc/translate_init.c b/target/ppc/translate_init.c index 2ae718242a..29bd6f3654 100644 --- a/target/ppc/translate_init.c +++ b/target/ppc/translate_init.c @@ -8975,8 +8975,8 @@ void cpu_ppc_set_papr(PowerPCCPU *cpu, PPCVirtualHype= rvisor *vhyp) env->spr[SPR_AMOR] =3D amor->default_value =3D 0xffffffffffffffffull; =20 /* Update some env bits based on new LPCR value */ - ppc_hash64_update_rmls(env); - ppc_hash64_update_vrma(env); + ppc_hash64_update_rmls(cpu); + ppc_hash64_update_vrma(cpu); =20 /* Tell KVM that we're in PAPR mode */ if (kvm_enabled()) { --=20 2.14.3