feat(cpus): make revision procedure call optional

For runtime errata, we should avoid generating calls to
`cpu_get_rev_var` unless its necessary. Make the path that generates
this call parameterized, and cache the result in a temporary register to
allow future calls that go down the alternate path to retrieve the cache
CPU revision.

Change-Id: I9882ede76568fbd9a7ccd4caa74eff0c66a7b20e
Signed-off-by: Harrison Mutai <harrison.mutai@arm.com>
This commit is contained in:
Harrison Mutai 2023-06-26 16:25:21 +01:00
parent bfd856004f
commit 4d22b0e5ba
2 changed files with 17 additions and 4 deletions

View file

@ -472,15 +472,25 @@
* _chosen: * _chosen:
* Compile time flag on whether the erratum is included * 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 .macro apply_erratum _cpu:req, _cve:req, _id:req, _chosen:req, _get_rev=GET_CPU_REV
.if \_chosen .if (\_chosen & \_get_rev)
mov x9, x30 mov x9, x30
bl cpu_get_rev_var bl cpu_get_rev_var
mov x10, x0
.elseif (\_chosen)
mov x9, x30
mov x0, x10
.endif
.if \_chosen
bl erratum_\_cpu\()_\_id\()_wa bl erratum_\_cpu\()_\_id\()_wa
mov x30, x9 mov x30, x9
.endif .endif
.endm .endm

View file

@ -66,6 +66,9 @@ CASSERT(sizeof(struct erratum_entry) == ERRATUM_ENTRY_SIZE,
#define NO_ASSERT 0 #define NO_ASSERT 0
#define NO_APPLY_AT_RESET 0 #define NO_APPLY_AT_RESET 0
#define APPLY_AT_RESET 1 #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 */ /* useful for errata that end up always being worked around */
#define ERRATUM_ALWAYS_CHOSEN 1 #define ERRATUM_ALWAYS_CHOSEN 1