feat(cpus): workaround for Cortex-A520(2938996) and Cortex-X4(2726228)

This patch implements errata functions for two errata, both of them
disable TRBE as a workaround. This patch doesn't have functions
that disable TRBE but only implemented helper functions that are
used to detect cores affected by Errata 2938996(Cortex-A520) & 2726228(Cortex-X4)

Cortex-X4 SDEN documentation:
    https://developer.arm.com/documentation/SDEN2432808/latest

Cortex-A520 SDEN Documentation:
    https://developer.arm.com/documentation/SDEN-2444153/latest

Signed-off-by: Arvind Ram Prakash <arvind.ramprakash@arm.com>
Change-Id: I8f886a1c21698f546a0996c719cc27dc0a23633a
This commit is contained in:
Arvind Ram Prakash 2024-08-05 16:04:37 -05:00 committed by Manish Pandey
parent 7754b770cf
commit 4a97ff5111
7 changed files with 90 additions and 6 deletions

View file

@ -826,6 +826,10 @@ For Cortex-X4, the following errata build flags are defined :
feature is enabled and can assist the Kernel in the process of feature is enabled and can assist the Kernel in the process of
mitigation of the erratum. mitigation of the erratum.
- ``ERRATA_X4_2726228``: This applies erratum 2726228 workaround to Cortex-X4
CPU. This needs to be enabled for revisions r0p0 and r0p1. It is fixed in
r0p2.
- ``ERRATA_X4_2740089``: This applies errata 2740089 workaround to Cortex-X4 - ``ERRATA_X4_2740089``: This applies errata 2740089 workaround to Cortex-X4
CPU. This needs to be enabled for revisions r0p0 and r0p1. It is fixed CPU. This needs to be enabled for revisions r0p0 and r0p1. It is fixed
in r0p2. in r0p2.
@ -899,6 +903,10 @@ For Cortex-A520, the following errata build flags are defined :
Cortex-A520 CPU. This needs to be enabled for revisions r0p0 and r0p1. Cortex-A520 CPU. This needs to be enabled for revisions r0p0 and r0p1.
It is still open. It is still open.
- ``ERRATA_A520_2938996``: This applies errata 2938996 workaround to
Cortex-A520 CPU. This needs to be enabled for revisions r0p0 and r0p1.
It is fixed in r0p2.
For Cortex-A715, the following errata build flags are defined : For Cortex-A715, the following errata build flags are defined :
- ``ERRATA_A715_2331818``: This applies errata 2331818 workaround to - ``ERRATA_A715_2331818``: This applies errata 2331818 workaround to

View file

@ -28,4 +28,15 @@
#define CORTEX_A520_CPUPWRCTLR_EL1 S3_0_C15_C2_7 #define CORTEX_A520_CPUPWRCTLR_EL1 S3_0_C15_C2_7
#define CORTEX_A520_CPUPWRCTLR_EL1_CORE_PWRDN_BIT U(1) #define CORTEX_A520_CPUPWRCTLR_EL1_CORE_PWRDN_BIT U(1)
#ifndef __ASSEMBLER__
#if ERRATA_A520_2938996
long check_erratum_cortex_a520_2938996(long cpu_rev);
#else
static inline long check_erratum_cortex_a520_2938996(long cpu_rev)
{
return 0;
}
#endif /* ERRATA_A520_2938996 */
#endif /* __ASSEMBLER__ */
#endif /* CORTEX_A520_H */ #endif /* CORTEX_A520_H */

View file

@ -34,4 +34,15 @@
#define CORTEX_X4_CPUACTLR5_EL1 S3_0_C15_C8_0 #define CORTEX_X4_CPUACTLR5_EL1 S3_0_C15_C8_0
#define CORTEX_X4_CPUACTLR5_EL1_BIT_14 (ULL(1) << 14) #define CORTEX_X4_CPUACTLR5_EL1_BIT_14 (ULL(1) << 14)
#ifndef __ASSEMBLER__
#if ERRATA_X4_2726228
long check_erratum_cortex_x4_2726228(long cpu_rev);
#else
static inline long check_erratum_cortex_x4_2726228(long cpu_rev)
{
return 0;
}
#endif /* ERRATA_X4_2726228 */
#endif /* __ASSEMBLER__ */
#endif /* CORTEX_X4_H */ #endif /* CORTEX_X4_H */

