From 511148ef5077dfb8f6bc7b9655e4ac19e16c4af0 Mon Sep 17 00:00:00 2001 From: Govindraj Raja Date: Tue, 21 Jan 2025 18:38:56 -0600 Subject: [PATCH] fix(cpus): workaround for Cortex-X925 erratum 3701747 Cortex-X925 erratum 3701747 that applies to r0p0, r0p1 and 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/109180/latest/ Change-Id: I080296666f89276b3260686c2bdb8de63fc174c1 Signed-off-by: Govindraj Raja --- docs/design/cpu-specific-build-macros.rst | 5 +++++ include/lib/cpus/aarch64/cortex_x925.h | 4 ++++ lib/cpus/aarch64/cortex_x925.S | 6 ++++++ lib/cpus/cpu-ops.mk | 5 +++++ lib/cpus/errata_common.c | 7 +++++++ 5 files changed, 27 insertions(+) diff --git a/docs/design/cpu-specific-build-macros.rst b/docs/design/cpu-specific-build-macros.rst index 63c316673..90c65be08 100644 --- a/docs/design/cpu-specific-build-macros.rst +++ b/docs/design/cpu-specific-build-macros.rst @@ -874,6 +874,11 @@ For Cortex-X4, the following errata build flags are defined : CPU. This needs to be enabled for revisions r0p0, r0p1, r0p2 and r0p3. It is still open. +For Cortex-X925, the following errata build flags are defined : + +- ``ERRATA_X925_3701747``: This applies errata 3701747 workaround to Cortex-X925 + CPU. This needs to be enabled for revisions r0p0 and r0p1. It is still open. + For Cortex-A510, the following errata build flags are defined : - ``ERRATA_A510_1922240``: This applies errata 1922240 workaround to diff --git a/include/lib/cpus/aarch64/cortex_x925.h b/include/lib/cpus/aarch64/cortex_x925.h index ecbbb599a..170afbf41 100644 --- a/include/lib/cpus/aarch64/cortex_x925.h +++ b/include/lib/cpus/aarch64/cortex_x925.h @@ -26,4 +26,8 @@ ******************************************************************************/ #define CORTEX_X925_CPUACTLR6_EL1 S3_0_C15_C8_1 +#ifndef __ASSEMBLER__ +long check_erratum_cortex_x925_3701747(long cpu_rev); +#endif /* __ASSEMBLER__ */ + #endif /* CORTEX_X925_H */ diff --git a/lib/cpus/aarch64/cortex_x925.S b/lib/cpus/aarch64/cortex_x925.S index 5b6632aef..e2e70dd9a 100644 --- a/lib/cpus/aarch64/cortex_x925.S +++ b/lib/cpus/aarch64/cortex_x925.S @@ -21,6 +21,12 @@ #error "Cortex-X925 supports only AArch64. Compile with CTX_INCLUDE_AARCH32_REGS=0" #endif +.global check_erratum_cortex_x925_3701747 + +add_erratum_entry cortex_x925, ERRATUM(3701747), ERRATA_X925_3701747, NO_APPLY_AT_RESET + +check_erratum_ls cortex_x925, ERRATUM(3701747), CPU_REV(0, 1) + /* Disable hardware page aggregation. Enables mitigation for `CVE-2024-5660` */ workaround_reset_start cortex_x925, CVE(2024, 5660), WORKAROUND_CVE_2024_5660 sysreg_bit_set CORTEX_X925_CPUECTLR_EL1, BIT(46) diff --git a/lib/cpus/cpu-ops.mk b/lib/cpus/cpu-ops.mk index e78234438..947902aa7 100644 --- a/lib/cpus/cpu-ops.mk +++ b/lib/cpus/cpu-ops.mk @@ -879,6 +879,11 @@ CPU_FLAG_LIST += ERRATA_X4_3076789 # of the Cortex-X4 cpu and is still open. CPU_FLAG_LIST += ERRATA_X4_3701758 +# Flag to apply erratum 3701747 workaround during context save/restore of +# ICH_VMCR_EL2 reg. This erratum applies to revisions r0p0, r0p1 of the +# Cortex-X925 cpu and is still open. +CPU_FLAG_LIST += ERRATA_X925_3701747 + # Flag to apply erratum 1922240 workaround during reset. This erratum applies # to revision r0p0 of the Cortex-A510 cpu and is fixed in r0p1. CPU_FLAG_LIST += ERRATA_A510_1922240 diff --git a/lib/cpus/errata_common.c b/lib/cpus/errata_common.c index acb9fe3d2..7f025b4b2 100644 --- a/lib/cpus/errata_common.c +++ b/lib/cpus/errata_common.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -107,6 +108,12 @@ bool errata_ich_vmcr_el2_applies(void) break; #endif /* ERRATA_X4_3701758 */ +#if ERRATA_X925_3701747 + case EXTRACT_PARTNUM(CORTEX_X925_MIDR): + if (check_erratum_cortex_x925_3701747(cpu_get_rev_var()) == ERRATA_APPLIES) + return true; + break; +#endif /* ERRATA_X925_3701747 */ default: break; }