From nobody Wed Nov 5 09:24:05 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 1499748220282170.73852080032862; Mon, 10 Jul 2017 21:43:40 -0700 (PDT) Received: from localhost ([::1]:44127 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dUn1O-0005tu-TC for importer@patchew.org; Tue, 11 Jul 2017 00:43:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40597) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dUmxN-0002J4-4K for qemu-devel@nongnu.org; Tue, 11 Jul 2017 00:39:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dUmxL-0007Tm-Sq for qemu-devel@nongnu.org; Tue, 11 Jul 2017 00:39:29 -0400 Received: from ozlabs.org ([103.22.144.67]:46605) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dUmxL-0007Sa-Gq; Tue, 11 Jul 2017 00:39:27 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 3x68Vx6FTNz9t2Q; Tue, 11 Jul 2017 14:39:21 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1499747961; bh=/DkvVvP07r7uYc9hBEBDmPOkAsADql/+9EO+iBSbHvw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=p99g8VymT1sdjM+LkGlnt5xkyhCc7PrZXBltYpEDplUi+x+RVH3vGjL93IBjnLyDW Ddgb2ixfixKAGnWXdPaUk7H6k0dPx4Eoq0THZu/RAgFPg8Dp7n6NqvacgUQC++Vf1Q jAOgwJZnh52ayHtM/xYfv0y4DO8TlVjAv/yAtSUQ= From: David Gibson To: peter.maydell@linaro.org Date: Tue, 11 Jul 2017 14:39:11 +1000 Message-Id: <20170711043917.1757-12-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170711043917.1757-1-david@gibson.dropbear.id.au> References: <20170711043917.1757-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 103.22.144.67 Subject: [Qemu-devel] [PULL 11/17] target/ppc: Refactor tcg radix mmu code 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: lvivier@redhat.com, qemu-devel@nongnu.org, mdroth@linux.vnet.ibm.com, surajjs@au1.ibm.com, aik@ozlabs.ru, sbobroff@au1.ibm.com, groug@kaod.org, agraf@suse.de, qemu-ppc@nongnu.org, Suraj Jitindar Singh , bharata@linux.vnet.ibm.com, David Gibson 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-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Suraj Jitindar Singh The mmu-radix64.c file implements functions to enable the radix mmu emulation in tcg mode. There is a function ppc_radix64_walk_tree() which performs the radix tree walk and also implicitly checks the pte protection. Move the protection checking of the pte from the ppc_radix64_walk_tree() function into the caller. This means the ppc_radix64_walk_tree() function can be used without protection checking which is useful for debugging. ppc_radix64_walk_tree() no longer needs to take the rwx and prot variables. Signed-off-by: Suraj Jitindar Singh Signed-off-by: David Gibson --- target/ppc/mmu-radix64.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/target/ppc/mmu-radix64.c b/target/ppc/mmu-radix64.c index 69fde65..1a650fd 100644 --- a/target/ppc/mmu-radix64.c +++ b/target/ppc/mmu-radix64.c @@ -147,11 +147,10 @@ static void ppc_radix64_set_rc(PowerPCCPU *cpu, int r= wx, uint64_t pte, } } =20 -static uint64_t ppc_radix64_walk_tree(PowerPCCPU *cpu, int rwx, vaddr eadd= r, +static uint64_t ppc_radix64_walk_tree(PowerPCCPU *cpu, vaddr eaddr, uint64_t base_addr, uint64_t nls, hwaddr *raddr, int *psize, - int *fault_cause, int *prot, - hwaddr *pte_addr) + int *fault_cause, hwaddr *pte_addr) { CPUState *cs =3D CPU(cpu); uint64_t index, pde; @@ -177,10 +176,6 @@ static uint64_t ppc_radix64_walk_tree(PowerPCCPU *cpu,= int rwx, vaddr eaddr, uint64_t rpn =3D pde & R_PTE_RPN; uint64_t mask =3D (1UL << *psize) - 1; =20 - if (ppc_radix64_check_prot(cpu, rwx, pde, fault_cause, prot)) { - return 0; /* Protection Denied Access */ - } - /* Or high bits of rpn and low bits to ea to form whole real addr = */ *raddr =3D (rpn & ~mask) | (eaddr & mask); *pte_addr =3D base_addr + (index * sizeof(pde)); @@ -188,9 +183,8 @@ static uint64_t ppc_radix64_walk_tree(PowerPCCPU *cpu, = int rwx, vaddr eaddr, } =20 /* Next Level of Radix Tree */ - return ppc_radix64_walk_tree(cpu, rwx, eaddr, pde & R_PDE_NLB, - pde & R_PDE_NLS, raddr, psize, - fault_cause, prot, pte_addr); + return ppc_radix64_walk_tree(cpu, eaddr, pde & R_PDE_NLB, pde & R_PDE_= NLS, + raddr, psize, fault_cause, pte_addr); } =20 int ppc_radix64_handle_mmu_fault(PowerPCCPU *cpu, vaddr eaddr, int rwx, @@ -241,11 +235,11 @@ int ppc_radix64_handle_mmu_fault(PowerPCCPU *cpu, vad= dr eaddr, int rwx, =20 /* Walk Radix Tree from Process Table Entry to Convert EA to RA */ page_size =3D PRTBE_R_GET_RTS(prtbe0); - pte =3D ppc_radix64_walk_tree(cpu, rwx, eaddr & R_EADDR_MASK, + pte =3D ppc_radix64_walk_tree(cpu, eaddr & R_EADDR_MASK, prtbe0 & PRTBE_R_RPDB, prtbe0 & PRTBE_R_RP= DS, - &raddr, &page_size, &fault_cause, &prot, - &pte_addr); - if (!pte) { + &raddr, &page_size, &fault_cause, &pte_add= r); + if (!pte || ppc_radix64_check_prot(cpu, rwx, pte, &fault_cause, &prot)= ) { + /* Couldn't get pte or access denied due to protection */ ppc_radix64_raise_si(cpu, rwx, eaddr, fault_cause); return 1; } --=20 2.9.4