From: Zhou Wang <wangzhou1@hisilicon.com>
To: Marc Zyngier <maz@kernel.org>, <linux-kernel@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH] irqchip/gic-v4: Fix ordering between vmapp and vpe locks
Date: Wed, 24 Jul 2024 09:26:13 +0800 [thread overview]
Message-ID: <d1a90045-887c-d339-46fc-003fb72742e8@hisilicon.com> (raw)
In-Reply-To: <20240723175203.3193882-1-maz@kernel.org>
On 2024/7/24 1:52, Marc Zyngier wrote:
> The (recently established) lock ordering mandates that the per-VM
> vmapp_lock is acquired before we take the per-VPE lock.
>
> As it turns out, its_vpe_set_affinity() takes the VPE lock, and
> then calls into its_send_vmovp(), which itself takes the vmapp
> lock. Obviously, this isn't what we want.
>
> As its_send_vmovp() is only called from its_vpe_set_affinity(),
> hoist the vmapp locking from the former into the latter, restoring
> the expected order.
>
> Fixes: f0eb154c39471 ("irqchip/gic-v4: Substitute vmovp_lock for a per-VM lock")
> Reported-by: Zhou Wang <wangzhou1@hisilicon.com>
Hi Marc,
Tested-by: Zhou Wang <wangzhou1@hisilicon.com>
Thanks,
Zhou
> Signed-off-by: Marc Zyngier <maz@kernel.org>
> ---
> drivers/irqchip/irq-gic-v3-its.c | 18 +++++++++++-------
> 1 file changed, 11 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c
> index 951ec140bcea2..b88c6011c8771 100644
> --- a/drivers/irqchip/irq-gic-v3-its.c
> +++ b/drivers/irqchip/irq-gic-v3-its.c
> @@ -1328,12 +1328,6 @@ static void its_send_vmovp(struct its_vpe *vpe)
> return;
> }
>
> - /*
> - * Protect against concurrent updates of the mapping state on
> - * individual VMs.
> - */
> - guard(raw_spinlock_irqsave)(&vpe->its_vm->vmapp_lock);
> -
> /*
> * Yet another marvel of the architecture. If using the
> * its_list "feature", we need to make sure that all ITSs
> @@ -3808,7 +3802,7 @@ static int its_vpe_set_affinity(struct irq_data *d,
> struct its_vpe *vpe = irq_data_get_irq_chip_data(d);
> unsigned int from, cpu = nr_cpu_ids;
> struct cpumask *table_mask;
> - unsigned long flags;
> + unsigned long flags, vmapp_flags;
>
> /*
> * Changing affinity is mega expensive, so let's be as lazy as
> @@ -3822,7 +3816,14 @@ static int its_vpe_set_affinity(struct irq_data *d,
> * protect us, and that we must ensure nobody samples vpe->col_idx
> * during the update, hence the lock below which must also be
> * taken on any vLPI handling path that evaluates vpe->col_idx.
> + *
> + * Finally, we must protect ourselves against concurrent
> + * updates of the mapping state on this VM should the ITS list
> + * be in use.
> */
> + if (its_list_map)
> + raw_spin_lock_irqsave(&vpe->its_vm->vmapp_lock, vmapp_flags);
> +
> from = vpe_to_cpuid_lock(vpe, &flags);
> table_mask = gic_data_rdist_cpu(from)->vpe_table_mask;
>
> @@ -3852,6 +3853,9 @@ static int its_vpe_set_affinity(struct irq_data *d,
> irq_data_update_effective_affinity(d, cpumask_of(cpu));
> vpe_to_cpuid_unlock(vpe, flags);
>
> + if (its_list_map)
> + raw_spin_unlock_irqrestore(&vpe->its_vm->vmapp_lock, vmapp_flags);
> +
> return IRQ_SET_MASK_OK_DONE;
> }
>
next prev parent reply other threads:[~2024-07-24 1:26 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-23 17:52 Marc Zyngier
2024-07-24 1:26 ` Zhou Wang [this message]
2024-07-26 20:52 ` Thomas Gleixner
2024-07-28 9:42 ` Marc Zyngier
2024-07-29 7:25 ` Marc Zyngier
2024-07-29 9:48 ` Thomas Gleixner
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=d1a90045-887c-d339-46fc-003fb72742e8@hisilicon.com \
--to=wangzhou1@hisilicon.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maz@kernel.org \
--cc=tglx@linutronix.de \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®