From: "Jan Beulich" Subject: Re: [RFC 0 PATCH 1/3] PVH dom0: create domctl_memory_mapping() function Date: Thu, 26 Sep 2013 08:03:21 +0100 Message-ID: <5243F85902000078000F6965@nat28.tlf.novell.com> References: <1380142988-9487-1-git-send-email-mukesh.rathor@oracle.com> <1380142988-9487-2-git-send-email-mukesh.rathor@oracle.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1VP5bH-0000LC-G9 for xen-devel@lists.xenproject.org; Thu, 26 Sep 2013 07:02:59 +0000 In-Reply-To: <1380142988-9487-2-git-send-email-mukesh.rathor@oracle.com> Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Mukesh Rathor Cc: xen-devel , keir.xen@gmail.com List-Id: xen-devel@lists.xenproject.org >>> On 25.09.13 at 23:03, Mukesh Rathor wrote: > +static long domctl_memory_mapping(struct domain *d, unsigned long gfn, > + unsigned long mfn, unsigned long nr_mfns, > + bool_t add) > +{ > + unsigned long i; > + long ret; > + > + if ( (mfn + nr_mfns - 1) < mfn || /* wrap? */ > + ((mfn | (mfn + nr_mfns - 1)) >> (paddr_bits - PAGE_SHIFT)) || > + (gfn + nr_mfns - 1) < gfn ) /* wrap? */ > + return -EINVAL; > + > + ret = xsm_iomem_mapping(XSM_HOOK, d, mfn, mfn + nr_mfns - 1, add); > + if ( ret ) > + return ret; Sigh - I said this more than once before: The order of the checks in the original code _is_ relevant. You can't move the first and third checks here, but leave the second one there. The way you use it in the later patch, the function is mis-named, and the checks aren't needed for that other case anyway (maybe the XSM one ought to be done, but that's the last check, so can be moved here if necessary). Hence just leave them in the caller (and thus retain their proper order). Jan