From patchwork Mon Jul 3 06:19:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suraj Jitindar Singh X-Patchwork-Id: 9821979 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 59E3160246 for ; Mon, 3 Jul 2017 06:21:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4E42128504 for ; Mon, 3 Jul 2017 06:21:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3FE922851A; Mon, 3 Jul 2017 06:21:31 +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.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID 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 C310828504 for ; Mon, 3 Jul 2017 06:21:30 +0000 (UTC) Received: from localhost ([::1]:60524 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dRuji-0008HW-17 for patchwork-qemu-devel@patchwork.kernel.org; Mon, 03 Jul 2017 02:21:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59761) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dRuiV-0008Go-Hp for qemu-devel@nongnu.org; Mon, 03 Jul 2017 02:20:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dRuiQ-0001T2-KU for qemu-devel@nongnu.org; Mon, 03 Jul 2017 02:20:15 -0400 Received: from mail-pg0-x243.google.com ([2607:f8b0:400e:c05::243]:34431) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dRuiO-0001NN-7k; Mon, 03 Jul 2017 02:20:08 -0400 Received: by mail-pg0-x243.google.com with SMTP id j186so22054206pge.1; Sun, 02 Jul 2017 23:20:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=FZTHvCPyHeDu9qWmvDEwc9D7T1nkFGcFjGWyh8QSMmo=; b=lFt0fKX/d7lh3E197HAg6D886TDQA3pf7bYMoTydaf7hgIw9AdBfjx+BO/Fa7iIelO E4PwOFNG4tYVbMBFGj5c7STR464qM+ZnBjU5ZynxjRC/qhqendB1PSjKCnI5l5ypYt2F OlvbsnJ1jNIym63YUh6qRBnf0wz3fNHwjcDRfoNqm20qyZE6JeAzrCJcGgRQYZ7dCmei tsH/J3eQVaAmS9qHeb/v+O7pCH3wo5BvaNGMp2JeMgPgeaA8d/f4tx0k7kMZSBGh9yi2 CGcF6SgV2h3jVNuxN6ZZ4xtLO8Lzqm/7431lN+ZahFbC3f2ffjTJsdwt6fY/fxt2l89b 3Dsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=FZTHvCPyHeDu9qWmvDEwc9D7T1nkFGcFjGWyh8QSMmo=; b=oRqX7ZxPfj60lEVv2xCewNY+bwO3vGZSKRN1OmCkRfOuvPpIxftvZFN9jVruzmnwVW Qf0dNLwCm34kRyg+NSoPvvrVNR+TtxbLlIrHskiHGlmu+LssxiDfsd7AaOD8jeccUjR8 xKIbtEdtFaM8ZufNNgQqfefmfoSkAJw/zcHGet+7LST/EIRSSm0EaWzG4mDdjTmwe/p9 PwTaXrOXCCum323OPzTmL7auWk+j8NKYfHehP3OhdWaxE5fqtvDM0XG4NCGYSkDaaFxQ c+Qb01Z8gFBENk+PVcqo+JninSBnzHc76WViPlzyuCx9yMnhrcDdui+pNxlKSvXyFA4K HWbA== X-Gm-Message-State: AIVw110o0S4QpqGiXve0evUXgd9VMo92LLqsJv3ExYHPS9YHAkemGPd5 uL5yGCvHVUOXlvct X-Received: by 10.99.66.196 with SMTP id p187mr8573235pga.191.1499062807162; Sun, 02 Jul 2017 23:20:07 -0700 (PDT) Received: from surajjs1.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id k18sm27313106pgf.5.2017.07.02.23.20.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 02 Jul 2017 23:20:06 -0700 (PDT) From: Suraj Jitindar Singh To: qemu-ppc@nongnu.org Date: Mon, 3 Jul 2017 16:19:48 +1000 Message-Id: <20170703061948.18220-4-sjitindarsingh@gmail.com> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170703061948.18220-1-sjitindarsingh@gmail.com> References: <20170703061948.18220-1-sjitindarsingh@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::243 Subject: [Qemu-devel] [Qemu-PPC] [PATCH 3/3] target/ppc: Add debug function to dump radix mmu translations 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: qemu-devel@nongnu.org, bsingharora@gmail.com, agraf@suse.de, Suraj Jitindar Singh , david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP In target/ppc/mmu-hash64.c there already exists the function dump_slb() to dump the hash translation entries (for effective to virtual translation at least). Implement the function ppc_radix64_dump() to allow all the kernel effective to real address mappings and corresponding ptes to be dumped. This is called when "info tlb" is invoked in the qemu console. Previously this command had no output when invoked with a radix guest. Signed-off-by: Suraj Jitindar Singh --- target/ppc/mmu-radix64.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++++ target/ppc/mmu-radix64.h | 1 + target/ppc/mmu_helper.c | 2 +- 3 files changed, 51 insertions(+), 1 deletion(-) diff --git a/target/ppc/mmu-radix64.c b/target/ppc/mmu-radix64.c index bbd37e3..f7eeead 100644 --- a/target/ppc/mmu-radix64.c +++ b/target/ppc/mmu-radix64.c @@ -296,3 +296,52 @@ hwaddr ppc_radix64_get_phys_page_debug(PowerPCCPU *cpu, target_ulong eaddr) return raddr & TARGET_PAGE_MASK; } + +static void ppc_radix64_dump_level(FILE *f, fprintf_function cpu_fprintf, + PowerPCCPU *cpu, uint64_t eaddr, + uint64_t base_addr, uint64_t nls, + uint64_t psize, int *num) +{ + CPUState *cs = CPU(cpu); + uint64_t i, pte; + + for (i = 0; i < (1 << nls); i++) { + eaddr &= ~((1ULL << psize) - 1); /* Clear the low bits */ + eaddr |= (i << (psize - nls)); + + pte = ldq_phys(cs->as, base_addr + (i * sizeof(pte))); + if (!(pte & R_PTE_VALID)) { /* Invalid Entry */ + continue; + } + + if (pte & R_PTE_LEAF) { + uint64_t mask = (1ULL << (psize - nls)) - 1; + cpu_fprintf(f, "%d\t0x%.16" PRIx64 " -> 0x%.16" PRIx64 + " pte: 0x%.16" PRIx64 "\n", (*num)++, + eaddr, pte & R_PTE_RPN & ~mask, pte); + } else { + ppc_radix64_dump_level(f, cpu_fprintf, cpu, eaddr, pte & R_PDE_NLB, + pte & R_PDE_NLS, psize - nls, num); + } + } +} + +void ppc_radix64_dump(FILE *f, fprintf_function cpu_fprintf, PowerPCCPU *cpu) +{ + CPUState *cs = CPU(cpu); + PPCVirtualHypervisorClass *vhc = + PPC_VIRTUAL_HYPERVISOR_GET_CLASS(cpu->vhyp); + uint64_t patbe, prtbe0; + int num = 0; + + /* Get Process Table */ + patbe = vhc->get_patbe(cpu->vhyp); + + /* Load the first entry -> Guest kernel mappings (all we dump for now) */ + prtbe0 = ldq_phys(cs->as, patbe & PATBE1_R_PRTB); + + cpu_fprintf(f, "\tEADDR\t\t RADDR\n"); + ppc_radix64_dump_level(f, cpu_fprintf, cpu, 0ULL, prtbe0 & PRTBE_R_RPDB, + prtbe0 & PRTBE_R_RPDS, PRTBE_R_GET_RTS(prtbe0), + &num); +} diff --git a/target/ppc/mmu-radix64.h b/target/ppc/mmu-radix64.h index 0ecf063..c6c22bd 100644 --- a/target/ppc/mmu-radix64.h +++ b/target/ppc/mmu-radix64.h @@ -47,6 +47,7 @@ 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); +void ppc_radix64_dump(FILE *f, fprintf_function cpu_fprintf, PowerPCCPU *cpu); 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 b7b9088..9587b07 100644 --- a/target/ppc/mmu_helper.c +++ b/target/ppc/mmu_helper.c @@ -1287,7 +1287,7 @@ void dump_mmu(FILE *f, fprintf_function cpu_fprintf, CPUPPCState *env) break; case POWERPC_MMU_VER_3_00: if (ppc64_radix_guest(ppc_env_get_cpu(env))) { - /* TODO - Unsupported */ + ppc_radix64_dump(f, cpu_fprintf, ppc_env_get_cpu(env)); } else { dump_slb(f, cpu_fprintf, ppc_env_get_cpu(env)); break;