From: "Jan Beulich" Subject: Re: [PATCH for-4.5] call xc_domain_irq_permission before xc_domain_irq_permission Date: Tue, 02 Dec 2014 09:57:09 +0000 Message-ID: <547D9B05020000780004C07B@mail.emea.novell.com> References: <4610426124.20141126210436@eikelenboom.it> <20141128164935.GA17910@zion.uk.xensource.com> <20141128170116.GB17910@zion.uk.xensource.com> <1868834068.20141128184004@eikelenboom.it> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XvkCm-0000e3-74 for xen-devel@lists.xenproject.org; Tue, 02 Dec 2014 09:57:12 +0000 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 Cc: Ian Jackson , linux@eikelenboom.it, Wei Liu , Ian Campbell , xen-devel List-Id: xen-devel@lists.xenproject.org >>> On 01.12.14 at 20:22, wrote: > xc_physdev_unmap_pirq might revoke the permission to map the irq from > the domain causing the following xc_domain_irq_permission call to fail > and return error (domain_pirq_to_irq returns 0). Apart from the patch title being rather confusing, isn't the root problem then xc_physdev_unmap_pirq() removes permissions? At least after the strict splitting of permission granting and mapping for MMIO (commit 0561e1f0) it would seem that if the underlying hypercall here behaves similarly to the original behavior there, it ought to be fixed in an analogous way. Jan > Call xc_domain_irq_permission first to prevent this from happening > (xc_physdev_unmap_pirq calls irq_deny_access, that doesn't fail if the > permission is already removed). > > This is a simple bug fix and I think should go in 4.5. > > Signed-off-by: Stefano Stabellini > > diff --git a/tools/libxl/libxl_pci.c b/tools/libxl/libxl_pci.c > index 316643c..904d255 100644 > --- a/tools/libxl/libxl_pci.c > +++ b/tools/libxl/libxl_pci.c > @@ -1288,14 +1290,14 @@ skip1: > goto out; > } > if ((fscanf(f, "%u", &irq) == 1) && irq) { > - rc = xc_physdev_unmap_pirq(ctx->xch, domid, irq); > - if (rc < 0) { > - LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, > "xc_physdev_unmap_pirq irq=%d", irq); > - } > rc = xc_domain_irq_permission(ctx->xch, domid, irq, 0); > if (rc < 0) { > LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, > "xc_domain_irq_permission irq=%d", irq); > } > + rc = xc_physdev_unmap_pirq(ctx->xch, domid, irq); > + if (rc < 0) { > + LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, > "xc_physdev_unmap_pirq irq=%d", irq); > + } > } > fclose(f); > } > > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xen.org > http://lists.xen.org/xen-devel