diff mbox series

[03/19] arm64: Run ARCH_WORKAROUND_2 enabling code on all CPUs

Message ID 20200918164729.31994-4-will@kernel.org
State New
Headers show
Series [01/19] arm64: Make use of ARCH_WORKAROUND_1 even when KVM is not enabled | expand

Commit Message

Will Deacon Sept. 18, 2020, 4:47 p.m. UTC
From: Marc Zyngier <maz@kernel.org>

Commit 606f8e7b27bf ("arm64: capabilities: Use linear array for
detection and verification") changed the way we deal with per-CPU errata
by only calling the .matches() callback until one CPU is found to be
affected. At this point, .matches() stop being called, and .cpu_enable()
will be called on all CPUs.

This breaks the ARCH_WORKAROUND_2 handling, as only a single CPU will be
mitigated.

In order to address this, forcefully call the .matches() callback from a
.cpu_enable() callback, which brings us back to the original behaviour.

Fixes: 606f8e7b27bf ("arm64: capabilities: Use linear array for detection and verification")
Cc: <stable@vger.kernel.org>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Signed-off-by: Will Deacon <will@kernel.org>
---
 arch/arm64/kernel/cpu_errata.c | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Suzuki K Poulose Sept. 18, 2020, 5:13 p.m. UTC | #1
On 09/18/2020 05:47 PM, Will Deacon wrote:
> From: Marc Zyngier <maz@kernel.org>

> 

> Commit 606f8e7b27bf ("arm64: capabilities: Use linear array for

> detection and verification") changed the way we deal with per-CPU errata

> by only calling the .matches() callback until one CPU is found to be

> affected. At this point, .matches() stop being called, and .cpu_enable()

> will be called on all CPUs.

> 

> This breaks the ARCH_WORKAROUND_2 handling, as only a single CPU will be

> mitigated.

> 

> In order to address this, forcefully call the .matches() callback from a

> .cpu_enable() callback, which brings us back to the original behaviour.

> 

> Fixes: 606f8e7b27bf ("arm64: capabilities: Use linear array for detection and verification")

> Cc: <stable@vger.kernel.org>

> Signed-off-by: Marc Zyngier <maz@kernel.org>

> Signed-off-by: Will Deacon <will@kernel.org>


Reviewed-by: Suzuki K Poulose <suzuki.poulose@arm.com>
diff mbox series

Patch

diff --git a/arch/arm64/kernel/cpu_errata.c b/arch/arm64/kernel/cpu_errata.c
index 3fe64bf5a58d..abfef5f3b5fd 100644
--- a/arch/arm64/kernel/cpu_errata.c
+++ b/arch/arm64/kernel/cpu_errata.c
@@ -457,6 +457,12 @@  static bool has_ssbd_mitigation(const struct arm64_cpu_capabilities *entry,
 	return required;
 }
 
+static void cpu_enable_ssbd_mitigation(const struct arm64_cpu_capabilities *cap)
+{
+	if (ssbd_state != ARM64_SSBD_FORCE_DISABLE)
+		cap->matches(cap, SCOPE_LOCAL_CPU);
+}
+
 /* known invulnerable cores */
 static const struct midr_range arm64_ssb_cpus[] = {
 	MIDR_ALL_VERSIONS(MIDR_CORTEX_A35),
@@ -914,6 +920,7 @@  const struct arm64_cpu_capabilities arm64_errata[] = {
 		.capability = ARM64_SSBD,
 		.type = ARM64_CPUCAP_LOCAL_CPU_ERRATUM,
 		.matches = has_ssbd_mitigation,
+		.cpu_enable = cpu_enable_ssbd_mitigation,
 		.midr_range_list = arm64_ssb_cpus,
 	},
 #ifdef CONFIG_ARM64_ERRATUM_1418040