From: "Jan Beulich" Subject: Re: [PATCH v4 4/7] xen, common: add the XEN_DOMCTL_memory_mapping hypercall Date: Tue, 25 Mar 2014 15:36:06 +0000 Message-ID: <5331B0760200007800001D90@nat28.tlf.novell.com> References: <1395712976-19454-1-git-send-email-avanzini.arianna@gmail.com> <1395712976-19454-5-git-send-email-avanzini.arianna@gmail.com> <53319C680200007800001C14@nat28.tlf.novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: 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: stefano.stabellini@eu.citrix.com Cc: Ian.Campbell@eu.citrix.com, paolo.valente@unimore.it, keir@xen.org, tim@xen.org, dario.faggioli@citrix.com, Ian.Jackson@eu.citrix.com, xen-devel@lists.xen.org, julien.grall@citrix.com, etrudeau@broadcom.com, Arianna Avanzini , viktor.kleinik@globallogic.com List-Id: xen-devel@lists.xenproject.org >>> On 25.03.14 at 16:10, wrote: > On Tue, 25 Mar 2014, Jan Beulich wrote: >> >>> On 25.03.14 at 13:35, wrote: >> > On Tue, 25 Mar 2014, Arianna Avanzini wrote: >> >> + add = unmap_mmio_regions(d, gfn, gfn_end - 1, mfn); >> >> + ret = iomem_deny_access(d, mfn, mfn_end - 1); >> >> + if ( ret && add ) >> >> + ret = -EIO; >> > >> > This is a functional change. The removed code did: >> > >> > - ret = iomem_deny_access(d, mfn, mfn + nr_mfns - 1); >> > - if ( !ret && add ) >> > - ret = -EIO; >> > >> > The change looks correct to me, but I would appreciate if you could >> > mention it explicitly in the commit message. >> >> I overlooked this, and no, it is not correct (and I don't follow why >> you think it is): We only want to force ret to -EIO if >> iomem_deny_access() didn't already return another error. > > I thought that the intention was to return -EIO if unmap_mmio_regions > failed, even if iomem_deny_access is successful. > iomem_deny_access errors should be taken care by the > iomem_access_permitted check above, returning -EPERM. It certainly doesn't matter _that_ much which error to return here, but code movement shouldn't be done with silent functional changes, the more that the change is buggy beyond altering original behavior: Consider the case of ret = 0 (iomem_deny_access() succeeded) and add = 1 (unmap_mmio_regions() failed) - the failure would be lost with the changed code. Jan