View file

@ -25,12 +25,21 @@
#define ERRATUM_MITIGATED ERRATUM_CHOSEN + ERRATUM_CHOSEN_SIZE #define ERRATUM_MITIGATED ERRATUM_CHOSEN + ERRATUM_CHOSEN_SIZE
#define ERRATUM_ENTRY_SIZE ERRATUM_MITIGATED + ERRATUM_MITIGATED_SIZE #define ERRATUM_ENTRY_SIZE ERRATUM_MITIGATED + ERRATUM_MITIGATED_SIZE
/* Errata status */
#define ERRATA_NOT_APPLIES 0
#define ERRATA_APPLIES 1
#define ERRATA_MISSING 2
#ifndef __ASSEMBLER__ #ifndef __ASSEMBLER__
#include <lib/cassert.h> #include <lib/cassert.h>
void print_errata_status(void); void print_errata_status(void);
void errata_print_msg(unsigned int status, const char *cpu, const char *id); void errata_print_msg(unsigned int status, const char *cpu, const char *id);
#if ERRATA_A520_2938996 || ERRATA_X4_2726228
unsigned int check_if_affected_core(void);
#endif
/* /*
* NOTE that this structure will be different on AArch32 and AArch64. The * NOTE that this structure will be different on AArch32 and AArch64. The
* uintptr_t will reflect the change and the alignment will be correct in both. * uintptr_t will reflect the change and the alignment will be correct in both.
@ -74,11 +83,6 @@ CASSERT(sizeof(struct erratum_entry) == ERRATUM_ENTRY_SIZE,
#endif /* __ASSEMBLER__ */ #endif /* __ASSEMBLER__ */
/* Errata status */
#define ERRATA_NOT_APPLIES 0
#define ERRATA_APPLIES 1
#define ERRATA_MISSING 2
/* Macro to get CPU revision code for checking errata version compatibility. */ /* Macro to get CPU revision code for checking errata version compatibility. */
#define CPU_REV(r, p) ((r << 4) | p) #define CPU_REV(r, p) ((r << 4) | p)

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2021-2023, Arm Limited. All rights reserved. * Copyright (c) 2021-2024, Arm Limited. All rights reserved.
* *
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
*/ */
@ -11,6 +11,9 @@
#include <cpu_macros.S> #include <cpu_macros.S>
#include <plat_macros.S> #include <plat_macros.S>
/* .global erratum_cortex_a520_2938996_wa */
.global check_erratum_cortex_a520_2938996
/* Hardware handled coherency */ /* Hardware handled coherency */
#if HW_ASSISTED_COHERENCY == 0 #if HW_ASSISTED_COHERENCY == 0
#error "Cortex A520 must be compiled with HW_ASSISTED_COHERENCY enabled" #error "Cortex A520 must be compiled with HW_ASSISTED_COHERENCY enabled"
@ -32,6 +35,25 @@ workaround_reset_start cortex_a520, ERRATUM(2858100), ERRATA_A520_2858100
workaround_reset_end cortex_a520, ERRATUM(2858100) workaround_reset_end cortex_a520, ERRATUM(2858100)
check_erratum_ls cortex_a520, ERRATUM(2858100), CPU_REV(0, 1) check_erratum_ls cortex_a520, ERRATUM(2858100), CPU_REV(0, 1)
workaround_runtime_start cortex_a520, ERRATUM(2938996), ERRATA_A520_2938996, CORTEX_A520_MIDR
workaround_runtime_end cortex_a520, ERRATUM(2938996)
check_erratum_custom_start cortex_a520, ERRATUM(2938996)
/* This erratum needs to be enabled for r0p0 and r0p1.
* Check if revision is less than or equal to r0p1.
*/
#if ERRATA_A520_2938996
mov x1, #1
b cpu_rev_var_ls
#else
mov x0, #ERRATA_MISSING
#endif
ret
check_erratum_custom_end cortex_a520, ERRATUM(2938996)
/* ---------------------------------------------------- /* ----------------------------------------------------
* HW will do the cache maintenance while powering down * HW will do the cache maintenance while powering down
* ---------------------------------------------------- * ----------------------------------------------------

View file

@ -22,10 +22,30 @@
#error "Cortex X4 supports only AArch64. Compile with CTX_INCLUDE_AARCH32_REGS=0" #error "Cortex X4 supports only AArch64. Compile with CTX_INCLUDE_AARCH32_REGS=0"
#endif #endif
.global check_erratum_cortex_x4_2726228
#if WORKAROUND_CVE_2022_23960 #if WORKAROUND_CVE_2022_23960
wa_cve_2022_23960_bhb_vector_table CORTEX_X4_BHB_LOOP_COUNT, cortex_x4 wa_cve_2022_23960_bhb_vector_table CORTEX_X4_BHB_LOOP_COUNT, cortex_x4
#endif /* WORKAROUND_CVE_2022_23960 */ #endif /* WORKAROUND_CVE_2022_23960 */
workaround_runtime_start cortex_x4, ERRATUM(2726228), ERRATA_X4_2726228, CORTEX_X4_MIDR
workaround_runtime_end cortex_x4, ERRATUM(2726228)
check_erratum_custom_start cortex_x4, ERRATUM(2726228)
/* This erratum needs to be enabled for r0p0 and r0p1.
* Check if revision is less than or equal to r0p1.
*/
#if ERRATA_X4_2726228
mov x1, #1
b cpu_rev_var_ls
#else
mov x0, #ERRATA_MISSING
#endif
ret
check_erratum_custom_end cortex_x4, ERRATUM(2726228)
workaround_runtime_start cortex_x4, ERRATUM(2740089), ERRATA_X4_2740089 workaround_runtime_start cortex_x4, ERRATUM(2740089), ERRATA_X4_2740089
/* dsb before isb of power down sequence */ /* dsb before isb of power down sequence */
dsb sy dsb sy

