Skip to content

Commit 471470b

Browse files
robherringwilldeacon
authored andcommitted
arm64: errata: Add Cortex-A520 speculative unprivileged load workaround
Implement the workaround for ARM Cortex-A520 erratum 2966298. On an affected Cortex-A520 core, a speculatively executed unprivileged load might leak data from a privileged load via a cache side channel. The issue only exists for loads within a translation regime with the same translation (e.g. same ASID and VMID). Therefore, the issue only affects the return to EL0. The workaround is to execute a TLBI before returning to EL0 after all loads of privileged data. A non-shareable TLBI to any address is sufficient. The workaround isn't necessary if page table isolation (KPTI) is enabled, but for simplicity it will be. Page table isolation should normally be disabled for Cortex-A520 as it supports the CSV3 feature and the E0PD feature (used when KASLR is enabled). Cc: stable@vger.kernel.org Signed-off-by: Rob Herring <robh@kernel.org> Link: https://lore.kernel.org/r/20230921194156.1050055-2-robh@kernel.org Signed-off-by: Will Deacon <will@kernel.org>
1 parent a654a69 commit 471470b

File tree

5 files changed

+28
-0
lines changed

5 files changed

+28
-0
lines changed

Documentation/arch/arm64/silicon-errata.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ stable kernels.
7171
+----------------+-----------------+-----------------+-----------------------------+
7272
| ARM | Cortex-A510 | #2658417 | ARM64_ERRATUM_2658417 |
7373
+----------------+-----------------+-----------------+-----------------------------+
74+
| ARM | Cortex-A520 | #2966298 | ARM64_ERRATUM_2966298 |
75+
+----------------+-----------------+-----------------+-----------------------------+
7476
| ARM | Cortex-A53 | #826319 | ARM64_ERRATUM_826319 |
7577
+----------------+-----------------+-----------------+-----------------------------+
7678
| ARM | Cortex-A53 | #827319 | ARM64_ERRATUM_827319 |

arch/arm64/Kconfig

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,6 +1037,19 @@ config ARM64_ERRATUM_2645198
10371037

10381038
If unsure, say Y.
10391039

1040+
config ARM64_ERRATUM_2966298
1041+
bool "Cortex-A520: 2966298: workaround for speculatively executed unprivileged load"
1042+
default y
1043+
help
1044+
This option adds the workaround for ARM Cortex-A520 erratum 2966298.
1045+
1046+
On an affected Cortex-A520 core, a speculatively executed unprivileged
1047+
load might leak data from a privileged level via a cache side channel.
1048+
1049+
Work around this problem by executing a TLBI before returning to EL0.
1050+
1051+
If unsure, say Y.
1052+
10401053
config CAVIUM_ERRATUM_22375
10411054
bool "Cavium erratum 22375, 24313"
10421055
default y

arch/arm64/kernel/cpu_errata.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -730,6 +730,14 @@ const struct arm64_cpu_capabilities arm64_errata[] = {
730730
.cpu_enable = cpu_clear_bf16_from_user_emulation,
731731
},
732732
#endif
733+
#ifdef CONFIG_ARM64_ERRATUM_2966298
734+
{
735+
.desc = "ARM erratum 2966298",
736+
.capability = ARM64_WORKAROUND_2966298,
737+
/* Cortex-A520 r0p0 - r0p1 */
738+
ERRATA_MIDR_REV_RANGE(MIDR_CORTEX_A520, 0, 0, 1),
739+
},
740+
#endif
733741
#ifdef CONFIG_AMPERE_ERRATUM_AC03_CPU_38
734742
{
735743
.desc = "AmpereOne erratum AC03_CPU_38",

arch/arm64/kernel/entry.S

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,10 @@ alternative_else_nop_endif
428428
ldp x28, x29, [sp, #16 * 14]
429429

430430
.if \el == 0
431+
alternative_if ARM64_WORKAROUND_2966298
432+
tlbi vale1, xzr
433+
dsb nsh
434+
alternative_else_nop_endif
431435
alternative_if_not ARM64_UNMAP_KERNEL_AT_EL0
432436
ldr lr, [sp, #S_LR]
433437
add sp, sp, #PT_REGS_SIZE // restore sp

arch/arm64/tools/cpucaps

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ WORKAROUND_2077057
8484
WORKAROUND_2457168
8585
WORKAROUND_2645198
8686
WORKAROUND_2658417
87+
WORKAROUND_2966298
8788
WORKAROUND_AMPERE_AC03_CPU_38
8889
WORKAROUND_TRBE_OVERWRITE_FILL_MODE
8990
WORKAROUND_TSB_FLUSH_FAILURE

0 commit comments

Comments
 (0)