ia64/xen-unstable

changeset 10507:94e354294cca

[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 <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Thu Jun 22 14:12:01 2006 +0100 (2006-06-22)
parents 12aaf4a2486b
children c2e8e9b1e192
files tools/libxc/xc_linux_restore.c
line diff
     1.1 --- a/tools/libxc/xc_linux_restore.c	Wed Jun 21 17:09:14 2006 +0100
     1.2 +++ b/tools/libxc/xc_linux_restore.c	Thu Jun 22 14:12:01 2006 +0100
     1.3 @@ -572,18 +572,10 @@ int xc_linux_restore(int xc_handle, int 
     1.4      nr_pins = 0;
     1.5      for (i = 0; i < max_pfn; i++) {
     1.6  
     1.7 -        if (i == (max_pfn-1) || nr_pins == MAX_PIN_BATCH) {
     1.8 -            if (xc_mmuext_op(xc_handle, pin, nr_pins, dom) < 0) {
     1.9 -                ERR("Failed to pin batch of %d page tables", nr_pins);
    1.10 -                goto out;
    1.11 -            }
    1.12 -            nr_pins = 0;
    1.13 -        }
    1.14 -
    1.15          if ( (pfn_type[i] & LPINTAB) == 0 )
    1.16              continue;
    1.17  
    1.18 -        switch(pfn_type[i]) {
    1.19 +        switch (pfn_type[i]) {
    1.20  
    1.21          case (L1TAB|LPINTAB):
    1.22              pin[nr_pins].cmd = MMUEXT_PIN_L1_TABLE;
    1.23 @@ -608,6 +600,20 @@ int xc_linux_restore(int xc_handle, int 
    1.24          pin[nr_pins].arg1.mfn = p2m[i];
    1.25          nr_pins++;
    1.26  
    1.27 +        /* Batch full? Then flush. */
    1.28 +        if (nr_pins == MAX_PIN_BATCH) {
    1.29 +            if (xc_mmuext_op(xc_handle, pin, nr_pins, dom) < 0) {
    1.30 +                ERR("Failed to pin batch of %d page tables", nr_pins);
    1.31 +                goto out;
    1.32 +            }
    1.33 +            nr_pins = 0;
    1.34 +        }
    1.35 +    }
    1.36 +
    1.37 +    /* Flush final partial batch. */
    1.38 +    if ((nr_pins != 0) && (xc_mmuext_op(xc_handle, pin, nr_pins, dom) < 0)) {
    1.39 +        ERR("Failed to pin batch of %d page tables", nr_pins);
    1.40 +        goto out;
    1.41      }
    1.42  
    1.43      DPRINTF("\b\b\b\b100%%\n");