diff options
author | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2009-08-18 15:00:34 -0400 |
---|---|---|
committer | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2009-08-26 23:12:51 -0400 |
commit | ea3cc330ac0cd521ff07c7cd432a1848c19a7e92 (patch) | |
tree | 82f3e84e28ebf5ae33d05ec0142c22b30a21c60a /arch/powerpc/include/asm | |
parent | f480fe3916de2e2cbb6e384cb685f0f1d8272188 (diff) |
powerpc/mm: Cleanup handling of execute permission
This is an attempt at cleaning up a bit the way we handle execute
permission on powerpc. _PAGE_HWEXEC is gone, _PAGE_EXEC is now only
defined by CPUs that can do something with it, and the myriad of
#ifdef's in the I$/D$ coherency code is reduced to 2 cases that
hopefully should cover everything.
The logic on BookE is a little bit different than what it was though
not by much. Since now, _PAGE_EXEC will be set by the generic code
for executable pages, we need to filter out if they are unclean and
recover it. However, I don't expect the code to be more bloated than
it already was in that area due to that change.
I could boast that this brings proper enforcing of per-page execute
permissions to all BookE and 40x but in fact, we've had that now for
some time as a side effect of my previous rework in that area (and
I didn't even know it :-) We would only enable execute permission if
the page was cache clean and we would only cache clean it if we took
and exec fault. Since we now enforce that the later only work if
VM_EXEC is part of the VMA flags, we de-fact already enforce per-page
execute permissions... Unless I missed something
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'arch/powerpc/include/asm')
-rw-r--r-- | arch/powerpc/include/asm/pgtable-ppc32.h | 7 | ||||
-rw-r--r-- | arch/powerpc/include/asm/pgtable-ppc64.h | 3 | ||||
-rw-r--r-- | arch/powerpc/include/asm/pte-40x.h | 2 | ||||
-rw-r--r-- | arch/powerpc/include/asm/pte-44x.h | 2 | ||||
-rw-r--r-- | arch/powerpc/include/asm/pte-8xx.h | 1 | ||||
-rw-r--r-- | arch/powerpc/include/asm/pte-book3e.h | 13 | ||||
-rw-r--r-- | arch/powerpc/include/asm/pte-common.h | 22 | ||||
-rw-r--r-- | arch/powerpc/include/asm/pte-fsl-booke.h | 2 | ||||
-rw-r--r-- | arch/powerpc/include/asm/pte-hash32.h | 1 |
9 files changed, 25 insertions, 28 deletions
diff --git a/arch/powerpc/include/asm/pgtable-ppc32.h b/arch/powerpc/include/asm/pgtable-ppc32.h index c9ff9d75990e..f2c52e253956 100644 --- a/arch/powerpc/include/asm/pgtable-ppc32.h +++ b/arch/powerpc/include/asm/pgtable-ppc32.h | |||
@@ -186,7 +186,7 @@ static inline unsigned long pte_update(pte_t *p, | |||
186 | #endif /* !PTE_ATOMIC_UPDATES */ | 186 | #endif /* !PTE_ATOMIC_UPDATES */ |
187 | 187 | ||
188 | #ifdef CONFIG_44x | 188 | #ifdef CONFIG_44x |
189 | if ((old & _PAGE_USER) && (old & _PAGE_HWEXEC)) | 189 | if ((old & _PAGE_USER) && (old & _PAGE_EXEC)) |
190 | icache_44x_need_flush = 1; | 190 | icache_44x_need_flush = 1; |
191 | #endif | 191 | #endif |
192 | return old; | 192 | return old; |
@@ -217,7 +217,7 @@ static inline unsigned long long pte_update(pte_t *p, | |||
217 | #endif /* !PTE_ATOMIC_UPDATES */ | 217 | #endif /* !PTE_ATOMIC_UPDATES */ |
218 | 218 | ||
219 | #ifdef CONFIG_44x | 219 | #ifdef CONFIG_44x |
220 | if ((old & _PAGE_USER) && (old & _PAGE_HWEXEC)) | 220 | if ((old & _PAGE_USER) && (old & _PAGE_EXEC)) |
221 | icache_44x_need_flush = 1; | 221 | icache_44x_need_flush = 1; |
222 | #endif | 222 | #endif |
223 | return old; | 223 | return old; |
@@ -267,8 +267,7 @@ static inline void huge_ptep_set_wrprotect(struct mm_struct *mm, | |||
267 | static inline void __ptep_set_access_flags(pte_t *ptep, pte_t entry) | 267 | static inline void __ptep_set_access_flags(pte_t *ptep, pte_t entry) |
268 | { | 268 | { |
269 | unsigned long bits = pte_val(entry) & | 269 | unsigned long bits = pte_val(entry) & |
270 | (_PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_RW | | 270 | (_PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_RW | _PAGE_EXEC); |
271 | _PAGE_HWEXEC | _PAGE_EXEC); | ||
272 | pte_update(ptep, 0, bits); | 271 | pte_update(ptep, 0, bits); |
273 | } | 272 | } |
274 | 273 | ||
diff --git a/arch/powerpc/include/asm/pgtable-ppc64.h b/arch/powerpc/include/asm/pgtable-ppc64.h index 200ec2dfa034..806abe7a3fa5 100644 --- a/arch/powerpc/include/asm/pgtable-ppc64.h +++ b/arch/powerpc/include/asm/pgtable-ppc64.h | |||
@@ -313,8 +313,7 @@ static inline void pte_clear(struct mm_struct *mm, unsigned long addr, | |||
313 | static inline void __ptep_set_access_flags(pte_t *ptep, pte_t entry) | 313 | static inline void __ptep_set_access_flags(pte_t *ptep, pte_t entry) |
314 | { | 314 | { |
315 | unsigned long bits = pte_val(entry) & | 315 | unsigned long bits = pte_val(entry) & |
316 | (_PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_RW | | 316 | (_PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_RW | _PAGE_EXEC); |
317 | _PAGE_EXEC | _PAGE_HWEXEC); | ||
318 | 317 | ||
319 | #ifdef PTE_ATOMIC_UPDATES | 318 | #ifdef PTE_ATOMIC_UPDATES |
320 | unsigned long old, tmp; | 319 | unsigned long old, tmp; |
diff --git a/arch/powerpc/include/asm/pte-40x.h b/arch/powerpc/include/asm/pte-40x.h index 07630faae029..6c3e1f4378d4 100644 --- a/arch/powerpc/include/asm/pte-40x.h +++ b/arch/powerpc/include/asm/pte-40x.h | |||
@@ -46,7 +46,7 @@ | |||
46 | #define _PAGE_RW 0x040 /* software: Writes permitted */ | 46 | #define _PAGE_RW 0x040 /* software: Writes permitted */ |
47 | #define _PAGE_DIRTY 0x080 /* software: dirty page */ | 47 | #define _PAGE_DIRTY 0x080 /* software: dirty page */ |
48 | #define _PAGE_HWWRITE 0x100 /* hardware: Dirty & RW, set in exception */ | 48 | #define _PAGE_HWWRITE 0x100 /* hardware: Dirty & RW, set in exception */ |
49 | #define _PAGE_HWEXEC 0x200 /* hardware: EX permission */ | 49 | #define _PAGE_EXEC 0x200 /* hardware: EX permission */ |
50 | #define _PAGE_ACCESSED 0x400 /* software: R: page referenced */ | 50 | #define _PAGE_ACCESSED 0x400 /* software: R: page referenced */ |
51 | 51 | ||
52 | #define _PMD_PRESENT 0x400 /* PMD points to page of PTEs */ | 52 | #define _PMD_PRESENT 0x400 /* PMD points to page of PTEs */ |
diff --git a/arch/powerpc/include/asm/pte-44x.h b/arch/powerpc/include/asm/pte-44x.h index 37e98bcf83e0..4192b9bad901 100644 --- a/arch/powerpc/include/asm/pte-44x.h +++ b/arch/powerpc/include/asm/pte-44x.h | |||
@@ -78,7 +78,7 @@ | |||
78 | #define _PAGE_PRESENT 0x00000001 /* S: PTE valid */ | 78 | #define _PAGE_PRESENT 0x00000001 /* S: PTE valid */ |
79 | #define _PAGE_RW 0x00000002 /* S: Write permission */ | 79 | #define _PAGE_RW 0x00000002 /* S: Write permission */ |
80 | #define _PAGE_FILE 0x00000004 /* S: nonlinear file mapping */ | 80 | #define _PAGE_FILE 0x00000004 /* S: nonlinear file mapping */ |
81 | #define _PAGE_HWEXEC 0x00000004 /* H: Execute permission */ | 81 | #define _PAGE_EXEC 0x00000004 /* H: Execute permission */ |
82 | #define _PAGE_ACCESSED 0x00000008 /* S: Page referenced */ | 82 | #define _PAGE_ACCESSED 0x00000008 /* S: Page referenced */ |
83 | #define _PAGE_DIRTY 0x00000010 /* S: Page dirty */ | 83 | #define _PAGE_DIRTY 0x00000010 /* S: Page dirty */ |
84 | #define _PAGE_SPECIAL 0x00000020 /* S: Special page */ | 84 | #define _PAGE_SPECIAL 0x00000020 /* S: Special page */ |
diff --git a/arch/powerpc/include/asm/pte-8xx.h b/arch/powerpc/include/asm/pte-8xx.h index 8c6e31251034..94e979718dcf 100644 --- a/arch/powerpc/include/asm/pte-8xx.h +++ b/arch/powerpc/include/asm/pte-8xx.h | |||
@@ -36,7 +36,6 @@ | |||
36 | /* These five software bits must be masked out when the entry is loaded | 36 | /* These five software bits must be masked out when the entry is loaded |
37 | * into the TLB. | 37 | * into the TLB. |
38 | */ | 38 | */ |
39 | #define _PAGE_EXEC 0x0008 /* software: i-cache coherency required */ | ||
40 | #define _PAGE_GUARDED 0x0010 /* software: guarded access */ | 39 | #define _PAGE_GUARDED 0x0010 /* software: guarded access */ |
41 | #define _PAGE_DIRTY 0x0020 /* software: page changed */ | 40 | #define _PAGE_DIRTY 0x0020 /* software: page changed */ |
42 | #define _PAGE_RW 0x0040 /* software: user write access allowed */ | 41 | #define _PAGE_RW 0x0040 /* software: user write access allowed */ |
diff --git a/arch/powerpc/include/asm/pte-book3e.h b/arch/powerpc/include/asm/pte-book3e.h index 1d27c77d7704..9800565aebb8 100644 --- a/arch/powerpc/include/asm/pte-book3e.h +++ b/arch/powerpc/include/asm/pte-book3e.h | |||
@@ -37,12 +37,13 @@ | |||
37 | #define _PAGE_WRITETHRU 0x800000 /* W: cache write-through */ | 37 | #define _PAGE_WRITETHRU 0x800000 /* W: cache write-through */ |
38 | 38 | ||
39 | /* "Higher level" linux bit combinations */ | 39 | /* "Higher level" linux bit combinations */ |
40 | #define _PAGE_EXEC _PAGE_BAP_SX /* Can be executed from potentially */ | 40 | #define _PAGE_EXEC _PAGE_BAP_UX /* .. and was cache cleaned */ |
41 | #define _PAGE_HWEXEC _PAGE_BAP_UX /* .. and was cache cleaned */ | 41 | #define _PAGE_RW (_PAGE_BAP_SW | _PAGE_BAP_UW) /* User write permission */ |
42 | #define _PAGE_RW (_PAGE_BAP_SW | _PAGE_BAP_UW) /* User write permission */ | 42 | #define _PAGE_KERNEL_RW (_PAGE_BAP_SW | _PAGE_BAP_SR | _PAGE_DIRTY) |
43 | #define _PAGE_KERNEL_RW (_PAGE_BAP_SW | _PAGE_BAP_SR | _PAGE_DIRTY) | 43 | #define _PAGE_KERNEL_RO (_PAGE_BAP_SR) |
44 | #define _PAGE_KERNEL_RO (_PAGE_BAP_SR) | 44 | #define _PAGE_KERNEL_RWX (_PAGE_BAP_SW | _PAGE_BAP_SR | _PAGE_DIRTY | _PAGE_BAP_SX) |
45 | #define _PAGE_USER (_PAGE_BAP_UR | _PAGE_BAP_SR) /* Can be read */ | 45 | #define _PAGE_KERNEL_ROX (_PAGE_BAP_SR | _PAGE_BAP_SX) |
46 | #define _PAGE_USER (_PAGE_BAP_UR | _PAGE_BAP_SR) /* Can be read */ | ||
46 | 47 | ||
47 | #define _PAGE_HASHPTE 0 | 48 | #define _PAGE_HASHPTE 0 |
48 | #define _PAGE_BUSY 0 | 49 | #define _PAGE_BUSY 0 |
diff --git a/arch/powerpc/include/asm/pte-common.h b/arch/powerpc/include/asm/pte-common.h index 8bb6464ba619..c3b65076a263 100644 --- a/arch/powerpc/include/asm/pte-common.h +++ b/arch/powerpc/include/asm/pte-common.h | |||
@@ -13,9 +13,6 @@ | |||
13 | #ifndef _PAGE_HWWRITE | 13 | #ifndef _PAGE_HWWRITE |
14 | #define _PAGE_HWWRITE 0 | 14 | #define _PAGE_HWWRITE 0 |
15 | #endif | 15 | #endif |
16 | #ifndef _PAGE_HWEXEC | ||
17 | #define _PAGE_HWEXEC 0 | ||
18 | #endif | ||
19 | #ifndef _PAGE_EXEC | 16 | #ifndef _PAGE_EXEC |
20 | #define _PAGE_EXEC 0 | 17 | #define _PAGE_EXEC 0 |
21 | #endif | 18 | #endif |
@@ -48,10 +45,16 @@ | |||
48 | #define PMD_PAGE_SIZE(pmd) bad_call_to_PMD_PAGE_SIZE() | 45 | #define PMD_PAGE_SIZE(pmd) bad_call_to_PMD_PAGE_SIZE() |
49 | #endif | 46 | #endif |
50 | #ifndef _PAGE_KERNEL_RO | 47 | #ifndef _PAGE_KERNEL_RO |
51 | #define _PAGE_KERNEL_RO 0 | 48 | #define _PAGE_KERNEL_RO 0 |
49 | #endif | ||
50 | #ifndef _PAGE_KERNEL_ROX | ||
51 | #define _PAGE_KERNEL_ROX (_PAGE_EXEC) | ||
52 | #endif | 52 | #endif |
53 | #ifndef _PAGE_KERNEL_RW | 53 | #ifndef _PAGE_KERNEL_RW |
54 | #define _PAGE_KERNEL_RW (_PAGE_DIRTY | _PAGE_RW | _PAGE_HWWRITE) | 54 | #define _PAGE_KERNEL_RW (_PAGE_DIRTY | _PAGE_RW | _PAGE_HWWRITE) |
55 | #endif | ||
56 | #ifndef _PAGE_KERNEL_RWX | ||
57 | #define _PAGE_KERNEL_RWX (_PAGE_DIRTY | _PAGE_RW | _PAGE_HWWRITE | _PAGE_EXEC) | ||
55 | #endif | 58 | #endif |
56 | #ifndef _PAGE_HPTEFLAGS | 59 | #ifndef _PAGE_HPTEFLAGS |
57 | #define _PAGE_HPTEFLAGS _PAGE_HASHPTE | 60 | #define _PAGE_HPTEFLAGS _PAGE_HASHPTE |
@@ -96,8 +99,7 @@ extern unsigned long bad_call_to_PMD_PAGE_SIZE(void); | |||
96 | #define PAGE_PROT_BITS (_PAGE_GUARDED | _PAGE_COHERENT | _PAGE_NO_CACHE | \ | 99 | #define PAGE_PROT_BITS (_PAGE_GUARDED | _PAGE_COHERENT | _PAGE_NO_CACHE | \ |
97 | _PAGE_WRITETHRU | _PAGE_ENDIAN | _PAGE_4K_PFN | \ | 100 | _PAGE_WRITETHRU | _PAGE_ENDIAN | _PAGE_4K_PFN | \ |
98 | _PAGE_USER | _PAGE_ACCESSED | \ | 101 | _PAGE_USER | _PAGE_ACCESSED | \ |
99 | _PAGE_RW | _PAGE_HWWRITE | _PAGE_DIRTY | \ | 102 | _PAGE_RW | _PAGE_HWWRITE | _PAGE_DIRTY | _PAGE_EXEC) |
100 | _PAGE_EXEC | _PAGE_HWEXEC) | ||
101 | 103 | ||
102 | /* | 104 | /* |
103 | * We define 2 sets of base prot bits, one for basic pages (ie, | 105 | * We define 2 sets of base prot bits, one for basic pages (ie, |
@@ -154,11 +156,9 @@ extern unsigned long bad_call_to_PMD_PAGE_SIZE(void); | |||
154 | _PAGE_NO_CACHE) | 156 | _PAGE_NO_CACHE) |
155 | #define PAGE_KERNEL_NCG __pgprot(_PAGE_BASE_NC | _PAGE_KERNEL_RW | \ | 157 | #define PAGE_KERNEL_NCG __pgprot(_PAGE_BASE_NC | _PAGE_KERNEL_RW | \ |
156 | _PAGE_NO_CACHE | _PAGE_GUARDED) | 158 | _PAGE_NO_CACHE | _PAGE_GUARDED) |
157 | #define PAGE_KERNEL_X __pgprot(_PAGE_BASE | _PAGE_KERNEL_RW | _PAGE_EXEC | \ | 159 | #define PAGE_KERNEL_X __pgprot(_PAGE_BASE | _PAGE_KERNEL_RWX) |
158 | _PAGE_HWEXEC) | ||
159 | #define PAGE_KERNEL_RO __pgprot(_PAGE_BASE | _PAGE_KERNEL_RO) | 160 | #define PAGE_KERNEL_RO __pgprot(_PAGE_BASE | _PAGE_KERNEL_RO) |
160 | #define PAGE_KERNEL_ROX __pgprot(_PAGE_BASE | _PAGE_KERNEL_RO | _PAGE_EXEC | \ | 161 | #define PAGE_KERNEL_ROX __pgprot(_PAGE_BASE | _PAGE_KERNEL_ROX) |
161 | _PAGE_HWEXEC) | ||
162 | 162 | ||
163 | /* Protection used for kernel text. We want the debuggers to be able to | 163 | /* Protection used for kernel text. We want the debuggers to be able to |
164 | * set breakpoints anywhere, so don't write protect the kernel text | 164 | * set breakpoints anywhere, so don't write protect the kernel text |
diff --git a/arch/powerpc/include/asm/pte-fsl-booke.h b/arch/powerpc/include/asm/pte-fsl-booke.h index 10820f58acf5..ce8a9e94ce7f 100644 --- a/arch/powerpc/include/asm/pte-fsl-booke.h +++ b/arch/powerpc/include/asm/pte-fsl-booke.h | |||
@@ -23,7 +23,7 @@ | |||
23 | #define _PAGE_FILE 0x00002 /* S: when !present: nonlinear file mapping */ | 23 | #define _PAGE_FILE 0x00002 /* S: when !present: nonlinear file mapping */ |
24 | #define _PAGE_RW 0x00004 /* S: Write permission (SW) */ | 24 | #define _PAGE_RW 0x00004 /* S: Write permission (SW) */ |
25 | #define _PAGE_DIRTY 0x00008 /* S: Page dirty */ | 25 | #define _PAGE_DIRTY 0x00008 /* S: Page dirty */ |
26 | #define _PAGE_HWEXEC 0x00010 /* H: SX permission */ | 26 | #define _PAGE_EXEC 0x00010 /* H: SX permission */ |
27 | #define _PAGE_ACCESSED 0x00020 /* S: Page referenced */ | 27 | #define _PAGE_ACCESSED 0x00020 /* S: Page referenced */ |
28 | 28 | ||
29 | #define _PAGE_ENDIAN 0x00040 /* H: E bit */ | 29 | #define _PAGE_ENDIAN 0x00040 /* H: E bit */ |
diff --git a/arch/powerpc/include/asm/pte-hash32.h b/arch/powerpc/include/asm/pte-hash32.h index 16e571c7f9ef..4aad4132d0a8 100644 --- a/arch/powerpc/include/asm/pte-hash32.h +++ b/arch/powerpc/include/asm/pte-hash32.h | |||
@@ -26,7 +26,6 @@ | |||
26 | #define _PAGE_WRITETHRU 0x040 /* W: cache write-through */ | 26 | #define _PAGE_WRITETHRU 0x040 /* W: cache write-through */ |
27 | #define _PAGE_DIRTY 0x080 /* C: page changed */ | 27 | #define _PAGE_DIRTY 0x080 /* C: page changed */ |
28 | #define _PAGE_ACCESSED 0x100 /* R: page referenced */ | 28 | #define _PAGE_ACCESSED 0x100 /* R: page referenced */ |
29 | #define _PAGE_EXEC 0x200 /* software: i-cache coherency required */ | ||
30 | #define _PAGE_RW 0x400 /* software: user write access allowed */ | 29 | #define _PAGE_RW 0x400 /* software: user write access allowed */ |
31 | #define _PAGE_SPECIAL 0x800 /* software: Special page */ | 30 | #define _PAGE_SPECIAL 0x800 /* software: Special page */ |
32 | 31 | ||