Skip to contentSkip to conversation

libxc: fix incorrect scanning of pfn array in pagebuf during migration

PATCH In review Shriram Rajagopalan 3 participants 3 messages Feb 25, 2011 – Mar 3, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libxc: fix incorrect scanning of pfn array in pagebuf during migration

# HG changeset patch
# User Shriram Rajagopalan <[email protected]>
# Date 1298664774 28800
# Node ID 739f8bfeb96f92ae6d15ea983ba2b46543dc6a5c
# Parent f16d772fdb6c58518299d4c3780b846bcbee6165
libxc: fix incorrect scanning of pfn array in pagebuf during migration

xc_domain_restore.c:apply_batch function makes two passes over the pfn_types array in pagebuf to allocate the needed MFNs. The curbatch parameter to this function specifies the array offset in pfn_types, from where the current scan should begin. But this variable is not taken into account (index always starts at 0) during the two passes. While this [bug] does not manifest itsef during save/restore or live migration, under Remus, xc_domain_restore fails due to corrupt guest page tables.

tools/libxc/xc_domain_restore.c +4 -4
diff -r f16d772fdb6c -r 739f8bfeb96f tools/libxc/xc_domain_restore.c
@@ -907,8 +907,8 @@
     for ( i = 0; i < j; i++ )
     {
         unsigned long pfn, pagetype;
-        pfn      = pagebuf->pfn_types[i] & ~XEN_DOMCTL_PFINFO_LTAB_MASK;
-        pagetype = pagebuf->pfn_types[i] &  XEN_DOMCTL_PFINFO_LTAB_MASK;
+        pfn      = pagebuf->pfn_types[i + curbatch] & ~XEN_DOMCTL_PFINFO_LTAB_MASK;
+        pagetype = pagebuf->pfn_types[i + curbatch] &  XEN_DOMCTL_PFINFO_LTAB_MASK;
 
         if ( (pagetype != XEN_DOMCTL_PFINFO_XTAB) && 
              (ctx->p2m[pfn] == INVALID_P2M_ENTRY) )
@@ -934,8 +934,8 @@
     for ( i = 0; i < j; i++ )
     {
         unsigned long pfn, pagetype;
-        pfn      = pagebuf->pfn_types[i] & ~XEN_DOMCTL_PFINFO_LTAB_MASK;
-        pagetype = pagebuf->pfn_types[i] &  XEN_DOMCTL_PFINFO_LTAB_MASK;
+        pfn      = pagebuf->pfn_types[i + curbatch] & ~XEN_DOMCTL_PFINFO_LTAB_MASK;
+        pagetype = pagebuf->pfn_types[i + curbatch] &  XEN_DOMCTL_PFINFO_LTAB_MASK;
 
         if ( pagetype == XEN_DOMCTL_PFINFO_XTAB )
             region_mfn[i] = ~0UL; /* map will fail but we don't care */
Acked-by on v1 1/1
#1 lore raw
Quoted 15 lines · Shriram Rajagopalan

# HG changeset patch
# User Shriram Rajagopalan <[email protected]>
# Date 1298664774 28800
# Node ID 739f8bfeb96f92ae6d15ea983ba2b46543dc6a5c
# Parent f16d772fdb6c58518299d4c3780b846bcbee6165
libxc: fix incorrect scanning of pfn array in pagebuf during migration

xc_domain_restore.c:apply_batch function makes two passes over the pfn_types array in pagebuf to allocate the needed MFNs. The curbatch parameter to this function specifies the array offset in pfn_types, from where the current scan should begin. But this variable is not taken into account (index always starts at 0) during the two passes. While this [bug] does not manifest itsef during save/restore or live migration, under Remus, xc_domain_restore fails due to corrupt guest page tables.

Quoted 1 line

Appears to have been broken by 21588:6c3d8aec202d which reverted two changesets from before Remus support was added and hence reintroduced some none-Remus compatible bits.

Quoted 31 lines

diff -r f16d772fdb6c -r 739f8bfeb96f tools/libxc/xc_domain_restore.c

tools/libxc/xc_domain_restore.c +4 -4
@@ -907,8 +907,8 @@
     for ( i = 0; i < j; i++ )
     {
         unsigned long pfn, pagetype;
-        pfn      = pagebuf->pfn_types[i] & ~XEN_DOMCTL_PFINFO_LTAB_MASK;
-        pagetype = pagebuf->pfn_types[i] &  XEN_DOMCTL_PFINFO_LTAB_MASK;
+        pfn      = pagebuf->pfn_types[i + curbatch] & ~XEN_DOMCTL_PFINFO_LTAB_MASK;
+        pagetype = pagebuf->pfn_types[i + curbatch] &  XEN_DOMCTL_PFINFO_LTAB_MASK;
 
         if ( (pagetype != XEN_DOMCTL_PFINFO_XTAB) && 
              (ctx->p2m[pfn] == INVALID_P2M_ENTRY) )
@@ -934,8 +934,8 @@
     for ( i = 0; i < j; i++ )
     {
         unsigned long pfn, pagetype;
-        pfn      = pagebuf->pfn_types[i] & ~XEN_DOMCTL_PFINFO_LTAB_MASK;
-        pagetype = pagebuf->pfn_types[i] &  XEN_DOMCTL_PFINFO_LTAB_MASK;
+        pfn      = pagebuf->pfn_types[i + curbatch] & ~XEN_DOMCTL_PFINFO_LTAB_MASK;
+        pagetype = pagebuf->pfn_types[i + curbatch] &  XEN_DOMCTL_PFINFO_LTAB_MASK;
 
         if ( pagetype == XEN_DOMCTL_PFINFO_XTAB )
             region_mfn[i] = ~0UL; /* map will fail but we don't care */

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#2 lore raw

Ian Campbell writes ("Re: [Xen-devel] [PATCH] libxc: fix incorrect scanning of pfn array in pagebuf during migration"):

Quoted 2 lines · Shriram Rajagopalan
Quoted 1 line

libxc: fix incorrect scanning of pfn array in pagebuf during migration

...

Quoted 1 line

Thanks to both of you, I have added my own ack and applied this.

Ian.