^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) #ifndef _ASM_POWERPC_PTE_WALK_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) #define _ASM_POWERPC_PTE_WALK_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) #include <linux/sched.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) /* Don't use this directly */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) extern pte_t *__find_linux_pte(pgd_t *pgdir, unsigned long ea,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) bool *is_thp, unsigned *hshift);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) static inline pte_t *find_linux_pte(pgd_t *pgdir, unsigned long ea,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) bool *is_thp, unsigned *hshift)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) pte_t *pte;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) VM_WARN(!arch_irqs_disabled(), "%s called with irq enabled\n", __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) pte = __find_linux_pte(pgdir, ea, is_thp, hshift);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #if defined(CONFIG_DEBUG_VM) && \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) !(defined(CONFIG_HUGETLB_PAGE) || defined(CONFIG_TRANSPARENT_HUGEPAGE))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) * We should not find huge page if these configs are not enabled.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) if (hshift)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) WARN_ON(*hshift);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) return pte;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) static inline pte_t *find_init_mm_pte(unsigned long ea, unsigned *hshift)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) pgd_t *pgdir = init_mm.pgd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) return __find_linux_pte(pgdir, ea, NULL, hshift);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) * This is what we should always use. Any other lockless page table lookup needs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) * careful audit against THP split.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) static inline pte_t *find_current_mm_pte(pgd_t *pgdir, unsigned long ea,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) bool *is_thp, unsigned *hshift)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) pte_t *pte;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) VM_WARN(!arch_irqs_disabled(), "%s called with irq enabled\n", __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) VM_WARN(pgdir != current->mm->pgd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) "%s lock less page table lookup called on wrong mm\n", __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) pte = __find_linux_pte(pgdir, ea, is_thp, hshift);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) #if defined(CONFIG_DEBUG_VM) && \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) !(defined(CONFIG_HUGETLB_PAGE) || defined(CONFIG_TRANSPARENT_HUGEPAGE))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) * We should not find huge page if these configs are not enabled.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) if (hshift)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) WARN_ON(*hshift);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) return pte;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) #endif /* _ASM_POWERPC_PTE_WALK_H */