Skip to content

Commit 46f269e

Browse files
glevandAlex Shi
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> (cherry picked from commit e7227d0e528f9a96d4a866f43e20dd9b33f0e782) Signed-off-by: Alex Shi <alex.shi@linaro.org>
1 parent a7ba39d commit 46f269e

3 files changed

Lines changed: 18 additions & 17 deletions

File tree

arch/arm64/include/asm/kvm_arm.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -83,17 +83,6 @@
8383
#define HCR_INT_OVERRIDE (HCR_FMO | HCR_IMO)
8484

8585

86-
/* Hyp System Control Register (SCTLR_EL2) bits */
87-
#define SCTLR_EL2_EE (1 << 25)
88-
#define SCTLR_EL2_WXN (1 << 19)
89-
#define SCTLR_EL2_I (1 << 12)
90-
#define SCTLR_EL2_SA (1 << 3)
91-
#define SCTLR_EL2_C (1 << 2)
92-
#define SCTLR_EL2_A (1 << 1)
93-
#define SCTLR_EL2_M 1
94-
#define SCTLR_EL2_FLAGS (SCTLR_EL2_M | SCTLR_EL2_A | SCTLR_EL2_C | \
95-
SCTLR_EL2_SA | SCTLR_EL2_I)
96-
9786
/* TCR_EL2 Registers bits */
9887
#define TCR_EL2_RES1 ((1 << 31) | (1 << 23))
9988
#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
@@ -82,10 +82,21 @@
8282
#define SET_PSTATE_PAN(x) __inst_arm(0xd5000000 | REG_PSTATE_PAN_IMM |\
8383
(!!x)<<8 | 0x1f)
8484

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

90101

91102
/* 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"
@@ -116,8 +117,8 @@ __do_hyp_init:
116117
dsb sy
117118

118119
mrs x4, sctlr_el2
119-
and x4, x4, #SCTLR_EL2_EE // preserve endianness of EL2
120-
ldr x5, =SCTLR_EL2_FLAGS
120+
and x4, x4, #SCTLR_ELx_EE // preserve endianness of EL2
121+
ldr x5, =SCTLR_ELx_FLAGS
121122
orr x4, x4, x5
122123
msr sctlr_el2, x4
123124
isb

0 commit comments

Comments
 (0)