[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen master] tools/mfn-dump: Fixes to 'dump-p2m'



commit f524e27671e2e8959d70d9e0c9d5c329d7feeda8
Author:     Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
AuthorDate: Thu Apr 24 22:06:27 2014 +0100
Commit:     Ian Campbell <ian.campbell@xxxxxxxxxx>
CommitDate: Fri May 2 13:34:35 2014 +0100

    tools/mfn-dump: Fixes to 'dump-p2m'
    
    * 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@xxxxxxxxxx>
    CC: Ian Campbell <Ian.Campbell@xxxxxxxxxx>
    CC: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>
    CC: Dario Faggioli <dario.faggioli@xxxxxxxxxx>
    Reviewed-by: Dario Faggioli <dario.faggioli@xxxxxxxxxx>
    Acked-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
---
 tools/misc/xen-mfndump.c |   68 ++++++++++++++++++++++++---------------------
 1 files 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);
 
--
generated by git-patchbot for /home/xen/git/xen.git#master

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.