From 94a75ad456a8bda75ca1e4343f00be249a201a69 Mon Sep 17 00:00:00 2001 From: Boyan Karatotev <boyan.karatotev@arm.com> Date: Tue, 4 Apr 2023 11:29:00 +0100 Subject: [PATCH] feat(cpus): add more errata framework helpers Figuring out the naming format of errata is annoying, so add a shorthand for the custom checker functions. Also add some more semantic macros instead of passing around constants. Signed-off-by: Boyan Karatotev <boyan.karatotev@arm.com> Change-Id: Ibdcf72146738026df4ebd047bfb30790fd4a1053 --- include/lib/cpus/aarch64/cpu_macros.S | 38 +++++++++++++++++++++++++++ include/lib/cpus/errata.h | 4 +++ 2 files changed, 42 insertions(+) diff --git a/include/lib/cpus/aarch64/cpu_macros.S b/include/lib/cpus/aarch64/cpu_macros.S index 724624c5e..404b7f91b 100644 --- a/include/lib/cpus/aarch64/cpu_macros.S +++ b/include/lib/cpus/aarch64/cpu_macros.S @@ -426,6 +426,23 @@ msr \_reg, x1 .endm +/* + * Clear a bit in a system register. Can clear multiple bits but is limited by + * the way the BIC instrucion encodes them. + * + * see sysreg_bit_set for usage + */ +.macro sysreg_bit_clear _reg:req, _bit:req + mrs x1, \_reg + bic x1, x1, #\_bit + msr \_reg, x1 +.endm + +.macro override_vector_table _table:req + adr x1, \_table + msr vbar_el3, x1 +.endm + /* * Apply erratum * @@ -497,6 +514,27 @@ endfunc check_erratum_\_cpu\()_\_id .endm +.macro check_erratum_chosen _cpu:req, _cve:req, _id:req, _chosen:req + func check_erratum_\_cpu\()_\_id + .if \_chosen + mov x0, #ERRATA_APPLIES + .else + mov x0, #ERRATA_MISSING + .endif + ret + endfunc check_erratum_\_cpu\()_\_id +.endm + +/* provide a shorthand for the name format for annoying errata */ +.macro check_erratum_custom_start _cpu:req, _cve:req, _id:req + func check_erratum_\_cpu\()_\_id +.endm + +.macro check_erratum_custom_end _cpu:req, _cve:req, _id:req + endfunc check_erratum_\_cpu\()_\_id +.endm + + /******************************************************************************* * CPU reset function wrapper ******************************************************************************/ diff --git a/include/lib/cpus/errata.h b/include/lib/cpus/errata.h index f8f9555d2..b280435d8 100644 --- a/include/lib/cpus/errata.h +++ b/include/lib/cpus/errata.h @@ -64,6 +64,10 @@ CASSERT(sizeof(struct erratum_entry) == ERRATUM_ENTRY_SIZE, #define CVE(year, id) year, id #define NO_ISB 1 #define NO_ASSERT 0 +#define NO_APPLY_AT_RESET 0 +#define APPLY_AT_RESET 1 +/* useful for errata that end up always being worked around */ +#define ERRATUM_ALWAYS_CHOSEN 1 #endif /* __ASSEMBLER__ */