lkml.org 
[lkml]   [2018]   [Dec]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 4/5] arm64/assembler: use callback to 3-way alt-patch DC CVAP instructions
Date
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(-)

diff --git a/arch/arm64/include/asm/assembler.h b/arch/arm64/include/asm/assembler.h
index 6142402c2eb4..09c5a5452f60 100644
--- a/arch/arm64/include/asm/assembler.h
+++ b/arch/arm64/include/asm/assembler.h
@@ -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
diff --git a/arch/arm64/kernel/cpu_errata.c b/arch/arm64/kernel/cpu_errata.c
index c5489b4612c5..a63e362da307 100644
--- a/arch/arm64/kernel/cpu_errata.c
+++ b/arch/arm64/kernel/cpu_errata.c
@@ -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];
+}
--
2.19.2
\
 
 \ /
  Last update: 2018-12-06 17:00    [W:0.053 / U:0.068 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site