Skip to content

Commit 8ab66cb

Browse files
Suzuki K Poulosectmarinas
authored andcommitted
arm64: cpufeature: ctr: Fix cpu capability check for late CPUs
The matches() routine for a capability must honor the "scope" passed to it and return the proper results. i.e, when passed with SCOPE_LOCAL_CPU, it should check the status of the capability on the current CPU. This is used by verify_local_cpu_capabilities() on a late secondary CPU to make sure that it's compliant with the established system features. However, ARM64_HAS_CACHE_{IDC/DIC} always checks the system wide registers and this could mean that a late secondary CPU could return "true" (since the CPU hasn't updated the system wide registers yet) and thus lead the system in an inconsistent state, where the system assumes it has IDC/DIC feature, while the new CPU doesn't. Fixes: commit 6ae4b6e ("arm64: Add support for new control bits CTR_EL0.DIC and CTR_EL0.IDC") Cc: Philip Elcan <pelcan@codeaurora.org> Cc: Shanker Donthineni <shankerd@codeaurora.org> 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 0c09d48 commit 8ab66cb

1 file changed

Lines changed: 18 additions & 4 deletions

File tree

‎arch/arm64/kernel/cpufeature.c‎

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -854,15 +854,29 @@ static bool has_no_fpsimd(const struct arm64_cpu_capabilities *entry, int __unus
854854
}
855855

856856
static bool has_cache_idc(const struct arm64_cpu_capabilities *entry,
857-
int __unused)
857+
int scope)
858858
{
859-
return read_sanitised_ftr_reg(SYS_CTR_EL0) & BIT(CTR_IDC_SHIFT);
859+
u64 ctr;
860+
861+
if (scope == SCOPE_SYSTEM)
862+
ctr = arm64_ftr_reg_ctrel0.sys_val;
863+
else
864+
ctr = read_cpuid_cachetype();
865+
866+
return ctr & BIT(CTR_IDC_SHIFT);
860867
}
861868

862869
static bool has_cache_dic(const struct arm64_cpu_capabilities *entry,
863-
int __unused)
870+
int scope)
864871
{
865-
return read_sanitised_ftr_reg(SYS_CTR_EL0) & BIT(CTR_DIC_SHIFT);
872+
u64 ctr;
873+
874+
if (scope == SCOPE_SYSTEM)
875+
ctr = arm64_ftr_reg_ctrel0.sys_val;
876+
else
877+
ctr = read_cpuid_cachetype();
878+
879+
return ctr & BIT(CTR_DIC_SHIFT);
866880
}
867881

868882
static bool __maybe_unused

0 commit comments

Comments
 (0)