1 /* Included from asm/pgtable-*.h only ! */
4 * Some bits are only used on some cpu families... Make sure that all
5 * the undefined gets a sensible default
8 #define _PAGE_HASHPTE 0
11 #define _PAGE_SHARED 0
14 #define _PAGE_HWWRITE 0
17 #define _PAGE_HWEXEC 0
23 #define _PAGE_ENDIAN 0
25 #ifndef _PAGE_COHERENT
26 #define _PAGE_COHERENT 0
28 #ifndef _PAGE_WRITETHRU
29 #define _PAGE_WRITETHRU 0
32 #define _PAGE_SPECIAL 0
35 #define _PAGE_4K_PFN 0
40 #ifndef _PMD_PRESENT_MASK
41 #define _PMD_PRESENT_MASK _PMD_PRESENT
45 #define PMD_PAGE_SIZE(pmd) bad_call_to_PMD_PAGE_SIZE()
47 #ifndef _PAGE_KERNEL_RO
48 #define _PAGE_KERNEL_RO 0
50 #ifndef _PAGE_KERNEL_RW
51 #define _PAGE_KERNEL_RW (_PAGE_DIRTY | _PAGE_RW | _PAGE_HWWRITE)
53 #ifndef _PAGE_HPTEFLAGS
54 #define _PAGE_HPTEFLAGS _PAGE_HASHPTE
56 #ifndef _PTE_NONE_MASK
57 #define _PTE_NONE_MASK _PAGE_HPTEFLAGS
60 /* Make sure we get a link error if PMD_PAGE_SIZE is ever called on a
61 * kernel without large page PMD support
64 extern unsigned long bad_call_to_PMD_PAGE_SIZE(void);
65 #endif /* __ASSEMBLY__ */
67 /* Location of the PFN in the PTE. Most 32-bit platforms use the same
68 * as _PAGE_SHIFT here (ie, naturally aligned).
69 * Platform who don't just pre-define the value so we don't override it here
72 #define PTE_RPN_SHIFT (PAGE_SHIFT)
75 /* The mask convered by the RPN must be a ULL on 32-bit platforms with
78 #if defined(CONFIG_PPC32) && defined(CONFIG_PTE_64BIT)
79 #define PTE_RPN_MAX (1ULL << (64 - PTE_RPN_SHIFT))
80 #define PTE_RPN_MASK (~((1ULL<<PTE_RPN_SHIFT)-1))
82 #define PTE_RPN_MAX (1UL << (32 - PTE_RPN_SHIFT))
83 #define PTE_RPN_MASK (~((1UL<<PTE_RPN_SHIFT)-1))
86 /* _PAGE_CHG_MASK masks of bits that are to be preserved accross
89 #define _PAGE_CHG_MASK (PTE_RPN_MASK | _PAGE_HPTEFLAGS | _PAGE_DIRTY | \
90 _PAGE_ACCESSED | _PAGE_SPECIAL)
92 /* Mask of bits returned by pte_pgprot() */
93 #define PAGE_PROT_BITS (_PAGE_GUARDED | _PAGE_COHERENT | _PAGE_NO_CACHE | \
94 _PAGE_WRITETHRU | _PAGE_ENDIAN | _PAGE_4K_PFN | \
95 _PAGE_USER | _PAGE_ACCESSED | \
96 _PAGE_RW | _PAGE_HWWRITE | _PAGE_DIRTY | \
97 _PAGE_EXEC | _PAGE_HWEXEC)
100 * We define 2 sets of base prot bits, one for basic pages (ie,
101 * cacheable kernel and user pages) and one for non cacheable
102 * pages. We always set _PAGE_COHERENT when SMP is enabled or
103 * the processor might need it for DMA coherency.
105 #define _PAGE_BASE_NC (_PAGE_PRESENT | _PAGE_ACCESSED | _PAGE_PSIZE)
106 #if defined(CONFIG_SMP) || defined(CONFIG_PPC_STD_MMU)
107 #define _PAGE_BASE (_PAGE_BASE_NC | _PAGE_COHERENT)
109 #define _PAGE_BASE (_PAGE_BASE_NC)
112 /* Permission masks used to generate the __P and __S table,
114 * Note:__pgprot is defined in arch/powerpc/include/asm/page.h
116 * Write permissions imply read permissions for now (we could make write-only
117 * pages on BookE but we don't bother for now). Execute permission control is
118 * possible on platforms that define _PAGE_EXEC
120 * Note due to the way vm flags are laid out, the bits are XWR
122 #define PAGE_NONE __pgprot(_PAGE_BASE)
123 #define PAGE_SHARED __pgprot(_PAGE_BASE | _PAGE_USER | _PAGE_RW)
124 #define PAGE_SHARED_X __pgprot(_PAGE_BASE | _PAGE_USER | _PAGE_RW | _PAGE_EXEC)
125 #define PAGE_COPY __pgprot(_PAGE_BASE | _PAGE_USER)
126 #define PAGE_COPY_X __pgprot(_PAGE_BASE | _PAGE_USER | _PAGE_EXEC)
127 #define PAGE_READONLY __pgprot(_PAGE_BASE | _PAGE_USER)
128 #define PAGE_READONLY_X __pgprot(_PAGE_BASE | _PAGE_USER | _PAGE_EXEC)
130 #define __P000 PAGE_NONE
131 #define __P001 PAGE_READONLY
132 #define __P010 PAGE_COPY
133 #define __P011 PAGE_COPY
134 #define __P100 PAGE_READONLY_X
135 #define __P101 PAGE_READONLY_X
136 #define __P110 PAGE_COPY_X
137 #define __P111 PAGE_COPY_X
139 #define __S000 PAGE_NONE
140 #define __S001 PAGE_READONLY
141 #define __S010 PAGE_SHARED
142 #define __S011 PAGE_SHARED
143 #define __S100 PAGE_READONLY_X
144 #define __S101 PAGE_READONLY_X
145 #define __S110 PAGE_SHARED_X
146 #define __S111 PAGE_SHARED_X
148 /* Permission masks used for kernel mappings */
149 #define PAGE_KERNEL __pgprot(_PAGE_BASE | _PAGE_KERNEL_RW)
150 #define PAGE_KERNEL_NC __pgprot(_PAGE_BASE_NC | _PAGE_KERNEL_RW | \
152 #define PAGE_KERNEL_NCG __pgprot(_PAGE_BASE_NC | _PAGE_KERNEL_RW | \
153 _PAGE_NO_CACHE | _PAGE_GUARDED)
154 #define PAGE_KERNEL_X __pgprot(_PAGE_BASE | _PAGE_KERNEL_RW | _PAGE_EXEC | \
156 #define PAGE_KERNEL_RO __pgprot(_PAGE_BASE | _PAGE_KERNEL_RO)
157 #define PAGE_KERNEL_ROX __pgprot(_PAGE_BASE | _PAGE_KERNEL_RO | _PAGE_EXEC | \
160 /* Protection used for kernel text. We want the debuggers to be able to
161 * set breakpoints anywhere, so don't write protect the kernel text
162 * on platforms where such control is possible.
164 #if defined(CONFIG_KGDB) || defined(CONFIG_XMON) || defined(CONFIG_BDI_SWITCH) ||\
165 defined(CONFIG_KPROBES)
166 #define PAGE_KERNEL_TEXT PAGE_KERNEL_X
168 #define PAGE_KERNEL_TEXT PAGE_KERNEL_ROX
171 /* Make modules code happy. We don't set RO yet */
172 #define PAGE_KERNEL_EXEC PAGE_KERNEL_X
174 /* Advertise special mapping type for AGP */
175 #define PAGE_AGP (PAGE_KERNEL_NC)
176 #define HAVE_PAGE_AGP
178 /* Advertise support for _PAGE_SPECIAL */
180 #define __HAVE_ARCH_PTE_SPECIAL