* [PATCH] vs. latest linuxppc_2_4_devel and linuxppc_2_4 for xmon
@ 2003-02-12 20:31 Cort Dougan
2003-02-13 0:03 ` Paul Mackerras
0 siblings, 1 reply; 2+ messages in thread
From: Cort Dougan @ 2003-02-12 20:31 UTC (permalink / raw)
To: linuxppc-dev
Allows printing of pgtables in xmon. Mighty useful in both trees.
diff -Nru a/arch/ppc/xmon/xmon.c b/arch/ppc/xmon/xmon.c
--- a/arch/ppc/xmon/xmon.c Wed Feb 12 13:28:51 2003
+++ b/arch/ppc/xmon/xmon.c Wed Feb 12 13:28:51 2003
@@ -138,6 +138,7 @@
ms set a block of memory\n\
md compare two blocks of memory\n\
M print System.map\n\
+ p print page tables for current\n\
r print registers\n\
S print special registers\n\
t print backtrace\n\
@@ -432,6 +433,9 @@
case 'M':
print_sysmap();
break;
+ case 'p':
+ print_pgtables();
+ break;
case 'S':
super_regs();
break;
@@ -689,6 +693,78 @@
}
}
+
+/*
+ * Lookup page mappings for the current task and for the
+ * kernel and print them all. -- Cort <cort@fsmlabs.com>
+ */
+static void
+print_pgtables(void)
+{
+ int i = 0;/* j = 0;*/
+ pgd_t *pgd;
+ pmd_t *pmd;
+ /*pte_t *pte;*/
+ struct mm_struct *mm = current->mm;
+
+ if (!mm) {
+ printf("!current->mm, using init_task\n");
+ mm = &init_mm;
+ }
+
+ printf("current %08x %s/%d\n", current, current->comm,
+ current->pid);
+
+ printf("User mappings: ");
+again:
+ printf("->mm %08x ->context %08x\n",
+ (ulong)mm, (ulong)mm->context);
+
+ if ( !mm->pgd ) {
+ printf("!mm->pgd\n");
+ return;
+ }
+
+ pgd = mm->pgd;
+
+ printf("PGD/PMD table spans %08x -> %08x\n",
+ (ulong)mm->pgd,
+ (ulong)mm->pgd+(PTRS_PER_PGD*sizeof(pgd_t)));
+
+
+ for ( i = 0 ; i < PTRS_PER_PGD; i++, pgd++ ) {
+ /* pmd is the same as the PGD on PPC -- Cort */
+ pmd = pmd_offset(pgd,0);
+
+ /* if there is a valid PMD (table of 1024 PTE's) */
+ if ( !pmd_none(*pmd) ) {
+ printf(" PMD %08x maps %08x,%08x (pmd_val %08x)\n",
+ pgd, i*PGDIR_SIZE,
+ (i*PGDIR_SIZE)+(PGDIR_SIZE-1),
+ pmd_val(*pmd));
+#if 0
+ pte = (pte_t *)pmd_page(*pmd);
+
+ for ( j = 0; j < PTRS_PER_PTE; j++,pte++ )
+ {
+ if ( !pte || !pte_none(*pte) )
+ continue;
+ printf(" PTE %08x maps %08x,%08x\n",
+ pte, (i*PGDIR_SIZE) + (j*PAGE_SIZE),
+ (i*PGDIR_SIZE) + (j*PAGE_SIZE) + (PAGE_SIZE-1));
+ }
+#endif
+ }
+ }
+
+ /* do the swapper_pg_dir */
+ if ( mm != &init_mm ) {
+ printf("Kernel mappings: ");
+ mm = &init_mm;
+ goto again;
+ }
+}
+
static void
backtrace(struct pt_regs *excp)
{
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] vs. latest linuxppc_2_4_devel and linuxppc_2_4 for xmon
2003-02-12 20:31 [PATCH] vs. latest linuxppc_2_4_devel and linuxppc_2_4 for xmon Cort Dougan
@ 2003-02-13 0:03 ` Paul Mackerras
0 siblings, 0 replies; 2+ messages in thread
From: Paul Mackerras @ 2003-02-13 0:03 UTC (permalink / raw)
To: Cort Dougan; +Cc: linuxppc-dev
Cort Dougan writes:
> Allows printing of pgtables in xmon. Mighty useful in both trees.
Nice idea. :)
The main problem I have with the patch is that it doesn't check the
pointers in the page table tree, so if the page tables are corrupted
then xmon itself will get a DSI. Yes, if that is the case then your
system is pretty badly hosed, but it is in those sorts of situations
that you most need xmon to work. We should also be using mread() to
read the pagetables safely.
The other problem is that it could print thousands or millions of
lines of output. It would be nice to be able to specify an address or
a range of addresses to look up rather than printing them all.
BTW, we have other points where we need to use mread() - for example I
noticed that the top-level xmon() function calls smp_processor_id(),
which is current->processor, which will break badly if r2 is bad.
Regards,
Paul.
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2003-02-13 0:03 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-02-12 20:31 [PATCH] vs. latest linuxppc_2_4_devel and linuxppc_2_4 for xmon Cort Dougan
2003-02-13 0:03 ` Paul Mackerras
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).