All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tools/mfn-dump: Fixes to 'dump-p2m'
@ 2014-04-24 21:06 Andrew Cooper
  2014-04-29 15:25 ` Dario Faggioli
  0 siblings, 1 reply; 5+ messages in thread
From: Andrew Cooper @ 2014-04-24 21:06 UTC (permalink / raw)
  To: Xen-devel; +Cc: Andrew Cooper, Dario Faggioli, Ian Jackson, Ian Campbell

* Don't walk off the end of p2m_table under the mistaken impression that it
  contains toolstack unsigned longs.  Despite its array type it contains guest
  unsigned longs so unconditionally needs casting to the guest width to use
  correctly.  Furthermore, a 64bit toolstack must be extra careful when it
  finds a 32bit guest's INVALID_MFN.

* Drop 'mapped' and 'pinned' descriptions.  This are both bogus, including all
  uses of the is_mapped() macro.

* Rearrange the type name printing to be more concise.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
CC: Ian Campbell <Ian.Campbell@citrix.com>
CC: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Dario Faggioli <dario.faggioli@citrix.com>
---
 tools/misc/xen-mfndump.c |   68 ++++++++++++++++++++++++----------------------
 1 file changed, 36 insertions(+), 32 deletions(-)

diff --git a/tools/misc/xen-mfndump.c b/tools/misc/xen-mfndump.c
index e1ea536..1af3bd8 100644
--- a/tools/misc/xen-mfndump.c
+++ b/tools/misc/xen-mfndump.c
@@ -101,43 +101,47 @@ int dump_p2m_func(int argc, char *argv[])
     {
         unsigned long pagetype = minfo.pfn_type[i] &
                                      XEN_DOMCTL_PFINFO_LTAB_MASK;
+        xen_pfn_t mfn;
 
-        printf("  pfn=0x%lx ==> mfn=0x%lx (type 0x%lx)", i, minfo.p2m_table[i],
-               pagetype >> XEN_DOMCTL_PFINFO_LTAB_SHIFT);
-
-        if ( is_mapped(minfo.p2m_table[i]) )
-            printf(" [mapped]");
-
-        if ( pagetype & XEN_DOMCTL_PFINFO_LPINTAB )
-            printf (" [pinned]");
-
-        if ( pagetype == XEN_DOMCTL_PFINFO_XTAB )
-            printf(" [xtab]");
-        if ( pagetype == XEN_DOMCTL_PFINFO_BROKEN )
-            printf(" [broken]");
-        if ( pagetype == XEN_DOMCTL_PFINFO_XALLOC )
-            printf( " [xalloc]");
-
-        switch ( pagetype & XEN_DOMCTL_PFINFO_LTABTYPE_MASK )
+        if ( minfo.guest_width == sizeof(uint64_t) )
+            mfn = ((uint64_t*)minfo.p2m_table)[i];
+        else
         {
-            case XEN_DOMCTL_PFINFO_L1TAB:
-                printf(" L1 table");
-                break;
-
-            case XEN_DOMCTL_PFINFO_L2TAB:
-                printf(" L2 table");
-                break;
+            mfn = ((uint32_t*)minfo.p2m_table)[i];
+#ifdef __x86_64__
+            if ( mfn == ~0U ) /* Expand a 32bit guest's idea of INVALID_MFN */
+                mfn = ~0UL;
+#endif
+        }
 
-            case XEN_DOMCTL_PFINFO_L3TAB:
-                printf(" L3 table");
-                break;
+        printf("  pfn=0x%lx ==> mfn=0x%lx (type 0x%lx)", i, mfn,
+               pagetype >> XEN_DOMCTL_PFINFO_LTAB_SHIFT);
 
-            case XEN_DOMCTL_PFINFO_L4TAB:
-                printf(" L4 table");
-                break;
+        switch ( pagetype >> XEN_DOMCTL_PFINFO_LTAB_SHIFT )
+        {
+        case 0x0: /* NOTAB */
+            printf("\n");
+            break;
+        case 0x1 ... 0x4: /* L1 -> L4 */
+            printf(" L%lu\n", pagetype >> XEN_DOMCTL_PFINFO_LTAB_SHIFT);
+            break;
+        case 0x9 ... 0xc: /* Pinned L1 -> L4 */
+            printf(" pinned L%lu\n",
+                   (pagetype >> XEN_DOMCTL_PFINFO_LTAB_SHIFT) & 7);
+            break;
+        case 0xd: /* BROKEN */
+            printf(" broken\n");
+            break;
+        case 0xe: /* XALLOC */
+            printf(" xalloc\n");
+            break;
+        case 0xf: /* XTAB */
+            printf(" invalid\n");
+            break;
+        default:
+            printf(" <invalid type>\n");
+            break;
         }
-
-        printf("\n");
     }
     printf(" --- End of P2M for domain %d ---\n", domid);
 
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-05-02 13:04 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-24 21:06 [PATCH] tools/mfn-dump: Fixes to 'dump-p2m' Andrew Cooper
2014-04-29 15:25 ` Dario Faggioli
2014-04-29 16:39   ` Andrew Cooper
2014-04-29 22:35     ` Dario Faggioli
2014-05-02 13:04   ` Ian Campbell

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.