From 77feb745e42296c553c33bcaea5be3304168eff3 Mon Sep 17 00:00:00 2001 From: Govindraj Raja Date: Tue, 21 Jan 2025 18:12:35 -0600 Subject: [PATCH] fix(cpus): workaround for Cortex-X3 erratum 3701769 Cortex-X3 erratum 3701769 that applies to r0p0, r1p0, r1p1 and r1p2 is still Open. The workaround is for EL3 software that performs context save/restore on a change of Security state to use a value of SCR_EL3.NS when accessing ICH_VMCR_EL2 that reflects the Security state that owns the data being saved or restored. SDEN documentation: https://developer.arm.com/documentation/SDEN-2055130/latest/ Change-Id: Ifd722e1bb8616ada2ad158297a7ca80b19a3370b Signed-off-by: Govindraj Raja --- docs/design/cpu-specific-build-macros.rst | 4 ++++ include/lib/cpus/aarch64/cortex_x3.h | 6 +++++- lib/cpus/aarch64/cortex_x3.S | 6 ++++++ lib/cpus/cpu-ops.mk | 5 +++++ lib/cpus/errata_common.c | 8 ++++++++ 5 files changed, 28 insertions(+), 1 deletion(-) diff --git a/docs/design/cpu-specific-build-macros.rst b/docs/design/cpu-specific-build-macros.rst index 00cfe191c..5862f673e 100644 --- a/docs/design/cpu-specific-build-macros.rst +++ b/docs/design/cpu-specific-build-macros.rst @@ -833,6 +833,10 @@ For Cortex-X3, the following errata build flags are defined : CPU. This needs to be enabled only for revisions r0p0, r1p0 and r1p1 of the CPU. It is fixed in r1p2. +- ``ERRATA_X3_3701769``: This applies errata 3701769 workaround to Cortex-X3 + CPU. This needs to be enabled only for revisions r0p0, r1p0, r1p1 and r1p2 + of the CPU and it is still open. + For Cortex-X4, the following errata build flags are defined : - ``ERRATA_X4_2701112``: This applies erratum 2701112 workaround to Cortex-X4 diff --git a/include/lib/cpus/aarch64/cortex_x3.h b/include/lib/cpus/aarch64/cortex_x3.h index c5f820cf4..8834db118 100644 --- a/include/lib/cpus/aarch64/cortex_x3.h +++ b/include/lib/cpus/aarch64/cortex_x3.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2024, Arm Limited. All rights reserved. + * Copyright (c) 2021-2025, Arm Limited. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -63,4 +63,8 @@ #define CORTEX_X3_CPUACTLR3_EL1 S3_0_C15_C1_2 #define CORTEX_X3_CPUACTLR3_EL1_BIT_47 (ULL(1) << 47) +#ifndef __ASSEMBLER__ +long check_erratum_cortex_x3_3701769(long cpu_rev); +#endif /* __ASSEMBLER__ */ + #endif /* CORTEX_X3_H */ diff --git a/lib/cpus/aarch64/cortex_x3.S b/lib/cpus/aarch64/cortex_x3.S index 4a0212e20..24dbf9d83 100644 --- a/lib/cpus/aarch64/cortex_x3.S +++ b/lib/cpus/aarch64/cortex_x3.S @@ -22,6 +22,12 @@ #error "Cortex-X3 supports only AArch64. Compile with CTX_INCLUDE_AARCH32_REGS=0" #endif +.global check_erratum_cortex_x3_3701769 + +add_erratum_entry cortex_x3, ERRATUM(3701769), ERRATA_X3_3701769, NO_APPLY_AT_RESET + +check_erratum_ls cortex_x3, ERRATUM(3701769), CPU_REV(1, 2) + #if WORKAROUND_CVE_2022_23960 wa_cve_2022_23960_bhb_vector_table CORTEX_X3_BHB_LOOP_COUNT, cortex_x3 #endif /* WORKAROUND_CVE_2022_23960 */ diff --git a/lib/cpus/cpu-ops.mk b/lib/cpus/cpu-ops.mk index a879bb0c7..fb153f71e 100644 --- a/lib/cpus/cpu-ops.mk +++ b/lib/cpus/cpu-ops.mk @@ -832,6 +832,11 @@ CPU_FLAG_LIST += ERRATA_X3_2742421 # to revisions r0p0, r1p0 and r1p1 of the Cortex-X3 cpu, it is fixed in r1p2. CPU_FLAG_LIST += ERRATA_X3_2743088 +# Flag to apply erratum 3701769 workaround during context save/restore of +# ICH_VMCR_EL2 reg. This erratum applies to revisions r0p0, r1p0, r1p1 and r1p2 +# of the Cortex-X3 cpu and is still open. +CPU_FLAG_LIST += ERRATA_X3_3701769 + # Flag to apply erratum 2779509 workaround on reset. This erratum applies # to revisions r0p0, r1p0, r1p1 of the Cortex-X3 cpu, it is fixed in r1p2. CPU_FLAG_LIST += ERRATA_X3_2779509 diff --git a/lib/cpus/errata_common.c b/lib/cpus/errata_common.c index 5dbc50d61..f61d6e8c2 100644 --- a/lib/cpus/errata_common.c +++ b/lib/cpus/errata_common.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -92,6 +93,13 @@ bool errata_ich_vmcr_el2_applies(void) break; #endif /* ERRATA_X2_3701772 */ +#if ERRATA_X3_3701769 + case EXTRACT_PARTNUM(CORTEX_X3_MIDR): + if (check_erratum_cortex_x3_3701769(cpu_get_rev_var()) == ERRATA_APPLIES) + return true; + break; +#endif /* ERRATA_X3_3701769 */ + default: break; }