diff options
| author | Matthew Leach <matthew.leach@arm.com> | 2013-10-11 09:52:17 -0400 |
|---|---|---|
| committer | Catalin Marinas <catalin.marinas@arm.com> | 2013-10-25 10:59:41 -0400 |
| commit | 9cf71728931a4073b9e3a4bcbf9dada86bc98370 (patch) | |
| tree | 3f691894d37da543d5077307c26e3d450952974e /arch/arm64/kernel/head.S | |
| parent | 828e9834e9a5b7e61046aa3c5f603a4fecba2fb4 (diff) | |
arm64: big-endian: set correct endianess on kernel entry
The endianness of memory accesses at EL2 and EL1 are configured by
SCTLR_EL2.EE and SCTLR_EL1.EE respectively. When the kernel is booted,
the state of SCTLR_EL{2,1}.EE is unknown, and thus the kernel must
ensure that they are set before performing any memory accesses.
This patch ensures that SCTLR_EL{2,1} are configured appropriately at
boot for kernels of either endianness.
Acked-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Matthew Leach <matthew.leach@arm.com>
[catalin.marinas@arm.com: fix SCTLR_EL1.E0E bit setting in head.S]
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Diffstat (limited to 'arch/arm64/kernel/head.S')
| -rw-r--r-- | arch/arm64/kernel/head.S | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S index 775ecb313ee7..7009387348b7 100644 --- a/arch/arm64/kernel/head.S +++ b/arch/arm64/kernel/head.S | |||
| @@ -159,12 +159,22 @@ ENTRY(el2_setup) | |||
| 159 | mrs x0, CurrentEL | 159 | mrs x0, CurrentEL |
| 160 | cmp x0, #PSR_MODE_EL2t | 160 | cmp x0, #PSR_MODE_EL2t |
| 161 | ccmp x0, #PSR_MODE_EL2h, #0x4, ne | 161 | ccmp x0, #PSR_MODE_EL2h, #0x4, ne |
| 162 | b.eq 1f | 162 | b.ne 1f |
| 163 | mrs x0, sctlr_el2 | ||
| 164 | CPU_BE( orr x0, x0, #(1 << 25) ) // Set the EE bit for EL2 | ||
| 165 | CPU_LE( bic x0, x0, #(1 << 25) ) // Clear the EE bit for EL2 | ||
| 166 | msr sctlr_el2, x0 | ||
| 167 | b 2f | ||
| 168 | 1: mrs x0, sctlr_el1 | ||
| 169 | CPU_BE( orr x0, x0, #(3 << 24) ) // Set the EE and E0E bits for EL1 | ||
| 170 | CPU_LE( bic x0, x0, #(3 << 24) ) // Clear the EE and E0E bits for EL1 | ||
| 171 | msr sctlr_el1, x0 | ||
| 163 | mov w20, #BOOT_CPU_MODE_EL1 // This cpu booted in EL1 | 172 | mov w20, #BOOT_CPU_MODE_EL1 // This cpu booted in EL1 |
| 173 | isb | ||
| 164 | ret | 174 | ret |
| 165 | 175 | ||
| 166 | /* Hyp configuration. */ | 176 | /* Hyp configuration. */ |
| 167 | 1: mov x0, #(1 << 31) // 64-bit EL1 | 177 | 2: mov x0, #(1 << 31) // 64-bit EL1 |
| 168 | msr hcr_el2, x0 | 178 | msr hcr_el2, x0 |
| 169 | 179 | ||
| 170 | /* Generic timers. */ | 180 | /* Generic timers. */ |
| @@ -181,7 +191,8 @@ ENTRY(el2_setup) | |||
| 181 | 191 | ||
| 182 | /* sctlr_el1 */ | 192 | /* sctlr_el1 */ |
| 183 | mov x0, #0x0800 // Set/clear RES{1,0} bits | 193 | mov x0, #0x0800 // Set/clear RES{1,0} bits |
| 184 | movk x0, #0x30d0, lsl #16 | 194 | CPU_BE( movk x0, #0x33d0, lsl #16 ) // Set EE and E0E on BE systems |
| 195 | CPU_LE( movk x0, #0x30d0, lsl #16 ) // Clear EE and E0E on LE systems | ||
| 185 | msr sctlr_el1, x0 | 196 | msr sctlr_el1, x0 |
| 186 | 197 | ||
| 187 | /* Coprocessor traps. */ | 198 | /* Coprocessor traps. */ |
