powerpc/book3s: Use config independent helpers for page table walk
Even when we have HugeTLB and THP disabled, kernel linear map can still be mapped with hugepages. This is only an issue with radix translation because hash MMU doesn't map kernel linear range in linux page table and other kernel map areas are not mapped using hugepage. Add config independent helpers and put WARN_ON() when we don't expect things to be mapped via hugepages. Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
This commit is contained in:
committed by
Michael Ellerman
parent
259a948c4b
commit
d6eacedd1f
@@ -1350,5 +1350,26 @@ static inline bool is_pte_rw_upgrade(unsigned long old_val, unsigned long new_va
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Like pmd_huge() and pmd_large(), but works regardless of config options
|
||||
*/
|
||||
#define pmd_is_leaf pmd_is_leaf
|
||||
static inline bool pmd_is_leaf(pmd_t pmd)
|
||||
{
|
||||
return !!(pmd_raw(pmd) & cpu_to_be64(_PAGE_PTE));
|
||||
}
|
||||
|
||||
#define pud_is_leaf pud_is_leaf
|
||||
static inline bool pud_is_leaf(pud_t pud)
|
||||
{
|
||||
return !!(pud_raw(pud) & cpu_to_be64(_PAGE_PTE));
|
||||
}
|
||||
|
||||
#define pgd_is_leaf pgd_is_leaf
|
||||
static inline bool pgd_is_leaf(pgd_t pgd)
|
||||
{
|
||||
return !!(pgd_raw(pgd) & cpu_to_be64(_PAGE_PTE));
|
||||
}
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
#endif /* _ASM_POWERPC_BOOK3S_64_PGTABLE_H_ */
|
||||
|
||||
@@ -140,6 +140,30 @@ static inline void pte_frag_set(mm_context_t *ctx, void *p)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef pmd_is_leaf
|
||||
#define pmd_is_leaf pmd_is_leaf
|
||||
static inline bool pmd_is_leaf(pmd_t pmd)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef pud_is_leaf
|
||||
#define pud_is_leaf pud_is_leaf
|
||||
static inline bool pud_is_leaf(pud_t pud)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef pgd_is_leaf
|
||||
#define pgd_is_leaf pgd_is_leaf
|
||||
static inline bool pgd_is_leaf(pgd_t pgd)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
|
||||
#endif /* _ASM_POWERPC_PGTABLE_H */
|
||||
|
||||
@@ -10,8 +10,20 @@ extern pte_t *__find_linux_pte(pgd_t *pgdir, unsigned long ea,
|
||||
static inline pte_t *find_linux_pte(pgd_t *pgdir, unsigned long ea,
|
||||
bool *is_thp, unsigned *hshift)
|
||||
{
|
||||
pte_t *pte;
|
||||
|
||||
VM_WARN(!arch_irqs_disabled(), "%s called with irq enabled\n", __func__);
|
||||
return __find_linux_pte(pgdir, ea, is_thp, hshift);
|
||||
pte = __find_linux_pte(pgdir, ea, is_thp, hshift);
|
||||
|
||||
#if defined(CONFIG_DEBUG_VM) && \
|
||||
!(defined(CONFIG_HUGETLB_PAGE) || defined(CONFIG_TRANSPARENT_HUGEPAGE))
|
||||
/*
|
||||
* We should not find huge page if these configs are not enabled.
|
||||
*/
|
||||
if (hshift)
|
||||
WARN_ON(*hshift);
|
||||
#endif
|
||||
return pte;
|
||||
}
|
||||
|
||||
static inline pte_t *find_init_mm_pte(unsigned long ea, unsigned *hshift)
|
||||
@@ -26,10 +38,22 @@ static inline pte_t *find_init_mm_pte(unsigned long ea, unsigned *hshift)
|
||||
static inline pte_t *find_current_mm_pte(pgd_t *pgdir, unsigned long ea,
|
||||
bool *is_thp, unsigned *hshift)
|
||||
{
|
||||
pte_t *pte;
|
||||
|
||||
VM_WARN(!arch_irqs_disabled(), "%s called with irq enabled\n", __func__);
|
||||
VM_WARN(pgdir != current->mm->pgd,
|
||||
"%s lock less page table lookup called on wrong mm\n", __func__);
|
||||
return __find_linux_pte(pgdir, ea, is_thp, hshift);
|
||||
pte = __find_linux_pte(pgdir, ea, is_thp, hshift);
|
||||
|
||||
#if defined(CONFIG_DEBUG_VM) && \
|
||||
!(defined(CONFIG_HUGETLB_PAGE) || defined(CONFIG_TRANSPARENT_HUGEPAGE))
|
||||
/*
|
||||
* We should not find huge page if these configs are not enabled.
|
||||
*/
|
||||
if (hshift)
|
||||
WARN_ON(*hshift);
|
||||
#endif
|
||||
return pte;
|
||||
}
|
||||
|
||||
#endif /* _ASM_POWERPC_PTE_WALK_H */
|
||||
|
||||
Reference in New Issue
Block a user