blob: a9e98233c4d498a2fe3b4a282329d358102a942d [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002#ifndef __ASM_SH_PGALLOC_H
3#define __ASM_SH_PGALLOC_H
4
Paul Mundt5f8c9902007-05-08 11:55:21 +09005#include <asm/page.h>
Mike Rapoport1355c312020-08-06 23:22:39 -07006
7#define __HAVE_ARCH_PMD_ALLOC_ONE
8#define __HAVE_ARCH_PMD_FREE
Mike Rapoportf9cb6542020-08-06 23:22:47 -07009#define __HAVE_ARCH_PGD_FREE
Mike Rapoport6fb12762019-09-23 15:35:25 -070010#include <asm-generic/pgalloc.h>
Paul Mundt5f8c9902007-05-08 11:55:21 +090011
Matt Fleming2a5eacc2009-12-31 12:19:24 +000012extern pgd_t *pgd_alloc(struct mm_struct *);
13extern void pgd_free(struct mm_struct *mm, pgd_t *pgd);
14
Paul Mundt782bb5a2010-01-13 19:11:14 +090015#if PAGETABLE_LEVELS > 2
Matt Fleming2a5eacc2009-12-31 12:19:24 +000016extern void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd);
17extern pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address);
18extern void pmd_free(struct mm_struct *mm, pmd_t *pmd);
Peter Zijlstrac7bcbc82020-07-17 13:10:07 +020019#define __pmd_free_tlb(tlb, pmdp, addr) pmd_free((tlb)->mm, (pmdp))
Matt Fleming5d9b4b12009-12-13 14:38:50 +000020#endif
Matt Flemingb73c8062009-11-25 22:00:08 +000021
Stuart Menefy99a596f2006-11-21 15:38:05 +090022static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd,
23 pte_t *pte)
24{
25 set_pmd(pmd, __pmd((unsigned long)pte));
26}
Linus Torvalds1da177e2005-04-16 15:20:36 -070027
28static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd,
Martin Schwidefsky2f569af2008-02-08 04:22:04 -080029 pgtable_t pte)
Linus Torvalds1da177e2005-04-16 15:20:36 -070030{
Stuart Menefy99a596f2006-11-21 15:38:05 +090031 set_pmd(pmd, __pmd((unsigned long)page_address(pte)));
Linus Torvalds1da177e2005-04-16 15:20:36 -070032}
33
Benjamin Herrenschmidt9e1b32c2009-07-22 15:44:28 +100034#define __pte_free_tlb(tlb,pte,addr) \
Martin Schwidefsky2f569af2008-02-08 04:22:04 -080035do { \
Mark Rutlandb4ed71f2019-09-25 16:49:46 -070036 pgtable_pte_page_dtor(pte); \
Martin Schwidefsky2f569af2008-02-08 04:22:04 -080037 tlb_remove_page((tlb), (pte)); \
38} while (0)
Linus Torvalds1da177e2005-04-16 15:20:36 -070039
Linus Torvalds1da177e2005-04-16 15:20:36 -070040#endif /* __ASM_SH_PGALLOC_H */