sparc: allow pte_offset_map() to fail
authorHugh Dickins <hughd@google.com>
Thu, 8 Jun 2023 19:32:36 +0000 (12:32 -0700)
committerAndrew Morton <akpm@linux-foundation.org>
Mon, 19 Jun 2023 23:19:09 +0000 (16:19 -0700)
In rare transient cases, not yet made possible, pte_offset_map() and
pte_offset_map_lock() may not find a page table: handle appropriately.

Link: https://lkml.kernel.org/r/22165adb-581c-9ce1-8aa6-a3385cd39055@google.com
Signed-off-by: Hugh Dickins <hughd@google.com>
Cc: Alexander Gordeev <agordeev@linux.ibm.com>
Cc: Alexandre Ghiti <alexghiti@rivosinc.com>
Cc: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Christian Borntraeger <borntraeger@linux.ibm.com>
Cc: Chris Zankel <chris@zankel.net>
Cc: Claudio Imbrenda <imbrenda@linux.ibm.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Greg Ungerer <gerg@linux-m68k.org>
Cc: Heiko Carstens <hca@linux.ibm.com>
Cc: Helge Deller <deller@gmx.de>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: John David Anglin <dave.anglin@bell.net>
Cc: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Max Filippov <jcmvbkbc@gmail.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Michal Simek <monstr@monstr.eu>
Cc: Mike Kravetz <mike.kravetz@oracle.com>
Cc: Mike Rapoport (IBM) <rppt@kernel.org>
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Qi Zheng <zhengqi.arch@bytedance.com>
Cc: Russell King <linux@armlinux.org.uk>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Will Deacon <will@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
arch/sparc/kernel/signal32.c
arch/sparc/mm/fault_64.c
arch/sparc/mm/tlb.c

index dad3896..ca450c7 100644 (file)
@@ -328,6 +328,8 @@ static void flush_signal_insns(unsigned long address)
                goto out_irqs_on;
 
        ptep = pte_offset_map(pmdp, address);
+       if (!ptep)
+               goto out_irqs_on;
        pte = *ptep;
        if (!pte_present(pte))
                goto out_unmap;
index d91305d..d8a407f 100644 (file)
@@ -99,6 +99,7 @@ static unsigned int get_user_insn(unsigned long tpc)
        local_irq_disable();
 
        pmdp = pmd_offset(pudp, tpc);
+again:
        if (pmd_none(*pmdp) || unlikely(pmd_bad(*pmdp)))
                goto out_irq_enable;
 
@@ -115,6 +116,8 @@ static unsigned int get_user_insn(unsigned long tpc)
 #endif
        {
                ptep = pte_offset_map(pmdp, tpc);
+               if (!ptep)
+                       goto again;
                pte = *ptep;
                if (pte_present(pte)) {
                        pa  = (pte_pfn(pte) << PAGE_SHIFT);
index 9a72554..7ecf855 100644 (file)
@@ -149,6 +149,8 @@ static void tlb_batch_pmd_scan(struct mm_struct *mm, unsigned long vaddr,
        pte_t *pte;
 
        pte = pte_offset_map(&pmd, vaddr);
+       if (!pte)
+               return;
        end = vaddr + HPAGE_SIZE;
        while (vaddr < end) {
                if (pte_val(*pte) & _PAGE_VALID) {