diff options
author | Catalin Marinas <catalin.marinas@arm.com> | 2011-09-05 12:51:56 -0400 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2011-10-06 10:40:05 -0400 |
commit | 442e70c0b3536e832547eed89629435462f4b515 (patch) | |
tree | f4a4869e204741792695c06824a8fb2aec9a49f9 | |
parent | 17f57211969bddca2e922299a2530b1c65ccabfa (diff) |
ARM: 7076/1: LPAE: Add (pte|pmd)val_t type definitions as u32
This patch defines the (pte|pmd)val_t as u32 and changes the page table
types to be based on these. The PMD bits are converted to the
corresponding type using the _AT macro.
The flush_pmd_entry/clean_pmd_entry argument was changed to (void *) to
allow them to be used with both PGD and PMD pointers and avoid code
duplication.
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
-rw-r--r-- | arch/arm/include/asm/pgalloc.h | 4 | ||||
-rw-r--r-- | arch/arm/include/asm/pgtable-2level-hwdef.h | 82 | ||||
-rw-r--r-- | arch/arm/include/asm/pgtable-2level-types.h | 17 | ||||
-rw-r--r-- | arch/arm/include/asm/tlbflush.h | 4 | ||||
-rw-r--r-- | arch/arm/mm/mm.h | 4 | ||||
-rw-r--r-- | arch/arm/mm/mmu.c | 4 |
6 files changed, 59 insertions, 56 deletions
diff --git a/arch/arm/include/asm/pgalloc.h b/arch/arm/include/asm/pgalloc.h index 22de005f159c..3e08fd3fbb6b 100644 --- a/arch/arm/include/asm/pgalloc.h +++ b/arch/arm/include/asm/pgalloc.h | |||
@@ -105,9 +105,9 @@ static inline void pte_free(struct mm_struct *mm, pgtable_t pte) | |||
105 | } | 105 | } |
106 | 106 | ||
107 | static inline void __pmd_populate(pmd_t *pmdp, phys_addr_t pte, | 107 | static inline void __pmd_populate(pmd_t *pmdp, phys_addr_t pte, |
108 | unsigned long prot) | 108 | pmdval_t prot) |
109 | { | 109 | { |
110 | unsigned long pmdval = (pte + PTE_HWTABLE_OFF) | prot; | 110 | pmdval_t pmdval = (pte + PTE_HWTABLE_OFF) | prot; |
111 | pmdp[0] = __pmd(pmdval); | 111 | pmdp[0] = __pmd(pmdval); |
112 | pmdp[1] = __pmd(pmdval + 256 * sizeof(pte_t)); | 112 | pmdp[1] = __pmd(pmdval + 256 * sizeof(pte_t)); |
113 | flush_pmd_entry(pmdp); | 113 | flush_pmd_entry(pmdp); |
diff --git a/arch/arm/include/asm/pgtable-2level-hwdef.h b/arch/arm/include/asm/pgtable-2level-hwdef.h index 436529c1cda2..2b52c40edd80 100644 --- a/arch/arm/include/asm/pgtable-2level-hwdef.h +++ b/arch/arm/include/asm/pgtable-2level-hwdef.h | |||
@@ -16,29 +16,29 @@ | |||
16 | * + Level 1 descriptor (PMD) | 16 | * + Level 1 descriptor (PMD) |
17 | * - common | 17 | * - common |
18 | */ | 18 | */ |
19 | #define PMD_TYPE_MASK (3 << 0) | 19 | #define PMD_TYPE_MASK (_AT(pmdval_t, 3) << 0) |
20 | #define PMD_TYPE_FAULT (0 << 0) | 20 | #define PMD_TYPE_FAULT (_AT(pmdval_t, 0) << 0) |
21 | #define PMD_TYPE_TABLE (1 << 0) | 21 | #define PMD_TYPE_TABLE (_AT(pmdval_t, 1) << 0) |
22 | #define PMD_TYPE_SECT (2 << 0) | 22 | #define PMD_TYPE_SECT (_AT(pmdval_t, 2) << 0) |
23 | #define PMD_BIT4 (1 << 4) | 23 | #define PMD_BIT4 (_AT(pmdval_t, 1) << 4) |
24 | #define PMD_DOMAIN(x) ((x) << 5) | 24 | #define PMD_DOMAIN(x) (_AT(pmdval_t, (x)) << 5) |
25 | #define PMD_PROTECTION (1 << 9) /* v5 */ | 25 | #define PMD_PROTECTION (_AT(pmdval_t, 1) << 9) /* v5 */ |
26 | /* | 26 | /* |
27 | * - section | 27 | * - section |
28 | */ | 28 | */ |
29 | #define PMD_SECT_BUFFERABLE (1 << 2) | 29 | #define PMD_SECT_BUFFERABLE (_AT(pmdval_t, 1) << 2) |
30 | #define PMD_SECT_CACHEABLE (1 << 3) | 30 | #define PMD_SECT_CACHEABLE (_AT(pmdval_t, 1) << 3) |
31 | #define PMD_SECT_XN (1 << 4) /* v6 */ | 31 | #define PMD_SECT_XN (_AT(pmdval_t, 1) << 4) /* v6 */ |
32 | #define PMD_SECT_AP_WRITE (1 << 10) | 32 | #define PMD_SECT_AP_WRITE (_AT(pmdval_t, 1) << 10) |
33 | #define PMD_SECT_AP_READ (1 << 11) | 33 | #define PMD_SECT_AP_READ (_AT(pmdval_t, 1) << 11) |
34 | #define PMD_SECT_TEX(x) ((x) << 12) /* v5 */ | 34 | #define PMD_SECT_TEX(x) (_AT(pmdval_t, (x)) << 12) /* v5 */ |
35 | #define PMD_SECT_APX (1 << 15) /* v6 */ | 35 | #define PMD_SECT_APX (_AT(pmdval_t, 1) << 15) /* v6 */ |
36 | #define PMD_SECT_S (1 << 16) /* v6 */ | 36 | #define PMD_SECT_S (_AT(pmdval_t, 1) << 16) /* v6 */ |
37 | #define PMD_SECT_nG (1 << 17) /* v6 */ | 37 | #define PMD_SECT_nG (_AT(pmdval_t, 1) << 17) /* v6 */ |
38 | #define PMD_SECT_SUPER (1 << 18) /* v6 */ | 38 | #define PMD_SECT_SUPER (_AT(pmdval_t, 1) << 18) /* v6 */ |
39 | #define PMD_SECT_AF (0) | 39 | #define PMD_SECT_AF (_AT(pmdval_t, 0)) |
40 | 40 | ||
41 | #define PMD_SECT_UNCACHED (0) | 41 | #define PMD_SECT_UNCACHED (_AT(pmdval_t, 0)) |
42 | #define PMD_SECT_BUFFERED (PMD_SECT_BUFFERABLE) | 42 | #define PMD_SECT_BUFFERED (PMD_SECT_BUFFERABLE) |
43 | #define PMD_SECT_WT (PMD_SECT_CACHEABLE) | 43 | #define PMD_SECT_WT (PMD_SECT_CACHEABLE) |
44 | #define PMD_SECT_WB (PMD_SECT_CACHEABLE | PMD_SECT_BUFFERABLE) | 44 | #define PMD_SECT_WB (PMD_SECT_CACHEABLE | PMD_SECT_BUFFERABLE) |
@@ -54,38 +54,38 @@ | |||
54 | * + Level 2 descriptor (PTE) | 54 | * + Level 2 descriptor (PTE) |
55 | * - common | 55 | * - common |
56 | */ | 56 | */ |
57 | #define PTE_TYPE_MASK (3 << 0) | 57 | #define PTE_TYPE_MASK (_AT(pteval_t, 3) << 0) |
58 | #define PTE_TYPE_FAULT (0 << 0) | 58 | #define PTE_TYPE_FAULT (_AT(pteval_t, 0) << 0) |
59 | #define PTE_TYPE_LARGE (1 << 0) | 59 | #define PTE_TYPE_LARGE (_AT(pteval_t, 1) << 0) |
60 | #define PTE_TYPE_SMALL (2 << 0) | 60 | #define PTE_TYPE_SMALL (_AT(pteval_t, 2) << 0) |
61 | #define PTE_TYPE_EXT (3 << 0) /* v5 */ | 61 | #define PTE_TYPE_EXT (_AT(pteval_t, 3) << 0) /* v5 */ |
62 | #define PTE_BUFFERABLE (1 << 2) | 62 | #define PTE_BUFFERABLE (_AT(pteval_t, 1) << 2) |
63 | #define PTE_CACHEABLE (1 << 3) | 63 | #define PTE_CACHEABLE (_AT(pteval_t, 1) << 3) |
64 | 64 | ||
65 | /* | 65 | /* |
66 | * - extended small page/tiny page | 66 | * - extended small page/tiny page |
67 | */ | 67 | */ |
68 | #define PTE_EXT_XN (1 << 0) /* v6 */ | 68 | #define PTE_EXT_XN (_AT(pteval_t, 1) << 0) /* v6 */ |
69 | #define PTE_EXT_AP_MASK (3 << 4) | 69 | #define PTE_EXT_AP_MASK (_AT(pteval_t, 3) << 4) |
70 | #define PTE_EXT_AP0 (1 << 4) | 70 | #define PTE_EXT_AP0 (_AT(pteval_t, 1) << 4) |
71 | #define PTE_EXT_AP1 (2 << 4) | 71 | #define PTE_EXT_AP1 (_AT(pteval_t, 2) << 4) |
72 | #define PTE_EXT_AP_UNO_SRO (0 << 4) | 72 | #define PTE_EXT_AP_UNO_SRO (_AT(pteval_t, 0) << 4) |
73 | #define PTE_EXT_AP_UNO_SRW (PTE_EXT_AP0) | 73 | #define PTE_EXT_AP_UNO_SRW (PTE_EXT_AP0) |
74 | #define PTE_EXT_AP_URO_SRW (PTE_EXT_AP1) | 74 | #define PTE_EXT_AP_URO_SRW (PTE_EXT_AP1) |
75 | #define PTE_EXT_AP_URW_SRW (PTE_EXT_AP1|PTE_EXT_AP0) | 75 | #define PTE_EXT_AP_URW_SRW (PTE_EXT_AP1|PTE_EXT_AP0) |
76 | #define PTE_EXT_TEX(x) ((x) << 6) /* v5 */ | 76 | #define PTE_EXT_TEX(x) (_AT(pteval_t, (x)) << 6) /* v5 */ |
77 | #define PTE_EXT_APX (1 << 9) /* v6 */ | 77 | #define PTE_EXT_APX (_AT(pteval_t, 1) << 9) /* v6 */ |
78 | #define PTE_EXT_COHERENT (1 << 9) /* XScale3 */ | 78 | #define PTE_EXT_COHERENT (_AT(pteval_t, 1) << 9) /* XScale3 */ |
79 | #define PTE_EXT_SHARED (1 << 10) /* v6 */ | 79 | #define PTE_EXT_SHARED (_AT(pteval_t, 1) << 10) /* v6 */ |
80 | #define PTE_EXT_NG (1 << 11) /* v6 */ | 80 | #define PTE_EXT_NG (_AT(pteval_t, 1) << 11) /* v6 */ |
81 | 81 | ||
82 | /* | 82 | /* |
83 | * - small page | 83 | * - small page |
84 | */ | 84 | */ |
85 | #define PTE_SMALL_AP_MASK (0xff << 4) | 85 | #define PTE_SMALL_AP_MASK (_AT(pteval_t, 0xff) << 4) |
86 | #define PTE_SMALL_AP_UNO_SRO (0x00 << 4) | 86 | #define PTE_SMALL_AP_UNO_SRO (_AT(pteval_t, 0x00) << 4) |
87 | #define PTE_SMALL_AP_UNO_SRW (0x55 << 4) | 87 | #define PTE_SMALL_AP_UNO_SRW (_AT(pteval_t, 0x55) << 4) |
88 | #define PTE_SMALL_AP_URO_SRW (0xaa << 4) | 88 | #define PTE_SMALL_AP_URO_SRW (_AT(pteval_t, 0xaa) << 4) |
89 | #define PTE_SMALL_AP_URW_SRW (0xff << 4) | 89 | #define PTE_SMALL_AP_URW_SRW (_AT(pteval_t, 0xff) << 4) |
90 | 90 | ||
91 | #endif | 91 | #endif |
diff --git a/arch/arm/include/asm/pgtable-2level-types.h b/arch/arm/include/asm/pgtable-2level-types.h index 8a01f62d8a16..66cb5b0e89c5 100644 --- a/arch/arm/include/asm/pgtable-2level-types.h +++ b/arch/arm/include/asm/pgtable-2level-types.h | |||
@@ -19,7 +19,10 @@ | |||
19 | #ifndef _ASM_PGTABLE_2LEVEL_TYPES_H | 19 | #ifndef _ASM_PGTABLE_2LEVEL_TYPES_H |
20 | #define _ASM_PGTABLE_2LEVEL_TYPES_H | 20 | #define _ASM_PGTABLE_2LEVEL_TYPES_H |
21 | 21 | ||
22 | typedef unsigned long pteval_t; | 22 | #include <asm/types.h> |
23 | |||
24 | typedef u32 pteval_t; | ||
25 | typedef u32 pmdval_t; | ||
23 | 26 | ||
24 | #undef STRICT_MM_TYPECHECKS | 27 | #undef STRICT_MM_TYPECHECKS |
25 | 28 | ||
@@ -28,9 +31,9 @@ typedef unsigned long pteval_t; | |||
28 | * These are used to make use of C type-checking.. | 31 | * These are used to make use of C type-checking.. |
29 | */ | 32 | */ |
30 | typedef struct { pteval_t pte; } pte_t; | 33 | typedef struct { pteval_t pte; } pte_t; |
31 | typedef struct { unsigned long pmd; } pmd_t; | 34 | typedef struct { pmdval_t pmd; } pmd_t; |
32 | typedef struct { unsigned long pgd[2]; } pgd_t; | 35 | typedef struct { pmdval_t pgd[2]; } pgd_t; |
33 | typedef struct { unsigned long pgprot; } pgprot_t; | 36 | typedef struct { pteval_t pgprot; } pgprot_t; |
34 | 37 | ||
35 | #define pte_val(x) ((x).pte) | 38 | #define pte_val(x) ((x).pte) |
36 | #define pmd_val(x) ((x).pmd) | 39 | #define pmd_val(x) ((x).pmd) |
@@ -46,9 +49,9 @@ typedef struct { unsigned long pgprot; } pgprot_t; | |||
46 | * .. while these make it easier on the compiler | 49 | * .. while these make it easier on the compiler |
47 | */ | 50 | */ |
48 | typedef pteval_t pte_t; | 51 | typedef pteval_t pte_t; |
49 | typedef unsigned long pmd_t; | 52 | typedef pmdval_t pmd_t; |
50 | typedef unsigned long pgd_t[2]; | 53 | typedef pmdval_t pgd_t[2]; |
51 | typedef unsigned long pgprot_t; | 54 | typedef pteval_t pgprot_t; |
52 | 55 | ||
53 | #define pte_val(x) (x) | 56 | #define pte_val(x) (x) |
54 | #define pmd_val(x) (x) | 57 | #define pmd_val(x) (x) |
diff --git a/arch/arm/include/asm/tlbflush.h b/arch/arm/include/asm/tlbflush.h index 8077145698ff..02b2f8203982 100644 --- a/arch/arm/include/asm/tlbflush.h +++ b/arch/arm/include/asm/tlbflush.h | |||
@@ -471,7 +471,7 @@ static inline void local_flush_tlb_kernel_page(unsigned long kaddr) | |||
471 | * these operations. This is typically used when we are removing | 471 | * these operations. This is typically used when we are removing |
472 | * PMD entries. | 472 | * PMD entries. |
473 | */ | 473 | */ |
474 | static inline void flush_pmd_entry(pmd_t *pmd) | 474 | static inline void flush_pmd_entry(void *pmd) |
475 | { | 475 | { |
476 | const unsigned int __tlb_flag = __cpu_tlb_flags; | 476 | const unsigned int __tlb_flag = __cpu_tlb_flags; |
477 | 477 | ||
@@ -487,7 +487,7 @@ static inline void flush_pmd_entry(pmd_t *pmd) | |||
487 | dsb(); | 487 | dsb(); |
488 | } | 488 | } |
489 | 489 | ||
490 | static inline void clean_pmd_entry(pmd_t *pmd) | 490 | static inline void clean_pmd_entry(void *pmd) |
491 | { | 491 | { |
492 | const unsigned int __tlb_flag = __cpu_tlb_flags; | 492 | const unsigned int __tlb_flag = __cpu_tlb_flags; |
493 | 493 | ||
diff --git a/arch/arm/mm/mm.h b/arch/arm/mm/mm.h index 010566799c80..ad7cce3bc431 100644 --- a/arch/arm/mm/mm.h +++ b/arch/arm/mm/mm.h | |||
@@ -12,8 +12,8 @@ static inline pmd_t *pmd_off_k(unsigned long virt) | |||
12 | 12 | ||
13 | struct mem_type { | 13 | struct mem_type { |
14 | pteval_t prot_pte; | 14 | pteval_t prot_pte; |
15 | unsigned int prot_l1; | 15 | pmdval_t prot_l1; |
16 | unsigned int prot_sect; | 16 | pmdval_t prot_sect; |
17 | unsigned int domain; | 17 | unsigned int domain; |
18 | }; | 18 | }; |
19 | 19 | ||
diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c index 36e983d98315..226f1804be12 100644 --- a/arch/arm/mm/mmu.c +++ b/arch/arm/mm/mmu.c | |||
@@ -60,7 +60,7 @@ EXPORT_SYMBOL(pgprot_kernel); | |||
60 | struct cachepolicy { | 60 | struct cachepolicy { |
61 | const char policy[16]; | 61 | const char policy[16]; |
62 | unsigned int cr_mask; | 62 | unsigned int cr_mask; |
63 | unsigned int pmd; | 63 | pmdval_t pmd; |
64 | pteval_t pte; | 64 | pteval_t pte; |
65 | }; | 65 | }; |
66 | 66 | ||
@@ -288,7 +288,7 @@ static void __init build_mem_type_table(void) | |||
288 | { | 288 | { |
289 | struct cachepolicy *cp; | 289 | struct cachepolicy *cp; |
290 | unsigned int cr = get_cr(); | 290 | unsigned int cr = get_cr(); |
291 | unsigned int user_pgprot, kern_pgprot, vecs_pgprot; | 291 | pteval_t user_pgprot, kern_pgprot, vecs_pgprot; |
292 | int cpu_arch = cpu_architecture(); | 292 | int cpu_arch = cpu_architecture(); |
293 | int i; | 293 | int i; |
294 | 294 | ||