Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ARM: 7075/1: LPAE: Factor out 2-level page table definitions into separate files

This patch moves page table definitions from asm/page.h, asm/pgtable.h
and asm/ptgable-hwdef.h into corresponding *-2level* files.

Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>

authored by

Catalin Marinas and committed by
Russell King
17f57211 e73fc88e

+302 -250
+1 -41
arch/arm/include/asm/page.h
··· 151 151 #define clear_page(page) memset((void *)(page), 0, PAGE_SIZE) 152 152 extern void copy_page(void *to, const void *from); 153 153 154 - typedef unsigned long pteval_t; 155 - 156 - #undef STRICT_MM_TYPECHECKS 157 - 158 - #ifdef STRICT_MM_TYPECHECKS 159 - /* 160 - * These are used to make use of C type-checking.. 161 - */ 162 - typedef struct { pteval_t pte; } pte_t; 163 - typedef struct { unsigned long pmd; } pmd_t; 164 - typedef struct { unsigned long pgd[2]; } pgd_t; 165 - typedef struct { unsigned long pgprot; } pgprot_t; 166 - 167 - #define pte_val(x) ((x).pte) 168 - #define pmd_val(x) ((x).pmd) 169 - #define pgd_val(x) ((x).pgd[0]) 170 - #define pgprot_val(x) ((x).pgprot) 171 - 172 - #define __pte(x) ((pte_t) { (x) } ) 173 - #define __pmd(x) ((pmd_t) { (x) } ) 174 - #define __pgprot(x) ((pgprot_t) { (x) } ) 175 - 176 - #else 177 - /* 178 - * .. while these make it easier on the compiler 179 - */ 180 - typedef pteval_t pte_t; 181 - typedef unsigned long pmd_t; 182 - typedef unsigned long pgd_t[2]; 183 - typedef unsigned long pgprot_t; 184 - 185 - #define pte_val(x) (x) 186 - #define pmd_val(x) (x) 187 - #define pgd_val(x) ((x)[0]) 188 - #define pgprot_val(x) (x) 189 - 190 - #define __pte(x) (x) 191 - #define __pmd(x) (x) 192 - #define __pgprot(x) (x) 193 - 194 - #endif /* STRICT_MM_TYPECHECKS */ 154 + #include <asm/pgtable-2level-types.h> 195 155 196 156 #endif /* CONFIG_MMU */ 197 157
+91
arch/arm/include/asm/pgtable-2level-hwdef.h
··· 1 + /* 2 + * arch/arm/include/asm/pgtable-2level-hwdef.h 3 + * 4 + * Copyright (C) 1995-2002 Russell King 5 + * 6 + * This program is free software; you can redistribute it and/or modify 7 + * it under the terms of the GNU General Public License version 2 as 8 + * published by the Free Software Foundation. 9 + */ 10 + #ifndef _ASM_PGTABLE_2LEVEL_HWDEF_H 11 + #define _ASM_PGTABLE_2LEVEL_HWDEF_H 12 + 13 + /* 14 + * Hardware page table definitions. 15 + * 16 + * + Level 1 descriptor (PMD) 17 + * - common 18 + */ 19 + #define PMD_TYPE_MASK (3 << 0) 20 + #define PMD_TYPE_FAULT (0 << 0) 21 + #define PMD_TYPE_TABLE (1 << 0) 22 + #define PMD_TYPE_SECT (2 << 0) 23 + #define PMD_BIT4 (1 << 4) 24 + #define PMD_DOMAIN(x) ((x) << 5) 25 + #define PMD_PROTECTION (1 << 9) /* v5 */ 26 + /* 27 + * - section 28 + */ 29 + #define PMD_SECT_BUFFERABLE (1 << 2) 30 + #define PMD_SECT_CACHEABLE (1 << 3) 31 + #define PMD_SECT_XN (1 << 4) /* v6 */ 32 + #define PMD_SECT_AP_WRITE (1 << 10) 33 + #define PMD_SECT_AP_READ (1 << 11) 34 + #define PMD_SECT_TEX(x) ((x) << 12) /* v5 */ 35 + #define PMD_SECT_APX (1 << 15) /* v6 */ 36 + #define PMD_SECT_S (1 << 16) /* v6 */ 37 + #define PMD_SECT_nG (1 << 17) /* v6 */ 38 + #define PMD_SECT_SUPER (1 << 18) /* v6 */ 39 + #define PMD_SECT_AF (0) 40 + 41 + #define PMD_SECT_UNCACHED (0) 42 + #define PMD_SECT_BUFFERED (PMD_SECT_BUFFERABLE) 43 + #define PMD_SECT_WT (PMD_SECT_CACHEABLE) 44 + #define PMD_SECT_WB (PMD_SECT_CACHEABLE | PMD_SECT_BUFFERABLE) 45 + #define PMD_SECT_MINICACHE (PMD_SECT_TEX(1) | PMD_SECT_CACHEABLE) 46 + #define PMD_SECT_WBWA (PMD_SECT_TEX(1) | PMD_SECT_CACHEABLE | PMD_SECT_BUFFERABLE) 47 + #define PMD_SECT_NONSHARED_DEV (PMD_SECT_TEX(2)) 48 + 49 + /* 50 + * - coarse table (not used) 51 + */ 52 + 53 + /* 54 + * + Level 2 descriptor (PTE) 55 + * - common 56 + */ 57 + #define PTE_TYPE_MASK (3 << 0) 58 + #define PTE_TYPE_FAULT (0 << 0) 59 + #define PTE_TYPE_LARGE (1 << 0) 60 + #define PTE_TYPE_SMALL (2 << 0) 61 + #define PTE_TYPE_EXT (3 << 0) /* v5 */ 62 + #define PTE_BUFFERABLE (1 << 2) 63 + #define PTE_CACHEABLE (1 << 3) 64 + 65 + /* 66 + * - extended small page/tiny page 67 + */ 68 + #define PTE_EXT_XN (1 << 0) /* v6 */ 69 + #define PTE_EXT_AP_MASK (3 << 4) 70 + #define PTE_EXT_AP0 (1 << 4) 71 + #define PTE_EXT_AP1 (2 << 4) 72 + #define PTE_EXT_AP_UNO_SRO (0 << 4) 73 + #define PTE_EXT_AP_UNO_SRW (PTE_EXT_AP0) 74 + #define PTE_EXT_AP_URO_SRW (PTE_EXT_AP1) 75 + #define PTE_EXT_AP_URW_SRW (PTE_EXT_AP1|PTE_EXT_AP0) 76 + #define PTE_EXT_TEX(x) ((x) << 6) /* v5 */ 77 + #define PTE_EXT_APX (1 << 9) /* v6 */ 78 + #define PTE_EXT_COHERENT (1 << 9) /* XScale3 */ 79 + #define PTE_EXT_SHARED (1 << 10) /* v6 */ 80 + #define PTE_EXT_NG (1 << 11) /* v6 */ 81 + 82 + /* 83 + * - small page 84 + */ 85 + #define PTE_SMALL_AP_MASK (0xff << 4) 86 + #define PTE_SMALL_AP_UNO_SRO (0x00 << 4) 87 + #define PTE_SMALL_AP_UNO_SRW (0x55 << 4) 88 + #define PTE_SMALL_AP_URO_SRW (0xaa << 4) 89 + #define PTE_SMALL_AP_URW_SRW (0xff << 4) 90 + 91 + #endif
+64
arch/arm/include/asm/pgtable-2level-types.h
··· 1 + /* 2 + * arch/arm/include/asm/pgtable-2level-types.h 3 + * 4 + * Copyright (C) 1995-2003 Russell King 5 + * 6 + * This program is free software; you can redistribute it and/or modify 7 + * it under the terms of the GNU General Public License version 2 as 8 + * published by the Free Software Foundation. 9 + * 10 + * This program is distributed in the hope that it will be useful, 11 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 + * GNU General Public License for more details. 14 + * 15 + * You should have received a copy of the GNU General Public License 16 + * along with this program; if not, write to the Free Software 17 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 + */ 19 + #ifndef _ASM_PGTABLE_2LEVEL_TYPES_H 20 + #define _ASM_PGTABLE_2LEVEL_TYPES_H 21 + 22 + typedef unsigned long pteval_t; 23 + 24 + #undef STRICT_MM_TYPECHECKS 25 + 26 + #ifdef STRICT_MM_TYPECHECKS 27 + /* 28 + * These are used to make use of C type-checking.. 29 + */ 30 + typedef struct { pteval_t pte; } pte_t; 31 + typedef struct { unsigned long pmd; } pmd_t; 32 + typedef struct { unsigned long pgd[2]; } pgd_t; 33 + typedef struct { unsigned long pgprot; } pgprot_t; 34 + 35 + #define pte_val(x) ((x).pte) 36 + #define pmd_val(x) ((x).pmd) 37 + #define pgd_val(x) ((x).pgd[0]) 38 + #define pgprot_val(x) ((x).pgprot) 39 + 40 + #define __pte(x) ((pte_t) { (x) } ) 41 + #define __pmd(x) ((pmd_t) { (x) } ) 42 + #define __pgprot(x) ((pgprot_t) { (x) } ) 43 + 44 + #else 45 + /* 46 + * .. while these make it easier on the compiler 47 + */ 48 + typedef pteval_t pte_t; 49 + typedef unsigned long pmd_t; 50 + typedef unsigned long pgd_t[2]; 51 + typedef unsigned long pgprot_t; 52 + 53 + #define pte_val(x) (x) 54 + #define pmd_val(x) (x) 55 + #define pgd_val(x) ((x)[0]) 56 + #define pgprot_val(x) (x) 57 + 58 + #define __pte(x) (x) 59 + #define __pmd(x) (x) 60 + #define __pgprot(x) (x) 61 + 62 + #endif /* STRICT_MM_TYPECHECKS */ 63 + 64 + #endif /* _ASM_PGTABLE_2LEVEL_TYPES_H */
+143
arch/arm/include/asm/pgtable-2level.h
··· 1 + /* 2 + * arch/arm/include/asm/pgtable-2level.h 3 + * 4 + * Copyright (C) 1995-2002 Russell King 5 + * 6 + * This program is free software; you can redistribute it and/or modify 7 + * it under the terms of the GNU General Public License version 2 as 8 + * published by the Free Software Foundation. 9 + */ 10 + #ifndef _ASM_PGTABLE_2LEVEL_H 11 + #define _ASM_PGTABLE_2LEVEL_H 12 + 13 + /* 14 + * Hardware-wise, we have a two level page table structure, where the first 15 + * level has 4096 entries, and the second level has 256 entries. Each entry 16 + * is one 32-bit word. Most of the bits in the second level entry are used 17 + * by hardware, and there aren't any "accessed" and "dirty" bits. 18 + * 19 + * Linux on the other hand has a three level page table structure, which can 20 + * be wrapped to fit a two level page table structure easily - using the PGD 21 + * and PTE only. However, Linux also expects one "PTE" table per page, and 22 + * at least a "dirty" bit. 23 + * 24 + * Therefore, we tweak the implementation slightly - we tell Linux that we 25 + * have 2048 entries in the first level, each of which is 8 bytes (iow, two 26 + * hardware pointers to the second level.) The second level contains two 27 + * hardware PTE tables arranged contiguously, preceded by Linux versions 28 + * which contain the state information Linux needs. We, therefore, end up 29 + * with 512 entries in the "PTE" level. 30 + * 31 + * This leads to the page tables having the following layout: 32 + * 33 + * pgd pte 34 + * | | 35 + * +--------+ 36 + * | | +------------+ +0 37 + * +- - - - + | Linux pt 0 | 38 + * | | +------------+ +1024 39 + * +--------+ +0 | Linux pt 1 | 40 + * | |-----> +------------+ +2048 41 + * +- - - - + +4 | h/w pt 0 | 42 + * | |-----> +------------+ +3072 43 + * +--------+ +8 | h/w pt 1 | 44 + * | | +------------+ +4096 45 + * 46 + * See L_PTE_xxx below for definitions of bits in the "Linux pt", and 47 + * PTE_xxx for definitions of bits appearing in the "h/w pt". 48 + * 49 + * PMD_xxx definitions refer to bits in the first level page table. 50 + * 51 + * The "dirty" bit is emulated by only granting hardware write permission 52 + * iff the page is marked "writable" and "dirty" in the Linux PTE. This 53 + * means that a write to a clean page will cause a permission fault, and 54 + * the Linux MM layer will mark the page dirty via handle_pte_fault(). 55 + * For the hardware to notice the permission change, the TLB entry must 56 + * be flushed, and ptep_set_access_flags() does that for us. 57 + * 58 + * The "accessed" or "young" bit is emulated by a similar method; we only 59 + * allow accesses to the page if the "young" bit is set. Accesses to the 60 + * page will cause a fault, and handle_pte_fault() will set the young bit 61 + * for us as long as the page is marked present in the corresponding Linux 62 + * PTE entry. Again, ptep_set_access_flags() will ensure that the TLB is 63 + * up to date. 64 + * 65 + * However, when the "young" bit is cleared, we deny access to the page 66 + * by clearing the hardware PTE. Currently Linux does not flush the TLB 67 + * for us in this case, which means the TLB will retain the transation 68 + * until either the TLB entry is evicted under pressure, or a context 69 + * switch which changes the user space mapping occurs. 70 + */ 71 + #define PTRS_PER_PTE 512 72 + #define PTRS_PER_PMD 1 73 + #define PTRS_PER_PGD 2048 74 + 75 + #define PTE_HWTABLE_PTRS (PTRS_PER_PTE) 76 + #define PTE_HWTABLE_OFF (PTE_HWTABLE_PTRS * sizeof(pte_t)) 77 + #define PTE_HWTABLE_SIZE (PTRS_PER_PTE * sizeof(u32)) 78 + 79 + /* 80 + * PMD_SHIFT determines the size of the area a second-level page table can map 81 + * PGDIR_SHIFT determines what a third-level page table entry can map 82 + */ 83 + #define PMD_SHIFT 21 84 + #define PGDIR_SHIFT 21 85 + 86 + #define PMD_SIZE (1UL << PMD_SHIFT) 87 + #define PMD_MASK (~(PMD_SIZE-1)) 88 + #define PGDIR_SIZE (1UL << PGDIR_SHIFT) 89 + #define PGDIR_MASK (~(PGDIR_SIZE-1)) 90 + 91 + /* 92 + * section address mask and size definitions. 93 + */ 94 + #define SECTION_SHIFT 20 95 + #define SECTION_SIZE (1UL << SECTION_SHIFT) 96 + #define SECTION_MASK (~(SECTION_SIZE-1)) 97 + 98 + /* 99 + * ARMv6 supersection address mask and size definitions. 100 + */ 101 + #define SUPERSECTION_SHIFT 24 102 + #define SUPERSECTION_SIZE (1UL << SUPERSECTION_SHIFT) 103 + #define SUPERSECTION_MASK (~(SUPERSECTION_SIZE-1)) 104 + 105 + #define USER_PTRS_PER_PGD (TASK_SIZE / PGDIR_SIZE) 106 + 107 + /* 108 + * "Linux" PTE definitions. 109 + * 110 + * We keep two sets of PTEs - the hardware and the linux version. 111 + * This allows greater flexibility in the way we map the Linux bits 112 + * onto the hardware tables, and allows us to have YOUNG and DIRTY 113 + * bits. 114 + * 115 + * The PTE table pointer refers to the hardware entries; the "Linux" 116 + * entries are stored 1024 bytes below. 117 + */ 118 + #define L_PTE_PRESENT (_AT(pteval_t, 1) << 0) 119 + #define L_PTE_YOUNG (_AT(pteval_t, 1) << 1) 120 + #define L_PTE_FILE (_AT(pteval_t, 1) << 2) /* only when !PRESENT */ 121 + #define L_PTE_DIRTY (_AT(pteval_t, 1) << 6) 122 + #define L_PTE_RDONLY (_AT(pteval_t, 1) << 7) 123 + #define L_PTE_USER (_AT(pteval_t, 1) << 8) 124 + #define L_PTE_XN (_AT(pteval_t, 1) << 9) 125 + #define L_PTE_SHARED (_AT(pteval_t, 1) << 10) /* shared(v6), coherent(xsc3) */ 126 + 127 + /* 128 + * These are the memory types, defined to be compatible with 129 + * pre-ARMv6 CPUs cacheable and bufferable bits: XXCB 130 + */ 131 + #define L_PTE_MT_UNCACHED (_AT(pteval_t, 0x00) << 2) /* 0000 */ 132 + #define L_PTE_MT_BUFFERABLE (_AT(pteval_t, 0x01) << 2) /* 0001 */ 133 + #define L_PTE_MT_WRITETHROUGH (_AT(pteval_t, 0x02) << 2) /* 0010 */ 134 + #define L_PTE_MT_WRITEBACK (_AT(pteval_t, 0x03) << 2) /* 0011 */ 135 + #define L_PTE_MT_MINICACHE (_AT(pteval_t, 0x06) << 2) /* 0110 (sa1100, xscale) */ 136 + #define L_PTE_MT_WRITEALLOC (_AT(pteval_t, 0x07) << 2) /* 0111 */ 137 + #define L_PTE_MT_DEV_SHARED (_AT(pteval_t, 0x04) << 2) /* 0100 */ 138 + #define L_PTE_MT_DEV_NONSHARED (_AT(pteval_t, 0x0c) << 2) /* 1100 */ 139 + #define L_PTE_MT_DEV_WC (_AT(pteval_t, 0x09) << 2) /* 1001 */ 140 + #define L_PTE_MT_DEV_CACHED (_AT(pteval_t, 0x0b) << 2) /* 1011 */ 141 + #define L_PTE_MT_MASK (_AT(pteval_t, 0x0f) << 2) 142 + 143 + #endif /* _ASM_PGTABLE_2LEVEL_H */
+1 -76
arch/arm/include/asm/pgtable-hwdef.h
··· 10 10 #ifndef _ASMARM_PGTABLE_HWDEF_H 11 11 #define _ASMARM_PGTABLE_HWDEF_H 12 12 13 - /* 14 - * Hardware page table definitions. 15 - * 16 - * + Level 1 descriptor (PMD) 17 - * - common 18 - */ 19 - #define PMD_TYPE_MASK (3 << 0) 20 - #define PMD_TYPE_FAULT (0 << 0) 21 - #define PMD_TYPE_TABLE (1 << 0) 22 - #define PMD_TYPE_SECT (2 << 0) 23 - #define PMD_BIT4 (1 << 4) 24 - #define PMD_DOMAIN(x) ((x) << 5) 25 - #define PMD_PROTECTION (1 << 9) /* v5 */ 26 - /* 27 - * - section 28 - */ 29 - #define PMD_SECT_BUFFERABLE (1 << 2) 30 - #define PMD_SECT_CACHEABLE (1 << 3) 31 - #define PMD_SECT_XN (1 << 4) /* v6 */ 32 - #define PMD_SECT_AP_WRITE (1 << 10) 33 - #define PMD_SECT_AP_READ (1 << 11) 34 - #define PMD_SECT_TEX(x) ((x) << 12) /* v5 */ 35 - #define PMD_SECT_APX (1 << 15) /* v6 */ 36 - #define PMD_SECT_S (1 << 16) /* v6 */ 37 - #define PMD_SECT_nG (1 << 17) /* v6 */ 38 - #define PMD_SECT_SUPER (1 << 18) /* v6 */ 39 - 40 - #define PMD_SECT_UNCACHED (0) 41 - #define PMD_SECT_BUFFERED (PMD_SECT_BUFFERABLE) 42 - #define PMD_SECT_WT (PMD_SECT_CACHEABLE) 43 - #define PMD_SECT_WB (PMD_SECT_CACHEABLE | PMD_SECT_BUFFERABLE) 44 - #define PMD_SECT_MINICACHE (PMD_SECT_TEX(1) | PMD_SECT_CACHEABLE) 45 - #define PMD_SECT_WBWA (PMD_SECT_TEX(1) | PMD_SECT_CACHEABLE | PMD_SECT_BUFFERABLE) 46 - #define PMD_SECT_NONSHARED_DEV (PMD_SECT_TEX(2)) 47 - 48 - /* 49 - * - coarse table (not used) 50 - */ 51 - 52 - /* 53 - * + Level 2 descriptor (PTE) 54 - * - common 55 - */ 56 - #define PTE_TYPE_MASK (3 << 0) 57 - #define PTE_TYPE_FAULT (0 << 0) 58 - #define PTE_TYPE_LARGE (1 << 0) 59 - #define PTE_TYPE_SMALL (2 << 0) 60 - #define PTE_TYPE_EXT (3 << 0) /* v5 */ 61 - #define PTE_BUFFERABLE (1 << 2) 62 - #define PTE_CACHEABLE (1 << 3) 63 - 64 - /* 65 - * - extended small page/tiny page 66 - */ 67 - #define PTE_EXT_XN (1 << 0) /* v6 */ 68 - #define PTE_EXT_AP_MASK (3 << 4) 69 - #define PTE_EXT_AP0 (1 << 4) 70 - #define PTE_EXT_AP1 (2 << 4) 71 - #define PTE_EXT_AP_UNO_SRO (0 << 4) 72 - #define PTE_EXT_AP_UNO_SRW (PTE_EXT_AP0) 73 - #define PTE_EXT_AP_URO_SRW (PTE_EXT_AP1) 74 - #define PTE_EXT_AP_URW_SRW (PTE_EXT_AP1|PTE_EXT_AP0) 75 - #define PTE_EXT_TEX(x) ((x) << 6) /* v5 */ 76 - #define PTE_EXT_APX (1 << 9) /* v6 */ 77 - #define PTE_EXT_COHERENT (1 << 9) /* XScale3 */ 78 - #define PTE_EXT_SHARED (1 << 10) /* v6 */ 79 - #define PTE_EXT_NG (1 << 11) /* v6 */ 80 - 81 - /* 82 - * - small page 83 - */ 84 - #define PTE_SMALL_AP_MASK (0xff << 4) 85 - #define PTE_SMALL_AP_UNO_SRO (0x00 << 4) 86 - #define PTE_SMALL_AP_UNO_SRW (0x55 << 4) 87 - #define PTE_SMALL_AP_URO_SRW (0xaa << 4) 88 - #define PTE_SMALL_AP_URW_SRW (0xff << 4) 13 + #include <asm/pgtable-2level-hwdef.h> 89 14 90 15 #endif
+2 -133
arch/arm/include/asm/pgtable.h
··· 24 24 #include <mach/vmalloc.h> 25 25 #include <asm/pgtable-hwdef.h> 26 26 27 + #include <asm/pgtable-2level.h> 28 + 27 29 /* 28 30 * Just any arbitrary offset to the start of the vmalloc VM area: the 29 31 * current 8MB value just means that there will be a 8MB "hole" after the ··· 43 41 #define VMALLOC_START (((unsigned long)high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1)) 44 42 #endif 45 43 46 - /* 47 - * Hardware-wise, we have a two level page table structure, where the first 48 - * level has 4096 entries, and the second level has 256 entries. Each entry 49 - * is one 32-bit word. Most of the bits in the second level entry are used 50 - * by hardware, and there aren't any "accessed" and "dirty" bits. 51 - * 52 - * Linux on the other hand has a three level page table structure, which can 53 - * be wrapped to fit a two level page table structure easily - using the PGD 54 - * and PTE only. However, Linux also expects one "PTE" table per page, and 55 - * at least a "dirty" bit. 56 - * 57 - * Therefore, we tweak the implementation slightly - we tell Linux that we 58 - * have 2048 entries in the first level, each of which is 8 bytes (iow, two 59 - * hardware pointers to the second level.) The second level contains two 60 - * hardware PTE tables arranged contiguously, preceded by Linux versions 61 - * which contain the state information Linux needs. We, therefore, end up 62 - * with 512 entries in the "PTE" level. 63 - * 64 - * This leads to the page tables having the following layout: 65 - * 66 - * pgd pte 67 - * | | 68 - * +--------+ 69 - * | | +------------+ +0 70 - * +- - - - + | Linux pt 0 | 71 - * | | +------------+ +1024 72 - * +--------+ +0 | Linux pt 1 | 73 - * | |-----> +------------+ +2048 74 - * +- - - - + +4 | h/w pt 0 | 75 - * | |-----> +------------+ +3072 76 - * +--------+ +8 | h/w pt 1 | 77 - * | | +------------+ +4096 78 - * 79 - * See L_PTE_xxx below for definitions of bits in the "Linux pt", and 80 - * PTE_xxx for definitions of bits appearing in the "h/w pt". 81 - * 82 - * PMD_xxx definitions refer to bits in the first level page table. 83 - * 84 - * The "dirty" bit is emulated by only granting hardware write permission 85 - * iff the page is marked "writable" and "dirty" in the Linux PTE. This 86 - * means that a write to a clean page will cause a permission fault, and 87 - * the Linux MM layer will mark the page dirty via handle_pte_fault(). 88 - * For the hardware to notice the permission change, the TLB entry must 89 - * be flushed, and ptep_set_access_flags() does that for us. 90 - * 91 - * The "accessed" or "young" bit is emulated by a similar method; we only 92 - * allow accesses to the page if the "young" bit is set. Accesses to the 93 - * page will cause a fault, and handle_pte_fault() will set the young bit 94 - * for us as long as the page is marked present in the corresponding Linux 95 - * PTE entry. Again, ptep_set_access_flags() will ensure that the TLB is 96 - * up to date. 97 - * 98 - * However, when the "young" bit is cleared, we deny access to the page 99 - * by clearing the hardware PTE. Currently Linux does not flush the TLB 100 - * for us in this case, which means the TLB will retain the transation 101 - * until either the TLB entry is evicted under pressure, or a context 102 - * switch which changes the user space mapping occurs. 103 - */ 104 - #define PTRS_PER_PTE 512 105 - #define PTRS_PER_PMD 1 106 - #define PTRS_PER_PGD 2048 107 - 108 - #define PTE_HWTABLE_PTRS (PTRS_PER_PTE) 109 - #define PTE_HWTABLE_OFF (PTE_HWTABLE_PTRS * sizeof(pte_t)) 110 - #define PTE_HWTABLE_SIZE (PTRS_PER_PTE * sizeof(u32)) 111 - 112 - /* 113 - * PMD_SHIFT determines the size of the area a second-level page table can map 114 - * PGDIR_SHIFT determines what a third-level page table entry can map 115 - */ 116 - #define PMD_SHIFT 21 117 - #define PGDIR_SHIFT 21 118 - 119 44 #define LIBRARY_TEXT_START 0x0c000000 120 45 121 46 #ifndef __ASSEMBLY__ ··· 53 124 #define pte_ERROR(pte) __pte_error(__FILE__, __LINE__, pte) 54 125 #define pmd_ERROR(pmd) __pmd_error(__FILE__, __LINE__, pmd) 55 126 #define pgd_ERROR(pgd) __pgd_error(__FILE__, __LINE__, pgd) 56 - #endif /* !__ASSEMBLY__ */ 57 - 58 - #define PMD_SIZE (1UL << PMD_SHIFT) 59 - #define PMD_MASK (~(PMD_SIZE-1)) 60 - #define PGDIR_SIZE (1UL << PGDIR_SHIFT) 61 - #define PGDIR_MASK (~(PGDIR_SIZE-1)) 62 127 63 128 /* 64 129 * This is the lowest virtual address we can permit any user space ··· 60 137 * non-high vector CPUs. 61 138 */ 62 139 #define FIRST_USER_ADDRESS PAGE_SIZE 63 - 64 - #define USER_PTRS_PER_PGD (TASK_SIZE / PGDIR_SIZE) 65 - 66 - /* 67 - * section address mask and size definitions. 68 - */ 69 - #define SECTION_SHIFT 20 70 - #define SECTION_SIZE (1UL << SECTION_SHIFT) 71 - #define SECTION_MASK (~(SECTION_SIZE-1)) 72 - 73 - /* 74 - * ARMv6 supersection address mask and size definitions. 75 - */ 76 - #define SUPERSECTION_SHIFT 24 77 - #define SUPERSECTION_SIZE (1UL << SUPERSECTION_SHIFT) 78 - #define SUPERSECTION_MASK (~(SUPERSECTION_SIZE-1)) 79 - 80 - /* 81 - * "Linux" PTE definitions. 82 - * 83 - * We keep two sets of PTEs - the hardware and the linux version. 84 - * This allows greater flexibility in the way we map the Linux bits 85 - * onto the hardware tables, and allows us to have YOUNG and DIRTY 86 - * bits. 87 - * 88 - * The PTE table pointer refers to the hardware entries; the "Linux" 89 - * entries are stored 1024 bytes below. 90 - */ 91 - #define L_PTE_PRESENT (_AT(pteval_t, 1) << 0) 92 - #define L_PTE_YOUNG (_AT(pteval_t, 1) << 1) 93 - #define L_PTE_FILE (_AT(pteval_t, 1) << 2) /* only when !PRESENT */ 94 - #define L_PTE_DIRTY (_AT(pteval_t, 1) << 6) 95 - #define L_PTE_RDONLY (_AT(pteval_t, 1) << 7) 96 - #define L_PTE_USER (_AT(pteval_t, 1) << 8) 97 - #define L_PTE_XN (_AT(pteval_t, 1) << 9) 98 - #define L_PTE_SHARED (_AT(pteval_t, 1) << 10) /* shared(v6), coherent(xsc3) */ 99 - 100 - /* 101 - * These are the memory types, defined to be compatible with 102 - * pre-ARMv6 CPUs cacheable and bufferable bits: XXCB 103 - */ 104 - #define L_PTE_MT_UNCACHED (_AT(pteval_t, 0x00) << 2) /* 0000 */ 105 - #define L_PTE_MT_BUFFERABLE (_AT(pteval_t, 0x01) << 2) /* 0001 */ 106 - #define L_PTE_MT_WRITETHROUGH (_AT(pteval_t, 0x02) << 2) /* 0010 */ 107 - #define L_PTE_MT_WRITEBACK (_AT(pteval_t, 0x03) << 2) /* 0011 */ 108 - #define L_PTE_MT_MINICACHE (_AT(pteval_t, 0x06) << 2) /* 0110 (sa1100, xscale) */ 109 - #define L_PTE_MT_WRITEALLOC (_AT(pteval_t, 0x07) << 2) /* 0111 */ 110 - #define L_PTE_MT_DEV_SHARED (_AT(pteval_t, 0x04) << 2) /* 0100 */ 111 - #define L_PTE_MT_DEV_NONSHARED (_AT(pteval_t, 0x0c) << 2) /* 1100 */ 112 - #define L_PTE_MT_DEV_WC (_AT(pteval_t, 0x09) << 2) /* 1001 */ 113 - #define L_PTE_MT_DEV_CACHED (_AT(pteval_t, 0x0b) << 2) /* 1011 */ 114 - #define L_PTE_MT_MASK (_AT(pteval_t, 0x0f) << 2) 115 - 116 - #ifndef __ASSEMBLY__ 117 140 118 141 /* 119 142 * The pgprot_* and protection_map entries will be fixed up in runtime