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 <john.powell@arm.com>
Change-Id: Ia77051f6b64c726a8c50596c78f220d323ab7d97
diff --git a/lib/cpus/errata_common.c b/lib/cpus/errata_common.c
index a391430..0530647 100644
--- a/lib/cpus/errata_common.c
+++ b/lib/cpus/errata_common.c
@@ -9,6 +9,7 @@
#include <arch.h>
#include <arch_helpers.h>
#include <cortex_a75.h>
+#include <cortex_a510.h>
#include <cortex_a520.h>
#include <cortex_a710.h>
#include <cortex_a715.h>
@@ -25,21 +26,26 @@
#include <neoverse_n3.h>
#include <neoverse_v3.h>
-#if ERRATA_A520_2938996 || ERRATA_X4_2726228
-unsigned int check_if_affected_core(void)
+bool check_if_trbe_disable_affected_core(void)
{
- uint32_t midr_val = read_midr();
- long rev_var = cpu_get_rev_var();
-
- if (EXTRACT_PARTNUM(midr_val) == EXTRACT_PARTNUM(CORTEX_A520_MIDR)) {
- return check_erratum_cortex_a520_2938996(rev_var);
- } else if (EXTRACT_PARTNUM(midr_val) == EXTRACT_PARTNUM(CORTEX_X4_MIDR)) {
- return check_erratum_cortex_x4_2726228(rev_var);
+ switch (EXTRACT_PARTNUM(read_midr())) {
+#if ERRATA_A520_2938996
+ case EXTRACT_PARTNUM(CORTEX_A520_MIDR):
+ return check_erratum_cortex_a520_2938996(cpu_get_rev_var()) == ERRATA_APPLIES;
+#endif
+#if ERRATA_X4_2726228
+ case EXTRACT_PARTNUM(CORTEX_X4_MIDR):
+ return check_erratum_cortex_x4_2726228(cpu_get_rev_var()) == ERRATA_APPLIES;
+#endif
+#if ERRATA_A510_2971420
+ case EXTRACT_PARTNUM(CORTEX_A510_MIDR):
+ return check_erratum_cortex_a510_2971420(cpu_get_rev_var()) == ERRATA_APPLIES;
+#endif
+ default:
+ break;
}
-
- return ERRATA_NOT_APPLIES;
+ return false;
}
-#endif
#if ERRATA_A75_764081
bool errata_a75_764081_applies(void)