From: kaf24@firebug.cl.cam.ac.uk Date: Thu, 22 Jun 2006 13:12:01 +0000 (+0100) Subject: [TOOLS] Fix pagetable-pinning loop in xc_linux_restore. X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~15921^2~5 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=c772fee4856d7eed19b94914178b707f548ee31f;p=xen.git [TOOLS] Fix pagetable-pinning loop in xc_linux_restore. Previously it would not pin last PFN in physmap even if it was a pagetable page. Signed-off-by: Keir Fraser --- diff --git a/tools/libxc/xc_linux_restore.c b/tools/libxc/xc_linux_restore.c index 88b60fe329..ad1d916d55 100644 --- a/tools/libxc/xc_linux_restore.c +++ b/tools/libxc/xc_linux_restore.c @@ -572,18 +572,10 @@ 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; - switch(pfn_type[i]) { + switch (pfn_type[i]) { case (L1TAB|LPINTAB): pin[nr_pins].cmd = MMUEXT_PIN_L1_TABLE; @@ -608,6 +600,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");