aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/include/asm/pgtable-ppc32.h
diff options
context:
space:
mode:
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>2009-03-19 15:34:08 -0400
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>2009-03-23 22:47:33 -0400
commit8d1cf34e7ad5c7738ce20d20bd7f002f562cb8b5 (patch)
treef731b8b2d3e71e7287bed977bdd7fc9ea6942d45 /arch/powerpc/include/asm/pgtable-ppc32.h
parent2a7d55fda58eb4e3652252d4f71222bd1ff90c5e (diff)
powerpc/mm: Tweak PTE bit combination definitions
This patch tweaks the way some PTE bit combinations are defined, in such a way that the 32 and 64-bit variant become almost identical and that will make it easier to bring in a new common pte-* file for the new variant of the Book3-E support. The combination of bits defining access to kernel pages are now clearly separated from the combination used by userspace and the core VM. The resulting generated code should remain identical unless I made a mistake. Note: While at it, I removed a non-sensical statement related to CONFIG_KGDB in ppc_mmu_32.c which could cause kernel mappings to be user accessible when that option is enabled. Probably something that bitrot. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'arch/powerpc/include/asm/pgtable-ppc32.h')
-rw-r--r--arch/powerpc/include/asm/pgtable-ppc32.h41
1 files changed, 20 insertions, 21 deletions
diff --git a/arch/powerpc/include/asm/pgtable-ppc32.h b/arch/powerpc/include/asm/pgtable-ppc32.h
index 67ceffc01b43..7ce331e51f90 100644
--- a/arch/powerpc/include/asm/pgtable-ppc32.h
+++ b/arch/powerpc/include/asm/pgtable-ppc32.h
@@ -144,6 +144,13 @@ extern int icache_44x_need_flush;
144#define PMD_PAGE_SIZE(pmd) bad_call_to_PMD_PAGE_SIZE() 144#define PMD_PAGE_SIZE(pmd) bad_call_to_PMD_PAGE_SIZE()
145#endif 145#endif
146 146
147#ifndef _PAGE_KERNEL_RO
148#define _PAGE_KERNEL_RO 0
149#endif
150#ifndef _PAGE_KERNEL_RW
151#define _PAGE_KERNEL_RW (_PAGE_DIRTY | _PAGE_RW | _PAGE_HWWRITE)
152#endif
153
147#define _PAGE_HPTEFLAGS _PAGE_HASHPTE 154#define _PAGE_HPTEFLAGS _PAGE_HASHPTE
148 155
149/* Location of the PFN in the PTE. Most platforms use the same as _PAGE_SHIFT 156/* Location of the PFN in the PTE. Most platforms use the same as _PAGE_SHIFT
@@ -186,30 +193,25 @@ extern int icache_44x_need_flush;
186#else 193#else
187#define _PAGE_BASE (_PAGE_PRESENT | _PAGE_ACCESSED) 194#define _PAGE_BASE (_PAGE_PRESENT | _PAGE_ACCESSED)
188#endif 195#endif
189#define _PAGE_BASE_NC (_PAGE_PRESENT | _PAGE_ACCESSED | _PAGE_NO_CACHE) 196#define _PAGE_BASE_NC (_PAGE_PRESENT | _PAGE_ACCESSED)
190 197
191#define _PAGE_WRENABLE (_PAGE_RW | _PAGE_DIRTY | _PAGE_HWWRITE) 198/* Permission masks used for kernel mappings */
192#define _PAGE_KERNEL (_PAGE_BASE | _PAGE_SHARED | _PAGE_WRENABLE) 199#define PAGE_KERNEL __pgprot(_PAGE_BASE | _PAGE_KERNEL_RW)
193#define _PAGE_KERNEL_NC (_PAGE_BASE_NC | _PAGE_SHARED | _PAGE_WRENABLE) 200#define PAGE_KERNEL_NC __pgprot(_PAGE_BASE_NC | _PAGE_KERNEL_RW | \
194 201 _PAGE_NO_CACHE)
195#ifdef CONFIG_PPC_STD_MMU 202#define PAGE_KERNEL_NCG __pgprot(_PAGE_BASE_NC | _PAGE_KERNEL_RW | \
196/* On standard PPC MMU, no user access implies kernel read/write access, 203 _PAGE_NO_CACHE | _PAGE_GUARDED)
197 * so to write-protect kernel memory we must turn on user access */ 204#define PAGE_KERNEL_X __pgprot(_PAGE_BASE | _PAGE_KERNEL_RW | _PAGE_EXEC)
198#define _PAGE_KERNEL_RO (_PAGE_BASE | _PAGE_SHARED | _PAGE_USER) 205#define PAGE_KERNEL_RO __pgprot(_PAGE_BASE | _PAGE_KERNEL_RO)
199#else 206#define PAGE_KERNEL_ROX __pgprot(_PAGE_BASE | _PAGE_KERNEL_RO | _PAGE_EXEC)
200#define _PAGE_KERNEL_RO (_PAGE_BASE | _PAGE_SHARED)
201#endif
202
203#define _PAGE_IO (_PAGE_KERNEL_NC | _PAGE_GUARDED)
204#define _PAGE_RAM (_PAGE_KERNEL | _PAGE_HWEXEC)
205 207
206#if defined(CONFIG_KGDB) || defined(CONFIG_XMON) || defined(CONFIG_BDI_SWITCH) ||\ 208#if defined(CONFIG_KGDB) || defined(CONFIG_XMON) || defined(CONFIG_BDI_SWITCH) ||\
207 defined(CONFIG_KPROBES) 209 defined(CONFIG_KPROBES)
208/* We want the debuggers to be able to set breakpoints anywhere, so 210/* We want the debuggers to be able to set breakpoints anywhere, so
209 * don't write protect the kernel text */ 211 * don't write protect the kernel text */
210#define _PAGE_RAM_TEXT _PAGE_RAM 212#define PAGE_KERNEL_TEXT PAGE_KERNEL_X
211#else 213#else
212#define _PAGE_RAM_TEXT (_PAGE_KERNEL_RO | _PAGE_HWEXEC) 214#define PAGE_KERNEL_TEXT PAGE_KERNEL_ROX
213#endif 215#endif
214 216
215#define PAGE_NONE __pgprot(_PAGE_BASE) 217#define PAGE_NONE __pgprot(_PAGE_BASE)
@@ -220,9 +222,6 @@ extern int icache_44x_need_flush;
220#define PAGE_COPY __pgprot(_PAGE_BASE | _PAGE_USER) 222#define PAGE_COPY __pgprot(_PAGE_BASE | _PAGE_USER)
221#define PAGE_COPY_X __pgprot(_PAGE_BASE | _PAGE_USER | _PAGE_EXEC) 223#define PAGE_COPY_X __pgprot(_PAGE_BASE | _PAGE_USER | _PAGE_EXEC)
222 224
223#define PAGE_KERNEL __pgprot(_PAGE_RAM)
224#define PAGE_KERNEL_NOCACHE __pgprot(_PAGE_IO)
225
226/* 225/*
227 * The PowerPC can only do execute protection on a segment (256MB) basis, 226 * The PowerPC can only do execute protection on a segment (256MB) basis,
228 * not on a page basis. So we consider execute permission the same as read. 227 * not on a page basis. So we consider execute permission the same as read.