]>
git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blob - arch/powerpc/include/asm/pgtable.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_POWERPC_PGTABLE_H
3 #define _ASM_POWERPC_PGTABLE_H
6 #include <linux/mmdebug.h>
7 #include <linux/mmzone.h>
8 #include <asm/processor.h> /* For TASK_SIZE */
11 #include <asm/tlbflush.h>
15 #endif /* !__ASSEMBLY__ */
17 #ifdef CONFIG_PPC_BOOK3S
18 #include <asm/book3s/pgtable.h>
20 #include <asm/nohash/pgtable.h>
21 #endif /* !CONFIG_PPC_BOOK3S */
23 /* Note due to the way vm flags are laid out, the bits are XWR */
24 #define __P000 PAGE_NONE
25 #define __P001 PAGE_READONLY
26 #define __P010 PAGE_COPY
27 #define __P011 PAGE_COPY
28 #define __P100 PAGE_READONLY_X
29 #define __P101 PAGE_READONLY_X
30 #define __P110 PAGE_COPY_X
31 #define __P111 PAGE_COPY_X
33 #define __S000 PAGE_NONE
34 #define __S001 PAGE_READONLY
35 #define __S010 PAGE_SHARED
36 #define __S011 PAGE_SHARED
37 #define __S100 PAGE_READONLY_X
38 #define __S101 PAGE_READONLY_X
39 #define __S110 PAGE_SHARED_X
40 #define __S111 PAGE_SHARED_X
45 static inline pmd_t
*pmd_ptr(struct mm_struct
*mm
, unsigned long va
)
47 return pmd_offset(pud_offset(p4d_offset(pgd_offset(mm
, va
), va
), va
), va
);
50 static inline pmd_t
*pmd_ptr_k(unsigned long va
)
52 return pmd_offset(pud_offset(p4d_offset(pgd_offset_k(va
), va
), va
), va
);
55 static inline pte_t
*virt_to_kpte(unsigned long vaddr
)
57 pmd_t
*pmd
= pmd_ptr_k(vaddr
);
59 return pmd_none(*pmd
) ? NULL
: pte_offset_kernel(pmd
, vaddr
);
63 #include <asm/tlbflush.h>
65 /* Keep these as a macros to avoid include dependency mess */
66 #define pte_page(x) pfn_to_page(pte_pfn(x))
67 #define mk_pte(page, pgprot) pfn_pte(page_to_pfn(page), (pgprot))
69 * Select all bits except the pfn
71 static inline pgprot_t
pte_pgprot(pte_t pte
)
73 unsigned long pte_flags
;
75 pte_flags
= pte_val(pte
) & ~PTE_RPN_MASK
;
76 return __pgprot(pte_flags
);
80 * ZERO_PAGE is a global shared page that is always zero: used
81 * for zero-mapped memory areas etc..
83 extern unsigned long empty_zero_page
[];
84 #define ZERO_PAGE(vaddr) (virt_to_page(empty_zero_page))
86 extern pgd_t swapper_pg_dir
[];
88 extern void paging_init(void);
90 extern unsigned long ioremap_bot
;
93 * kern_addr_valid is intended to indicate whether an address is a valid
94 * kernel address. Most 32-bit archs define it as always true (like this)
95 * but most 64-bit archs actually perform a test. What should we do here?
97 #define kern_addr_valid(addr) (1)
99 #include <asm-generic/pgtable.h>
101 #ifndef CONFIG_TRANSPARENT_HUGEPAGE
102 #define pmd_large(pmd) 0
105 /* can we use this in kvm */
106 unsigned long vmalloc_to_phys(void *vmalloc_addr
);
108 void pgtable_cache_add(unsigned int shift
);
110 pte_t
*early_pte_alloc_kernel(pmd_t
*pmdp
, unsigned long va
);
112 #if defined(CONFIG_STRICT_KERNEL_RWX) || defined(CONFIG_PPC32)
113 void mark_initmem_nx(void);
115 static inline void mark_initmem_nx(void) { }
119 * When used, PTE_FRAG_NR is defined in subarch pgtable.h
120 * so we are sure it is included when arriving here.
123 static inline void *pte_frag_get(mm_context_t
*ctx
)
125 return ctx
->pte_frag
;
128 static inline void pte_frag_set(mm_context_t
*ctx
, void *p
)
133 #define PTE_FRAG_NR 1
134 #define PTE_FRAG_SIZE_SHIFT PAGE_SHIFT
135 #define PTE_FRAG_SIZE (1UL << PTE_FRAG_SIZE_SHIFT)
137 static inline void *pte_frag_get(mm_context_t
*ctx
)
142 static inline void pte_frag_set(mm_context_t
*ctx
, void *p
)
148 #define pmd_is_leaf pmd_is_leaf
149 static inline bool pmd_is_leaf(pmd_t pmd
)
156 #define pud_is_leaf pud_is_leaf
157 static inline bool pud_is_leaf(pud_t pud
)
164 #define p4d_is_leaf p4d_is_leaf
165 static inline bool p4d_is_leaf(p4d_t p4d
)
172 #define is_ioremap_addr is_ioremap_addr
173 static inline bool is_ioremap_addr(const void *x
)
175 unsigned long addr
= (unsigned long)x
;
177 return addr
>= IOREMAP_BASE
&& addr
< IOREMAP_END
;
179 #endif /* CONFIG_PPC64 */
181 #endif /* __ASSEMBLY__ */
183 #endif /* _ASM_POWERPC_PGTABLE_H */