Skip to content

Commit f2bd352

Browse files
fix(errata): workaround for Cortex-A510 erratum 2971420
Cortex-A510 erratum 2971420 applies to revisions r0p1, r0p2, r0p3, r1p0, r1p1, r1p2 and r1p3, and is still open. Under some conditions, data might be corrupted if Trace Buffer Extension (TRBE) is enabled. The workaround is to disable trace collection via TRBE by programming MDCR_EL3.NSTB[1] to the opposite value of SCR_EL3.NS on a security state switch. Since we only enable TRBE for non-secure world, the workaround is to disable TRBE by setting the NSTB field to 00 so accesses are trapped to EL3 and secure state owns the buffer. SDEN: https://developer.arm.com/documentation/SDEN-1873361/latest/ Signed-off-by: John Powell <[email protected]> Change-Id: Ia77051f6b64c726a8c50596c78f220d323ab7d97
1 parent d7cacc5 commit f2bd352

File tree

7 files changed

+42
-19
lines changed

7 files changed

+42
-19
lines changed

docs/design/cpu-specific-build-macros.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -956,6 +956,10 @@ For Cortex-A510, the following errata build flags are defined :
956956
Cortex-A510 CPU. This needs to be applied to revision r0p0, r0p1, r0p2,
957957
r0p3, r1p0, r1p1 and r1p2. It is fixed in r1p3.
958958

959+
- ``ERRATA_A510_2971420``: This applies erratum 2971420 workaround to
960+
Cortex-A510 CPU. This needs to be applied to revisions r0p1, r0p2, r0p3,
961+
r1p0, r1p1, r1p2 and r1p3 and is still open.
962+
959963
For Cortex-A520, the following errata build flags are defined :
960964

961965
- ``ERRATA_A520_2630792``: This applies errata 2630792 workaround to

include/lib/cpus/aarch64/cortex_a510.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2022-2023, Arm Limited. All rights reserved.
2+
* Copyright (c) 2022-2025, Arm Limited. All rights reserved.
33
*
44
* SPDX-License-Identifier: BSD-3-Clause
55
*/
@@ -52,4 +52,12 @@
5252
#define CORTEX_A510_CPUACTLR_EL1_DATA_CORRUPT_SHIFT U(18)
5353
#define CORTEX_A510_CPUACTLR_EL1_DATA_CORRUPT_WIDTH U(1)
5454

55+
#ifndef __ASSEMBLER__
56+
57+
#if ERRATA_A510_2971420
58+
long check_erratum_cortex_a510_2971420(long cpu_rev);
59+
#endif
60+
61+
#endif /* __ASSEMBLER__ */
62+
5563
#endif /* CORTEX_A510_H */

include/lib/cpus/errata.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,8 @@ static inline bool errata_a75_764081_applies(void)
6767
}
6868
#endif
6969

70-
#if ERRATA_A520_2938996 || ERRATA_X4_2726228
71-
unsigned int check_if_affected_core(void);
72-
#endif
7370

71+
bool check_if_trbe_disable_affected_core(void);
7472
int check_wa_cve_2024_7881(void);
7573
bool errata_ich_vmcr_el2_applies(void);
7674

lib/cpus/aarch64/cortex_a510.S

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,10 @@ check_erratum_custom_start cortex_a510, ERRATUM(2313941)
178178
ret
179179
check_erratum_custom_end cortex_a510, ERRATUM(2313941)
180180