View file

@ -823,6 +823,10 @@ CPU_FLAG_LIST += ERRATA_X3_2779509
# cpu and is fixed in r0p1. # cpu and is fixed in r0p1.
CPU_FLAG_LIST += ERRATA_X4_2701112 CPU_FLAG_LIST += ERRATA_X4_2701112
# Flag to apply erratum 2726228 workaround during warmboot. This erratum
# applies to all revisions <= r0p1 of the Cortex-X4 cpu, it is fixed in r0p2.
CPU_FLAG_LIST += ERRATA_X4_2726228
# Flag to apply erratum 2740089 workaround during powerdown. This erratum # Flag to apply erratum 2740089 workaround during powerdown. This erratum
# applies to all revisions <= r0p1 of the Cortex-X4 cpu, it is fixed in r0p2. # applies to all revisions <= r0p1 of the Cortex-X4 cpu, it is fixed in r0p2.
CPU_FLAG_LIST += ERRATA_X4_2740089 CPU_FLAG_LIST += ERRATA_X4_2740089
@ -896,6 +900,10 @@ CPU_FLAG_LIST += ERRATA_A520_2630792
# applies to revision r0p0 and r0p1 of the Cortex-A520 cpu and is still open. # applies to revision r0p0 and r0p1 of the Cortex-A520 cpu and is still open.
CPU_FLAG_LIST += ERRATA_A520_2858100 CPU_FLAG_LIST += ERRATA_A520_2858100
# Flag to apply erratum 2938996 workaround during reset. This erratum
# applies to revision r0p0 and r0p1 of the Cortex-A520 cpu and is fixed in r0p2.
CPU_FLAG_LIST += ERRATA_A520_2938996
# Flag to apply erratum 2331132 workaround during reset. This erratum applies # Flag to apply erratum 2331132 workaround during reset. This erratum applies
# to revisions r0p0, r0p1 and r0p2. It is still open. # to revisions r0p0, r0p1 and r0p2. It is still open.
CPU_FLAG_LIST += ERRATA_V2_2331132 CPU_FLAG_LIST += ERRATA_V2_2331132