[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [RFC 04/19] xen/arm: route_irq_to_guest: Check validity of the IRQ
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 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |