]> xenbits.xensource.com Git - people/vhanquez/xen.git/commitdiff
[TOOLS] Fix pagetable-pinning loop in xc_linux_restore.
authorkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Thu, 22 Jun 2006 13:20:01 +0000 (14:20 +0100)
committerkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Thu, 22 Jun 2006 13:20:01 +0000 (14:20 +0100)
Previously it would not pin last PFN in physmap even if it was
a pagetable page.
Signed-off-by: Keir Fraser <keir@xensource.com>
xen-unstable changeset:   10475:94e354294cca7ce0c4f1b7ae2ec5eb62ddac71ac
xen-unstable date:        Thu Jun 22 14:12:01 2006 +0100

tools/libxc/xc_linux_restore.c

index 9ef994995c8521fcce710b8e06029bf89edb6d17..d3ad4b4a01b1b5154a90c18f47b970fa1156a251 100644 (file)
@@ -545,14 +545,6 @@ int xc_linux_restore(int xc_handle, int io_fd,
     nr_pins = 0; 
     for (i = 0; i < max_pfn; i++) {
 
-        if (i == (max_pfn-1) || nr_pins == MAX_PIN_BATCH) {
-            if (xc_mmuext_op(xc_handle, pin, nr_pins, dom) < 0) { 
-                ERR("Failed to pin batch of %d page tables", nr_pins); 
-                goto out;
-            } 
-            nr_pins = 0;
-        }
-
         if ( (pfn_type[i] & LPINTAB) == 0 )
             continue;
 
@@ -581,6 +573,20 @@ int xc_linux_restore(int xc_handle, int io_fd,
         pin[nr_pins].arg1.mfn = p2m[i];
         nr_pins++; 
 
+        /* Batch full? Then flush. */
+        if (nr_pins == MAX_PIN_BATCH) {
+            if (xc_mmuext_op(xc_handle, pin, nr_pins, dom) < 0) { 
+                ERR("Failed to pin batch of %d page tables", nr_pins); 
+                goto out;
+            } 
+            nr_pins = 0;
+        }
+    }
+
+    /* Flush final partial batch. */
+    if ((nr_pins != 0) && (xc_mmuext_op(xc_handle, pin, nr_pins, dom) < 0)) { 
+        ERR("Failed to pin batch of %d page tables", nr_pins); 
+        goto out;
     }
 
     DPRINTF("\b\b\b\b100%%\n");