|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH] arm/gicv3: Fix deadlock in gicv3_set_affinity()
On Mon Nov 30, 2026 at 4:01 PM CET, Orzel, Michal wrote:
>
>
> On 26-Nov-26 17:38, Alejandro Vallejo wrote:
> > gicv3_irq_set_affinity() acquires the gicv3 lock with a bare spin_lock()
> > with IRQs on from arch_move_irqs(). This happens when a vCPU with
> > physical IRQs routed to it changes pCPU. The same function is called
> > with IRQs off from vgic_migrate_irq().
> >
> > If the wrong interrupt arrives while moving IRQs, Xen would re-lock
> > the mutex, but it'll never succeed because it's already locked in the
> > interrupted thread of that very pCPU.
> >
> > Have gicv3_irq_set_affinity() use spin_lock_irqsave() instead to avoid
> > the deadly embrace.
> >
> > Fixes: bc183a0235e0 ("xen/arm: Add support for GIC v3")
> > Signed-off-by: Alejandro Vallejo <alejandro.garciavallejo@xxxxxxx>
> > ---
> > xen/arch/arm/gic-v3.c | 5 +++--
> > 1 file changed, 3 insertions(+), 2 deletions(-)
> >
> > diff --git a/xen/arch/arm/gic-v3.c b/xen/arch/arm/gic-v3.c
> > index cca49d2a2a..ec1e341f2e 100644
> > --- a/xen/arch/arm/gic-v3.c
> > +++ b/xen/arch/arm/gic-v3.c
> > @@ -1463,6 +1463,7 @@ static void gicv3_irq_set_affinity(struct irq_desc
> > *desc, const cpumask_t *mask)
> > unsigned int cpu;
> > uint64_t affinity;
> > void __iomem *addr;
> > + unsigned long flags;
> >
> > if ( desc->irq < NR_GIC_LOCAL_IRQS )
> > return;
> > @@ -1473,7 +1474,7 @@ static void gicv3_irq_set_affinity(struct irq_desc
> > *desc, const cpumask_t *mask)
> >
> > ASSERT(!cpumask_empty(mask));
> >
> > - spin_lock(&gicv3.lock);
> > + spin_lock_irqsave(&gicv3.lock, flags);
> >
> > cpu = gicv3_get_cpu_from_mask(mask);
> > affinity = gicv3_mpidr_to_affinity(cpu);
> > @@ -1481,7 +1482,7 @@ static void gicv3_irq_set_affinity(struct irq_desc
> > *desc, const cpumask_t *mask)
> > affinity &= ~GICD_IROUTER_SPI_MODE_ANY;
> > writeq_relaxed_non_atomic(affinity, addr);
> >
> > - spin_unlock(&gicv3.lock);
> > + spin_unlock_irqrestore(&gicv3.lock, flags);
> > }
> >
> > static int gicv3_make_hwdom_dt_node(const struct domain *d,
> >
> > base-commit: 1208df803530bb885419627ab36a43313b98ce5c
>
> gicv2_irq_set_affinity() has the same problem.
True, I only looked at v3.
>
> Shouldn't arch_move_irqs() be fixed instead? It is the only
> irq_set_affinity() caller running with IRQs on. All the others hold a lock
> taken with irqsave. Fixing the caller would cover both GICs.
Works for me. Let me send a v2.
Cheers,
Alejandro
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |