irqchip/gic-v4.1: Ensure accessing the correct RD when writing INVALLR
PATCH v2 1/1 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 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_INVALLR into account. Let's take the vpe_lock before evaluating vpe->col_idx to fix it.
---
* From v1:
- Add a proper Fixes: tag
- Cc stable
drivers/irqchip/irq-gic-v3-its.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/irqchip/irq-gic-v3-its.c +7 -3
@@ -4087,18 +4087,22 @@ static void its_vpe_4_1_deschedule(struct its_vpe *vpe,static void its_vpe_4_1_invall (struct its_vpe *vpe) {void __iomem *rdbase; +unsigned long flags;u64 val; +int cpu; val =GICR_INVALLR_V ; val |=FIELD_PREP (GICR_INVALLR_VPEID , vpe->vpe_id);/* 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 (val, rdbase +GICR_INVALLR );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); }static int its_vpe_4_1_set_vcpu_affinity (struct irq_data *d,void *vcpu_info)
Signature · 1 line
2.19.1
Quoted 9 lines · Zenghui Yu
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
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 takeGICR_INVALLRinto account. Let's take thevpe_lockbefore evaluatingvpe->col_idxto fix it.
Applied to irq/irqchip-5.9, thanks!
[1/1] irqchip/gic-v4.1: Ensure accessing the correct RD when writing INVALLR
commit: fdccf1d9d10395abfe082f50694f374997c6e101
Cheers,
M.
Signature · 1 line
Without deviation from the norm, progress is not possible.