From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Cooper Subject: Re: [PATCH] domctl: don't truncate XEN_DOMCTL_max_mem requests Date: Wed, 22 Apr 2015 13:03:01 +0100 Message-ID: <55378DF5.7020001@citrix.com> References: <5537A8700200007800074B0B@mail.emea.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============8009233118053562224==" Return-path: Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YktN0-0006vd-3O for xen-devel@lists.xenproject.org; Wed, 22 Apr 2015 12:03:10 +0000 In-Reply-To: <5537A8700200007800074B0B@mail.emea.novell.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Jan Beulich , xen-devel Cc: Ian Campbell , Ian Jackson , Keir Fraser , Tim Deegan List-Id: xen-devel@lists.xenproject.org --===============8009233118053562224== Content-Type: multipart/alternative; boundary="------------080603000807030205040908" --------------080603000807030205040908 Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit On 22/04/15 12:56, Jan Beulich wrote: > Instead saturate the value if the input can't be represented in the > respective struct domain field. > > Signed-off-by: Jan Beulich Reviewed-by: Andrew Cooper Do I take it you have a 16TB guest to hand? > > --- 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; > } > > > > > > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xen.org > http://lists.xen.org/xen-devel --------------080603000807030205040908 Content-Type: text/html; charset="windows-1252" Content-Transfer-Encoding: 7bit
On 22/04/15 12:56, Jan Beulich wrote:
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>

Do I take it you have a 16TB guest to hand?


--- 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;
     }





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

--------------080603000807030205040908-- --===============8009233118053562224== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --===============8009233118053562224==--