Path: blob/master/arch/powerpc/include/asm/book3s/32/pgalloc.h
29278 views
/* SPDX-License-Identifier: GPL-2.0 */1#ifndef _ASM_POWERPC_BOOK3S_32_PGALLOC_H2#define _ASM_POWERPC_BOOK3S_32_PGALLOC_H34#include <linux/threads.h>5#include <linux/slab.h>67static inline pgd_t *pgd_alloc(struct mm_struct *mm)8{9pgd_t *pgd = kmem_cache_alloc(PGT_CACHE(PGD_INDEX_SIZE),10pgtable_gfp_flags(mm, GFP_KERNEL));1112#ifdef CONFIG_PPC_BOOK3S_60313memcpy(pgd + USER_PTRS_PER_PGD, swapper_pg_dir + USER_PTRS_PER_PGD,14(MAX_PTRS_PER_PGD - USER_PTRS_PER_PGD) * sizeof(pgd_t));15#endif16return pgd;17}1819static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)20{21kmem_cache_free(PGT_CACHE(PGD_INDEX_SIZE), pgd);22}2324/*25* We don't have any real pmd's, and this code never triggers because26* the pgd will always be present..27*/28/* #define pmd_alloc_one(mm,address) ({ BUG(); ((pmd_t *)2); }) */29#define pmd_free(mm, x) do { } while (0)30#define __pmd_free_tlb(tlb,x,a) do { } while (0)31/* #define pgd_populate(mm, pmd, pte) BUG() */3233static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmdp,34pte_t *pte)35{36*pmdp = __pmd(__pa(pte) | _PMD_PRESENT);37}3839static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmdp,40pgtable_t pte_page)41{42*pmdp = __pmd(__pa(pte_page) | _PMD_PRESENT);43}4445static inline void pgtable_free(void *table, unsigned index_size)46{47if (!index_size) {48pte_fragment_free((unsigned long *)table, 0);49} else {50BUG_ON(index_size > MAX_PGTABLE_INDEX_SIZE);51kmem_cache_free(PGT_CACHE(index_size), table);52}53}5455static inline void pgtable_free_tlb(struct mmu_gather *tlb,56void *table, int shift)57{58unsigned long pgf = (unsigned long)table;59BUG_ON(shift > MAX_PGTABLE_INDEX_SIZE);60pgf |= shift;61tlb_remove_table(tlb, (void *)pgf);62}6364static inline void __tlb_remove_table(void *_table)65{66void *table = (void *)((unsigned long)_table & ~MAX_PGTABLE_INDEX_SIZE);67unsigned shift = (unsigned long)_table & MAX_PGTABLE_INDEX_SIZE;6869pgtable_free(table, shift);70}7172static inline void __pte_free_tlb(struct mmu_gather *tlb, pgtable_t table,73unsigned long address)74{75pgtable_free_tlb(tlb, table, 0);76}77#endif /* _ASM_POWERPC_BOOK3S_32_PGALLOC_H */787980