linux-mips
[Top] [All Lists]

RFC: add code to dump the kernel page tables for visual inspection by ke

To: ralf@linux-mips.org, linux-mips@linux-mips.org
Subject: RFC: add code to dump the kernel page tables for visual inspection by kernel developers
From: Dragos Tatulea <dragos.tatulea@gmail.com>
Date: Sat, 9 Oct 2010 14:03:08 +0200
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:received:from:date :message-id:subject:to:content-type; bh=OkDLex9C9cQcM3JFDjktjKBwxOMp2QDyfGMuPIjBvqA=; b=YXD1hYsuva0pnTVkZqIAs1fi65uBFGX1gZp5hBE8z8UzC1Vd/H/Nl+sSVfmq3jpqnM Oz9bLtlgrLv1ZLQ6W/97Cg0G/spR387HvrWZ0tb75xUdLj4SUz/WqciA8hJzn9SrA9KF qO0+N1I1dEHnq/E0OPnBeb7LqfexpoVf4e1GM=
Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:from:date:message-id:subject:to:content-type; b=LhfZ9V4ixXRAnWH0oYCF0JN7aniFDejnDqd75rmiG5wnHvv93jNxv8DtXx9EBrtuAk hH6xbbCsYJ/tXr+NWoJrCrx6e1CcyYDQbFvWcxqGWgdcFyd5OZpEERrRxELK+SCWxMp5 DmHsadmH/sxoPsyZQdGl8Cp2kjawCftSp4MD0=
Original-recipient: rfc822;linux-mips@linux-mips.org
Sender: linux-mips-bounce@linux-mips.org
On the linux-mips.org TODO list, there's the $SUBJ item. Ralf B.
hinted that a good starting point would be the dump_list_process
function which was removed in 2.6.23 (during lib-32 & lib-64 merge?).
This patch is just a copy paste from the lib-64 version of this
function (with small modifications for 32 bit compatibility).

Any other interesting "features" that should get in?

diff --git a/arch/mips/lib/dump_tlb.c b/arch/mips/lib/dump_tlb.c
index 3f69725..7d705c8 100644
--- a/arch/mips/lib/dump_tlb.c
+++ b/arch/mips/lib/dump_tlb.c
@@ -6,6 +6,7 @@
  */
 #include <linux/kernel.h>
 #include <linux/mm.h>
+#include <linux/sched.h>

 #include <asm/mipsregs.h>
 #include <asm/page.h>
@@ -109,3 +110,71 @@ void dump_tlb_all(void)
 {
        dump_tlb(0, current_cpu_data.tlbsize - 1);
 }
+
+void dump_list_process(struct task_struct *t, void *address)
+{
+       pgd_t   *page_dir, *pgd;
+       pud_t   *pud;
+       pmd_t   *pmd;
+       pte_t   *pte, page;
+       unsigned long addr, val;
+       int width;
+
+#if defined(CONFIG_64BIT)
+       width = 16;
+#else
+       width = 8;
+#endif
+
+       addr = (unsigned long) address;
+
+       printk("Addr                 == %0*lx\n", width, addr);
+       printk("tasks->mm.pgd        == %0*lx\n", width,
+              (unsigned long) t->mm->pgd);
+
+       page_dir = pgd_offset(t->mm, 0UL);
+       printk("page_dir == %0*lx\n", width, (unsigned long) page_dir);
+
+       pgd = pgd_offset(t->mm, addr);
+       printk("pgd == %0*lx\n", width, (unsigned long) pgd);
+
+       pud = pud_offset(pgd, addr);
+       printk("pud == %0*lx\n", width, (unsigned long) pud);
+
+       pmd = pmd_offset(pud, addr);
+       printk("pmd == %0*lx\n", width, (unsigned long) pmd);
+
+       pte = pte_offset(pmd, addr);
+       printk("pte == %0*lx\n", width, (long) pte);
+
+       page = *pte;
+       printk("page == %08lx\n", pte_val(page));
+
+       val = pte_val(page);
+       if (val & _PAGE_PRESENT)
+               printk("present ");
+       if (val & _PAGE_READ)
+               printk("read ");
+       if (val & _PAGE_WRITE)
+               printk("write ");
+       if (val & _PAGE_ACCESSED)
+               printk("accessed ");
+       if (val & _PAGE_MODIFIED)
+               printk("modified ");
+#if defined(CONFIG_64BIT_PHYS_ADDR) && defined(CONFIG_CPU_MIPS32)
+       if (val & _PAGE_R4KBUG)
+               printk("r4kbug ");
+#endif
+       if (val & _PAGE_GLOBAL)
+               printk("global ");
+       if (val & _PAGE_VALID)
+               printk("valid ");
+       if (val & _PAGE_DIRTY)
+               printk("dirty ");
+       printk("\n");
+}
+
+void dump_list_current(void *address)
+{
+       dump_list_process(current, address);
+}

<Prev in Thread] Current Thread [Next in Thread>