Skip to content

Commit e7227d0

Browse files
glevandwildea01
authored andcommitted
arm64: Cleanup SCTLR flags
We currently have macros defining flags for the arm64 sctlr registers in both kvm_arm.h and sysreg.h. To clean things up and simplify move the definitions of the SCTLR_EL2 flags from kvm_arm.h to sysreg.h, rename any SCTLR_EL1 or SCTLR_EL2 flags that are common to both registers to be SCTLR_ELx, with 'x' indicating a common flag, and fixup all files to include the proper header or to use the new macro names. Signed-off-by: Geoff Levand <geoff@infradead.org> [Restored pgtable-hwdef.h include] Signed-off-by: James Morse <james.morse@arm.com> Acked-by: Marc Zyngier <marc.zyngier@arm.com> Signed-off-by: Will Deacon <will.deacon@arm.com>
1 parent 7b7293a commit e7227d0

File tree

3 files changed

+18
-17
lines changed

3 files changed

+18
-17
lines changed

arch/arm64/include/asm/kvm_arm.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -84,17 +84,6 @@
8484
#define HCR_INT_OVERRIDE (HCR_FMO | HCR_IMO)
8585
#define HCR_HOST_VHE_FLAGS (HCR_RW | HCR_TGE | HCR_E2H)
8686

87-
/* Hyp System Control Register (SCTLR_EL2) bits */
88-
#define SCTLR_EL2_EE (1 << 25)
89-
#define SCTLR_EL2_WXN (1 << 19)
90-
#define SCTLR_EL2_I (1 << 12)
91-
#define SCTLR_EL2_SA (1 << 3)
92-
#define SCTLR_EL2_C (1 << 2)
93-
#define SCTLR_EL2_A (1 << 1)
94-
#define SCTLR_EL2_M 1
95-
#define SCTLR_EL2_FLAGS (SCTLR_EL2_M | SCTLR_EL2_A | SCTLR_EL2_C | \
96-
SCTLR_EL2_SA | SCTLR_EL2_I)
97-
9887
/* TCR_EL2 Registers bits */
9988
#define TCR_EL2_RES1 ((1 << 31) | (1 << 23))
10089
#define TCR_EL2_TBI (1 << 20)

arch/arm64/include/asm/sysreg.h

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,21 @@
8686
#define SET_PSTATE_UAO(x) __inst_arm(0xd5000000 | REG_PSTATE_UAO_IMM |\
8787
(!!x)<<8 | 0x1f)
8888

89-
/* SCTLR_EL1 */
90-
#define SCTLR_EL1_CP15BEN (0x1 << 5)
91-
#define SCTLR_EL1_SED (0x1 << 8)
92-
#define SCTLR_EL1_SPAN (0x1 << 23)
89+
/* Common SCTLR_ELx flags. */
90+
#define SCTLR_ELx_EE (1 << 25)
91+
#define SCTLR_ELx_I (1 << 12)
92+
#define SCTLR_ELx_SA (1 << 3)
93+
#define SCTLR_ELx_C (1 << 2)
94+
#define SCTLR_ELx_A (1 << 1)
95+
#define SCTLR_ELx_M 1
96+
97+
#define SCTLR_ELx_FLAGS (SCTLR_ELx_M | SCTLR_ELx_A | SCTLR_ELx_C | \
98+
SCTLR_ELx_SA | SCTLR_ELx_I)
99+
100+
/* SCTLR_EL1 specific flags. */
101+
#define SCTLR_EL1_SPAN (1 << 23)
102+
#define SCTLR_EL1_SED (1 << 8)
103+
#define SCTLR_EL1_CP15BEN (1 << 5)
93104

94105

95106
/* id_aa64isar0 */

arch/arm64/kvm/hyp-init.S

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <asm/kvm_arm.h>
2222
#include <asm/kvm_mmu.h>
2323
#include <asm/pgtable-hwdef.h>
24+
#include <asm/sysreg.h>
2425

2526
.text
2627
.pushsection .hyp.idmap.text, "ax"
@@ -103,8 +104,8 @@ __do_hyp_init:
103104
dsb sy
104105

105106
mrs x4, sctlr_el2
106-
and x4, x4, #SCTLR_EL2_EE // preserve endianness of EL2
107-
ldr x5, =SCTLR_EL2_FLAGS
107+
and x4, x4, #SCTLR_ELx_EE // preserve endianness of EL2
108+
ldr x5, =SCTLR_ELx_FLAGS
108109
orr x4, x4, x5
109110
msr sctlr_el2, x4
110111
isb

0 commit comments

Comments
 (0)