public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] irqchipi/gic-v4: Ensure accessing the correct RD when and writing INVLPIR
@ 2023-04-12  4:15 Kunkun Jiang
  2023-04-12  9:42 ` Marc Zyngier
  0 siblings, 1 reply; 9+ messages in thread
From: Kunkun Jiang @ 2023-04-12  4:15 UTC (permalink / raw)
  To: Thomas Gleixner, Marc Zyngier, Zenghui Yu,
	open list:IRQCHIP DRIVERS
  Cc: wanghaibin.wang, Kunkun Jiang, chenxiang66, tangnianyao

commit f3a059219bc7 ("irqchip/gic-v4.1: Ensure mutual exclusion between
vPE affinity change and RD access") tried to address the race
between the RD accesses and the vPE affinity change, but somehow
forgot to take GICR_INVLPIR into account. Let's take the vpe_lock
before evaluating vpe->col_idx to fix it.

Fixes: f3a059219bc7 ("irqchip/gic-v4.1: Ensure mutual exclusion between vPE affinity change and RD access")
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
Signed-off-by: Nianyao Tang <tangnianyao@huawei.com>
---
 drivers/irqchip/irq-gic-v3-its.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c
index 586271b8aa39..041f06922587 100644
--- a/drivers/irqchip/irq-gic-v3-its.c
+++ b/drivers/irqchip/irq-gic-v3-its.c
@@ -3943,13 +3943,17 @@ static void its_vpe_send_inv(struct irq_data *d)
 
 	if (gic_rdists->has_direct_lpi) {
 		void __iomem *rdbase;
+		unsigned long flags;
+		int cpu;
 
 		/* Target the redistributor this VPE is currently known on */
-		raw_spin_lock(&gic_data_rdist_cpu(vpe->col_idx)->rd_lock);
-		rdbase = per_cpu_ptr(gic_rdists->rdist, vpe->col_idx)->rd_base;
+		cpu = vpe_to_cpuid_lock(vpe, &flags);
+		raw_spin_lock(&gic_data_rdist_cpu(cpu)->rd_lock);
+		rdbase = per_cpu_ptr(gic_rdists->rdist, cpu)->rd_base;
 		gic_write_lpir(d->parent_data->hwirq, rdbase + GICR_INVLPIR);
 		wait_for_syncr(rdbase);
-		raw_spin_unlock(&gic_data_rdist_cpu(vpe->col_idx)->rd_lock);
+		raw_spin_unlock(&gic_data_rdist_cpu(cpu)->rd_lock);
+		vpe_to_cpuid_unlock(vpe, flags);
 	} else {
 		its_vpe_send_cmd(vpe, its_send_inv);
 	}
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2023-06-30 10:55 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-12  4:15 [PATCH] irqchipi/gic-v4: Ensure accessing the correct RD when and writing INVLPIR Kunkun Jiang
2023-04-12  9:42 ` Marc Zyngier
     [not found]   ` <f618c540-879c-ca5b-31af-e55472d8208c@huawei.com>
2023-04-13  7:35     ` Marc Zyngier
2023-05-16 10:15     ` Marc Zyngier
2023-05-16 12:01       ` Kunkun Jiang
2023-06-17  7:02         ` Marc Zyngier
2023-06-17  7:35         ` Marc Zyngier
2023-06-21 12:30           ` Kunkun Jiang
2023-06-30 10:37             ` Kunkun Jiang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox