From mboxrd@z Thu Jan 1 00:00:00 1970 From: Julien Grall Subject: Re: [RFC 04/19] xen/arm: route_irq_to_guest: Check validity of the IRQ Date: Wed, 18 Jun 2014 20:03:58 +0100 Message-ID: <53A1E29E.9010307@linaro.org> References: <1402935486-29136-1-git-send-email-julien.grall@linaro.org> <1402935486-29136-5-git-send-email-julien.grall@linaro.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; Format="flowed" 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 1WxL9N-0001jS-Rj for xen-devel@lists.xenproject.org; Wed, 18 Jun 2014 19:04:02 +0000 Received: by mail-we0-f176.google.com with SMTP id u56so1292981wes.7 for ; Wed, 18 Jun 2014 12:04:00 -0700 (PDT) In-Reply-To: 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: xen-devel@lists.xenproject.org, stefano.stabellini@citrix.com, ian.campbell@citrix.com, tim@xen.org List-Id: xen-devel@lists.xenproject.org Hi Stefano, On 18/06/14 19:52, Stefano Stabellini wrote: >> +/* Route an IRQ to a specific guest. >> + * For now the vIRQ is equal to the pIRQ and only SPIs are routabled to >> + * the guest. >> + */ >> int route_irq_to_guest(struct domain *d, unsigned int irq, >> const char * devname) >> { >> @@ -369,6 +373,20 @@ int route_irq_to_guest(struct domain *d, unsigned int irq, >> unsigned long flags; >> int retval = 0; >> >> + if ( !is_routable_irq(irq) ) >> + { >> + dprintk(XENLOG_G_ERR, "the IRQ%u is not routable\n", irq); >> + return -EINVAL; >> + } >> + >> + if ( irq > vgic_num_irqs(d) ) >> + { >> + dprintk(XENLOG_G_ERR, >> + "the IRQ number %u is too high for domain %u (max = %u)\n", >> + irq, d->domain_id, vgic_num_irqs(d)); >> + return -EINVAL; >> + } > > I think it makes sense to move the "irq > vgic_num_irqs(d)" check > within is_routable_irq. is_routable_irq checks that Xen is effectively able to route the IRQ to a guest, rather than the check "irq > vgic_num_irqs(d)" is here because we assume a virq == pirq. I suspect we will have to handle virq != pirq sooner or later because allocate 1000 irq_pending structure unconditionally per guest is a waste of memory. Furthermore, I will use it in different place is_routable_irq (see patch #6, #9) where we don't necessary have the domain in hand. Regards, -- Julien Grall