From nobody Wed Nov 5 09:32:31 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 1499748093259472.10134985434354; Mon, 10 Jul 2017 21:41:33 -0700 (PDT) Received: from localhost ([::1]:44118 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dUmzM-000434-3S for importer@patchew.org; Tue, 11 Jul 2017 00:41:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40568) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dUmxM-0002IP-1Q for qemu-devel@nongnu.org; Tue, 11 Jul 2017 00:39:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dUmxK-0007TE-TP for qemu-devel@nongnu.org; Tue, 11 Jul 2017 00:39:28 -0400 Received: from ozlabs.org ([103.22.144.67]:37791) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dUmxK-0007SQ-Hb; Tue, 11 Jul 2017 00:39:26 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 3x68Vx4tgnz9t1G; 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=JK8ZDu8ivMcYdNSZZz21ldjw5oUYlRnYRaWPc6NORgE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XAEdjsVIWW+tKOvS6uz+0w+K+zsFZDixlWMkVU+sKGnE0e4AG/PVAZ+B6tTrJShdR /JOc8MQAeaLRArxSnqOjU4pO73bORgrSDkMisb2ahcpGKJrd7pMIfGpBh+o14hgg2r 7qDbRloza4gUgFy/PzP3QQPwAYsIttfcs01kxqKI= From: David Gibson To: peter.maydell@linaro.org Date: Tue, 11 Jul 2017 14:39:12 +1000 Message-Id: <20170711043917.1757-13-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 12/17] target/ppc: Add debug function for radix mmu translation 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 In target/ppc/mmu-hash64.c there already exists the function ppc_hash64_get_phys_page_debug() to get the physical (real) address for a given effective address in hash mode. Implement the function ppc_radix64_get_phys_page_debug() to allow a real address to be obtained for a given effective address in radix mode. This is used when a debugger is attached to qemu. Previously we just had a comment saying this is unimplemented which then fell through to the default case and caused an abort due to unrecognised mmu model as the default had no case for the V3 mmu, which was misleading at best. We reuse ppc_radix64_walk_tree() which is used by the radix fault handler since the process of walking the radix tree is identical. Reported-by: Balbir Singh Signed-off-by: Suraj Jitindar Singh Signed-off-by: David Gibson --- target/ppc/mmu-radix64.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ target/ppc/mmu-radix64.h | 1 + target/ppc/mmu_helper.c | 3 ++- 3 files changed, 48 insertions(+), 1 deletion(-) diff --git a/target/ppc/mmu-radix64.c b/target/ppc/mmu-radix64.c index 1a650fd..bbd37e3 100644 --- a/target/ppc/mmu-radix64.c +++ b/target/ppc/mmu-radix64.c @@ -251,3 +251,48 @@ int ppc_radix64_handle_mmu_fault(PowerPCCPU *cpu, vadd= r eaddr, int rwx, prot, mmu_idx, 1UL << page_size); return 0; } + +hwaddr ppc_radix64_get_phys_page_debug(PowerPCCPU *cpu, target_ulong eaddr) +{ + CPUState *cs =3D CPU(cpu); + CPUPPCState *env =3D &cpu->env; + PPCVirtualHypervisorClass *vhc =3D + PPC_VIRTUAL_HYPERVISOR_GET_CLASS(cpu->vhyp); + hwaddr raddr, pte_addr; + uint64_t lpid =3D 0, pid =3D 0, offset, size, patbe, prtbe0, pte; + int page_size, fault_cause =3D 0; + + /* Handle Real Mode */ + if (msr_dr =3D=3D 0) { + /* In real mode top 4 effective addr bits (mostly) ignored */ + return eaddr & 0x0FFFFFFFFFFFFFFFULL; + } + + /* Virtual Mode Access - get the fully qualified address */ + if (!ppc_radix64_get_fully_qualified_addr(env, eaddr, &lpid, &pid)) { + return -1; + } + + /* Get Process Table */ + patbe =3D vhc->get_patbe(cpu->vhyp); + + /* Index Process Table by PID to Find Corresponding Process Table Entr= y */ + offset =3D pid * sizeof(struct prtb_entry); + size =3D 1ULL << ((patbe & PATBE1_R_PRTS) + 12); + if (offset >=3D size) { + /* offset exceeds size of the process table */ + return -1; + } + prtbe0 =3D ldq_phys(cs->as, (patbe & PATBE1_R_PRTB) + offset); + + /* 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, eaddr & R_EADDR_MASK, + prtbe0 & PRTBE_R_RPDB, prtbe0 & PRTBE_R_RP= DS, + &raddr, &page_size, &fault_cause, &pte_add= r); + if (!pte) { + return -1; + } + + return raddr & TARGET_PAGE_MASK; +} diff --git a/target/ppc/mmu-radix64.h b/target/ppc/mmu-radix64.h index 1d5c7cf..0ecf063 100644 --- a/target/ppc/mmu-radix64.h +++ b/target/ppc/mmu-radix64.h @@ -46,6 +46,7 @@ =20 int ppc_radix64_handle_mmu_fault(PowerPCCPU *cpu, vaddr eaddr, int rwx, int mmu_idx); +hwaddr ppc_radix64_get_phys_page_debug(PowerPCCPU *cpu, target_ulong addr); =20 static inline int ppc_radix64_get_prot_eaa(uint64_t pte) { diff --git a/target/ppc/mmu_helper.c b/target/ppc/mmu_helper.c index 65d1c86..b7b9088 100644 --- a/target/ppc/mmu_helper.c +++ b/target/ppc/mmu_helper.c @@ -30,6 +30,7 @@ #include "helper_regs.h" #include "qemu/error-report.h" #include "mmu-book3s-v3.h" +#include "mmu-radix64.h" =20 //#define DEBUG_MMU //#define DEBUG_BATS @@ -1432,7 +1433,7 @@ hwaddr ppc_cpu_get_phys_page_debug(CPUState *cs, vadd= r addr) return ppc_hash64_get_phys_page_debug(cpu, addr); case POWERPC_MMU_VER_3_00: if (ppc64_radix_guest(ppc_env_get_cpu(env))) { - /* TODO - Unsupported */ + return ppc_radix64_get_phys_page_debug(cpu, addr); } else { return ppc_hash64_get_phys_page_debug(cpu, addr); } --=20 2.9.4