diff --git a/include/lib/cpus/aarch64/cpu_macros.S b/include/lib/cpus/aarch64/cpu_macros.S index d945d7c84..6faef5db9 100644 --- a/include/lib/cpus/aarch64/cpu_macros.S +++ b/include/lib/cpus/aarch64/cpu_macros.S @@ -472,15 +472,25 @@ * _chosen: * Compile time flag on whether the erratum is included * - * clobbers: x0-x9 (PCS compliant) + * _get_rev: + * Optional parameter that determines whether to insert a call to the CPU revision fetching + * procedure. Stores the result of this in the temporary register x10. + * + * clobbers: x0-x10 (PCS compliant) */ -.macro apply_erratum _cpu:req, _cve:req, _id:req, _chosen:req - .if \_chosen +.macro apply_erratum _cpu:req, _cve:req, _id:req, _chosen:req, _get_rev=GET_CPU_REV + .if (\_chosen & \_get_rev) mov x9, x30 bl cpu_get_rev_var + mov x10, x0 + .elseif (\_chosen) + mov x9, x30 + mov x0, x10 + .endif + + .if \_chosen bl erratum_\_cpu\()_\_id\()_wa mov x30, x9 - .endif .endm diff --git a/include/lib/cpus/errata.h b/include/lib/cpus/errata.h index b280435d8..20808989a 100644 --- a/include/lib/cpus/errata.h +++ b/include/lib/cpus/errata.h @@ -66,6 +66,9 @@ CASSERT(sizeof(struct erratum_entry) == ERRATUM_ENTRY_SIZE, #define NO_ASSERT 0 #define NO_APPLY_AT_RESET 0 #define APPLY_AT_RESET 1 +#define GET_CPU_REV 1 +#define NO_GET_CPU_REV 0 + /* useful for errata that end up always being worked around */ #define ERRATUM_ALWAYS_CHOSEN 1