Skip to content

Commit e6fe228

Browse files
mpetorvalds
authored andcommitted
powerpc/mm: Convert to using lock_mm_and_find_vma()
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent ae870a6 commit e6fe228

2 files changed

Lines changed: 4 additions & 36 deletions

File tree

arch/powerpc/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ config PPC
278278
select IRQ_DOMAIN
279279
select IRQ_FORCED_THREADING
280280
select KASAN_VMALLOC if KASAN && MODULES
281+
select LOCK_MM_AND_FIND_VMA
281282
select MMU_GATHER_PAGE_SIZE
282283
select MMU_GATHER_RCU_TABLE_FREE
283284
select MMU_GATHER_MERGE_VMAS

arch/powerpc/mm/fault.c

Lines changed: 3 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,6 @@ static int __bad_area(struct pt_regs *regs, unsigned long address, int si_code)
8484
return __bad_area_nosemaphore(regs, address, si_code);
8585
}
8686

87-
static noinline int bad_area(struct pt_regs *regs, unsigned long address)
88-
{
89-
return __bad_area(regs, address, SEGV_MAPERR);
90-
}
91-
9287
static noinline int bad_access_pkey(struct pt_regs *regs, unsigned long address,
9388
struct vm_area_struct *vma)
9489
{
@@ -515,40 +510,12 @@ static int ___do_page_fault(struct pt_regs *regs, unsigned long address,
515510
* we will deadlock attempting to validate the fault against the
516511
* address space. Luckily the kernel only validly references user
517512
* space from well defined areas of code, which are listed in the
518-
* exceptions table.
519-
*
520-
* As the vast majority of faults will be valid we will only perform
521-
* the source reference check when there is a possibility of a deadlock.
522-
* Attempt to lock the address space, if we cannot we then validate the
523-
* source. If this is invalid we can skip the address space check,
524-
* thus avoiding the deadlock.
513+
* exceptions table. lock_mm_and_find_vma() handles that logic.
525514
*/
526-
if (unlikely(!mmap_read_trylock(mm))) {
527-
if (!is_user && !search_exception_tables(regs->nip))
528-
return bad_area_nosemaphore(regs, address);
529-
530515
retry:
531-
mmap_read_lock(mm);
532-
} else {
533-
/*
534-
* The above down_read_trylock() might have succeeded in
535-
* which case we'll have missed the might_sleep() from
536-
* down_read():
537-
*/
538-
might_sleep();
539-
}
540-
541-
vma = find_vma(mm, address);
516+
vma = lock_mm_and_find_vma(mm, address, regs);
542517
if (unlikely(!vma))
543-
return bad_area(regs, address);
544-
545-
if (unlikely(vma->vm_start > address)) {
546-
if (unlikely(!(vma->vm_flags & VM_GROWSDOWN)))
547-
return bad_area(regs, address);
548-
549-
if (unlikely(expand_stack(vma, address)))
550-
return bad_area(regs, address);
551-
}
518+
return bad_area_nosemaphore(regs, address);
552519

553520
if (unlikely(access_pkey_error(is_write, is_exec,
554521
(error_code & DSISR_KEYFAULT), vma)))

0 commit comments

Comments
 (0)