libxc: fix incorrect scanning of pfn array in pagebuf during migration
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
@@ -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 */
Quoted 15 lines · Shriram Rajagopalan
# HG changeset patch
# User Shriram Rajagopalan <[email protected]>
# Date 1298664774 28800
# Node ID739f8bfeb96f92ae6d15ea983ba2b46543dc6a5c
# Parentf16d772fdb6c58518299d4c3780b846bcbee6165
libxc: fix incorrect scanning of pfn array in pagebuf during migrationxc_domain_restore.c:apply_batch function makes two passes over the
pfn_typesarray in pagebuf to allocate the needed MFNs. The curbatch parameter to this function specifies the array offset inpfn_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_restorefails due to corrupt guest page tables.
Quoted 1 line
Signed-off-by Shriram Rajagopalan <[email protected]>
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-r739f8bfeb96ftools/libxc/xc_domain_restore.ctools/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
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
Acked-by Ian Campbell <[email protected]>
Thanks to both of you, I have added my own ack and applied this.
Ian.