1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_POWERPC_BOOK3S_32_PGALLOC_H
3 #define _ASM_POWERPC_BOOK3S_32_PGALLOC_H
5 #include <linux/threads.h>
6 #include <linux/slab.h>
8 static inline pgd_t
*pgd_alloc(struct mm_struct
*mm
)
10 return kmem_cache_alloc(PGT_CACHE(PGD_INDEX_SIZE
),
11 pgtable_gfp_flags(mm
, GFP_KERNEL
));
14 static inline void pgd_free(struct mm_struct
*mm
, pgd_t
*pgd
)
16 kmem_cache_free(PGT_CACHE(PGD_INDEX_SIZE
), pgd
);
20 * We don't have any real pmd's, and this code never triggers because
21 * the pgd will always be present..
23 /* #define pmd_alloc_one(mm,address) ({ BUG(); ((pmd_t *)2); }) */
24 #define pmd_free(mm, x) do { } while (0)
25 #define __pmd_free_tlb(tlb,x,a) do { } while (0)
26 /* #define pgd_populate(mm, pmd, pte) BUG() */
28 static inline void pmd_populate_kernel(struct mm_struct
*mm
, pmd_t
*pmdp
,
31 *pmdp
= __pmd(__pa(pte
) | _PMD_PRESENT
);
34 static inline void pmd_populate(struct mm_struct
*mm
, pmd_t
*pmdp
,
37 *pmdp
= __pmd(__pa(pte_page
) | _PMD_PRESENT
);
40 static inline void pgtable_free(void *table
, unsigned index_size
)
43 pte_fragment_free((unsigned long *)table
, 0);
45 BUG_ON(index_size
> MAX_PGTABLE_INDEX_SIZE
);
46 kmem_cache_free(PGT_CACHE(index_size
), table
);
50 #define get_hugepd_cache_index(x) (x)
52 static inline void pgtable_free_tlb(struct mmu_gather
*tlb
,
53 void *table
, int shift
)
55 unsigned long pgf
= (unsigned long)table
;
56 BUG_ON(shift
> MAX_PGTABLE_INDEX_SIZE
);
58 tlb_remove_table(tlb
, (void *)pgf
);
61 static inline void __tlb_remove_table(void *_table
)
63 void *table
= (void *)((unsigned long)_table
& ~MAX_PGTABLE_INDEX_SIZE
);
64 unsigned shift
= (unsigned long)_table
& MAX_PGTABLE_INDEX_SIZE
;
66 pgtable_free(table
, shift
);
69 static inline void __pte_free_tlb(struct mmu_gather
*tlb
, pgtable_t table
,
70 unsigned long address
)
72 pgtable_free_tlb(tlb
, table
, 0);
74 #endif /* _ASM_POWERPC_BOOK3S_32_PGALLOC_H */