All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] domctl: don't truncate XEN_DOMCTL_max_mem requests
@ 2015-04-22 11:56 Jan Beulich
  2015-04-22 12:03 ` Andrew Cooper
  2015-05-04  7:49 ` Ping: " Jan Beulich
  0 siblings, 2 replies; 5+ messages in thread
From: Jan Beulich @ 2015-04-22 11:56 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Campbell, Keir Fraser, Ian Jackson, Tim Deegan

[-- Attachment #1: Type: text/plain, Size: 947 bytes --]

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>

--- a/xen/common/domctl.c
+++ b/xen/common/domctl.c
@@ -944,7 +944,7 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xe
 
     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);
         /*
@@ -952,7 +952,7 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xe
          * 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;
     }




[-- Attachment #2: domctl-max-mem-saturation.patch --]
[-- Type: text/plain, Size: 995 bytes --]

domctl: don't truncate XEN_DOMCTL_max_mem requests

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>

--- a/xen/common/domctl.c
+++ b/xen/common/domctl.c
@@ -944,7 +944,7 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xe
 
     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);
         /*
@@ -952,7 +952,7 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xe
          * 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;
     }

[-- Attachment #3: Type: text/plain, Size: 126 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-05-04 14:14 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-22 11:56 [PATCH] domctl: don't truncate XEN_DOMCTL_max_mem requests Jan Beulich
2015-04-22 12:03 ` Andrew Cooper
2015-04-22 12:08   ` Jan Beulich
2015-05-04  7:49 ` Ping: " Jan Beulich
2015-05-04 14:14   ` Tim Deegan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.