Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef _ASM_POWERPC_PGTABLE_H
0003 #define _ASM_POWERPC_PGTABLE_H
0004 
0005 #ifndef __ASSEMBLY__
0006 #include <linux/mmdebug.h>
0007 #include <linux/mmzone.h>
0008 #include <asm/processor.h>      /* For TASK_SIZE */
0009 #include <asm/mmu.h>
0010 #include <asm/page.h>
0011 #include <asm/tlbflush.h>
0012 
0013 struct mm_struct;
0014 
0015 #endif /* !__ASSEMBLY__ */
0016 
0017 #ifdef CONFIG_PPC_BOOK3S
0018 #include <asm/book3s/pgtable.h>
0019 #else
0020 #include <asm/nohash/pgtable.h>
0021 #endif /* !CONFIG_PPC_BOOK3S */
0022 
0023 #ifndef __ASSEMBLY__
0024 
0025 #ifndef MAX_PTRS_PER_PGD
0026 #define MAX_PTRS_PER_PGD PTRS_PER_PGD
0027 #endif
0028 
0029 /* Keep these as a macros to avoid include dependency mess */
0030 #define pte_page(x)     pfn_to_page(pte_pfn(x))
0031 #define mk_pte(page, pgprot)    pfn_pte(page_to_pfn(page), (pgprot))
0032 /*
0033  * Select all bits except the pfn
0034  */
0035 static inline pgprot_t pte_pgprot(pte_t pte)
0036 {
0037     unsigned long pte_flags;
0038 
0039     pte_flags = pte_val(pte) & ~PTE_RPN_MASK;
0040     return __pgprot(pte_flags);
0041 }
0042 
0043 #ifndef pmd_page_vaddr
0044 static inline unsigned long pmd_page_vaddr(pmd_t pmd)
0045 {
0046     return ((unsigned long)__va(pmd_val(pmd) & ~PMD_MASKED_BITS));
0047 }
0048 #define pmd_page_vaddr pmd_page_vaddr
0049 #endif
0050 /*
0051  * ZERO_PAGE is a global shared page that is always zero: used
0052  * for zero-mapped memory areas etc..
0053  */
0054 extern unsigned long empty_zero_page[];
0055 #define ZERO_PAGE(vaddr) (virt_to_page(empty_zero_page))
0056 
0057 extern pgd_t swapper_pg_dir[];
0058 
0059 extern void paging_init(void);
0060 void poking_init(void);
0061 
0062 extern unsigned long ioremap_bot;
0063 extern const pgprot_t protection_map[16];
0064 
0065 /*
0066  * kern_addr_valid is intended to indicate whether an address is a valid
0067  * kernel address.  Most 32-bit archs define it as always true (like this)
0068  * but most 64-bit archs actually perform a test.  What should we do here?
0069  */
0070 #define kern_addr_valid(addr)   (1)
0071 
0072 #ifndef CONFIG_TRANSPARENT_HUGEPAGE
0073 #define pmd_large(pmd)      0
0074 #endif
0075 
0076 /* can we use this in kvm */
0077 unsigned long vmalloc_to_phys(void *vmalloc_addr);
0078 
0079 void pgtable_cache_add(unsigned int shift);
0080 
0081 pte_t *early_pte_alloc_kernel(pmd_t *pmdp, unsigned long va);
0082 
0083 #if defined(CONFIG_STRICT_KERNEL_RWX) || defined(CONFIG_PPC32)
0084 void mark_initmem_nx(void);
0085 #else
0086 static inline void mark_initmem_nx(void) { }
0087 #endif
0088 
0089 /*
0090  * When used, PTE_FRAG_NR is defined in subarch pgtable.h
0091  * so we are sure it is included when arriving here.
0092  */
0093 #ifdef PTE_FRAG_NR
0094 static inline void *pte_frag_get(mm_context_t *ctx)
0095 {
0096     return ctx->pte_frag;
0097 }
0098 
0099 static inline void pte_frag_set(mm_context_t *ctx, void *p)
0100 {
0101     ctx->pte_frag = p;
0102 }
0103 #else
0104 #define PTE_FRAG_NR     1
0105 #define PTE_FRAG_SIZE_SHIFT PAGE_SHIFT
0106 #define PTE_FRAG_SIZE       (1UL << PTE_FRAG_SIZE_SHIFT)
0107 
0108 static inline void *pte_frag_get(mm_context_t *ctx)
0109 {
0110     return NULL;
0111 }
0112 
0113 static inline void pte_frag_set(mm_context_t *ctx, void *p)
0114 {
0115 }
0116 #endif
0117 
0118 #ifndef pmd_is_leaf
0119 #define pmd_is_leaf pmd_is_leaf
0120 static inline bool pmd_is_leaf(pmd_t pmd)
0121 {
0122     return false;
0123 }
0124 #endif
0125 
0126 #ifndef pud_is_leaf
0127 #define pud_is_leaf pud_is_leaf
0128 static inline bool pud_is_leaf(pud_t pud)
0129 {
0130     return false;
0131 }
0132 #endif
0133 
0134 #ifndef p4d_is_leaf
0135 #define p4d_is_leaf p4d_is_leaf
0136 static inline bool p4d_is_leaf(p4d_t p4d)
0137 {
0138     return false;
0139 }
0140 #endif
0141 
0142 #define pmd_pgtable pmd_pgtable
0143 static inline pgtable_t pmd_pgtable(pmd_t pmd)
0144 {
0145     return (pgtable_t)pmd_page_vaddr(pmd);
0146 }
0147 
0148 #ifdef CONFIG_PPC64
0149 #define is_ioremap_addr is_ioremap_addr
0150 static inline bool is_ioremap_addr(const void *x)
0151 {
0152     unsigned long addr = (unsigned long)x;
0153 
0154     return addr >= IOREMAP_BASE && addr < IOREMAP_END;
0155 }
0156 
0157 struct seq_file;
0158 void arch_report_meminfo(struct seq_file *m);
0159 #endif /* CONFIG_PPC64 */
0160 
0161 #endif /* __ASSEMBLY__ */
0162 
0163 #endif /* _ASM_POWERPC_PGTABLE_H */