Skip to content

Commit afdfd93

Browse files
pccctmarinas
authored andcommitted
arm64: mte: optimize GCR_EL1 modification on kernel entry/exit
Accessing GCR_EL1 and issuing an ISB can be expensive on some microarchitectures. Although we must write to GCR_EL1, we can restructure the code to avoid reading from it because the new value can be derived entirely from the exclusion mask, which is already in a GPR. Do so. Signed-off-by: Peter Collingbourne <[email protected]> Link: https://linux-review.googlesource.com/id/I560a190a74176ca4cc5191dad08f77f6b1577c75 Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Catalin Marinas <[email protected]>
1 parent 80c7c36 commit afdfd93

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

arch/arm64/kernel/entry.S

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -168,15 +168,11 @@ alternative_else_nop_endif
168168
#endif
169169
.endm
170170

171-
.macro mte_set_gcr, tmp, tmp2
171+
.macro mte_set_gcr, mte_ctrl, tmp
172172
#ifdef CONFIG_ARM64_MTE
173-
/*
174-
* Calculate and set the exclude mask preserving
175-
* the RRND (bit[16]) setting.
176-
*/
177-
mrs_s \tmp2, SYS_GCR_EL1
178-
bfxil \tmp2, \tmp, #MTE_CTRL_GCR_USER_EXCL_SHIFT, #16
179-
msr_s SYS_GCR_EL1, \tmp2
173+
ubfx \tmp, \mte_ctrl, #MTE_CTRL_GCR_USER_EXCL_SHIFT, #16
174+
orr \tmp, \tmp, #SYS_GCR_EL1_RRND
175+
msr_s SYS_GCR_EL1, \tmp
180176
#endif
181177
.endm
182178

0 commit comments

Comments
 (0)