Skip to content

Commit f0cc697

Browse files
committed
Merge branch 'for-next/errata' into for-next/core
* for-next/errata: arm64: errata: Add workaround for Arm errata 3194386 and 3312417 arm64: cputype: Add Neoverse-V3 definitions arm64: cputype: Add Cortex-X4 definitions arm64: barrier: Restore spec_bar() macro
2 parents 54e1a2a + 7187bb7 commit f0cc697

File tree

9 files changed

+96
-0
lines changed

9 files changed

+96
-0
lines changed

Documentation/arch/arm64/silicon-errata.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,8 @@ stable kernels.
140140
+----------------+-----------------+-----------------+-----------------------------+
141141
| ARM | Cortex-X2 | #2224489 | ARM64_ERRATUM_2224489 |
142142
+----------------+-----------------+-----------------+-----------------------------+
143+
| ARM | Cortex-X4 | #3194386 | ARM64_ERRATUM_3194386 |
144+
+----------------+-----------------+-----------------+-----------------------------+
143145
| ARM | Neoverse-N1 | #1188873,1418040| ARM64_ERRATUM_1418040 |
144146
+----------------+-----------------+-----------------+-----------------------------+
145147
| ARM | Neoverse-N1 | #1349291 | N/A |
@@ -156,6 +158,8 @@ stable kernels.
156158
+----------------+-----------------+-----------------+-----------------------------+
157159
| ARM | Neoverse-V1 | #1619801 | N/A |
158160
+----------------+-----------------+-----------------+-----------------------------+
161+
| ARM | Neoverse-V3 | #3312417 | ARM64_ERRATUM_3312417 |
162+
+----------------+-----------------+-----------------+-----------------------------+
159163
| ARM | MMU-500 | #841119,826419 | N/A |
160164
+----------------+-----------------+-----------------+-----------------------------+
161165
| ARM | MMU-600 | #1076982,1209401| N/A |

arch/arm64/Kconfig

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,6 +1066,48 @@ config ARM64_ERRATUM_3117295
10661066

10671067
If unsure, say Y.
10681068

1069+
config ARM64_WORKAROUND_SPECULATIVE_SSBS
1070+
bool
1071+
1072+
config ARM64_ERRATUM_3194386
1073+
bool "Cortex-X4: 3194386: workaround for MSR SSBS not self-synchronizing"
1074+
select ARM64_WORKAROUND_SPECULATIVE_SSBS
1075+
default y
1076+
help
1077+
This option adds the workaround for ARM Cortex-X4 erratum 3194386.
1078+
1079+
On affected cores "MSR SSBS, #0" instructions may not affect
1080+
subsequent speculative instructions, which may permit unexepected
1081+
speculative store bypassing.
1082+
1083+
Work around this problem by placing a speculation barrier after
1084+
kernel changes to SSBS. The presence of the SSBS special-purpose
1085+
register is hidden from hwcaps and EL0 reads of ID_AA64PFR1_EL1, such
1086+
that userspace will use the PR_SPEC_STORE_BYPASS prctl to change
1087+
SSBS.
1088+
1089+
If unsure, say Y.
1090+
1091+
config ARM64_ERRATUM_3312417
1092+
bool "Neoverse-V3: 3312417: workaround for MSR SSBS not self-synchronizing"
1093+
select ARM64_WORKAROUND_SPECULATIVE_SSBS
1094+
default y
1095+
help
1096+
This option adds the workaround for ARM Neoverse-V3 erratum 3312417.
1097+
1098+
On affected cores "MSR SSBS, #0" instructions may not affect
1099+
subsequent speculative instructions, which may permit unexepected
1100+
speculative store bypassing.
1101+
1102+
Work around this problem by placing a speculation barrier after
1103+
kernel changes to SSBS. The presence of the SSBS special-purpose
1104+
register is hidden from hwcaps and EL0 reads of ID_AA64PFR1_EL1, such
1105+
that userspace will use the PR_SPEC_STORE_BYPASS prctl to change
1106+
SSBS.
1107+
1108+
If unsure, say Y.
1109+
1110+
10691111
config CAVIUM_ERRATUM_22375
10701112
bool "Cavium erratum 22375, 24313"
10711113
default y

arch/arm64/include/asm/barrier.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@
4040
*/
4141
#define dgh() asm volatile("hint #6" : : : "memory")
4242

43+
#define spec_bar() asm volatile(ALTERNATIVE("dsb nsh\nisb\n", \
44+
SB_BARRIER_INSN"nop\n", \
45+
ARM64_HAS_SB))
46+
4347
#ifdef CONFIG_ARM64_PSEUDO_NMI
4448
#define pmr_sync() \
4549
do { \

arch/arm64/include/asm/cpucaps.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ cpucap_is_possible(const unsigned int cap)
5858
return IS_ENABLED(CONFIG_NVIDIA_CARMEL_CNP_ERRATUM);
5959
case ARM64_WORKAROUND_REPEAT_TLBI:
6060
return IS_ENABLED(CONFIG_ARM64_WORKAROUND_REPEAT_TLBI);
61+
case ARM64_WORKAROUND_SPECULATIVE_SSBS:
62+
return IS_ENABLED(CONFIG_ARM64_WORKAROUND_SPECULATIVE_SSBS);
6163
}
6264

