Skip to content

Commit cc7130b

Browse files
aikmpe
authored andcommitted
powerpc/iommu: Annotate nested lock for lockdep
The IOMMU table is divided into pools for concurrent mappings and each pool has a separate spinlock. When taking the ownership of an IOMMU group to pass through a device to a VM, we lock these spinlocks which triggers a false negative warning in lockdep (below). This fixes it by annotating the large pool's spinlock as a nest lock which makes lockdep not complaining when locking nested locks if the nest lock is locked already. === WARNING: possible recursive locking detected 5.11.0-le_syzkaller_a+fstn1 #100 Not tainted -------------------------------------------- qemu-system-ppc/4129 is trying to acquire lock: c0000000119bddb0 (&(p->lock)/1){....}-{2:2}, at: iommu_take_ownership+0xac/0x1e0 but task is already holding lock: c0000000119bdd30 (&(p->lock)/1){....}-{2:2}, at: iommu_take_ownership+0xac/0x1e0 other info that might help us debug this: Possible unsafe locking scenario: CPU0 ---- lock(&(p->lock)/1); lock(&(p->lock)/1); === Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://lore.kernel.org/r/20210301063653.51003-1-aik@ozlabs.ru
1 parent 4be518d commit cc7130b

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

arch/powerpc/kernel/iommu.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1088,7 +1088,7 @@ int iommu_take_ownership(struct iommu_table *tbl)
10881088

10891089
spin_lock_irqsave(&tbl->large_pool.lock, flags);
10901090
for (i = 0; i < tbl->nr_pools; i++)
1091-
spin_lock(&tbl->pools[i].lock);
1091+
spin_lock_nest_lock(&tbl->pools[i].lock, &tbl->large_pool.lock);
10921092

10931093
iommu_table_release_pages(tbl);
10941094

@@ -1116,7 +1116,7 @@ void iommu_release_ownership(struct iommu_table *tbl)
11161116

11171117
spin_lock_irqsave(&tbl->large_pool.lock, flags);
11181118
for (i = 0; i < tbl->nr_pools; i++)
1119-
spin_lock(&tbl->pools[i].lock);
1119+
spin_lock_nest_lock(&tbl->pools[i].lock, &tbl->large_pool.lock);
11201120

11211121
memset(tbl->it_map, 0, sz);
11221122

0 commit comments

Comments
 (0)