Skip to content

Commit d914b80

Browse files
pccctmarinas
authored andcommitted
arm64: avoid double ISB on kernel entry
Although an ISB is required in order to make the MTE-related system register update to GCR_EL1 effective, and the same is true for PAC-related updates to SCTLR_EL1 or APIAKey{Hi,Lo}_EL1, we issue two ISBs on machines that support both features while we only need to issue one. To avoid the unnecessary additional ISB, remove the ISBs from the PAC and MTE-specific alternative blocks and add a couple of additional blocks that cause us to only execute one ISB if both features are supported. Signed-off-by: Peter Collingbourne <[email protected]> Link: https://linux-review.googlesource.com/id/Idee7e8114d5ae5a0b171d06220a0eb4bb015a51c Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Catalin Marinas <[email protected]>
1 parent afdfd93 commit d914b80

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

arch/arm64/kernel/entry.S

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,6 @@ alternative_else_nop_endif
184184
ldr_l \tmp, gcr_kernel_excl
185185

186186
mte_set_gcr \tmp, \tmp2
187-
isb
188187
1:
189188
#endif
190189
.endm
@@ -257,14 +256,26 @@ alternative_if ARM64_HAS_ADDRESS_AUTH
257256
orr x0, x0, SCTLR_ELx_ENIA
258257
msr sctlr_el1, x0
259258
2:
260-
isb
261259
alternative_else_nop_endif
262260
#endif
263261

264262
apply_ssbd 1, x22, x23
265263

266264
mte_set_kernel_gcr x22, x23
267265

266+
/*
267+
* Any non-self-synchronizing system register updates required for
268+
* kernel entry should be placed before this point.
269+
*/
270+
alternative_if ARM64_MTE
271+
isb
272+
b 1f
273+
alternative_else_nop_endif
274+
alternative_if ARM64_HAS_ADDRESS_AUTH
275+
isb
276+
alternative_else_nop_endif
277+
1:
278+
268279
scs_load tsk
269280
.else
270281
add x21, sp, #PT_REGS_SIZE

0 commit comments

Comments
 (0)