Skip to content

Commit f97fd45

Browse files
Marc ZyngierKAGA-KOKO
authored andcommitted
irqchip/gic-v4: Fix ordering between vmapp and vpe locks
The recently established lock ordering mandates that the per-VM vmapp_lock is acquired before taking 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 is a lock order violation. 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: f0eb154 ("irqchip/gic-v4: Substitute vmovp_lock for a per-VM lock") Reported-by: Zhou Wang <[email protected]> Signed-off-by: Marc Zyngier <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Link: https://lore.kernel.org/all/[email protected]
1 parent 4d936f1 commit f97fd45

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

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

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1329,12 +1329,6 @@ static void its_send_vmovp(struct its_vpe *vpe)
13291329
return;
13301330
}
13311331

1332-
/*
1333-
* Protect against concurrent updates of the mapping state on
1334-
* individual VMs.
1335-
*/
1336-
guard(raw_spinlock_irqsave)(&vpe->its_vm->vmapp_lock);
1337-
13381332
/*
13391333
* Yet another marvel of the architecture. If using the
13401334
* its_list "feature", we need to make sure that all ITSs
@@ -3824,7 +3818,14 @@ static int its_vpe_set_affinity(struct irq_data *d,
38243818
* protect us, and that we must ensure nobody samples vpe->col_idx
38253819
* during the update, hence the lock below which must also be
38263820
* taken on any vLPI handling path that evaluates vpe->col_idx.
3821+
*
3822+
* Finally, we must protect ourselves against concurrent updates of
3823+
* the mapping state on this VM should the ITS list be in use (see
3824+
* the shortcut in its_send_vmovp() otherewise).
38273825
*/
3826+
if (its_list_map)
3827+
raw_spin_lock(&vpe->its_vm->vmapp_lock);
3828+
38283829
from = vpe_to_cpuid_lock(vpe, &flags);
38293830
table_mask = gic_data_rdist_cpu(from)->vpe_table_mask;
38303831

@@ -3854,6 +3855,9 @@ static int its_vpe_set_affinity(struct irq_data *d,
38543855
irq_data_update_effective_affinity(d, cpumask_of(cpu));
38553856
vpe_to_cpuid_unlock(vpe, flags);
38563857

3858+
if (its_list_map)
3859+
raw_spin_unlock(&vpe->its_vm->vmapp_lock);
3860+
38573861
return IRQ_SET_MASK_OK_DONE;
38583862
}
38593863

0 commit comments

Comments
 (0)