From patchwork Fri Jul 1 07:10:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?C=C3=A9dric_Le_Goater?= X-Patchwork-Id: 9209361 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 461E4607D6 for ; Fri, 1 Jul 2016 07:17:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 31B0C2868E for ; Fri, 1 Jul 2016 07:17:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2641F28691; Fri, 1 Jul 2016 07:17:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A1C492868E for ; Fri, 1 Jul 2016 07:17:35 +0000 (UTC) Received: from localhost ([::1]:54196 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bIshi-0006EV-JH for patchwork-qemu-devel@patchwork.kernel.org; Fri, 01 Jul 2016 03:17:34 -0400 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) Received: from hermes.ibm.com (LFbn-1-2234-107.w90-76.abo.wanadoo.fr [90.76.55.107]) (Authenticated sender: clg@kaod.org) by player158.ha.ovh.net (Postfix) with ESMTPSA id 9A7E86200A2; Fri, 1 Jul 2016 09:10:51 +0200 (CEST) From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: David Gibson Date: Fri, 1 Jul 2016 09:10:13 +0200 Message-Id: <1467357013-4039-5-git-send-email-clg@kaod.org> X-Mailer: git-send-email 2.1.4 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 X-Ovh-Tracer-Id: 1693634939095911398 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeeltddrudekgdduudejucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] X-Received-From: 178.33.44.239 Subject: [Qemu-devel] [PATCH 4/4] ppc: fix VRMA support 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: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , qemu-ppc@nongnu.org, Alexander Graf , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 uninitialized in this function [-Werror=maybe-uninitialized] pte_offset = 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édric 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) } } +static int ppc_hash64_make_vrma_slb(CPUPPCState *env, ppc_slb_t *slb) +{ + uint32_t vrmasd; + const struct ppc_one_seg_page_size *sps = NULL; + target_ulong esid, vsid; + int i; + + vsid = SLB_VSID_VRMA; + vrmasd = (env->spr[SPR_LPCR] & LPCR_VRMASD) >> LPCR_VRMASD_SHIFT; + vsid |= (vrmasd << 4) & (SLB_VSID_L | SLB_VSID_LP); + esid = SLB_ESID_V; + + for (i = 0; i < PPC_PAGE_SIZES_MAX_SZ; i++) { + const struct ppc_one_seg_page_size *sps1 = &env->sps.sps[i]; + + if (!sps1->page_shift) { + break; + } + + if ((vsid & SLB_VSID_LLP_MASK) == sps1->slb_enc) { + sps = 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 = vsid; + slb->esid = esid; + slb->sps = 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, vaddr 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 = SLB_VSID_VRMA; - vrmasd = (env->spr[SPR_LPCR] & LPCR_VRMASD) >> - LPCR_VRMASD_SHIFT; - slb.vsid |= (vrmasd << 4) & (SLB_VSID_L | SLB_VSID_LP); - slb.esid = 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 *cpu, target_ulong addr) /* 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 = SLB_VSID_VRMA; - vrmasd = (env->spr[SPR_LPCR] & LPCR_VRMASD) >> LPCR_VRMASD_SHIFT; - slb.vsid |= (vrmasd << 4) & (SLB_VSID_L | SLB_VSID_LP); - slb.esid = SLB_ESID_V; + ppc_hash64_make_vrma_slb(env, &slb); goto skip_slb; } /* RMA. Check bounds in RMLS */