From: Catalin Marinas <catalin.marinas@arm.com>
To: Suzuki K Poulose <suzuki.poulose@arm.com>
Cc: Mark Rutland <mark.rutland@arm.com>,
Sai Prakash Ranjan <saiprakash.ranjan@codeaurora.org>,
Will Deacon <will@kernel.org>, Stephen Boyd <swboyd@chromium.org>,
Marc Zyngier <maz@kernel.org>,
kernel-team@android.com, linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] arm64: errata: Fix handling of 1418040 with late CPU onlining
Date: Fri, 6 Nov 2020 12:44:00 +0000 [thread overview]
Message-ID: <20201106124400.GF29329@gaia> (raw)
In-Reply-To: <f9752d64-d7fb-2521-8c68-a0f90768c4ef@arm.com>
On Fri, Nov 06, 2020 at 12:18:32PM +0000, Suzuki K Poulose wrote:
> On 11/6/20 11:49 AM, Will Deacon wrote:
> > 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.
>
> The capability state is not altered after the SMP boot for all types
> of caps. The weak caps are there to allow a late CPU to turn online
> without getting "banned". This may be something we could relax with
> a new flag in the scope.
Like this? Of course, it needs some testing.
diff --git a/arch/arm64/include/asm/cpufeature.h b/arch/arm64/include/asm/cpufeature.h
index 97244d4feca9..b896e72131d7 100644
--- a/arch/arm64/include/asm/cpufeature.h
+++ b/arch/arm64/include/asm/cpufeature.h
@@ -246,6 +246,8 @@ extern struct arm64_ftr_reg arm64_ftr_reg_ctrel0;
#define ARM64_CPUCAP_OPTIONAL_FOR_LATE_CPU ((u16)BIT(5))
/* Panic when a conflict is detected */
#define ARM64_CPUCAP_PANIC_ON_CONFLICT ((u16)BIT(6))
+/* Together with PERMITTED_FOR_LATE_CPU, set the corresponding cpu_hwcaps bit */
+#define ARM64_CPUCAP_SET_FOR_LATE_CPU ((u16)BIT(7))
/*
* CPU errata workarounds that need to be enabled at boot time if one or
@@ -481,6 +483,16 @@ static __always_inline bool cpus_have_const_cap(int num)
return cpus_have_cap(num);
}
+/*
+ * Test for a capability with a runtime check. This is an alias for
+ * cpus_have_cap() but with the name chosen to emphasize the applicability to
+ * late capability setting.
+ */
+static __always_inline bool cpus_have_late_cap(int num)
+{
+ return cpus_have_cap(num);
+}
+
static inline void cpus_set_cap(unsigned int num)
{
if (num >= ARM64_NCAPS) {
diff --git a/arch/arm64/kernel/cpu_errata.c b/arch/arm64/kernel/cpu_errata.c
index 61314fd70f13..6b7de7292e8c 100644
--- a/arch/arm64/kernel/cpu_errata.c
+++ b/arch/arm64/kernel/cpu_errata.c
@@ -481,7 +481,8 @@ const struct arm64_cpu_capabilities arm64_errata[] = {
* also need the non-affected CPUs to be able to come
* in at any point in time. Wonderful.
*/
- .type = ARM64_CPUCAP_WEAK_LOCAL_CPU_FEATURE,
+ .type = ARM64_CPUCAP_WEAK_LOCAL_CPU_FEATURE |
+ ARM64_CPUCAP_SET_FOR_LATE_CPU,
},
#endif
#ifdef CONFIG_ARM64_WORKAROUND_SPECULATIVE_AT
diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c
index dcc165b3fc04..51e63be41ea5 100644
--- a/arch/arm64/kernel/cpufeature.c
+++ b/arch/arm64/kernel/cpufeature.c
@@ -1720,6 +1720,12 @@ cpucap_late_cpu_permitted(const struct arm64_cpu_capabilities *cap)
return !!(cap->type & ARM64_CPUCAP_PERMITTED_FOR_LATE_CPU);
}
+static bool
+cpucap_set_for_late_cpu(const struct arm64_cpu_capabilities *cap)
+{
+ return !!(cap->type & ARM64_CPUCAP_SET_FOR_LATE_CPU);
+}
+
static bool
cpucap_panic_on_conflict(const struct arm64_cpu_capabilities *cap)
{
@@ -2489,6 +2495,11 @@ static void verify_local_cpu_caps(u16 scope_mask)
*/
if (cpu_has_cap && !cpucap_late_cpu_permitted(caps))
break;
+ /*
+ * Set the capability bit if it allows late setting.
+ */
+ if (cpucap_set_for_late_cpu(caps))
+ cpus_set_cap(caps->capability);
}
}
diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c
index 4784011cecac..152639962845 100644
--- a/arch/arm64/kernel/process.c
+++ b/arch/arm64/kernel/process.c
@@ -523,7 +523,7 @@ static void erratum_1418040_thread_switch(struct task_struct *prev,
u64 val;
if (!(IS_ENABLED(CONFIG_ARM64_ERRATUM_1418040) &&
- cpus_have_const_cap(ARM64_WORKAROUND_1418040)))
+ cpus_have_late_cap(ARM64_WORKAROUND_1418040)))
return;
prev32 = is_compat_thread(task_thread_info(prev));
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2020-11-06 12:44 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-06 11:49 [PATCH] arm64: errata: Fix handling of 1418040 with late CPU onlining Will Deacon
2020-11-06 12:15 ` Marc Zyngier
2020-11-06 12:18 ` Suzuki K Poulose
2020-11-06 12:28 ` Will Deacon
2020-11-06 12:44 ` Catalin Marinas [this message]
2020-11-10 10:39 ` Suzuki K Poulose
2020-11-10 12:05 ` Catalin Marinas
2020-11-10 12:14 ` Suzuki K Poulose
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201106124400.GF29329@gaia \
--to=catalin.marinas@arm.com \
--cc=kernel-team@android.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=mark.rutland@arm.com \
--cc=maz@kernel.org \
--cc=saiprakash.ranjan@codeaurora.org \
--cc=suzuki.poulose@arm.com \
--cc=swboyd@chromium.org \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).