Skip to content

Commit 3af9571

Browse files
Zenghui YuMarc Zyngier
authored andcommitted
irqchip/gic-v4.1: Ensure accessing the correct RD when writing INVALLR
The GICv4.1 spec tells us that it's CONSTRAINED UNPREDICTABLE to issue a register-based invalidation operation for a vPEID not mapped to that RD, or another RD within the same CommonLPIAff group. To follow this rule, commit f3a0592 ("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_INVALLR into account. Let's take the vpe_lock before evaluating vpe->col_idx to fix it. Fixes: f3a0592 ("irqchip/gic-v4.1: Ensure mutual exclusion between vPE affinity change and RD access") Signed-off-by: Zenghui Yu <[email protected]> Signed-off-by: Marc Zyngier <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/r/[email protected]
1 parent 9808357 commit 3af9571

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

drivers/irqchip/irq-gic-v3-its.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4079,18 +4079,22 @@ static void its_vpe_4_1_deschedule(struct its_vpe *vpe,
40794079
static void its_vpe_4_1_invall(struct its_vpe *vpe)
40804080
{
40814081
void __iomem *rdbase;
4082+
unsigned long flags;
40824083
u64 val;
4084+
int cpu;
40834085

40844086
val = GICR_INVALLR_V;
40854087
val |= FIELD_PREP(GICR_INVALLR_VPEID, vpe->vpe_id);
40864088

40874089
/* Target the redistributor this vPE is currently known on */
4088-
raw_spin_lock(&gic_data_rdist_cpu(vpe->col_idx)->rd_lock);
4089-
rdbase = per_cpu_ptr(gic_rdists->rdist, vpe->col_idx)->rd_base;
4090+
cpu = vpe_to_cpuid_lock(vpe, &flags);
4091+
raw_spin_lock(&gic_data_rdist_cpu(cpu)->rd_lock);
4092+
rdbase = per_cpu_ptr(gic_rdists->rdist, cpu)->rd_base;
40904093
gic_write_lpir(val, rdbase + GICR_INVALLR);
40914094

40924095
wait_for_syncr(rdbase);
4093-
raw_spin_unlock(&gic_data_rdist_cpu(vpe->col_idx)->rd_lock);
4096+
raw_spin_unlock(&gic_data_rdist_cpu(cpu)->rd_lock);
4097+
vpe_to_cpuid_unlock(vpe, flags);
40944098
}
40954099

40964100
static int its_vpe_4_1_set_vcpu_affinity(struct irq_data *d, void *vcpu_info)

0 commit comments

Comments
 (0)