6365
return true;

arch/arm64/include/asm/cputype.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@
8787
#define ARM_CPU_PART_NEOVERSE_N2 0xD49
8888
#define ARM_CPU_PART_CORTEX_A78C 0xD4B
8989
#define ARM_CPU_PART_NEOVERSE_V2 0xD4F
90+
#define ARM_CPU_PART_CORTEX_X4 0xD82
91+
#define ARM_CPU_PART_NEOVERSE_V3 0xD84
9092

9193
#define APM_CPU_PART_XGENE 0x000
9294
#define APM_CPU_VAR_POTENZA 0x00
@@ -161,6 +163,8 @@
161163
#define MIDR_NEOVERSE_N2 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_NEOVERSE_N2)
162164
#define MIDR_CORTEX_A78C MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A78C)
163165
#define MIDR_NEOVERSE_V2 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_NEOVERSE_V2)
166+
#define MIDR_CORTEX_X4 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_X4)
167+
#define MIDR_NEOVERSE_V3 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_NEOVERSE_V3)
164168
#define MIDR_THUNDERX MIDR_CPU_MODEL(ARM_CPU_IMP_CAVIUM, CAVIUM_CPU_PART_THUNDERX)
165169
#define MIDR_THUNDERX_81XX MIDR_CPU_MODEL(ARM_CPU_IMP_CAVIUM, CAVIUM_CPU_PART_THUNDERX_81XX)
166170
#define MIDR_THUNDERX_83XX MIDR_CPU_MODEL(ARM_CPU_IMP_CAVIUM, CAVIUM_CPU_PART_THUNDERX_83XX)

arch/arm64/kernel/cpu_errata.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,18 @@ 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[] = {
437+
#ifdef CONFIG_ARM64_ERRATUM_3194386
438+
MIDR_ALL_VERSIONS(MIDR_CORTEX_X4),
439+
#endif
440+
#ifdef CONFIG_ARM64_ERRATUM_3312417
441+
MIDR_ALL_VERSIONS(MIDR_NEOVERSE_V3),
442+
#endif
443+
{}
444+
};
445+
#endif
446+
435447
const struct arm64_cpu_capabilities arm64_errata[] = {
436448
#ifdef CONFIG_ARM64_WORKAROUND_CLEAN_CACHE
437449
{
@@ -729,6 +741,13 @@ const struct arm64_cpu_capabilities arm64_errata[] = {
729741
MIDR_FIXED(MIDR_CPU_VAR_REV(1,1), BIT(25)),
730742
},
731743
#endif
744+
#ifdef CONFIG_ARM64_WORKAROUND_SPECULATIVE_SSBS
745+
{
746+
.desc = "ARM errata 3194386, 3312417",
747+
.capability = ARM64_WORKAROUND_SPECULATIVE_SSBS,
748+
ERRATA_MIDR_RANGE_LIST(erratum_spec_ssbs_list),
749+
},
750+
#endif
732751
#ifdef CONFIG_ARM64_WORKAROUND_SPECULATIVE_UNPRIV_LOAD
733752
{
734753
.desc = "ARM errata 2966298, 3117295",

arch/arm64/kernel/cpufeature.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2307,6 +2307,14 @@ static void user_feature_fixup(void)
23072307
if (regp)
23082308
regp->user_mask &= ~ID_AA64ISAR1_EL1_BF16_MASK;
23092309
}
2310+
2311+
if (cpus_have_cap(ARM64_WORKAROUND_SPECULATIVE_SSBS)) {
2312+
struct arm64_ftr_reg *regp;
2313+
2314+
regp = get_arm64_ftr_reg(SYS_ID_AA64PFR1_EL1);
2315+
if (regp)
2316+
regp->user_mask &= ~ID_AA64PFR1_EL1_SSBS_MASK;
2317+
}
23102318
}
23112319

23122320
static void elf_hwcap_fixup(void)

arch/arm64/kernel/proton-pack.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,18 @@ static enum mitigation_state spectre_v4_enable_hw_mitigation(void)
558558

559559
/* SCTLR_EL1.DSSBS was initialised to 0 during boot */
560560
set_pstate_ssbs(0);
561+
562+
/*
563+
* SSBS is self-synchronizing and is intended to affect subsequent
564+
* speculative instructions, but some CPUs can speculate with a stale
565+
* value of SSBS.
566+
*
567+
* Mitigate this with an unconditional speculation barrier, as CPUs
568+
* could mis-speculate branches and bypass a conditional barrier.
569+
*/
570+
if (IS_ENABLED(CONFIG_ARM64_WORKAROUND_SPECULATIVE_SSBS))
571+
spec_bar();
572+
561573
return SPECTRE_MITIGATED;
562574
}
563575

arch/arm64/tools/cpucaps

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,4 +102,5 @@ WORKAROUND_NVIDIA_CARMEL_CNP
102102
WORKAROUND_QCOM_FALKOR_E1003
103103
WORKAROUND_REPEAT_TLBI
104104
WORKAROUND_SPECULATIVE_AT
105+
WORKAROUND_SPECULATIVE_SSBS
105106
WORKAROUND_SPECULATIVE_UNPRIV_LOAD

0 commit comments

Comments
 (0)