diff options
author | Cyril Chemparathy <cyril@ti.com> | 2012-07-21 19:47:52 -0400 |
---|---|---|
committer | Will Deacon <will.deacon@arm.com> | 2013-05-30 11:02:11 -0400 |
commit | a7fbc0d62a4d46e642af889e7288fede5078bc46 (patch) | |
tree | 5ca6452ed4dd9f9e2b89441d829d5cd3fad4ed80 | |
parent | 1fc84ae84b5153e32a4b6ace507f9663e10b0cb2 (diff) |
ARM: LPAE: factor out T1SZ and TTBR1 computations
This patch moves the TTBR1 offset calculation and the T1SZ calculation out
of the TTB setup assembly code. This should not affect functionality in
any way, but improves code readability as well as readability of subsequent
patches in this series.
Signed-off-by: Cyril Chemparathy <cyril@ti.com>
Signed-off-by: Vitaly Andrianov <vitalya@ti.com>
Acked-by: Nicolas Pitre <nico@linaro.org>
Tested-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
Tested-by: Subash Patel <subash.rp@samsung.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
-rw-r--r-- | arch/arm/include/asm/pgtable-3level-hwdef.h | 20 | ||||
-rw-r--r-- | arch/arm/mm/proc-v7-3level.S | 29 |
2 files changed, 28 insertions, 21 deletions
diff --git a/arch/arm/include/asm/pgtable-3level-hwdef.h b/arch/arm/include/asm/pgtable-3level-hwdef.h index 18f5cef82ad5..c6c6e6df22f3 100644 --- a/arch/arm/include/asm/pgtable-3level-hwdef.h +++ b/arch/arm/include/asm/pgtable-3level-hwdef.h | |||
@@ -79,4 +79,24 @@ | |||
79 | #define PHYS_MASK_SHIFT (40) | 79 | #define PHYS_MASK_SHIFT (40) |
80 | #define PHYS_MASK ((1ULL << PHYS_MASK_SHIFT) - 1) | 80 | #define PHYS_MASK ((1ULL << PHYS_MASK_SHIFT) - 1) |
81 | 81 | ||
82 | /* | ||
83 | * TTBR0/TTBR1 split (PAGE_OFFSET): | ||
84 | * 0x40000000: T0SZ = 2, T1SZ = 0 (not used) | ||
85 | * 0x80000000: T0SZ = 0, T1SZ = 1 | ||
86 | * 0xc0000000: T0SZ = 0, T1SZ = 2 | ||
87 | * | ||
88 | * Only use this feature if PHYS_OFFSET <= PAGE_OFFSET, otherwise | ||
89 | * booting secondary CPUs would end up using TTBR1 for the identity | ||
90 | * mapping set up in TTBR0. | ||
91 | */ | ||
92 | #if defined CONFIG_VMSPLIT_2G | ||
93 | #define TTBR1_OFFSET 16 /* skip two L1 entries */ | ||
94 | #elif defined CONFIG_VMSPLIT_3G | ||
95 | #define TTBR1_OFFSET (4096 * (1 + 3)) /* only L2, skip pgd + 3*pmd */ | ||
96 | #else | ||
97 | #define TTBR1_OFFSET 0 | ||
98 | #endif | ||
99 | |||
100 | #define TTBR1_SIZE (((PAGE_OFFSET >> 30) - 1) << 16) | ||
101 | |||
82 | #endif | 102 | #endif |
diff --git a/arch/arm/mm/proc-v7-3level.S b/arch/arm/mm/proc-v7-3level.S index 995857d3b530..58ab7477bb61 100644 --- a/arch/arm/mm/proc-v7-3level.S +++ b/arch/arm/mm/proc-v7-3level.S | |||
@@ -114,7 +114,7 @@ ENDPROC(cpu_v7_set_pte_ext) | |||
114 | */ | 114 | */ |
115 | .macro v7_ttb_setup, zero, ttbr0, ttbr1, tmp | 115 | .macro v7_ttb_setup, zero, ttbr0, ttbr1, tmp |
116 | ldr \tmp, =swapper_pg_dir @ swapper_pg_dir virtual address | 116 | ldr \tmp, =swapper_pg_dir @ swapper_pg_dir virtual address |
117 | cmp \ttbr1, \tmp @ PHYS_OFFSET > PAGE_OFFSET? (branch below) | 117 | cmp \ttbr1, \tmp @ PHYS_OFFSET > PAGE_OFFSET? |
118 | mrc p15, 0, \tmp, c2, c0, 2 @ TTB control register | 118 | mrc p15, 0, \tmp, c2, c0, 2 @ TTB control register |
119 | orr \tmp, \tmp, #TTB_EAE | 119 | orr \tmp, \tmp, #TTB_EAE |
120 | ALT_SMP(orr \tmp, \tmp, #TTB_FLAGS_SMP) | 120 | ALT_SMP(orr \tmp, \tmp, #TTB_FLAGS_SMP) |
@@ -122,27 +122,14 @@ ENDPROC(cpu_v7_set_pte_ext) | |||
122 | ALT_SMP(orr \tmp, \tmp, #TTB_FLAGS_SMP << 16) | 122 | ALT_SMP(orr \tmp, \tmp, #TTB_FLAGS_SMP << 16) |
123 | ALT_UP(orr \tmp, \tmp, #TTB_FLAGS_UP << 16) | 123 | ALT_UP(orr \tmp, \tmp, #TTB_FLAGS_UP << 16) |
124 | /* | 124 | /* |
125 | * TTBR0/TTBR1 split (PAGE_OFFSET): | 125 | * Only use split TTBRs if PHYS_OFFSET <= PAGE_OFFSET (cmp above), |
126 | * 0x40000000: T0SZ = 2, T1SZ = 0 (not used) | 126 | * otherwise booting secondary CPUs would end up using TTBR1 for the |
127 | * 0x80000000: T0SZ = 0, T1SZ = 1 | 127 | * identity mapping set up in TTBR0. |
128 | * 0xc0000000: T0SZ = 0, T1SZ = 2 | ||
129 | * | ||
130 | * Only use this feature if PHYS_OFFSET <= PAGE_OFFSET, otherwise | ||
131 | * booting secondary CPUs would end up using TTBR1 for the identity | ||
132 | * mapping set up in TTBR0. | ||
133 | */ | 128 | */ |
134 | bhi 9001f @ PHYS_OFFSET > PAGE_OFFSET? | 129 | orrls \tmp, \tmp, #TTBR1_SIZE @ TTBCR.T1SZ |
135 | orr \tmp, \tmp, #(((PAGE_OFFSET >> 30) - 1) << 16) @ TTBCR.T1SZ | 130 | mcr p15, 0, \tmp, c2, c0, 2 @ TTBCR |
136 | #if defined CONFIG_VMSPLIT_2G | 131 | addls \ttbr1, \ttbr1, #TTBR1_OFFSET |
137 | /* PAGE_OFFSET == 0x80000000, T1SZ == 1 */ | 132 | mcrr p15, 1, \ttbr1, \zero, c2 @ load TTBR1 |
138 | add \ttbr1, \ttbr1, #1 << 4 @ skip two L1 entries | ||
139 | #elif defined CONFIG_VMSPLIT_3G | ||
140 | /* PAGE_OFFSET == 0xc0000000, T1SZ == 2 */ | ||
141 | add \ttbr1, \ttbr1, #4096 * (1 + 3) @ only L2 used, skip pgd+3*pmd | ||
142 | #endif | ||
143 | /* CONFIG_VMSPLIT_1G does not need TTBR1 adjustment */ | ||
144 | 9001: mcr p15, 0, \tmp, c2, c0, 2 @ TTB control register | ||
145 | mcrr p15, 1, \ttbr1, \zero, c2 @ load TTBR1 | ||
146 | .endm | 133 | .endm |
147 | 134 | ||
148 | __CPUINIT | 135 | __CPUINIT |