diff options
author | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2009-03-19 15:34:08 -0400 |
---|---|---|
committer | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2009-03-23 22:47:33 -0400 |
commit | 8d1cf34e7ad5c7738ce20d20bd7f002f562cb8b5 (patch) | |
tree | f731b8b2d3e71e7287bed977bdd7fc9ea6942d45 /arch | |
parent | 2a7d55fda58eb4e3652252d4f71222bd1ff90c5e (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')
-rw-r--r-- | arch/powerpc/include/asm/fixmap.h | 2 | ||||
-rw-r--r-- | arch/powerpc/include/asm/pgtable-ppc32.h | 41 | ||||
-rw-r--r-- | arch/powerpc/include/asm/pgtable-ppc64.h | 46 | ||||
-rw-r--r-- | arch/powerpc/include/asm/pgtable.h | 4 | ||||
-rw-r--r-- | arch/powerpc/include/asm/pte-8xx.h | 3 | ||||
-rw-r--r-- | arch/powerpc/include/asm/pte-hash32.h | 1 | ||||
-rw-r--r-- | arch/powerpc/include/asm/pte-hash64-4k.h | 3 | ||||
-rw-r--r-- | arch/powerpc/include/asm/pte-hash64.h | 47 | ||||
-rw-r--r-- | arch/powerpc/mm/fsl_booke_mmu.c | 2 | ||||
-rw-r--r-- | arch/powerpc/mm/pgtable_32.c | 4 | ||||
-rw-r--r-- | arch/powerpc/mm/ppc_mmu_32.c | 10 | ||||
-rw-r--r-- | arch/powerpc/sysdev/cpm_common.c | 2 |
12 files changed, 89 insertions, 76 deletions
diff --git a/arch/powerpc/include/asm/fixmap.h b/arch/powerpc/include/asm/fixmap.h index 8428b38a3d30..d60fd18f428c 100644 --- a/arch/powerpc/include/asm/fixmap.h +++ b/arch/powerpc/include/asm/fixmap.h | |||
@@ -61,7 +61,7 @@ extern void __set_fixmap (enum fixed_addresses idx, | |||
61 | * Some hardware wants to get fixmapped without caching. | 61 | * Some hardware wants to get fixmapped without caching. |
62 | */ | 62 | */ |
63 | #define set_fixmap_nocache(idx, phys) \ | 63 | #define set_fixmap_nocache(idx, phys) \ |
64 | __set_fixmap(idx, phys, PAGE_KERNEL_NOCACHE) | 64 | __set_fixmap(idx, phys, PAGE_KERNEL_NCG) |
65 | 65 | ||
66 | #define clear_fixmap(idx) \ | 66 | #define clear_fixmap(idx) \ |
67 | __set_fixmap(idx, 0, __pgprot(0)) | 67 | __set_fixmap(idx, 0, __pgprot(0)) |
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. |
diff --git a/arch/powerpc/include/asm/pgtable-ppc64.h b/arch/powerpc/include/asm/pgtable-ppc64.h index 542073836b29..5a575f2905f5 100644 --- a/arch/powerpc/include/asm/pgtable-ppc64.h +++ b/arch/powerpc/include/asm/pgtable-ppc64.h | |||
@@ -81,11 +81,6 @@ | |||
81 | */ | 81 | */ |
82 | #include <asm/pte-hash64.h> | 82 | #include <asm/pte-hash64.h> |
83 | 83 | ||
84 | /* To make some generic powerpc code happy */ | ||
85 | #ifndef _PAGE_HWEXEC | ||
86 | #define _PAGE_HWEXEC 0 | ||
87 | #endif | ||
88 | |||
89 | /* Some other useful definitions */ | 84 | /* Some other useful definitions */ |
90 | #define PTE_RPN_MAX (1UL << (64 - PTE_RPN_SHIFT)) | 85 | #define PTE_RPN_MAX (1UL << (64 - PTE_RPN_SHIFT)) |
91 | #define PTE_RPN_MASK (~((1UL<<PTE_RPN_SHIFT)-1)) | 86 | #define PTE_RPN_MASK (~((1UL<<PTE_RPN_SHIFT)-1)) |
@@ -96,28 +91,44 @@ | |||
96 | #define _PAGE_CHG_MASK (PTE_RPN_MASK | _PAGE_HPTEFLAGS | _PAGE_DIRTY | \ | 91 | #define _PAGE_CHG_MASK (PTE_RPN_MASK | _PAGE_HPTEFLAGS | _PAGE_DIRTY | \ |
97 | _PAGE_ACCESSED | _PAGE_SPECIAL) | 92 | _PAGE_ACCESSED | _PAGE_SPECIAL) |
98 | 93 | ||
94 | #define _PAGE_BASE_NC (_PAGE_PRESENT | _PAGE_ACCESSED | _PAGE_PSIZE) | ||
95 | #define _PAGE_BASE (_PAGE_BASE_NC | _PAGE_COHERENT) | ||
99 | 96 | ||
100 | 97 | ||
101 | /* __pgprot defined in arch/powerpc/include/asm/page.h */ | 98 | /* Permission masks used to generate the __P and __S table, |
102 | #define PAGE_NONE __pgprot(_PAGE_PRESENT | _PAGE_ACCESSED) | 99 | * |
103 | 100 | * Note:__pgprot is defined in arch/powerpc/include/asm/page.h | |
104 | #define PAGE_SHARED __pgprot(_PAGE_BASE | _PAGE_RW | _PAGE_USER) | 101 | */ |
105 | #define PAGE_SHARED_X __pgprot(_PAGE_BASE | _PAGE_RW | _PAGE_USER | _PAGE_EXEC) | 102 | #define PAGE_NONE __pgprot(_PAGE_BASE) |
103 | #define PAGE_SHARED __pgprot(_PAGE_BASE | _PAGE_USER | _PAGE_RW) | ||
104 | #define PAGE_SHARED_X __pgprot(_PAGE_BASE | _PAGE_USER | _PAGE_RW | _PAGE_EXEC) | ||
106 | #define PAGE_COPY __pgprot(_PAGE_BASE | _PAGE_USER) | 105 | #define PAGE_COPY __pgprot(_PAGE_BASE | _PAGE_USER) |
107 | #define PAGE_COPY_X __pgprot(_PAGE_BASE | _PAGE_USER | _PAGE_EXEC) | 106 | #define PAGE_COPY_X __pgprot(_PAGE_BASE | _PAGE_USER | _PAGE_EXEC) |
108 | #define PAGE_READONLY __pgprot(_PAGE_BASE | _PAGE_USER) | 107 | #define PAGE_READONLY __pgprot(_PAGE_BASE | _PAGE_USER) |
109 | #define PAGE_READONLY_X __pgprot(_PAGE_BASE | _PAGE_USER | _PAGE_EXEC) | 108 | #define PAGE_READONLY_X __pgprot(_PAGE_BASE | _PAGE_USER | _PAGE_EXEC) |
110 | #define PAGE_KERNEL __pgprot(_PAGE_BASE | _PAGE_WRENABLE) | ||
111 | #define PAGE_KERNEL_CI __pgprot(_PAGE_PRESENT | _PAGE_ACCESSED | \ | ||
112 | _PAGE_WRENABLE | _PAGE_NO_CACHE | _PAGE_GUARDED) | ||
113 | #define PAGE_KERNEL_EXEC __pgprot(_PAGE_BASE | _PAGE_WRENABLE | _PAGE_EXEC) | ||
114 | 109 | ||
115 | #define PAGE_AGP __pgprot(_PAGE_BASE | _PAGE_WRENABLE | _PAGE_NO_CACHE) | 110 | /* Permission masks used for kernel mappings */ |
116 | #define HAVE_PAGE_AGP | 111 | #define PAGE_KERNEL __pgprot(_PAGE_BASE | _PAGE_KERNEL_RW) |
112 | #define PAGE_KERNEL_NC __pgprot(_PAGE_BASE_NC | _PAGE_KERNEL_RW | \ | ||
113 | _PAGE_NO_CACHE) | ||
114 | #define PAGE_KERNEL_NCG __pgprot(_PAGE_BASE_NC | _PAGE_KERNEL_RW | \ | ||
115 | _PAGE_NO_CACHE | _PAGE_GUARDED) | ||
116 | #define PAGE_KERNEL_X __pgprot(_PAGE_BASE | _PAGE_KERNEL_RW | _PAGE_EXEC) | ||
117 | #define PAGE_KERNEL_RO __pgprot(_PAGE_BASE | _PAGE_KERNEL_RO) | ||
118 | #define PAGE_KERNEL_ROX __pgprot(_PAGE_BASE | _PAGE_KERNEL_RO | _PAGE_EXEC) | ||
119 | |||
120 | /* Protection bits for use by pte_pgprot() */ | ||
121 | #define PAGE_PROT_BITS (_PAGE_GUARDED | _PAGE_COHERENT | \ | ||
122 | _PAGE_NO_CACHE | _PAGE_WRITETHRU | \ | ||
123 | _PAGE_4K_PFN | _PAGE_USER | _PAGE_RW | \ | ||
124 | _PAGE_ACCESSED | _PAGE_DIRTY | _PAGE_EXEC) | ||
125 | |||
117 | 126 | ||
118 | /* We always have _PAGE_SPECIAL on 64 bit */ | 127 | /* We always have _PAGE_SPECIAL on 64 bit */ |
119 | #define __HAVE_ARCH_PTE_SPECIAL | 128 | #define __HAVE_ARCH_PTE_SPECIAL |
120 | 129 | ||
130 | /* Make modules code happy. We don't set RO yet */ | ||
131 | #define PAGE_KERNEL_EXEC PAGE_KERNEL_X | ||
121 | 132 | ||
122 | /* | 133 | /* |
123 | * POWER4 and newer have per page execute protection, older chips can only | 134 | * POWER4 and newer have per page execute protection, older chips can only |
@@ -395,7 +406,8 @@ static inline void pte_clear(struct mm_struct *mm, unsigned long addr, | |||
395 | static inline void __ptep_set_access_flags(pte_t *ptep, pte_t entry) | 406 | static inline void __ptep_set_access_flags(pte_t *ptep, pte_t entry) |
396 | { | 407 | { |
397 | unsigned long bits = pte_val(entry) & | 408 | unsigned long bits = pte_val(entry) & |
398 | (_PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_RW | _PAGE_EXEC); | 409 | (_PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_RW | |
410 | _PAGE_EXEC | _PAGE_HWEXEC); | ||
399 | unsigned long old, tmp; | 411 | unsigned long old, tmp; |
400 | 412 | ||
401 | __asm__ __volatile__( | 413 | __asm__ __volatile__( |
diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h index 5c1c4880723c..81574f94ea32 100644 --- a/arch/powerpc/include/asm/pgtable.h +++ b/arch/powerpc/include/asm/pgtable.h | |||
@@ -25,6 +25,10 @@ static inline void assert_pte_locked(struct mm_struct *mm, unsigned long addr) | |||
25 | # include <asm/pgtable-ppc32.h> | 25 | # include <asm/pgtable-ppc32.h> |
26 | #endif | 26 | #endif |
27 | 27 | ||
28 | /* Special mapping for AGP */ | ||
29 | #define PAGE_AGP (PAGE_KERNEL_NC) | ||
30 | #define HAVE_PAGE_AGP | ||
31 | |||
28 | #ifndef __ASSEMBLY__ | 32 | #ifndef __ASSEMBLY__ |
29 | 33 | ||
30 | /* Insert a PTE, top-level function is out of line. It uses an inline | 34 | /* Insert a PTE, top-level function is out of line. It uses an inline |
diff --git a/arch/powerpc/include/asm/pte-8xx.h b/arch/powerpc/include/asm/pte-8xx.h index b07acfd330b0..8c6e31251034 100644 --- a/arch/powerpc/include/asm/pte-8xx.h +++ b/arch/powerpc/include/asm/pte-8xx.h | |||
@@ -59,6 +59,9 @@ | |||
59 | /* Until my rework is finished, 8xx still needs atomic PTE updates */ | 59 | /* Until my rework is finished, 8xx still needs atomic PTE updates */ |
60 | #define PTE_ATOMIC_UPDATES 1 | 60 | #define PTE_ATOMIC_UPDATES 1 |
61 | 61 | ||
62 | /* We need to add _PAGE_SHARED to kernel pages */ | ||
63 | #define _PAGE_KERNEL_RO (_PAGE_SHARED) | ||
64 | #define _PAGE_KERNEL_RW (_PAGE_DIRTY | _PAGE_RW | _PAGE_HWWRITE) | ||
62 | 65 | ||
63 | #endif /* __KERNEL__ */ | 66 | #endif /* __KERNEL__ */ |
64 | #endif /* _ASM_POWERPC_PTE_8xx_H */ | 67 | #endif /* _ASM_POWERPC_PTE_8xx_H */ |
diff --git a/arch/powerpc/include/asm/pte-hash32.h b/arch/powerpc/include/asm/pte-hash32.h index 6afe22b02f2f..16e571c7f9ef 100644 --- a/arch/powerpc/include/asm/pte-hash32.h +++ b/arch/powerpc/include/asm/pte-hash32.h | |||
@@ -44,6 +44,5 @@ | |||
44 | /* Hash table based platforms need atomic updates of the linux PTE */ | 44 | /* Hash table based platforms need atomic updates of the linux PTE */ |
45 | #define PTE_ATOMIC_UPDATES 1 | 45 | #define PTE_ATOMIC_UPDATES 1 |
46 | 46 | ||
47 | |||
48 | #endif /* __KERNEL__ */ | 47 | #endif /* __KERNEL__ */ |
49 | #endif /* _ASM_POWERPC_PTE_HASH32_H */ | 48 | #endif /* _ASM_POWERPC_PTE_HASH32_H */ |
diff --git a/arch/powerpc/include/asm/pte-hash64-4k.h b/arch/powerpc/include/asm/pte-hash64-4k.h index 29fdc158fe3f..c134e809aac3 100644 --- a/arch/powerpc/include/asm/pte-hash64-4k.h +++ b/arch/powerpc/include/asm/pte-hash64-4k.h | |||
@@ -8,9 +8,6 @@ | |||
8 | #define _PAGE_F_GIX _PAGE_GROUP_IX | 8 | #define _PAGE_F_GIX _PAGE_GROUP_IX |
9 | #define _PAGE_SPECIAL 0x10000 /* software: special page */ | 9 | #define _PAGE_SPECIAL 0x10000 /* software: special page */ |
10 | 10 | ||
11 | /* There is no 4K PFN hack on 4K pages */ | ||
12 | #define _PAGE_4K_PFN 0 | ||
13 | |||
14 | /* PTE flags to conserve for HPTE identification */ | 11 | /* PTE flags to conserve for HPTE identification */ |
15 | #define _PAGE_HPTEFLAGS (_PAGE_BUSY | _PAGE_HASHPTE | \ | 12 | #define _PAGE_HPTEFLAGS (_PAGE_BUSY | _PAGE_HASHPTE | \ |
16 | _PAGE_SECONDARY | _PAGE_GROUP_IX) | 13 | _PAGE_SECONDARY | _PAGE_GROUP_IX) |
diff --git a/arch/powerpc/include/asm/pte-hash64.h b/arch/powerpc/include/asm/pte-hash64.h index 62766636cc1e..b61b7e4a18de 100644 --- a/arch/powerpc/include/asm/pte-hash64.h +++ b/arch/powerpc/include/asm/pte-hash64.h | |||
@@ -6,36 +6,41 @@ | |||
6 | * Common bits between 4K and 64K pages in a linux-style PTE. | 6 | * Common bits between 4K and 64K pages in a linux-style PTE. |
7 | * These match the bits in the (hardware-defined) PowerPC PTE as closely | 7 | * These match the bits in the (hardware-defined) PowerPC PTE as closely |
8 | * as possible. Additional bits may be defined in pgtable-hash64-*.h | 8 | * as possible. Additional bits may be defined in pgtable-hash64-*.h |
9 | * | ||
10 | * Note: We only support user read/write permissions. Supervisor always | ||
11 | * have full read/write to pages above PAGE_OFFSET (pages below that | ||
12 | * always use the user access permissions). | ||
13 | * | ||
14 | * We could create separate kernel read-only if we used the 3 PP bits | ||
15 | * combinations that newer processors provide but we currently don't. | ||
9 | */ | 16 | */ |
10 | #define _PAGE_PRESENT 0x0001 /* software: pte contains a translation */ | 17 | #define _PAGE_PRESENT 0x0001 /* software: pte contains a translation */ |
11 | #define _PAGE_USER 0x0002 /* matches one of the PP bits */ | 18 | #define _PAGE_USER 0x0002 /* matches one of the PP bits */ |
12 | #define _PAGE_FILE 0x0002 /* (!present only) software: pte holds file offset */ | 19 | #define _PAGE_FILE 0x0002 /* (!present only) software: pte holds file offset */ |
13 | #define _PAGE_EXEC 0x0004 /* No execute on POWER4 and newer (we invert) */ | 20 | #define _PAGE_EXEC 0x0004 /* No execute on POWER4 and newer (we invert) */ |
14 | #define _PAGE_GUARDED 0x0008 | 21 | #define _PAGE_GUARDED 0x0008 |
15 | #define _PAGE_COHERENT 0x0010 /* M: enforce memory coherence (SMP systems) */ | 22 | #define _PAGE_COHERENT 0x0010 /* M: enforce memory coherence (SMP systems) */ |
16 | #define _PAGE_NO_CACHE 0x0020 /* I: cache inhibit */ | 23 | #define _PAGE_NO_CACHE 0x0020 /* I: cache inhibit */ |
17 | #define _PAGE_WRITETHRU 0x0040 /* W: cache write-through */ | 24 | #define _PAGE_WRITETHRU 0x0040 /* W: cache write-through */ |
18 | #define _PAGE_DIRTY 0x0080 /* C: page changed */ | 25 | #define _PAGE_DIRTY 0x0080 /* C: page changed */ |
19 | #define _PAGE_ACCESSED 0x0100 /* R: page referenced */ | 26 | #define _PAGE_ACCESSED 0x0100 /* R: page referenced */ |
20 | #define _PAGE_RW 0x0200 /* software: user write access allowed */ | 27 | #define _PAGE_RW 0x0200 /* software: user write access allowed */ |
21 | #define _PAGE_BUSY 0x0800 /* software: PTE & hash are busy */ | 28 | #define _PAGE_BUSY 0x0800 /* software: PTE & hash are busy */ |
29 | |||
30 | /* No separate kernel read-only */ | ||
31 | #define _PAGE_KERNEL_RW (_PAGE_RW | _PAGE_DIRTY) /* user access blocked by key */ | ||
32 | #define _PAGE_KERNEL_RO _PAGE_KERNEL_RW | ||
22 | 33 | ||
23 | /* Strong Access Ordering */ | 34 | /* Strong Access Ordering */ |
24 | #define _PAGE_SAO (_PAGE_WRITETHRU | _PAGE_NO_CACHE | _PAGE_COHERENT) | 35 | #define _PAGE_SAO (_PAGE_WRITETHRU | _PAGE_NO_CACHE | _PAGE_COHERENT) |
25 | 36 | ||
26 | #define _PAGE_BASE (_PAGE_PRESENT | _PAGE_ACCESSED | _PAGE_COHERENT) | 37 | /* No page size encoding in the linux PTE */ |
27 | 38 | #define _PAGE_PSIZE 0 | |
28 | #define _PAGE_WRENABLE (_PAGE_RW | _PAGE_DIRTY) | ||
29 | 39 | ||
30 | /* PTEIDX nibble */ | 40 | /* PTEIDX nibble */ |
31 | #define _PTEIDX_SECONDARY 0x8 | 41 | #define _PTEIDX_SECONDARY 0x8 |
32 | #define _PTEIDX_GROUP_IX 0x7 | 42 | #define _PTEIDX_GROUP_IX 0x7 |
33 | 43 | ||
34 | #define PAGE_PROT_BITS (_PAGE_GUARDED | _PAGE_COHERENT | \ | ||
35 | _PAGE_NO_CACHE | _PAGE_WRITETHRU | \ | ||
36 | _PAGE_4K_PFN | _PAGE_RW | _PAGE_USER | \ | ||
37 | _PAGE_ACCESSED | _PAGE_DIRTY | _PAGE_EXEC) | ||
38 | |||
39 | 44 | ||
40 | #ifdef CONFIG_PPC_64K_PAGES | 45 | #ifdef CONFIG_PPC_64K_PAGES |
41 | #include <asm/pte-hash64-64k.h> | 46 | #include <asm/pte-hash64-64k.h> |
diff --git a/arch/powerpc/mm/fsl_booke_mmu.c b/arch/powerpc/mm/fsl_booke_mmu.c index 985b6c361ab4..bb3d65998e6b 100644 --- a/arch/powerpc/mm/fsl_booke_mmu.c +++ b/arch/powerpc/mm/fsl_booke_mmu.c | |||
@@ -162,7 +162,7 @@ unsigned long __init mmu_mapin_ram(void) | |||
162 | phys_addr_t phys = memstart_addr; | 162 | phys_addr_t phys = memstart_addr; |
163 | 163 | ||
164 | while (cam[tlbcam_index] && tlbcam_index < ARRAY_SIZE(cam)) { | 164 | while (cam[tlbcam_index] && tlbcam_index < ARRAY_SIZE(cam)) { |
165 | settlbcam(tlbcam_index, virt, phys, cam[tlbcam_index], _PAGE_KERNEL, 0); | 165 | settlbcam(tlbcam_index, virt, phys, cam[tlbcam_index], PAGE_KERNEL_X, 0); |
166 | virt += cam[tlbcam_index]; | 166 | virt += cam[tlbcam_index]; |
167 | phys += cam[tlbcam_index]; | 167 | phys += cam[tlbcam_index]; |
168 | tlbcam_index++; | 168 | tlbcam_index++; |
diff --git a/arch/powerpc/mm/pgtable_32.c b/arch/powerpc/mm/pgtable_32.c index 0f8c4371dfab..430d0908fa50 100644 --- a/arch/powerpc/mm/pgtable_32.c +++ b/arch/powerpc/mm/pgtable_32.c | |||
@@ -164,7 +164,7 @@ __ioremap_caller(phys_addr_t addr, unsigned long size, unsigned long flags, | |||
164 | 164 | ||
165 | /* Make sure we have the base flags */ | 165 | /* Make sure we have the base flags */ |
166 | if ((flags & _PAGE_PRESENT) == 0) | 166 | if ((flags & _PAGE_PRESENT) == 0) |
167 | flags |= _PAGE_KERNEL; | 167 | flags |= PAGE_KERNEL; |
168 | 168 | ||
169 | /* Non-cacheable page cannot be coherent */ | 169 | /* Non-cacheable page cannot be coherent */ |
170 | if (flags & _PAGE_NO_CACHE) | 170 | if (flags & _PAGE_NO_CACHE) |
@@ -296,7 +296,7 @@ void __init mapin_ram(void) | |||
296 | p = memstart_addr + s; | 296 | p = memstart_addr + s; |
297 | for (; s < total_lowmem; s += PAGE_SIZE) { | 297 | for (; s < total_lowmem; s += PAGE_SIZE) { |
298 | ktext = ((char *) v >= _stext && (char *) v < etext); | 298 | ktext = ((char *) v >= _stext && (char *) v < etext); |
299 | f = ktext ?_PAGE_RAM_TEXT : _PAGE_RAM; | 299 | f = ktext ? PAGE_KERNEL_TEXT : PAGE_KERNEL; |
300 | map_page(v, p, f); | 300 | map_page(v, p, f); |
301 | #ifdef CONFIG_PPC_STD_MMU_32 | 301 | #ifdef CONFIG_PPC_STD_MMU_32 |
302 | if (ktext) | 302 | if (ktext) |
diff --git a/arch/powerpc/mm/ppc_mmu_32.c b/arch/powerpc/mm/ppc_mmu_32.c index fe65c405412c..2d2a87e10154 100644 --- a/arch/powerpc/mm/ppc_mmu_32.c +++ b/arch/powerpc/mm/ppc_mmu_32.c | |||
@@ -74,9 +74,6 @@ unsigned long p_mapped_by_bats(phys_addr_t pa) | |||
74 | 74 | ||
75 | unsigned long __init mmu_mapin_ram(void) | 75 | unsigned long __init mmu_mapin_ram(void) |
76 | { | 76 | { |
77 | #ifdef CONFIG_POWER4 | ||
78 | return 0; | ||
79 | #else | ||
80 | unsigned long tot, bl, done; | 77 | unsigned long tot, bl, done; |
81 | unsigned long max_size = (256<<20); | 78 | unsigned long max_size = (256<<20); |
82 | 79 | ||
@@ -95,7 +92,7 @@ unsigned long __init mmu_mapin_ram(void) | |||
95 | break; | 92 | break; |
96 | } | 93 | } |
97 | 94 | ||
98 | setbat(2, PAGE_OFFSET, 0, bl, _PAGE_RAM); | 95 | setbat(2, PAGE_OFFSET, 0, bl, PAGE_KERNEL_X); |
99 | done = (unsigned long)bat_addrs[2].limit - PAGE_OFFSET + 1; | 96 | done = (unsigned long)bat_addrs[2].limit - PAGE_OFFSET + 1; |
100 | if ((done < tot) && !bat_addrs[3].limit) { | 97 | if ((done < tot) && !bat_addrs[3].limit) { |
101 | /* use BAT3 to cover a bit more */ | 98 | /* use BAT3 to cover a bit more */ |
@@ -103,12 +100,11 @@ unsigned long __init mmu_mapin_ram(void) | |||
103 | for (bl = 128<<10; bl < max_size; bl <<= 1) | 100 | for (bl = 128<<10; bl < max_size; bl <<= 1) |
104 | if (bl * 2 > tot) | 101 | if (bl * 2 > tot) |
105 | break; | 102 | break; |
106 | setbat(3, PAGE_OFFSET+done, done, bl, _PAGE_RAM); | 103 | setbat(3, PAGE_OFFSET+done, done, bl, PAGE_KERNEL_X); |
107 | done = (unsigned long)bat_addrs[3].limit - PAGE_OFFSET + 1; | 104 | done = (unsigned long)bat_addrs[3].limit - PAGE_OFFSET + 1; |
108 | } | 105 | } |
109 | 106 | ||
110 | return done; | 107 | return done; |
111 | #endif | ||
112 | } | 108 | } |
113 | 109 | ||
114 | /* | 110 | /* |
@@ -136,9 +132,7 @@ void __init setbat(int index, unsigned long virt, phys_addr_t phys, | |||
136 | wimgxpp |= (flags & _PAGE_RW)? BPP_RW: BPP_RX; | 132 | wimgxpp |= (flags & _PAGE_RW)? BPP_RW: BPP_RX; |
137 | bat[1].batu = virt | (bl << 2) | 2; /* Vs=1, Vp=0 */ | 133 | bat[1].batu = virt | (bl << 2) | 2; /* Vs=1, Vp=0 */ |
138 | bat[1].batl = BAT_PHYS_ADDR(phys) | wimgxpp; | 134 | bat[1].batl = BAT_PHYS_ADDR(phys) | wimgxpp; |
139 | #ifndef CONFIG_KGDB /* want user access for breakpoints */ | ||
140 | if (flags & _PAGE_USER) | 135 | if (flags & _PAGE_USER) |
141 | #endif | ||
142 | bat[1].batu |= 1; /* Vp = 1 */ | 136 | bat[1].batu |= 1; /* Vp = 1 */ |
143 | if (flags & _PAGE_GUARDED) { | 137 | if (flags & _PAGE_GUARDED) { |
144 | /* G bit must be zero in IBATs */ | 138 | /* G bit must be zero in IBATs */ |
diff --git a/arch/powerpc/sysdev/cpm_common.c b/arch/powerpc/sysdev/cpm_common.c index 00d3d17c84a3..e4b6d66d93de 100644 --- a/arch/powerpc/sysdev/cpm_common.c +++ b/arch/powerpc/sysdev/cpm_common.c | |||
@@ -56,7 +56,7 @@ void __init udbg_init_cpm(void) | |||
56 | { | 56 | { |
57 | if (cpm_udbg_txdesc) { | 57 | if (cpm_udbg_txdesc) { |
58 | #ifdef CONFIG_CPM2 | 58 | #ifdef CONFIG_CPM2 |
59 | setbat(1, 0xf0000000, 0xf0000000, 1024*1024, _PAGE_IO); | 59 | setbat(1, 0xf0000000, 0xf0000000, 1024*1024, PAGE_KERNEL_NCG); |
60 | #endif | 60 | #endif |
61 | udbg_putc = udbg_putc_cpm; | 61 | udbg_putc = udbg_putc_cpm; |
62 | } | 62 | } |