From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41163) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bIsbO-0005IZ-Sk for qemu-devel@nongnu.org; Fri, 01 Jul 2016 03:11:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bIsbK-0007D9-NA for qemu-devel@nongnu.org; Fri, 01 Jul 2016 03:11:02 -0400 Received: from 3.mo53.mail-out.ovh.net ([178.33.44.239]:36792) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bIsbK-0007Cs-Cd for qemu-devel@nongnu.org; Fri, 01 Jul 2016 03:10:58 -0400 Received: from player158.ha.ovh.net (b7.ovh.net [213.186.33.57]) by mo53.mail-out.ovh.net (Postfix) with ESMTP id E64AFFF9291 for ; Fri, 1 Jul 2016 09:10:57 +0200 (CEST) From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Date: Fri, 1 Jul 2016 09:10:13 +0200 Message-Id: <1467357013-4039-5-git-send-email-clg@kaod.org> In-Reply-To: <1467357013-4039-1-git-send-email-clg@kaod.org> References: <1467357013-4039-1-git-send-email-clg@kaod.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH 4/4] ppc: fix VRMA support List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: David Gibson Cc: Alexander Graf , Benjamin Herrenschmidt , qemu-devel@nongnu.org, qemu-ppc@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= commit 08109fd4360d ('ppc: Add proper real mode translation support') introduced VRMA support for which SLB entries need to be created. But it did not take into account the changes in ppc_slb_t and missed the setting of the segment page size attribute. However, gcc spotted it : target-ppc/mmu-hash64.c: In function 'ppc_hash64_get_phys_page_debug': target-ppc/mmu-hash64.c:936:16: error: '*((void *)&slb+16)' may be used u= ninitialized in this function [-Werror=3Dmaybe-uninitialized] pte_offset =3D ppc_hash64_htab_lookup(cpu, &slb, addr, &pte); This adds an extra routine to built the slb and compute the segment page size. Signed-off-by: C=C3=A9dric Le Goater --- I am not sure how to handle errors. Could there be one ? If so, should we generate a POWERPC_EXCP_MCHECK ? target-ppc/mmu-hash64.c | 53 ++++++++++++++++++++++++++++++++++++-------= ------ 1 file changed, 39 insertions(+), 14 deletions(-) diff --git a/target-ppc/mmu-hash64.c b/target-ppc/mmu-hash64.c index 7ef45ee53bf5..117f198a9a2e 100644 --- a/target-ppc/mmu-hash64.c +++ b/target-ppc/mmu-hash64.c @@ -684,6 +684,43 @@ static int64_t ppc_hash64_get_rmls(CPUPPCState *env) } } =20 +static int ppc_hash64_make_vrma_slb(CPUPPCState *env, ppc_slb_t *slb) +{ + uint32_t vrmasd; + const struct ppc_one_seg_page_size *sps =3D NULL; + target_ulong esid, vsid; + int i; + + vsid =3D SLB_VSID_VRMA; + vrmasd =3D (env->spr[SPR_LPCR] & LPCR_VRMASD) >> LPCR_VRMASD_SHIFT; + vsid |=3D (vrmasd << 4) & (SLB_VSID_L | SLB_VSID_LP); + esid =3D SLB_ESID_V; + + for (i =3D 0; i < PPC_PAGE_SIZES_MAX_SZ; i++) { + const struct ppc_one_seg_page_size *sps1 =3D &env->sps.sps[i]; + + if (!sps1->page_shift) { + break; + } + + if ((vsid & SLB_VSID_LLP_MASK) =3D=3D sps1->slb_enc) { + sps =3D sps1; + break; + } + } + + if (!sps) { + error_report("Bad page size encoding esid 0x"TARGET_FMT_lx + " vsid 0x"TARGET_FMT_lx, esid, vsid); + return -1; + } + + slb->vsid =3D vsid; + slb->esid =3D esid; + slb->sps =3D sps; + return 0; +} + int ppc_hash64_handle_mmu_fault(PowerPCCPU *cpu, vaddr eaddr, int rwx, int mmu_idx) { @@ -722,13 +759,7 @@ int ppc_hash64_handle_mmu_fault(PowerPCCPU *cpu, vad= dr eaddr, } else { /* Otherwise, check VPM for RMA vs VRMA */ if (env->spr[SPR_LPCR] & LPCR_VPM0) { - uint32_t vrmasd; - /* VRMA, we make up an SLB entry */ - slb.vsid =3D SLB_VSID_VRMA; - vrmasd =3D (env->spr[SPR_LPCR] & LPCR_VRMASD) >> - LPCR_VRMASD_SHIFT; - slb.vsid |=3D (vrmasd << 4) & (SLB_VSID_L | SLB_VSID_LP)= ; - slb.esid =3D SLB_ESID_V; + ppc_hash64_make_vrma_slb(env, &slb); goto skip_slb; } /* RMA. Check bounds in RMLS */ @@ -893,13 +924,7 @@ hwaddr ppc_hash64_get_phys_page_debug(PowerPCCPU *cp= u, target_ulong addr) =20 /* Otherwise, check VPM for RMA vs VRMA */ if (env->spr[SPR_LPCR] & LPCR_VPM0) { - uint32_t vrmasd; - - /* VRMA, we make up an SLB entry */ - slb.vsid =3D SLB_VSID_VRMA; - vrmasd =3D (env->spr[SPR_LPCR] & LPCR_VRMASD) >> LPCR_VRMASD= _SHIFT; - slb.vsid |=3D (vrmasd << 4) & (SLB_VSID_L | SLB_VSID_LP); - slb.esid =3D SLB_ESID_V; + ppc_hash64_make_vrma_slb(env, &slb); goto skip_slb; } /* RMA. Check bounds in RMLS */ --=20 2.1.4