powerpc32: Fix pte_offset_kernel() to return NULL for bad pages
authorChristophe Leroy <christophe.leroy@c-s.fr>
Tue, 9 Feb 2016 16:07:56 +0000 (17:07 +0100)
committerScott Wood <oss@buserror.net>
Fri, 11 Mar 2016 23:18:02 +0000 (17:18 -0600)
The fixmap related functions try to map kernel pages that are
already mapped through Large TLBs. pte_offset_kernel() has to
return NULL for LTLBs, otherwise the caller will try to access
level 2 table which doesn't exist

Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
Signed-off-by: Scott Wood <oss@buserror.net>
arch/powerpc/include/asm/nohash/32/pgtable.h

index c82cbf52d19ea07cef31629c75b6502ea9955dcd..e2016007c04e2623665c0163d63a71703da49caa 100644 (file)
@@ -309,7 +309,8 @@ static inline void __ptep_set_access_flags(pte_t *ptep, pte_t entry)
 #define pte_index(address)             \
        (((address) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
 #define pte_offset_kernel(dir, addr)   \
-       ((pte_t *) pmd_page_vaddr(*(dir)) + pte_index(addr))
+       (pmd_bad(*(dir)) ? NULL : (pte_t *)pmd_page_vaddr(*(dir)) + \
+                                 pte_index(addr))
 #define pte_offset_map(dir, addr)              \
        ((pte_t *) kmap_atomic(pmd_page(*(dir))) + pte_index(addr))
 #define pte_unmap(pte)         kunmap_atomic(pte)