aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/include
diff options
context:
space:
mode:
authorLEROY Christophe <christophe.leroy@c-s.fr>2015-01-19 11:04:38 -0500
committerScott Wood <scottwood@freescale.com>2015-01-29 21:11:51 -0500
commita7b9f671f2d141528491c346e21e8a179cee9d21 (patch)
tree963edf92d3bc966992c78c4fa94d368003f9b396 /arch/powerpc/include
parentd2caa3cebda8b626336e100b80a0ed6f909dccab (diff)
powerpc32: adds handling of _PAGE_RO
Some powerpc like the 8xx don't have a RW bit in PTE bits but a RO (Read Only) bit. This patch implements the handling of a _PAGE_RO flag to be used in place of _PAGE_RW Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr> [scottwood@freescale.com: fix whitespace] Signed-off-by: Scott Wood <scottwood@freescale.com>
Diffstat (limited to 'arch/powerpc/include')
-rw-r--r--arch/powerpc/include/asm/pgtable-ppc32.h8
-rw-r--r--arch/powerpc/include/asm/pgtable.h7
-rw-r--r--arch/powerpc/include/asm/pte-common.h25
3 files changed, 27 insertions, 13 deletions
diff --git a/arch/powerpc/include/asm/pgtable-ppc32.h b/arch/powerpc/include/asm/pgtable-ppc32.h
index 234e07c47803..62a3e49a9a14 100644
--- a/arch/powerpc/include/asm/pgtable-ppc32.h
+++ b/arch/powerpc/include/asm/pgtable-ppc32.h
@@ -275,7 +275,7 @@ static inline pte_t ptep_get_and_clear(struct mm_struct *mm, unsigned long addr,
275static inline void ptep_set_wrprotect(struct mm_struct *mm, unsigned long addr, 275static inline void ptep_set_wrprotect(struct mm_struct *mm, unsigned long addr,
276 pte_t *ptep) 276 pte_t *ptep)
277{ 277{
278 pte_update(ptep, (_PAGE_RW | _PAGE_HWWRITE), 0); 278 pte_update(ptep, (_PAGE_RW | _PAGE_HWWRITE), _PAGE_RO);
279} 279}
280static inline void huge_ptep_set_wrprotect(struct mm_struct *mm, 280static inline void huge_ptep_set_wrprotect(struct mm_struct *mm,
281 unsigned long addr, pte_t *ptep) 281 unsigned long addr, pte_t *ptep)
@@ -286,9 +286,11 @@ static inline void huge_ptep_set_wrprotect(struct mm_struct *mm,
286 286
287static inline void __ptep_set_access_flags(pte_t *ptep, pte_t entry) 287static inline void __ptep_set_access_flags(pte_t *ptep, pte_t entry)
288{ 288{
289 unsigned long bits = pte_val(entry) & 289 unsigned long set = pte_val(entry) &
290 (_PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_RW | _PAGE_EXEC); 290 (_PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_RW | _PAGE_EXEC);
291 pte_update(ptep, 0, bits); 291 unsigned long clr = ~pte_val(entry) & _PAGE_RO;
292
293 pte_update(ptep, clr, set);
292} 294}
293 295
294#define __HAVE_ARCH_PTE_SAME 296#define __HAVE_ARCH_PTE_SAME
diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h
index a8805fee0df9..7e77f2ca5132 100644
--- a/arch/powerpc/include/asm/pgtable.h
+++ b/arch/powerpc/include/asm/pgtable.h
@@ -30,7 +30,8 @@ struct mm_struct;
30#include <asm/tlbflush.h> 30#include <asm/tlbflush.h>
31 31
32/* Generic accessors to PTE bits */ 32/* Generic accessors to PTE bits */
33static inline int pte_write(pte_t pte) { return pte_val(pte) & _PAGE_RW; } 33static inline int pte_write(pte_t pte)
34{ return (pte_val(pte) & (_PAGE_RW | _PAGE_RO)) != _PAGE_RO; }
34static inline int pte_dirty(pte_t pte) { return pte_val(pte) & _PAGE_DIRTY; } 35static inline int pte_dirty(pte_t pte) { return pte_val(pte) & _PAGE_DIRTY; }
35static inline int pte_young(pte_t pte) { return pte_val(pte) & _PAGE_ACCESSED; } 36static inline int pte_young(pte_t pte) { return pte_val(pte) & _PAGE_ACCESSED; }
36static inline int pte_file(pte_t pte) { return pte_val(pte) & _PAGE_FILE; } 37static inline int pte_file(pte_t pte) { return pte_val(pte) & _PAGE_FILE; }
@@ -115,12 +116,14 @@ static inline unsigned long pte_pfn(pte_t pte) {
115 116
116/* Generic modifiers for PTE bits */ 117/* Generic modifiers for PTE bits */
117static inline pte_t pte_wrprotect(pte_t pte) { 118static inline pte_t pte_wrprotect(pte_t pte) {
118 pte_val(pte) &= ~(_PAGE_RW | _PAGE_HWWRITE); return pte; } 119 pte_val(pte) &= ~(_PAGE_RW | _PAGE_HWWRITE);
120 pte_val(pte) |= _PAGE_RO; return pte; }
119static inline pte_t pte_mkclean(pte_t pte) { 121static inline pte_t pte_mkclean(pte_t pte) {
120 pte_val(pte) &= ~(_PAGE_DIRTY | _PAGE_HWWRITE); return pte; } 122 pte_val(pte) &= ~(_PAGE_DIRTY | _PAGE_HWWRITE); return pte; }
121static inline pte_t pte_mkold(pte_t pte) { 123static inline pte_t pte_mkold(pte_t pte) {
122 pte_val(pte) &= ~_PAGE_ACCESSED; return pte; } 124 pte_val(pte) &= ~_PAGE_ACCESSED; return pte; }
123static inline pte_t pte_mkwrite(pte_t pte) { 125static inline pte_t pte_mkwrite(pte_t pte) {
126 pte_val(pte) &= ~_PAGE_RO;
124 pte_val(pte) |= _PAGE_RW; return pte; } 127 pte_val(pte) |= _PAGE_RW; return pte; }
125static inline pte_t pte_mkdirty(pte_t pte) { 128static inline pte_t pte_mkdirty(pte_t pte) {
126 pte_val(pte) |= _PAGE_DIRTY; return pte; } 129 pte_val(pte) |= _PAGE_DIRTY; return pte; }
diff --git a/arch/powerpc/include/asm/pte-common.h b/arch/powerpc/include/asm/pte-common.h
index e040c3595129..2aef9b7a0eb2 100644
--- a/arch/powerpc/include/asm/pte-common.h
+++ b/arch/powerpc/include/asm/pte-common.h
@@ -34,6 +34,12 @@
34#ifndef _PAGE_PSIZE 34#ifndef _PAGE_PSIZE
35#define _PAGE_PSIZE 0 35#define _PAGE_PSIZE 0
36#endif 36#endif
37/* _PAGE_RO and _PAGE_RW shall not be defined at the same time */
38#ifndef _PAGE_RO
39#define _PAGE_RO 0
40#else
41#define _PAGE_RW 0
42#endif
37#ifndef _PMD_PRESENT_MASK 43#ifndef _PMD_PRESENT_MASK
38#define _PMD_PRESENT_MASK _PMD_PRESENT 44#define _PMD_PRESENT_MASK _PMD_PRESENT
39#endif 45#endif
@@ -42,10 +48,10 @@
42#define PMD_PAGE_SIZE(pmd) bad_call_to_PMD_PAGE_SIZE() 48#define PMD_PAGE_SIZE(pmd) bad_call_to_PMD_PAGE_SIZE()
43#endif 49#endif
44#ifndef _PAGE_KERNEL_RO 50#ifndef _PAGE_KERNEL_RO
45#define _PAGE_KERNEL_RO 0 51#define _PAGE_KERNEL_RO (_PAGE_RO)
46#endif 52#endif
47#ifndef _PAGE_KERNEL_ROX 53#ifndef _PAGE_KERNEL_ROX
48#define _PAGE_KERNEL_ROX (_PAGE_EXEC) 54#define _PAGE_KERNEL_ROX (_PAGE_EXEC | _PAGE_RO)
49#endif 55#endif
50#ifndef _PAGE_KERNEL_RW 56#ifndef _PAGE_KERNEL_RW
51#define _PAGE_KERNEL_RW (_PAGE_DIRTY | _PAGE_RW | _PAGE_HWWRITE) 57#define _PAGE_KERNEL_RW (_PAGE_DIRTY | _PAGE_RW | _PAGE_HWWRITE)
@@ -95,7 +101,7 @@ extern unsigned long bad_call_to_PMD_PAGE_SIZE(void);
95/* Mask of bits returned by pte_pgprot() */ 101/* Mask of bits returned by pte_pgprot() */
96#define PAGE_PROT_BITS (_PAGE_GUARDED | _PAGE_COHERENT | _PAGE_NO_CACHE | \ 102#define PAGE_PROT_BITS (_PAGE_GUARDED | _PAGE_COHERENT | _PAGE_NO_CACHE | \
97 _PAGE_WRITETHRU | _PAGE_ENDIAN | _PAGE_4K_PFN | \ 103 _PAGE_WRITETHRU | _PAGE_ENDIAN | _PAGE_4K_PFN | \
98 _PAGE_USER | _PAGE_ACCESSED | \ 104 _PAGE_USER | _PAGE_ACCESSED | _PAGE_RO | \
99 _PAGE_RW | _PAGE_HWWRITE | _PAGE_DIRTY | _PAGE_EXEC) 105 _PAGE_RW | _PAGE_HWWRITE | _PAGE_DIRTY | _PAGE_EXEC)
100 106
101#ifdef CONFIG_NUMA_BALANCING 107#ifdef CONFIG_NUMA_BALANCING
@@ -128,11 +134,14 @@ extern unsigned long bad_call_to_PMD_PAGE_SIZE(void);
128 */ 134 */
129#define PAGE_NONE __pgprot(_PAGE_BASE) 135#define PAGE_NONE __pgprot(_PAGE_BASE)
130#define PAGE_SHARED __pgprot(_PAGE_BASE | _PAGE_USER | _PAGE_RW) 136#define PAGE_SHARED __pgprot(_PAGE_BASE | _PAGE_USER | _PAGE_RW)
131#define PAGE_SHARED_X __pgprot(_PAGE_BASE | _PAGE_USER | _PAGE_RW | _PAGE_EXEC) 137#define PAGE_SHARED_X __pgprot(_PAGE_BASE | _PAGE_USER | _PAGE_RW | \
132#define PAGE_COPY __pgprot(_PAGE_BASE | _PAGE_USER) 138 _PAGE_EXEC)
133#define PAGE_COPY_X __pgprot(_PAGE_BASE | _PAGE_USER | _PAGE_EXEC) 139#define PAGE_COPY __pgprot(_PAGE_BASE | _PAGE_USER | _PAGE_RO)
134#define PAGE_READONLY __pgprot(_PAGE_BASE | _PAGE_USER) 140#define PAGE_COPY_X __pgprot(_PAGE_BASE | _PAGE_USER | _PAGE_RO | \
135#define PAGE_READONLY_X __pgprot(_PAGE_BASE | _PAGE_USER | _PAGE_EXEC) 141 _PAGE_EXEC)
142#define PAGE_READONLY __pgprot(_PAGE_BASE | _PAGE_USER | _PAGE_RO)
143#define PAGE_READONLY_X __pgprot(_PAGE_BASE | _PAGE_USER | _PAGE_RO | \
144 _PAGE_EXEC)
136 145
137#define __P000 PAGE_NONE 146#define __P000 PAGE_NONE
138#define __P001 PAGE_READONLY 147#define __P001 PAGE_READONLY