[PATCH 3/5] arm64/alternative_cb: add support for alternative sequences
From: Ard Biesheuvel
Date: Thu Dec 06 2018 - 10:59:51 EST
Permit callback type alternatives to carry a sequence of alternative
instructions, and leave it up to the callback handler to decide how
to use them.
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@xxxxxxxxxx>
---
arch/arm64/include/asm/alternative.h | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/arch/arm64/include/asm/alternative.h b/arch/arm64/include/asm/alternative.h
index 987c1514183a..6b7726ee6b0a 100644
--- a/arch/arm64/include/asm/alternative.h
+++ b/arch/arm64/include/asm/alternative.h
@@ -156,7 +156,7 @@ static inline void apply_alternatives_module(void *start, size_t length) { }
.popsection
.pushsection .altinstr_replacement, "ax"
663: .word \cb - .
-664: .popsection
+ .popsection
661:
.endm
@@ -185,10 +185,21 @@ static inline void apply_alternatives_module(void *start, size_t length) { }
.org . - (662b-661b) + (664b-663b)
.endm
+.macro alternative_cb_alt
+ .set .Lasm_alt_mode, 1
+ .pushsection .altinstr_replacement, "ax"
+ .org 663b + AARCH64_INSN_SIZE
+.endm
+
/*
* Callback-based alternative epilogue
*/
.macro alternative_cb_end
+ .if .Lasm_alt_mode==0
+ .pushsection .altinstr_replacement, "ax"
+ .org 663b + AARCH64_INSN_SIZE
+ .endif
+664: .popsection
662:
.endm
--
2.19.2