All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Orzel, Michal" <michal.orzel@amd.com>
To: Alejandro Vallejo <alejandro.garciavallejo@amd.com>,
	<xen-devel@lists.xenproject.org>
Cc: Stefano Stabellini <sstabellini@kernel.org>,
	Julien Grall <julien@xen.org>,
	Bertrand Marquis <bertrand.marquis@arm.com>,
	"Volodymyr Babchuk" <Volodymyr_Babchuk@epam.com>
Subject: Re: [PATCH] arm/gicv3: Fix deadlock in gicv3_set_affinity()
Date: Mon, 30 Nov 2026 16:01:43 +0100	[thread overview]
Message-ID: <93b2d668-2e57-46ca-87de-8ab9908cac8b@amd.com> (raw)
In-Reply-To: <20261126163828.4051516-1-alejandro.garciavallejo@amd.com>



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@amd.com>
> ---
>  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.

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.

~Michal


  reply	other threads:[~2026-11-30 15:02 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-26 16:38 [PATCH] arm/gicv3: Fix deadlock in gicv3_set_affinity() Alejandro Vallejo
2026-11-30 15:01 ` Orzel, Michal [this message]
2026-11-30 18:56   ` Alejandro Vallejo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=93b2d668-2e57-46ca-87de-8ab9908cac8b@amd.com \
    --to=michal.orzel@amd.com \
    --cc=Volodymyr_Babchuk@epam.com \
    --cc=alejandro.garciavallejo@amd.com \
    --cc=bertrand.marquis@arm.com \
    --cc=julien@xen.org \
    --cc=sstabellini@kernel.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.