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;
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");