From: "Jan Beulich" Subject: Re: [V1 PATCH 3/3] P2M error code propogation Date: Wed, 09 Apr 2014 10:19:25 +0100 Message-ID: <53452CBD020000780000709E@nat28.tlf.novell.com> References: <1397008058-31504-1-git-send-email-mukesh.rathor@oracle.com> <1397008058-31504-4-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.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WXofK-00088M-6V for xen-devel@lists.xenproject.org; Wed, 09 Apr 2014 09:19:30 +0000 In-Reply-To: <1397008058-31504-4-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: kevin.tian@intel.com, George.Dunlap@eu.citrix.com, tim@xen.org, eddie.dong@intel.com, keir.xen@gmail.com, jun.nakajima@intel.com, xen-devel@lists.xenproject.org List-Id: xen-devel@lists.xenproject.org >>> On 09.04.14 at 03:47, wrote: > @@ -690,20 +689,22 @@ long arch_do_domctl( > } > else > { > + int tmp_rc; Blank line after declarations please. > printk(XENLOG_G_INFO > "memory_map:remove: dom%d gfn=%lx mfn=%lx nr=%lx\n", > d->domain_id, gfn, mfn, nr_mfns); > > if ( paging_mode_translate(d) ) > for ( i = 0; i < nr_mfns; i++ ) > - add |= !clear_mmio_p2m_entry(d, gfn + i); > - ret = iomem_deny_access(d, mfn, mfn + nr_mfns - 1); > - if ( !ret && add ) > - ret = -EIO; > + if ( (tmp_rc = clear_mmio_p2m_entry(d, gfn + i)) ) > + ret = tmp_rc; > + tmp_rc = iomem_deny_access(d, mfn, mfn + nr_mfns - 1); > + if ( !ret && tmp_rc ) > + ret = tmp_rc; > if ( ret && is_hardware_domain(current->domain) ) > printk(XENLOG_ERR > "memory_map: error %ld %s dom%d access to [%lx,%lx]\n", > - ret, add ? "removing" : "denying", d->domain_id, > + ret, tmp_rc ? "denying" : "removing", d->domain_id, This isn't functionally identical to the old code. > @@ -753,7 +750,7 @@ set_mmio_p2m_entry(struct domain *d, unsigned long gfn, > mfn_t mfn) > struct p2m_domain *p2m = p2m_get_hostp2m(d); > > if ( !paging_mode_translate(d) ) > - return 0; > + return -EPERM; I think EPERM isn't quite right here, the (elsewhere) previously resulting EIO would seem more appropriate. Same further down obviously. > @@ -1401,11 +1398,8 @@ long p2m_set_mem_access(struct domain *d, unsigned long pfn, uint32_t nr, > for ( pfn += start; nr > start; ++pfn ) > { > mfn = p2m->get_entry(p2m, pfn, &t, &_a, 0, NULL); > - if ( p2m->set_entry(p2m, pfn, mfn, PAGE_ORDER_4K, t, a) == 0 ) > - { > - rc = -ENOMEM; > + if ( (rc = p2m->set_entry(p2m, pfn, mfn, PAGE_ORDER_4K, t, a)) ) > break; I think constructs like this, namely to the somewhat odd "requirement" of needing to add an extra pair of parentheses around the assignment to avoid a compiler warning, would benefit from being split into assignment and separate if(). Jan