Skip to content

Commit a9162f2

Browse files
Carsten OtteMartin Schwidefsky
Carsten Otte
authored and
Martin Schwidefsky
committed
[S390] fix possible deadlock in gmap_map_segment
Fix possible deadlock reported by lockdep: qemu-system-s39/2963 is trying to acquire lock: (&mm->mmap_sem){++++++}, at: gmap_alloc_table+0x9c/0x120 but task is already holding lock: (&mm->mmap_sem){++++++}, at: gmap_map_segment+0xa6/0x27c Actually gmap_alloc_table is the only called in gmap_map_segment with mmap_sem held, thus it's safe to simply remove the inner lock. Signed-off-by: Carsten Otte <[email protected]> Signed-off-by: Martin Schwidefsky <[email protected]>
1 parent 69ba974 commit a9162f2

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

arch/s390/mm/pgtable.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,9 @@ void gmap_disable(struct gmap *gmap)
256256
}
257257
EXPORT_SYMBOL_GPL(gmap_disable);
258258

259+
/*
260+
* gmap_alloc_table is assumed to be called with mmap_sem held
261+
*/
259262
static int gmap_alloc_table(struct gmap *gmap,
260263
unsigned long *table, unsigned long init)
261264
{
@@ -267,14 +270,12 @@ static int gmap_alloc_table(struct gmap *gmap,
267270
return -ENOMEM;
268271
new = (unsigned long *) page_to_phys(page);
269272
crst_table_init(new, init);
270-
down_read(&gmap->mm->mmap_sem);
271273
if (*table & _REGION_ENTRY_INV) {
272274
list_add(&page->lru, &gmap->crst_list);
273275
*table = (unsigned long) new | _REGION_ENTRY_LENGTH |
274276
(*table & _REGION_ENTRY_TYPE_MASK);
275277
} else
276278
__free_pages(page, ALLOC_ORDER);
277-
up_read(&gmap->mm->mmap_sem);
278279
return 0;
279280
}
280281

0 commit comments

Comments
 (0)