Skip to content

Commit 67badb2

Browse files
Suzuki K Poulosegregkh
authored andcommitted
arm64: Handle mismatched cache type
commit 314d53d upstream. Track mismatches in the cache type register (CTR_EL0), other than the D/I min line sizes and trap user accesses if there are any. Fixes: be68a8a ("arm64: cpufeature: Fix CTR_EL0 field definitions") Cc: <stable@vger.kernel.org> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Will Deacon <will.deacon@arm.com> Cc: Catalin Marinas <catalin.marinas@arm.com> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com> Signed-off-by: Will Deacon <will.deacon@arm.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent a683009 commit 67badb2

2 files changed

Lines changed: 16 additions & 4 deletions

File tree

arch/arm64/include/asm/cpucaps.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@
3737
#define ARM64_UNMAP_KERNEL_AT_EL0 16
3838
#define ARM64_HARDEN_BRANCH_PREDICTOR 17
3939
#define ARM64_SSBD 18
40+
#define ARM64_MISMATCHED_CACHE_TYPE 19
4041

41-
#define ARM64_NCAPS 19
42+
#define ARM64_NCAPS 20
4243

4344
#endif /* __ASM_CPUCAPS_H */

arch/arm64/kernel/cpu_errata.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,15 @@ is_affected_midr_range(const struct arm64_cpu_capabilities *entry, int scope)
3232
}
3333

3434
static bool
35-
has_mismatched_cache_line_size(const struct arm64_cpu_capabilities *entry,
36-
int scope)
35+
has_mismatched_cache_type(const struct arm64_cpu_capabilities *entry,
36+
int scope)
3737
{
3838
u64 mask = CTR_CACHE_MINLINE_MASK;
3939

40+
/* Skip matching the min line sizes for cache type check */
41+
if (entry->capability == ARM64_MISMATCHED_CACHE_TYPE)
42+
mask ^= arm64_ftr_reg_ctrel0.strict_mask;
43+
4044
WARN_ON(scope != SCOPE_LOCAL_CPU || preemptible());
4145
return (read_cpuid_cachetype() & mask) !=
4246
(arm64_ftr_reg_ctrel0.sys_val & mask);
@@ -449,7 +453,14 @@ const struct arm64_cpu_capabilities arm64_errata[] = {
449453
{
450454
.desc = "Mismatched cache line size",
451455
.capability = ARM64_MISMATCHED_CACHE_LINE_SIZE,
452-
.matches = has_mismatched_cache_line_size,
456+
.matches = has_mismatched_cache_type,
457+
.def_scope = SCOPE_LOCAL_CPU,
458+
.enable = cpu_enable_trap_ctr_access,
459+
},
460+
{
461+
.desc = "Mismatched cache type",
462+
.capability = ARM64_MISMATCHED_CACHE_TYPE,
463+
.matches = has_mismatched_cache_type,
453464
.def_scope = SCOPE_LOCAL_CPU,
454465
.enable = cpu_enable_trap_ctr_access,
455466
},

0 commit comments

Comments
 (0)