Skip to content

Commit 4afe8e7

Browse files
Suzuki K Poulosectmarinas
authored andcommitted
arm64: cpufeature: Trap CTR_EL0 access only where it is necessary
When there is a mismatch in the CTR_EL0 field, we trap access to CTR from EL0 on all CPUs to expose the safe value. However, we could skip trapping on a CPU which matches the safe value. Cc: Mark Rutland <mark.rutland@arm.com> Cc: Will Deacon <will.deacon@arm.com> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
1 parent 1602df0 commit 4afe8e7

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

‎arch/arm64/kernel/cpu_errata.c‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,12 @@ has_mismatched_cache_type(const struct arm64_cpu_capabilities *entry,
9999
static void
100100
cpu_enable_trap_ctr_access(const struct arm64_cpu_capabilities *__unused)
101101
{
102-
sysreg_clear_set(sctlr_el1, SCTLR_EL1_UCT, 0);
102+
u64 mask = arm64_ftr_reg_ctrel0.strict_mask;
103+
104+
/* Trap CTR_EL0 access on this CPU, only if it has a mismatch */
105+
if ((read_cpuid_cachetype() & mask) !=
106+
(arm64_ftr_reg_ctrel0.sys_val & mask))
107+
sysreg_clear_set(sctlr_el1, SCTLR_EL1_UCT, 0);
103108
}
104109

105110
atomic_t arm64_el2_vector_last_slot = ATOMIC_INIT(-1);

0 commit comments

Comments
 (0)