]> xenbits.xensource.com Git - xen.git/commitdiff
domctl: don't truncate XEN_DOMCTL_max_mem requests
authorJan Beulich <jbeulich@suse.com>
Tue, 5 May 2015 16:00:03 +0000 (18:00 +0200)
committerJan Beulich <jbeulich@suse.com>
Tue, 5 May 2015 16:00:03 +0000 (18:00 +0200)
Instead saturate the value if the input can't be represented in the
respective struct domain field.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Tim Deegan <tim@xen.org>
xen/common/domctl.c

index 28aea55f44bc208814409e88b8ad39920ca1ad17..e571e762bc667d732275f763e0a4c7e64291bb96 100644 (file)
@@ -946,7 +946,7 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl)
 
     case XEN_DOMCTL_max_mem:
     {
-        unsigned long new_max = op->u.max_mem.max_memkb >> (PAGE_SHIFT - 10);
+        uint64_t new_max = op->u.max_mem.max_memkb >> (PAGE_SHIFT - 10);
 
         spin_lock(&d->page_alloc_lock);
         /*
@@ -954,7 +954,7 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl)
          * that the domain will now be allowed to "ratchet" down to new_max. In
          * the meantime, while tot > max, all new allocations are disallowed.
          */
-        d->max_pages = new_max;
+        d->max_pages = min(new_max, (uint64_t)(typeof(d->max_pages))-1);
         spin_unlock(&d->page_alloc_lock);
         break;
     }