* [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* Re: [PATCH] tools/mfn-dump: Fixes to 'dump-p2m'
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-05-02 13:04 ` Ian Campbell
0 siblings, 2 replies; 5+ messages in thread
From: Dario Faggioli @ 2014-04-29 15:25 UTC (permalink / raw)
To: Andrew Cooper; +Cc: Ian Jackson, Ian Campbell, Xen-devel
[-- Attachment #1.1: Type: text/plain, Size: 1494 bytes --]
On gio, 2014-04-24 at 22:06 +0100, Andrew Cooper wrote:
> * 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.
>
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.
> * 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>
>
In any case, I think this is all correct and I like the new look of the
code, so:
Reviewed-by: Dario Faggioli <dario.faggioli@citrix.com>
Sorry again for the delay,
Dario
--
<<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)
[-- Attachment #1.2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
[-- Attachment #2: Type: text/plain, Size: 126 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] tools/mfn-dump: Fixes to 'dump-p2m'
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
1 sibling, 1 reply; 5+ messages in thread
From: Andrew Cooper @ 2014-04-29 16:39 UTC (permalink / raw)
To: Dario Faggioli; +Cc: Ian Jackson, Ian Campbell, Xen-devel
[-- Attachment #1.1: Type: text/plain, Size: 1680 bytes --]
On 29/04/14 16:25, Dario Faggioli wrote:
> On gio, 2014-04-24 at 22:06 +0100, Andrew Cooper wrote:
>> * 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.
>>
> 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
[-- Attachment #1.2: Type: text/html, Size: 2314 bytes --]
[-- Attachment #2: Type: text/plain, Size: 126 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] tools/mfn-dump: Fixes to 'dump-p2m'
2014-04-29 16:39 ` Andrew Cooper
@ 2014-04-29 22:35 ` Dario Faggioli
0 siblings, 0 replies; 5+ messages in thread
From: Dario Faggioli @ 2014-04-29 22:35 UTC (permalink / raw)
To: Andrew Cooper; +Cc: Ian Jackson, Ian Campbell, Xen-devel
[-- Attachment #1.1: Type: text/plain, Size: 1411 bytes --]
On mar, 2014-04-29 at 17:39 +0100, Andrew Cooper wrote:
> 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.
>
Right. The fact that such macro is present in xc_domain_save.c was the
exact region why I was asking. :-)
> 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
--
<<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)
[-- Attachment #1.2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
[-- Attachment #2: Type: text/plain, Size: 126 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] tools/mfn-dump: Fixes to 'dump-p2m'
2014-04-29 15:25 ` Dario Faggioli
2014-04-29 16:39 ` Andrew Cooper
@ 2014-05-02 13:04 ` Ian Campbell
1 sibling, 0 replies; 5+ messages in thread
From: Ian Campbell @ 2014-05-02 13:04 UTC (permalink / raw)
To: Dario Faggioli; +Cc: Andrew Cooper, Ian Jackson, Xen-devel
On Tue, 2014-04-29 at 17:25 +0200, Dario Faggioli wrote:
> Reviewed-by: Dario Faggioli <dario.faggioli@citrix.com>
Acked + applied.
^ permalink raw reply [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.