linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Mark Rutland <mark.rutland@arm.com>
To: linux-arm-kernel@lists.infradead.org, catalin.marinas@arm.com,
	will@kernel.org
Cc: mark.rutland@arm.com, robin.murphy@arm.com, james.morse@arm.com,
	hch@lst.de
Subject: [PATCHv4 04/17] arm64: head.S: cleanup SCTLR_ELx initialization
Date: Fri, 13 Nov 2020 12:49:24 +0000	[thread overview]
Message-ID: <20201113124937.20574-5-mark.rutland@arm.com> (raw)
In-Reply-To: <20201113124937.20574-1-mark.rutland@arm.com>

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: Mark Rutland <mark.rutland@arm.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: James Morse <james.morse@arm.com>
Cc: Will Deacon <will@kernel.org>
---
 arch/arm64/include/asm/sysreg.h | 18 ++++++++++++------
 arch/arm64/kernel/head.S        |  6 +++---
 arch/arm64/mm/proc.S            |  2 +-
 3 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/arch/arm64/include/asm/sysreg.h b/arch/arm64/include/asm/sysreg.h
index 24160f7410e8..117bf97666ee 100644
--- a/arch/arm64/include/asm/sysreg.h
+++ b/arch/arm64/include/asm/sysreg.h
@@ -582,6 +582,9 @@
 #define ENDIAN_SET_EL2		0
 #endif
 
+#define INIT_SCTLR_EL2_MMU_OFF \
+	(SCTLR_EL2_RES1 | ENDIAN_SET_EL2)
+
 /* SCTLR_EL1 specific flags. */
 #define SCTLR_EL1_ATA0		(BIT(42))
 
@@ -615,12 +618,15 @@
 #define ENDIAN_SET_EL1		0
 #endif
 
-#define SCTLR_EL1_SET	(SCTLR_ELx_M    | SCTLR_ELx_C    | SCTLR_ELx_SA   |\
-			 SCTLR_EL1_SA0  | 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)
+#define INIT_SCTLR_EL1_MMU_OFF \
+	(ENDIAN_SET_EL1 | SCTLR_EL1_RES1)
+
+#define INIT_SCTLR_EL1_MMU_ON \
+	(SCTLR_ELx_M    | SCTLR_ELx_C    | SCTLR_ELx_SA   | SCTLR_EL1_SA0   | \
+	 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) */
 #define MAIR_ATTR_DEVICE_nGnRnE		UL(0x00)
diff --git a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S
index 5a31086e8e85..4d113a4ef929 100644
--- a/arch/arm64/kernel/head.S
+++ b/arch/arm64/kernel/head.S
@@ -494,13 +494,13 @@ SYM_FUNC_START(init_kernel_el)
 	mrs	x0, CurrentEL
 	cmp	x0, #CurrentEL_EL2
 	b.eq	1f
-	mov_q	x0, (SCTLR_EL1_RES1 | ENDIAN_SET_EL1)
+	mov_q	x0, INIT_SCTLR_EL1_MMU_OFF
 	msr	sctlr_el1, x0
 	mov	w0, #BOOT_CPU_MODE_EL1		// This cpu booted in EL1
 	isb
 	ret
 
-1:	mov_q	x0, (SCTLR_EL2_RES1 | ENDIAN_SET_EL2)
+1:	mov_q	x0, INIT_SCTLR_EL2_MMU_OFF
 	msr	sctlr_el2, x0
 
 #ifdef CONFIG_ARM64_VHE
@@ -621,7 +621,7 @@ SYM_INNER_LABEL(install_el2_stub, SYM_L_LOCAL)
 	 * requires no configuration, and all non-hyp-specific EL2 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
 
 	/* Coprocessor traps. */
diff --git a/arch/arm64/mm/proc.S b/arch/arm64/mm/proc.S
index 23c326a06b2d..29f064e117d9 100644
--- a/arch/arm64/mm/proc.S
+++ b/arch/arm64/mm/proc.S
@@ -489,6 +489,6 @@ SYM_FUNC_START(__cpu_setup)
 	/*
 	 * Prepare SCTLR
 	 */
