From: "Jan Beulich" Subject: [PATCH] domctl: don't truncate XEN_DOMCTL_max_mem requests Date: Wed, 22 Apr 2015 12:56:00 +0100 Message-ID: <5537A8700200007800074B0B@mail.emea.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__PartC6F2A940.1__=" Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YktG8-0006bH-0k for xen-devel@lists.xenproject.org; Wed, 22 Apr 2015 11:56:04 +0000 List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel Cc: Ian Campbell , Keir Fraser , Ian Jackson , Tim Deegan List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__PartC6F2A940.1__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Instead saturate the value if the input can't be represented in the respective struct domain field. Signed-off-by: Jan Beulich --- a/xen/common/domctl.c +++ b/xen/common/domctl.c @@ -944,7 +944,7 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xe =20 case XEN_DOMCTL_max_mem: { - unsigned long new_max =3D op->u.max_mem.max_memkb >> (PAGE_SHIFT = - 10); + uint64_t new_max =3D op->u.max_mem.max_memkb >> (PAGE_SHIFT - = 10); =20 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 =3D new_max; + d->max_pages =3D min(new_max, (uint64_t)(typeof(d->max_pages))-1);= spin_unlock(&d->page_alloc_lock); break; } --=__PartC6F2A940.1__= Content-Type: text/plain; name="domctl-max-mem-saturation.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="domctl-max-mem-saturation.patch" domctl: don't truncate XEN_DOMCTL_max_mem requests=0A=0AInstead saturate = the value if the input can't be represented in the=0Arespective struct = domain field.=0A=0ASigned-off-by: Jan Beulich =0A=0A--- = a/xen/common/domctl.c=0A+++ b/xen/common/domctl.c=0A@@ -944,7 +944,7 @@ = long do_domctl(XEN_GUEST_HANDLE_PARAM(xe=0A =0A case XEN_DOMCTL_max_mem= :=0A {=0A- unsigned long new_max =3D op->u.max_mem.max_memkb >> = (PAGE_SHIFT - 10);=0A+ uint64_t new_max =3D op->u.max_mem.max_memkb = >> (PAGE_SHIFT - 10);=0A =0A spin_lock(&d->page_alloc_lock);=0A = /*=0A@@ -952,7 +952,7 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xe=0A = * that the domain will now be allowed to "ratchet" down to = new_max. In=0A * the meantime, while tot > max, all new allocation= s are disallowed.=0A */=0A- d->max_pages =3D new_max;=0A+ = d->max_pages =3D min(new_max, (uint64_t)(typeof(d->max_pages))-1);=0A= spin_unlock(&d->page_alloc_lock);=0A break;=0A }=0A --=__PartC6F2A940.1__= 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 --=__PartC6F2A940.1__=--