Skip to content

Commit 3493ce8

Browse files
antonblanchardgregkh
authored andcommitted
powerpc: Fix deadlock in icswx code
commit 8bdafa3 upstream. The icswx code introduced an A-B B-A deadlock: CPU0 CPU1 ---- ---- lock(&anon_vma->mutex); lock(&mm->mmap_sem); lock(&anon_vma->mutex); lock(&mm->mmap_sem); Instead of using the mmap_sem to keep mm_users constant, take the page table spinlock. Signed-off-by: Anton Blanchard <anton@samba.org> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
1 parent 85e71ae commit 3493ce8

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

arch/powerpc/mm/mmu_context_hash64.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,8 @@ int use_cop(unsigned long acop, struct mm_struct *mm)
136136
if (!mm || !acop)
137137
return -EINVAL;
138138

139-
/* We need to make sure mm_users doesn't change */
140-
down_read(&mm->mmap_sem);
139+
/* The page_table_lock ensures mm_users won't change under us */
140+
spin_lock(&mm->page_table_lock);
141141
spin_lock(mm->context.cop_lockp);
142142

143143
if (mm->context.cop_pid == COP_PID_NONE) {
@@ -164,7 +164,7 @@ int use_cop(unsigned long acop, struct mm_struct *mm)
164164

165165
out:
166166
spin_unlock(mm->context.cop_lockp);
167-
up_read(&mm->mmap_sem);
167+
spin_unlock(&mm->page_table_lock);
168168

169169
return ret;
170170
}
@@ -185,8 +185,8 @@ void drop_cop(unsigned long acop, struct mm_struct *mm)
185185
if (WARN_ON_ONCE(!mm))
186186
return;
187187

188-
/* We need to make sure mm_users doesn't change */
189-
down_read(&mm->mmap_sem);
188+
/* The page_table_lock ensures mm_users won't change under us */
189+
spin_lock(&mm->page_table_lock);
190190
spin_lock(mm->context.cop_lockp);
191191

192192
mm->context.acop &= ~acop;
@@ -213,7 +213,7 @@ void drop_cop(unsigned long acop, struct mm_struct *mm)
213213
}
214214

215215
spin_unlock(mm->context.cop_lockp);
216-
up_read(&mm->mmap_sem);
216+
spin_unlock(&mm->page_table_lock);
217217
}
218218
EXPORT_SYMBOL_GPL(drop_cop);
219219

0 commit comments

Comments
 (0)