Skip to content

Commit f969f03

Browse files
committed
arm64: errata: Fix handling of 1418040 with late CPU onlining
In a surprising turn of events, it transpires that CPU capabilities configured as ARM64_CPUCAP_WEAK_LOCAL_CPU_FEATURE are never set as the result of late-onlining. Therefore our handling of erratum 1418040 does not get activated if it is not required by any of the boot CPUs, even though we allow late-onlining of an affected CPU. In order to get things working again, replace the cpus_have_const_cap() invocation with an explicit check for the current CPU using this_cpu_has_cap(). Cc: Sai Prakash Ranjan <saiprakash.ranjan@codeaurora.org> Cc: Stephen Boyd <swboyd@chromium.org> Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: Mark Rutland <mark.rutland@arm.com> Reviewed-by: Suzuki K Poulose <suzuki.poulose@arm.com> Acked-by: Marc Zyngier <maz@kernel.org> Link: https://lore.kernel.org/r/20201106114952.10032-1-will@kernel.org Signed-off-by: Will Deacon <will@kernel.org>
1 parent 108aa50 commit f969f03

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

arch/arm64/include/asm/cpufeature.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,8 @@ extern struct arm64_ftr_reg arm64_ftr_reg_ctrel0;
268268
/*
269269
* CPU feature detected at boot time based on feature of one or more CPUs.
270270
* All possible conflicts for a late CPU are ignored.
271+
* NOTE: this means that a late CPU with the feature will *not* cause the
272+
* capability to be advertised by cpus_have_*cap()!
271273
*/
272274
#define ARM64_CPUCAP_WEAK_LOCAL_CPU_FEATURE \
273275
(ARM64_CPUCAP_SCOPE_LOCAL_CPU | \

arch/arm64/kernel/process.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -522,14 +522,13 @@ static void erratum_1418040_thread_switch(struct task_struct *prev,
522522
bool prev32, next32;
523523
u64 val;
524524

525-
if (!(IS_ENABLED(CONFIG_ARM64_ERRATUM_1418040) &&
526-
cpus_have_const_cap(ARM64_WORKAROUND_1418040)))
525+
if (!IS_ENABLED(CONFIG_ARM64_ERRATUM_1418040))
527526
return;
528527

529528
prev32 = is_compat_thread(task_thread_info(prev));
530529
next32 = is_compat_thread(task_thread_info(next));
531530

532-
if (prev32 == next32)
531+
if (prev32 == next32 || !this_cpu_has_cap(ARM64_WORKAROUND_1418040))
533532
return;
534533

535534
val = read_sysreg(cntkctl_el1);

0 commit comments

Comments
 (0)