[PATCH v3 04/18] arm64: assembler: user_alt label optional

Fuad Tabba tabba at google.com
Thu May 20 05:43:52 PDT 2021


Make the label for the extable entry in user_alt optional, only
generating an extable entry if provided.

This is needed later in the series, to avoid instruction
duplication in the assembly code.

While at it, clean up the label used to be globally unique using
\@ as for other macros.

Signed-off-by: Fuad Tabba <tabba at google.com>
---
 arch/arm64/include/asm/alternative-macros.h | 9 ++++++---
 arch/arm64/mm/cache.S                       | 2 +-
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/arch/arm64/include/asm/alternative-macros.h b/arch/arm64/include/asm/alternative-macros.h
index 8a078fc662ac..01ef954c9b2d 100644
--- a/arch/arm64/include/asm/alternative-macros.h
+++ b/arch/arm64/include/asm/alternative-macros.h
@@ -197,9 +197,12 @@ alternative_endif
 #define _ALTERNATIVE_CFG(insn1, insn2, cap, cfg, ...)	\
 	alternative_insn insn1, insn2, cap, IS_ENABLED(cfg)
 
-.macro user_alt, label, oldinstr, newinstr, cond
-9999:	alternative_insn "\oldinstr", "\newinstr", \cond
-	_asm_extable 9999b, \label
+.macro user_alt, oldinstr, newinstr, cond, label
+.Lextable_\@:
+	alternative_insn "\oldinstr", "\newinstr", \cond
+	.ifnc \label,
+	_asm_extable .Lextable_\@, \label
+	.endif
 .endm
 
 #endif  /*  __ASSEMBLY__  */
diff --git a/arch/arm64/mm/cache.S b/arch/arm64/mm/cache.S
index 2d881f34dd9d..5ff8dfa86975 100644
--- a/arch/arm64/mm/cache.S
+++ b/arch/arm64/mm/cache.S
@@ -47,7 +47,7 @@ alternative_else_nop_endif
 	sub	x3, x2, #1
 	bic	x4, x0, x3
 1:
-user_alt 9f, "dc cvau, x4",  "dc civac, x4",  ARM64_WORKAROUND_CLEAN_CACHE
+user_alt "dc cvau, x4",  "dc civac, x4",  ARM64_WORKAROUND_CLEAN_CACHE, 9f
 	add	x4, x4, x2
 	cmp	x4, x1
 	b.lo	1b
-- 
2.31.1.751.gd2f1c929bd-goog




More information about the linux-arm-kernel mailing list