@@ -390,11 +390,12 @@ alternative_else
dc civac, \kaddr
alternative_endif
.elseif (\op == cvap)
-alternative_if ARM64_HAS_DCPOP
- sys 3, c7, c12, 1, \kaddr // dc cvap
-alternative_else
+alternative_cb arm64_handle_dc_cvap
+ dc civac, \kaddr
+alternative_cb_alt
+ sys 3, c7, c12, 1, \kaddr // dc cvap
dc cvac, \kaddr
-alternative_endif
+alternative_cb_end
.else
dc \op, \kaddr
.endif
@@ -755,3 +755,17 @@ const struct arm64_cpu_capabilities arm64_errata[] = {
{
}
};
+
+asmlinkage void __init arm64_handle_dc_cvap(struct alt_instr *alt,
+ __le32 *origptr, __le32 *updptr,
+ int nr_inst, int nr_alts)
+{
+ struct alt_instr_cb *alt_insn = offset_to_ptr(&alt->alt_offset);
+
+ BUG_ON(nr_inst != 1 || nr_alts != 2);
+
+ if (cpus_have_cap(ARM64_HAS_DCPOP))
+ updptr[0] = alt_insn->insn[0];
+ else if (!cpus_have_cap(ARM64_WORKAROUND_CLEAN_CACHE))
+ updptr[0] = alt_insn->insn[1];
+}
Use the enhanced alternative_cb implementation to reimplement the code patching logic for DC CVAP instructions so that we don't fall back to DV CVAC instructions on systems that require those to be upgraded to DC CIVAC to work around silicon errata. At the same time, we don't want to use DV CIVAC needlessly, since doing so may adversely affect performance. Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> --- arch/arm64/include/asm/assembler.h | 9 +++++---- arch/arm64/kernel/cpu_errata.c | 14 ++++++++++++++ 2 files changed, 19 insertions(+), 4 deletions(-) -- 2.19.2