181+
.global check_erratum_cortex_a510_2971420
182+
add_erratum_entry cortex_a510, ERRATUM(2971420), ERRATA_A510_2971420
183+
check_erratum_range cortex_a510, ERRATUM(2971420), CPU_REV(0, 1), CPU_REV(1, 3)
184+
181185
/* ----------------------------------------------------
182186
* HW will do the cache maintenance while powering down
183187
* ----------------------------------------------------

lib/cpus/cpu-ops.mk

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -966,6 +966,11 @@ CPU_FLAG_LIST += ERRATA_A510_2666669
966966
# Cortex-A510 cpu and is fixed in r1p3.
967967
CPU_FLAG_LIST += ERRATA_A510_2684597
968968

969+
# Flag to apply erratum 2971420 workaround during context switch. This erratum
970+
# applies to revisions r0p1, r0p2, r0p3, r1p0, r1p1, r1p2 and r1p3 of the
971+
# Cortex-A510 cpu and is still open.
972+
CPU_FLAG_LIST += ERRATA_A510_2971420
973+
969974
# Flag to apply erratum 2630792 workaround during reset. This erratum applies
970975
# to revisions r0p0, r0p1 of the Cortex-A520 cpu and is still open.
971976
CPU_FLAG_LIST += ERRATA_A520_2630792

lib/cpus/errata_common.c

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <arch.h>
1010
#include <arch_helpers.h>
1111
#include <cortex_a75.h>
12+
#include <cortex_a510.h>
1213
#include <cortex_a520.h>
1314
#include <cortex_a710.h>
1415
#include <cortex_a715.h>
@@ -25,21 +26,26 @@
2526
#include <neoverse_n3.h>
2627
#include <neoverse_v3.h>
2728

28-
#if ERRATA_A520_2938996 || ERRATA_X4_2726228
29-
unsigned int check_if_affected_core(void)
29+
bool check_if_trbe_disable_affected_core(void)
3030
{
31-
uint32_t midr_val = read_midr();
32-
long rev_var = cpu_get_rev_var();
33-
34-
if (EXTRACT_PARTNUM(midr_val) == EXTRACT_PARTNUM(CORTEX_A520_MIDR)) {
35-
return check_erratum_cortex_a520_2938996(rev_var);
36-
} else if (EXTRACT_PARTNUM(midr_val) == EXTRACT_PARTNUM(CORTEX_X4_MIDR)) {
37-
return check_erratum_cortex_x4_2726228(rev_var);
31+
switch (EXTRACT_PARTNUM(read_midr())) {
32+
#if ERRATA_A520_2938996
33+
case EXTRACT_PARTNUM(CORTEX_A520_MIDR):
34+
return check_erratum_cortex_a520_2938996(cpu_get_rev_var()) == ERRATA_APPLIES;
35+
#endif
36+
#if ERRATA_X4_2726228
37+
case EXTRACT_PARTNUM(CORTEX_X4_MIDR):
38+
return check_erratum_cortex_x4_2726228(cpu_get_rev_var()) == ERRATA_APPLIES;
39+
#endif
40+
#if ERRATA_A510_2971420
41+
case EXTRACT_PARTNUM(CORTEX_A510_MIDR):
42+
return check_erratum_cortex_a510_2971420(cpu_get_rev_var()) == ERRATA_APPLIES;
43+
#endif
44+
default:
45+
break;
3846
}
39-
40-
return ERRATA_NOT_APPLIES;
47+
return false;
4148
}
42-
#endif
4349

4450
#if ERRATA_A75_764081
4551
bool errata_a75_764081_applies(void)

lib/el3_runtime/aarch64/context_mgmt.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1673,13 +1673,11 @@ void cm_handle_asymmetric_features(void)
16731673
}
16741674
#endif
16751675

1676-
#if ERRATA_A520_2938996 || ERRATA_X4_2726228
1677-
if (check_if_affected_core() == ERRATA_APPLIES) {
1676+
if (check_if_trbe_disable_affected_core()) {
16781677
if (is_feat_trbe_supported()) {
16791678
trbe_disable(ctx);
16801679
}
16811680
}
1682-
#endif
16831681

16841682
#if ENABLE_FEAT_TCR2 == FEAT_STATE_CHECK_ASYMMETRIC
16851683
el3_state_t *el3_state = get_el3state_ctx(ctx);

0 commit comments

Comments
 (0)