-	mov_q	x0, SCTLR_EL1_SET
+	mov_q	x0, INIT_SCTLR_EL1_MMU_ON
 	ret					// return to head.S
 SYM_FUNC_END(__cpu_setup)
-- 
2.11.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  parent reply	other threads:[~2020-11-13 12:50 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-13 12:49 [PATCHv4 00/17] arm64: remove set_fs() and friends Mark Rutland
2020-11-13 12:49 ` [PATCHv4 01/17] arm64: ensure ERET from kthread is illegal Mark Rutland
2020-11-13 12:49 ` [PATCHv4 02/17] arm64: add C wrappers for SET_PSTATE_*() Mark Rutland
2020-11-13 12:49 ` [PATCHv4 03/17] arm64: head.S: rename el2_setup -> init_kernel_el Mark Rutland
2020-11-13 12:49 ` Mark Rutland [this message]
2020-11-13 12:49 ` [PATCHv4 05/17] arm64: head.S: always initialize PSTATE Mark Rutland
2020-11-13 12:49 ` [PATCHv4 06/17] arm64: sdei: move uaccess logic to arch/arm64/ Mark Rutland
2020-11-16 17:42   ` Catalin Marinas
2020-11-26 18:42   ` James Morse
2020-11-13 12:49 ` [PATCHv4 07/17] arm64: sdei: explicitly simulate PAN/UAO entry Mark Rutland
2020-11-26 18:42   ` James Morse
2020-12-01 12:14     ` Mark Rutland
2020-11-13 12:49 ` [PATCHv4 08/17] arm64: uaccess: move uao_* alternatives to asm-uaccess.h Mark Rutland
2020-11-14  9:22   ` Christoph Hellwig
2020-11-16 12:25     ` Mark Rutland
2020-11-13 12:49 ` [PATCHv4 09/17] arm64: uaccess: rename privileged uaccess routines Mark Rutland
2020-11-13 12:49 ` [PATCHv4 10/17] arm64: uaccess: simplify __copy_user_flushcache() Mark Rutland
2020-11-13 12:49 ` [PATCHv4 11/17] arm64: uaccess: refactor __{get,put}_user Mark Rutland
2020-11-13 12:49 ` [PATCHv4 12/17] arm64: uaccess: split user/kernel routines Mark Rutland
2020-11-26 18:42   ` James Morse
2020-12-01 11:03     ` Mark Rutland
2020-12-02 12:19       ` Mark Rutland
2020-11-13 12:49 ` [PATCHv4 13/17] arm64: uaccess cleanup macro naming Mark Rutland
2020-11-13 12:49 ` [PATCHv4 14/17] arm64: uaccess: remove set_fs() Mark Rutland
2020-11-16 17:40   ` Catalin Marinas
2020-11-17 10:44     ` Mark Rutland
2020-11-17 10:54       ` Catalin Marinas
2020-11-17 10:57         ` Mark Rutland
2020-11-17 11:02           ` Catalin Marinas
2020-11-17 11:07             ` Mark Rutland
2020-11-17 11:10               ` Catalin Marinas
2020-11-26 18:42               ` James Morse
2020-11-26 18:42   ` James Morse
2020-12-01 12:30     ` Mark Rutland
2020-11-13 12:49 ` [PATCHv4 15/17] arm64: uaccess: remove addr_limit_user_check() Mark Rutland
2020-11-13 12:49 ` [PATCHv4 16/17] arm64: uaccess: remove redundant PAN toggling Mark Rutland
2020-11-13 12:49 ` [PATCHv4 17/17] arm64: uaccess: remove vestigal UAO support Mark Rutland
2020-11-25 19:10 ` [PATCHv4 00/17] arm64: remove set_fs() and friends Catalin Marinas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201113124937.20574-5-mark.rutland@arm.com \
    --to=mark.rutland@arm.com \
    --cc=catalin.marinas@arm.com \
    --cc=hch@lst.de \
    --cc=james.morse@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=robin.murphy@arm.com \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).