devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: James Morse <james.morse@arm.com>
To: linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org
Cc: Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Lorenzo Pieralisi <lpieralisi@kernel.org>,
	Sudeep Holla <sudeep.holla@arm.com>,
	Marc Zyngier <maz@kernel.org>,
	Oliver Upton <oliver.upton@linux.dev>,
	James Morse <james.morse@arm.com>,
	Rob Herring <robh+dt@kernel.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>
Subject: [PATCH 6/6] arm64: errata: Add a commandline option to enable/disable #2701951
Date: Thu, 30 Mar 2023 17:51:28 +0100	[thread overview]
Message-ID: <20230330165128.3237939-7-james.morse@arm.com> (raw)
In-Reply-To: <20230330165128.3237939-1-james.morse@arm.com>

Erratum #2701951 affects the FWB feature in a number of CPUs, but is
only going to be visible on parts that don't use an arm interconnect.
This is not something the operating system can discover, it has to
be described by platform firmware.

The firmware discovery API is not deployed on existing systems.

Add a commandline option to allow the workaround to override the
value from firmware, or provide a value if the firmware is not
implemented.

The property is named arm64.arm-interconnect, as this is the
description in the 'configurations affected' section of the erratum.

Signed-off-by: James Morse <james.morse@arm.com>
---
 .../admin-guide/kernel-parameters.txt         |  4 +++
 arch/arm64/kernel/cpu_errata.c                | 36 +++++++++++++++++++
 2 files changed, 40 insertions(+)

diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index 6221a1d057dd..5898fde6a9e4 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -391,6 +391,10 @@
 	arcrimi=	[HW,NET] ARCnet - "RIM I" (entirely mem-mapped) cards
 			Format: <io>,<irq>,<nodeID>
 
+	arm64.arm-interconnect [ARM64]
+			Indicates the FWB erratum can be disabled because this
+			SoC uses an arm interconnect.
+
 	arm64.nobti	[ARM64] Unconditionally disable Branch Target
 			Identification support
 
diff --git a/arch/arm64/kernel/cpu_errata.c b/arch/arm64/kernel/cpu_errata.c
index 55da9e588b9e..c5570904e8b4 100644
--- a/arch/arm64/kernel/cpu_errata.c
+++ b/arch/arm64/kernel/cpu_errata.c
@@ -138,6 +138,32 @@ cpu_clear_bf16_from_user_emulation(const struct arm64_cpu_capabilities *__unused
 	raw_spin_unlock(&reg_user_mask_modification);
 }
 
+static enum  {
+	FWB_WA_FORCED_ON = 1,
+	FWB_WA_UNKNOWN = 0,
+	FWB_WA_FORCED_OFF = -1,
+} __fwb_workaround_forced;
+#ifdef CONFIG_ARM64_ERRATUM_2701951
+static int __init parse_fwb_workaround_cmdline_override(char *str)
+{
+	bool arm_interconnect;
+	int ret = kstrtobool(str, &arm_interconnect);
+
+	if (ret)
+		return ret;
+
+	/*
+	 * Erratum #2701951's "Configurations Affected" says the erratum can
+	 * only be seen on SoC's "that do not use Arm interconnect IP."
+	 */
+	if (arm_interconnect)
+		__fwb_workaround_forced = FWB_WA_FORCED_OFF;
+	else
+		__fwb_workaround_forced = FWB_WA_FORCED_ON;
+	return 0;
+}
+early_param("arm64.arm-interconnect", parse_fwb_workaround_cmdline_override);
+#endif /* CONFIG_ARM64_ERRATUM_2701951 */
 bool has_stage2_fwb_errata(const struct arm64_cpu_capabilities *ignored,
 			   int scope)
 {
@@ -205,9 +231,19 @@ bool has_stage2_fwb_errata(const struct arm64_cpu_capabilities *ignored,
 		}
 
 		if (fwb_broken) {
+			if (__fwb_workaround_forced == FWB_WA_FORCED_OFF) {
+				pr_info_once("Workaround for erratum #2701951 disabled by command-line option\n");
+				return false;
+			}
 			pr_info_once("Stage-2 Force Write-Back disabled due to erratum #2701951\n");
 			return true;
 		}
+
+		/* Allow the commandline to override whatever firmware said */
+		if (has_feature && __fwb_workaround_forced == FWB_WA_FORCED_ON) {
+			pr_info_once("Workaround for erratum #2701951 enabled by command-line option\n");
+			return true;
+		}
 	}
 
 	return false;
-- 
2.39.2


  parent reply	other threads:[~2023-03-30 16:53 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-30 16:51 [PATCH 0/6] arm64: errata: Disable FWB on parts with non-ARM interconnects James Morse
2023-03-30 16:51 ` [PATCH 1/6] dt-bindings: firmware: Add arm,errata-management James Morse
2023-03-30 20:50   ` Rob Herring
2023-03-31  8:29   ` Krzysztof Kozlowski
2023-03-31 16:58     ` James Morse
2023-04-03  9:15       ` Krzysztof Kozlowski
2023-04-03 12:05         ` Marc Zyngier
2023-03-31 13:46   ` Rob Herring
2023-03-31 16:58     ` James Morse
2023-04-03 15:45       ` Rob Herring
2023-04-04 15:19         ` James Morse
2023-03-30 16:51 ` [PATCH 2/6] firmware: smccc: Add support for erratum discovery API James Morse
2023-03-30 20:34   ` kernel test robot
2023-03-30 16:51 ` [PATCH 3/6] arm64: cputype: Add new part numbers for Cortex-X3, and Neoverse-V2 James Morse
2023-03-30 16:51 ` [PATCH 4/6] arm64: errata: Disable FWB on parts with non-ARM interconnects James Morse
2023-03-30 16:51 ` [PATCH 5/6] firmware: smccc: Allow errata management to be overridden by device tree James Morse
2023-03-30 20:44   ` kernel test robot
2023-03-31 17:05     ` James Morse
2023-03-30 16:51 ` James Morse [this message]
2023-03-31 12:57 ` [PATCH 0/6] arm64: errata: Disable FWB on parts with non-ARM interconnects Rob Herring
2023-03-31 13:03   ` Rob Herring
2023-05-11 17:15 ` Catalin Marinas
2023-05-11 18:42   ` Marc Zyngier
2023-05-11 21:13     ` Catalin Marinas
2023-05-16 16:29       ` James Morse
2023-05-23 12:24         ` Robin Murphy
2023-05-23 10:48 ` Will Deacon

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=20230330165128.3237939-7-james.morse@arm.com \
    --to=james.morse@arm.com \
    --cc=catalin.marinas@arm.com \
    --cc=devicetree@vger.kernel.org \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=lpieralisi@kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=maz@kernel.org \
    --cc=oliver.upton@linux.dev \
    --cc=robh+dt@kernel.org \
    --cc=sudeep.holla@arm.com \
    --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).