tools/mfn-dump: Fixes to 'dump-p2m'
PATCH 1/1 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.
--- tools/misc/xen-mfndump.c | 68 ++++++++++++++++++++++++---------------------- 1 file changed, 36 insertions(+), 32 deletions(-)
tools/misc/xen-mfndump.c +36 -32
@@ -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);
Signature · 1 line
1.7.10.4
Quoted 9 lines · Andrew Cooper
* Don't walk off the end of
p2m_tableunder 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'sINVALID_MFN.* Drop 'mapped' and 'pinned' descriptions. This are both bogus, including all uses of the
is_mapped()macro.
Just a question, what do you mean by 'bogus' here? About pinned, I think I see it, and I like the way you put it in the patch. About 'mapped' and is_mapped()? Do you mean to say it's not useful information here?
Again, just curious.
Quoted 7 lines
* Rearrange the type name printing to be more concise.
Signed-off-by Andrew Cooper <[email protected]>CC Ian Campbell <[email protected]>CC Ian Jackson <[email protected]>CC Dario Faggioli <[email protected]>
In any case, I think this is all correct and I like the new look of the code, so:
Sorry again for the delay,
Dario
Signature · 4 lines
<<This happens because I choose it to happen!>> (Raistlin Majere) ----------------------------------------------------------------- Dario Faggioli, Ph.D, http://about.me/dario.faggioli Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 2 lines · Dario Faggioli
Quoted 1 line · Andrew Cooper
* Don't walk off the end of
p2m_tableunder the mistaken impression
that it
Quoted 1 line
Quoted 1 line
contains toolstack unsigned longs. Despite its array type it
contains guest
Quoted 1 line
Quoted 1 line
unsigned longs so unconditionally needs casting to the guest width
to use
Quoted 1 line
Quoted 1 line
correctly. Furthermore, a 64bit toolstack must be extra careful
when it
Quoted 3 lines
Quoted 3 lines
finds a 32bit guest's
INVALID_MFN.* Drop 'mapped' and 'pinned' descriptions. This are both bogus,
including all
Quoted 7 lines
Quoted 2 lines
uses of the
is_mapped()macro.Just a question, what do you mean by 'bogus' here? About pinned, I think I see it, and I like the way you put it in the patch. About 'mapped' and
is_mapped()? Do you mean to say it's not useful information here?Again, just curious.
The top bit of the type has nothing to do with mappings, or certainly nothing that I am aware of, having successfully rewritten PV migration from scratch.
The guest can still have mappings to its pinned pagetables, which would have the top bit of the type set.
In xc_domain_save.c, this macro is used 4 times. 3 are used on mfns and 1 is used on a type (for a bit of debugging code which appears dead anyway). I expect noone has every tried migrating a PV domain whose pages are located in mfns with the 44th bit set.
So by bogus, I mean the macro itself, and all uses of it.
My best guess is that is some vestigial code left over from a previous way of doing things, although I didn't encounter anything related to this in code archaeology I performed when trying to work out why the legacy migration did certain things the way they did.
~Andrew
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 4 lines · Andrew Cooper
The top bit of the type has nothing to do with mappings, or certainly nothing that I am aware of, having successfully rewritten PV migration from scratch.
Quoted 8 lines
The guest can still have mappings to its pinned pagetables, which would have the top bit of the type set.
In
xc_domain_save.c, this macro is used 4 times. 3 are used on mfns and 1 is used on a type (for a bit of debugging code which appears dead anyway). I expect noone has every tried migrating a PV domain whose pages are located in mfns with the 44th bit set.
Right. The fact that such macro is present in xc_domain_save.c was the exact region why I was asking. :-)
Quoted 7 lines
So by bogus, I mean the macro itself, and all uses of it.
My best guess is that is some vestigial code left over from a previous way of doing things, although I didn't encounter anything related to this in code archaeology I performed when trying to work out why the legacy migration did certain things the way they did.
I see. Makes sense, thanks for clearing my doubts. :-)
Regards,
Dario
Signature · 4 lines
<<This happens because I choose it to happen!>> (Raistlin Majere) ----------------------------------------------------------------- Dario Faggioli, Ph.D, http://about.me/dario.faggioli Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 1 line · Dario Faggioli
Reviewed-by Dario Faggioli <[email protected]>
Acked + applied.