[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH v4 2/6] xen/arm: track the state of guest IRQs



On Thu, 12 Dec 2013, Ian Campbell wrote:
> On Wed, 2013-12-11 at 19:07 +0000, Stefano Stabellini wrote:
> > @@ -916,6 +910,36 @@ static void maintenance_interrupt(int irq, void 
> > *dev_id, struct cpu_user_regs *r
> >              cpu = p->desc->arch.eoi_cpu;
> >              pirq = p->desc->irq;
> >          }
> > +        if ( test_bit(GIC_IRQ_GUEST_PENDING, &p->status) &&
> > +             test_bit(GIC_IRQ_GUEST_ENABLED, &p->status))
> > +        {
> > +            BUG_ON(!list_empty(&p->lr_queue));
> > +
> > +            list_for_each_entry ( iter, &v->arch.vgic.lr_pending, lr_queue 
> > )
> > +            {
> > +                if ( iter->priority > p->priority )
> > +                {
> > +                    list_add_tail(&p->lr_queue, &iter->lr_queue);
> > +                    goto out;
> > +                }
> > +            }
> > +            list_add_tail(&p->lr_queue, &v->arch.vgic.lr_pending);
> > +out:
> 
> Is there really no helper function for all that? It looks very similar
> to the tail of gic_set_guest_irq.

That's a good point, I can add an helper.


> > +            set_int = 1;
> > +        }
> > +
> > +        clear_bit(GIC_IRQ_GUEST_VISIBLE, &p->status);
> > +
> > +        if ( !list_empty(&v->arch.vgic.lr_pending) ) {
> > +            p2 = list_entry(v->arch.vgic.lr_pending.next, typeof(*p2), 
> > lr_queue);
> > +            gic_set_lr(i, p2->irq, GICH_LR_PENDING, p2->priority);
> > +            list_del_init(&p2->lr_queue);
> > +            set_bit(i, &this_cpu(lr_mask));
> > +            set_int = 1;
> > +        }
> > +        spin_unlock_irq(&gic.lock);
> > +
> > +        spin_lock_irq(&v->arch.vgic.lock);
> >          list_del_init(&p->inflight);
> >          spin_unlock_irq(&v->arch.vgic.lock);
> >  
> > @@ -931,6 +955,12 @@ static void maintenance_interrupt(int irq, void 
> > *dev_id, struct cpu_user_regs *r
> >  
> >          i++;
> >      }
> > +    if ( !set_int )
> > +    {
> > +        spin_lock_irq(&gic.lock);
> 
> Dropping the lock and then retaking it here is a bit of a suspicious
> pattern -- what if something changes in the interim?

Vcpu A has EOIed a guest IRQ, causing a maintenance_interrupt.
At the same time vcpu B is trying to inject a new interrupt into the
vcpu A.


A: maintenance_interrupt: set_int = 0
B: create a new inflight irq for A
B: send an IPI
A: receive an IPI
A: gic_inject->gic_inject_irq_start
A: maintenance_interrupt: gic_inject_irq_stop
A: gic_inject->gic_inject_irq_start


It works! :)

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.