Skip to content

Commit 926b66e

Browse files
Yicong Yangctmarinas
authored andcommitted
arm64: setup: name 'tcr2' register
TCR2_EL1 introduced some additional controls besides TCR_EL1. Currently only PIE is supported and enabled by writing TCR2_EL1 directly if PIE detected. Introduce a named register 'tcr2' just like 'tcr' we've already had. It'll be initialized to 0 and updated if certain feature detected and needs to be enabled. Touch the TCR2_EL1 registers at last with the updated 'tcr2' value if FEAT_TCR2 supported by checking ID_AA64MMFR3_EL1.TCRX. Then we can extend the support of other features controlled by TCR2_EL1. Reviewed-by: Catalin Marinas <catalin.marinas@arm.com> Signed-off-by: Yicong Yang <yangyicong@hisilicon.com> Link: https://lore.kernel.org/r/20241102104235.62560-3-yangyicong@huawei.com Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
1 parent aa47dcd commit 926b66e

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

arch/arm64/mm/proc.S

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -465,10 +465,12 @@ SYM_FUNC_START(__cpu_setup)
465465
*/
466466
mair .req x17
467467
tcr .req x16
468+
tcr2 .req x15
468469
mov_q mair, MAIR_EL1_SET
469470
mov_q tcr, TCR_T0SZ(IDMAP_VA_BITS) | TCR_T1SZ(VA_BITS_MIN) | TCR_CACHE_FLAGS | \
470471
TCR_SHARED | TCR_TG_FLAGS | TCR_KASLR_FLAGS | TCR_ASID16 | \
471472
TCR_TBI0 | TCR_A1 | TCR_KASAN_SW_FLAGS | TCR_MTE_FLAGS
473+
mov tcr2, xzr
472474

473475
tcr_clear_errata_bits tcr, x9, x5
474476

@@ -525,11 +527,16 @@ alternative_else_nop_endif
525527
#undef PTE_MAYBE_NG
526528
#undef PTE_MAYBE_SHARED
527529

528-
mov x0, TCR2_EL1x_PIE
529-
msr REG_TCR2_EL1, x0
530+
orr tcr2, tcr2, TCR2_EL1x_PIE
530531

531532
.Lskip_indirection:
532533

534+
mrs_s x1, SYS_ID_AA64MMFR3_EL1
535+
ubfx x1, x1, #ID_AA64MMFR3_EL1_TCRX_SHIFT, #4
536+
cbz x1, 1f
537+
msr REG_TCR2_EL1, tcr2
538+
1:
539+
533540
/*
534541
* Prepare SCTLR
535542
*/
@@ -538,4 +545,5 @@ alternative_else_nop_endif
538545

539546
.unreq mair
540547
.unreq tcr
548+
.unreq tcr2
541549
SYM_FUNC_END(__cpu_setup)

0 commit comments

Comments
 (0)