Skip to content

Commit 3689c75

Browse files
wildea01ctmarinas
authored andcommitted
arm64: cpuinfo: remove I-cache VIPT aliasing detection
The CCSIDR_EL1.{NumSets,Associativity,LineSize} fields are only for use in conjunction with set/way cache maintenance and are not guaranteed to represent the actual microarchitectural features of a design. The architecture explicitly states: | You cannot make any inference about the actual sizes of caches based | on these parameters. We currently use these fields to determine whether or the I-cache is aliasing, which is bogus and known to break on some platforms. Instead, assume the I-cache is always aliasing if it advertises a VIPT policy. Acked-by: Mark Rutland <mark.rutland@arm.com> Signed-off-by: Will Deacon <will.deacon@arm.com> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
1 parent 97da385 commit 3689c75

2 files changed

Lines changed: 10 additions & 26 deletions

File tree

‎arch/arm64/include/asm/cachetype.h‎

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -63,19 +63,6 @@ extern unsigned long __icache_flags;
6363
#define CACHE_NUMSETS(x) (CCSIDR_EL1_NUMSETS(x) + 1)
6464
#define CACHE_ASSOCIATIVITY(x) (CCSIDR_EL1_ASSOCIATIVITY(x) + 1)
6565

66-
extern u64 __attribute_const__ cache_get_ccsidr(u64 csselr);
67-
68-
/* Helpers for Level 1 Instruction cache csselr = 1L */
69-
static inline int icache_get_linesize(void)
70-
{
71-
return CACHE_LINESIZE(cache_get_ccsidr(1L));
72-
}
73-
74-
static inline int icache_get_numsets(void)
75-
{
76-
return CACHE_NUMSETS(cache_get_ccsidr(1L));
77-
}
78-
7966
/*
8067
* Whilst the D-side always behaves as PIPT on AArch64, aliasing is
8168
* permitted in the I-cache.

‎arch/arm64/kernel/cpuinfo.c‎

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -289,20 +289,17 @@ static void cpuinfo_detect_icache_policy(struct cpuinfo_arm64 *info)
289289
unsigned int cpu = smp_processor_id();
290290
u32 l1ip = CTR_L1IP(info->reg_ctr);
291291

292-
if (l1ip != ICACHE_POLICY_PIPT) {
293-
/*
294-
* VIPT caches are non-aliasing if the VA always equals the PA
295-
* in all bit positions that are covered by the index. This is
296-
* the case if the size of a way (# of sets * line size) does
297-
* not exceed PAGE_SIZE.
298-
*/
299-
u32 waysize = icache_get_numsets() * icache_get_linesize();
300-
301-
if (l1ip != ICACHE_POLICY_VIPT || waysize > PAGE_SIZE)
302-
set_bit(ICACHEF_ALIASING, &__icache_flags);
303-
}
304-
if (l1ip == ICACHE_POLICY_AIVIVT)
292+
switch (l1ip) {
293+
case ICACHE_POLICY_PIPT:
294+
break;
295+
default:
296+
case ICACHE_POLICY_AIVIVT:
305297
set_bit(ICACHEF_AIVIVT, &__icache_flags);
298+
/* Fallthrough */
299+
case ICACHE_POLICY_VIPT:
300+
/* Assume aliasing */
301+
set_bit(ICACHEF_ALIASING, &__icache_flags);
302+
}
306303

307304
pr_info("Detected %s I-cache on CPU%d\n", icache_policy_str[l1ip], cpu);
308305
}

0 commit comments

Comments
 (0)