Commit 2ffac9e3 authored by Mark Rutland's avatar Mark Rutland Committed by Catalin Marinas

arm64: head.S: cleanup SCTLR_ELx initialization

Let's make SCTLR_ELx initialization a bit clearer by using meaningful
names for the initialization values, following the same scheme for
SCTLR_EL1 and SCTLR_EL2.

These definitions will be used more widely in subsequent patches.

There should be no functional change as a result of this patch.
Signed-off-by: default avatarMark Rutland <mark.rutland@arm.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: James Morse <james.morse@arm.com>
Cc: Will Deacon <will@kernel.org>
Link: https://lore.kernel.org/r/20201113124937.20574-5-mark.rutland@arm.comSigned-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
parent ecbb11ab
...@@ -582,6 +582,9 @@ ...@@ -582,6 +582,9 @@
#define ENDIAN_SET_EL2 0 #define ENDIAN_SET_EL2 0
#endif #endif
#define INIT_SCTLR_EL2_MMU_OFF \
(SCTLR_EL2_RES1 | ENDIAN_SET_EL2)
/* SCTLR_EL1 specific flags. */ /* SCTLR_EL1 specific flags. */
#define SCTLR_EL1_ATA0 (BIT(42)) #define SCTLR_EL1_ATA0 (BIT(42))
...@@ -615,12 +618,15 @@ ...@@ -615,12 +618,15 @@
#define ENDIAN_SET_EL1 0 #define ENDIAN_SET_EL1 0
#endif #endif
#define SCTLR_EL1_SET (SCTLR_ELx_M | SCTLR_ELx_C | SCTLR_ELx_SA |\ #define INIT_SCTLR_EL1_MMU_OFF \
SCTLR_EL1_SA0 | SCTLR_EL1_SED | SCTLR_ELx_I |\ (ENDIAN_SET_EL1 | SCTLR_EL1_RES1)
SCTLR_EL1_DZE | SCTLR_EL1_UCT |\
SCTLR_EL1_NTWE | SCTLR_ELx_IESB | SCTLR_EL1_SPAN |\ #define INIT_SCTLR_EL1_MMU_ON \
SCTLR_ELx_ITFSB| SCTLR_ELx_ATA | SCTLR_EL1_ATA0 |\ (SCTLR_ELx_M | SCTLR_ELx_C | SCTLR_ELx_SA | SCTLR_EL1_SA0 | \
ENDIAN_SET_EL1 | SCTLR_EL1_UCI | SCTLR_EL1_RES1) SCTLR_EL1_SED | SCTLR_ELx_I | SCTLR_EL1_DZE | SCTLR_EL1_UCT | \
SCTLR_EL1_NTWE | SCTLR_ELx_IESB | SCTLR_EL1_SPAN | SCTLR_ELx_ITFSB | \
SCTLR_ELx_ATA | SCTLR_EL1_ATA0 | ENDIAN_SET_EL1 | SCTLR_EL1_UCI | \
SCTLR_EL1_RES1)
/* MAIR_ELx memory attributes (used by Linux) */ /* MAIR_ELx memory attributes (used by Linux) */
#define MAIR_ATTR_DEVICE_nGnRnE UL(0x00) #define MAIR_ATTR_DEVICE_nGnRnE UL(0x00)
......
...@@ -494,13 +494,13 @@ SYM_FUNC_START(init_kernel_el) ...@@ -494,13 +494,13 @@ SYM_FUNC_START(init_kernel_el)
mrs x0, CurrentEL mrs x0, CurrentEL
cmp x0, #CurrentEL_EL2 cmp x0, #CurrentEL_EL2
b.eq 1f b.eq 1f
mov_q x0, (SCTLR_EL1_RES1 | ENDIAN_SET_EL1) mov_q x0, INIT_SCTLR_EL1_MMU_OFF
msr sctlr_el1, x0 msr sctlr_el1, x0
mov w0, #BOOT_CPU_MODE_EL1 // This cpu booted in EL1 mov w0, #BOOT_CPU_MODE_EL1 // This cpu booted in EL1
isb isb
ret ret
1: mov_q x0, (SCTLR_EL2_RES1 | ENDIAN_SET_EL2) 1: mov_q x0, INIT_SCTLR_EL2_MMU_OFF
msr sctlr_el2, x0 msr sctlr_el2, x0
#ifdef CONFIG_ARM64_VHE #ifdef CONFIG_ARM64_VHE
...@@ -621,7 +621,7 @@ SYM_INNER_LABEL(install_el2_stub, SYM_L_LOCAL) ...@@ -621,7 +621,7 @@ SYM_INNER_LABEL(install_el2_stub, SYM_L_LOCAL)
* requires no configuration, and all non-hyp-specific EL2 setup * requires no configuration, and all non-hyp-specific EL2 setup
* will be done via the _EL1 system register aliases in __cpu_setup. * will be done via the _EL1 system register aliases in __cpu_setup.
*/ */
mov_q x0, (SCTLR_EL1_RES1 | ENDIAN_SET_EL1) mov_q x0, INIT_SCTLR_EL1_MMU_OFF
msr sctlr_el1, x0 msr sctlr_el1, x0
/* Coprocessor traps. */ /* Coprocessor traps. */
......
...@@ -489,6 +489,6 @@ SYM_FUNC_START(__cpu_setup) ...@@ -489,6 +489,6 @@ SYM_FUNC_START(__cpu_setup)
/* /*
* Prepare SCTLR * Prepare SCTLR
*/ */
mov_q x0, SCTLR_EL1_SET mov_q x0, INIT_SCTLR_EL1_MMU_ON
ret // return to head.S ret // return to head.S
SYM_FUNC_END(__cpu_setup) SYM_FUNC_END(__cpu_setup)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment