arm64: mte: configure initial state for system registers

The fields in SCTLR_EL1 and HCR_EL2 for enabling MTE are set, and if the
ID_AA64PFR1_EL1 register shows MTE is present, the GCR_EL1 register is
also configured, and the two TFSR registers which hold pending tag check
faults are cleared.

Reviewed by:	andrew
Sponsored by:	Arm Ltd
Signed-off-by:	Harry Moulton <harry.moulton@arm.com>
Differential Revision:	https://reviews.freebsd.org/D55946
This commit is contained in:
Harry Moulton
2026-04-13 12:54:38 +01:00
committed by Andrew Turner
parent aa555b6004
commit 58de791536
+16 -1
View File
@@ -398,7 +398,7 @@ LENTRY(enter_kernel_el)
*/
/* Configure the Hypervisor */
ldr x2, =(HCR_RW | HCR_APK | HCR_API)
ldr x2, =(HCR_RW | HCR_APK | HCR_API | HCR_ATA)
msr hcr_el2, x2
/* Stash value of HCR_EL2 for later */
@@ -1063,6 +1063,21 @@ LENTRY(start_mmu)
isb
ldr x2, mair
/*
* If MTE is supported, configure GCR_EL1 and clear the TFSR registers of
* any pending tag check faults
*/
CHECK_CPU_FEAT(x3, ID_AA64PFR1, MTE, MTE, 1f)
/* Set GCR_EL1, non-zero tags excluded by default */
mov x3, #(GCR_Exclude_MASK | GCR_RRND)
msr GCR_EL1_REG, x3
/* Clear any pending tag check faults */
msr TFSR_EL1_REG, xzr
msr TFSRE0_EL1_REG, xzr
1:
msr mair_el1, x2
/*