unsigned long nval = 0;
va_list args;
- BUG_ON(*id > 5);
- BUG_ON(mask & (1U << *id));
+ BUG_ON(id && *id > 5);
+ BUG_ON(id && (mask & (1U << *id)));
va_start(args, mask);
rc = p2m_pod_set_mem_target(d, target.target_pages);
}
- p2m = p2m_get_hostp2m(d);
- target.tot_pages = d->tot_pages;
- target.pod_cache_pages = p2m->pod.count;
- target.pod_entries = p2m->pod.entry_count;
-
- if ( copy_to_guest(arg, &target, 1) )
+ if ( rc == -EAGAIN )
+ {
+ rc = hypercall_create_continuation(
+ __HYPERVISOR_memory_op, "lh", op, arg);
+ }
+ else if ( rc >= 0 )
{
- rc= -EFAULT;
- goto pod_target_out_unlock;
+ p2m = p2m_get_hostp2m(d);
+ target.tot_pages = d->tot_pages;
+ target.pod_cache_pages = p2m->pod.count;
+ target.pod_entries = p2m->pod.entry_count;
+
+ if ( copy_to_guest(arg, &target, 1) )
+ {
+ rc= -EFAULT;
+ goto pod_target_out_unlock;
+ }
}
pod_target_out_unlock:
/* Set the size of the cache, allocating or freeing as necessary. */
static int
-p2m_pod_set_cache_target(struct p2m_domain *p2m, unsigned long pod_target)
+p2m_pod_set_cache_target(struct p2m_domain *p2m, unsigned long pod_target, int preemptible)
{
struct domain *d = p2m->domain;
int ret = 0;
}
p2m_pod_cache_add(p2m, page, order);
+
+ if ( hypercall_preempt_check() && preemptible )
+ {
+ ret = -EAGAIN;
+ goto out;
+ }
}
/* Decreasing the target */
put_page(page+i);
put_page(page+i);
+
+ if ( hypercall_preempt_check() && preemptible )
+ {
+ ret = -EAGAIN;
+ goto out;
+ }
}
}
ASSERT( pod_target >= p2m->pod.count );
- ret = p2m_pod_set_cache_target(p2m, pod_target);
+ ret = p2m_pod_set_cache_target(p2m, pod_target, 1/*preemptible*/);
out:
p2m_unlock(p2m);
/* If we've reduced our "liabilities" beyond our "assets", free some */
if ( p2m->pod.entry_count < p2m->pod.count )
{
- p2m_pod_set_cache_target(p2m, p2m->pod.entry_count);
+ p2m_pod_set_cache_target(p2m, p2m->pod.entry_count, 0/*can't preempt*/);
}
out_unlock:
if ( rc < 0 )
break;
+ if ( rc == __HYPERVISOR_memory_op )
+ hypercall_xlat_continuation(NULL, 0x2, nat, arg);
+
XLAT_pod_target(&cmp, nat);
if ( copy_to_guest(arg, &cmp, 1) )