Skip to content

Commit ec76876

Browse files
mrutland-armctmarinas
authored andcommitted
arm64: errata: Unify speculative SSBS errata logic
Cortex-X4 erratum 3194386 and Neoverse-V3 erratum 3312417 are identical, with duplicate Kconfig text and some unsightly ifdeffery. While we try to share code behind CONFIG_ARM64_WORKAROUND_SPECULATIVE_SSBS, having separate options results in a fair amount of boilerplate code, and this will only get worse as we expand the set of affected CPUs. To reduce this boilerplate, unify the two behind a common Kconfig option. This removes the duplicate text and Kconfig logic, and removes the need for the intermediate ARM64_WORKAROUND_SPECULATIVE_SSBS option. The set of affected CPUs is described as a list so that this can easily be extended. I've used ARM64_ERRATUM_3194386 (matching the Neoverse-V3 erratum ID) as the common option, matching the way we use ARM64_ERRATUM_1319367 to cover Cortex-A57 erratum 1319537 and Cortex-A72 erratum 1319367. Signed-off-by: Mark Rutland <[email protected]> Cc: James Morse <[email protected]> Cc: Will Deacon <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Catalin Marinas <[email protected]>
1 parent fd2ff5f commit ec76876

File tree

5 files changed

+9
-34
lines changed

5 files changed

+9
-34
lines changed

Documentation/arch/arm64/silicon-errata.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ stable kernels.
158158
+----------------+-----------------+-----------------+-----------------------------+
159159
| ARM | Neoverse-V1 | #1619801 | N/A |
160160
+----------------+-----------------+-----------------+-----------------------------+
161-
| ARM | Neoverse-V3 | #3312417 | ARM64_ERRATUM_3312417 |
161+
| ARM | Neoverse-V3 | #3312417 | ARM64_ERRATUM_3194386 |
162162
+----------------+-----------------+-----------------+-----------------------------+
163163
| ARM | MMU-500 | #841119,826419 | N/A |
164164
+----------------+-----------------+-----------------+-----------------------------+

arch/arm64/Kconfig

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1067,34 +1067,14 @@ config ARM64_ERRATUM_3117295
10671067

10681068
If unsure, say Y.
10691069

1070-
config ARM64_WORKAROUND_SPECULATIVE_SSBS
1071-
bool
1072-
10731070
config ARM64_ERRATUM_3194386
1074-
bool "Cortex-X4: 3194386: workaround for MSR SSBS not self-synchronizing"
1075-
select ARM64_WORKAROUND_SPECULATIVE_SSBS
1071+
bool "Cortex-X4/Neoverse-V3: workaround for MSR SSBS not self-synchronizing"
10761072
default y
10771073
help
1078-
This option adds the workaround for ARM Cortex-X4 erratum 3194386.
1074+
This option adds the workaround for the following errata:
10791075

1080-
On affected cores "MSR SSBS, #0" instructions may not affect
1081-
subsequent speculative instructions, which may permit unexepected
1082-
speculative store bypassing.
1083-
1084-
Work around this problem by placing a speculation barrier after
1085-
kernel changes to SSBS. The presence of the SSBS special-purpose
1086-
register is hidden from hwcaps and EL0 reads of ID_AA64PFR1_EL1, such
1087-
that userspace will use the PR_SPEC_STORE_BYPASS prctl to change
1088-
SSBS.
1089-
1090-
If unsure, say Y.
1091-
1092-
config ARM64_ERRATUM_3312417
1093-
bool "Neoverse-V3: 3312417: workaround for MSR SSBS not self-synchronizing"
1094-
select ARM64_WORKAROUND_SPECULATIVE_SSBS
1095-
default y
1096-
help
1097-
This option adds the workaround for ARM Neoverse-V3 erratum 3312417.
1076+
* ARM Cortex-X4 erratum 3194386
1077+
* ARM Neoverse-V3 erratum 3312417
10981078

10991079
On affected cores "MSR SSBS, #0" instructions may not affect
11001080
subsequent speculative instructions, which may permit unexepected
@@ -1108,7 +1088,6 @@ config ARM64_ERRATUM_3312417
11081088

11091089
If unsure, say Y.
11101090

1111-
11121091
config CAVIUM_ERRATUM_22375
11131092
bool "Cavium erratum 22375, 24313"
11141093
default y

arch/arm64/include/asm/cpucaps.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ cpucap_is_possible(const unsigned int cap)
5959
case ARM64_WORKAROUND_REPEAT_TLBI:
6060
return IS_ENABLED(CONFIG_ARM64_WORKAROUND_REPEAT_TLBI);
6161
case ARM64_WORKAROUND_SPECULATIVE_SSBS:
62-
return IS_ENABLED(CONFIG_ARM64_WORKAROUND_SPECULATIVE_SSBS);
62+
return IS_ENABLED(CONFIG_ARM64_ERRATUM_3194386);
6363
}
6464

6565
return true;

arch/arm64/kernel/cpu_errata.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -432,14 +432,10 @@ static const struct midr_range erratum_spec_unpriv_load_list[] = {
432432
};
433433
#endif
434434

435-
#ifdef CONFIG_ARM64_WORKAROUND_SPECULATIVE_SSBS
436-
static const struct midr_range erratum_spec_ssbs_list[] = {
437435
#ifdef CONFIG_ARM64_ERRATUM_3194386
436+
static const struct midr_range erratum_spec_ssbs_list[] = {
438437
MIDR_ALL_VERSIONS(MIDR_CORTEX_X4),
439-
#endif
440-
#ifdef CONFIG_ARM64_ERRATUM_3312417
441438
MIDR_ALL_VERSIONS(MIDR_NEOVERSE_V3),
442-
#endif
443439
{}
444440
};
445441
#endif
@@ -741,7 +737,7 @@ const struct arm64_cpu_capabilities arm64_errata[] = {
741737
MIDR_FIXED(MIDR_CPU_VAR_REV(1,1), BIT(25)),
742738
},
743739
#endif
744-
#ifdef CONFIG_ARM64_WORKAROUND_SPECULATIVE_SSBS
740+
#ifdef CONFIG_ARM64_ERRATUM_3194386
745741
{
746742
.desc = "ARM errata 3194386, 3312417",
747743
.capability = ARM64_WORKAROUND_SPECULATIVE_SSBS,

arch/arm64/kernel/proton-pack.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ static enum mitigation_state spectre_v4_enable_hw_mitigation(void)
567567
* Mitigate this with an unconditional speculation barrier, as CPUs
568568
* could mis-speculate branches and bypass a conditional barrier.
569569
*/
570-
if (IS_ENABLED(CONFIG_ARM64_WORKAROUND_SPECULATIVE_SSBS))
570+
if (IS_ENABLED(CONFIG_ARM64_ERRATUM_3194386))
571571
spec_bar();
572572

573573
return SPECTRE_MITIGATED;

0 commit comments

Comments
 (0)