Skip to content

Commit 0b2f658

Browse files
Andrew Jonespalmer-dabbelt
authored andcommitted
RISC-V: alternatives: Support patching multiple insns in assembly
As pointed out in commit d374a16 ("RISC-V: fix compile error from deduplicated __ALTERNATIVE_CFG_2"), we need quotes around parameters passed to macros within macros to avoid spaces being interpreted as separators. ALT_NEW_CONTENT was trying to handle this by defining new_c has a vararg, but this isn't sufficient for calling ALTERNATIVE() from assembly with multiple instructions in the new/old sequences. Remove the vararg "hack" and use quotes. Signed-off-by: Andrew Jones <ajones@ventanamicro.com> Reviewed-by: Conor Dooley <conor.dooley@microchip.com> Link: https://lore.kernel.org/r/20230224162631.405473-2-ajones@ventanamicro.com Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
1 parent 816a697 commit 0b2f658

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

arch/riscv/include/asm/alternative-macros.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
.4byte \patch_id
1515
.endm
1616

17-
.macro ALT_NEW_CONTENT vendor_id, patch_id, enable = 1, new_c : vararg
17+
.macro ALT_NEW_CONTENT vendor_id, patch_id, enable = 1, new_c
1818
.if \enable
1919
.pushsection .alternative, "a"
2020
ALT_ENTRY 886b, 888f, \vendor_id, \patch_id, 889f - 888f
@@ -41,13 +41,13 @@
4141
\old_c
4242
.option pop
4343
887 :
44-
ALT_NEW_CONTENT \vendor_id, \patch_id, \enable, \new_c
44+
ALT_NEW_CONTENT \vendor_id, \patch_id, \enable, "\new_c"
4545
.endm
4646

4747
.macro ALTERNATIVE_CFG_2 old_c, new_c_1, vendor_id_1, patch_id_1, enable_1, \
4848
new_c_2, vendor_id_2, patch_id_2, enable_2
4949
ALTERNATIVE_CFG "\old_c", "\new_c_1", \vendor_id_1, \patch_id_1, \enable_1
50-
ALT_NEW_CONTENT \vendor_id_2, \patch_id_2, \enable_2, \new_c_2
50+
ALT_NEW_CONTENT \vendor_id_2, \patch_id_2, \enable_2, "\new_c_2"
5151
.endm
5252

5353
#define __ALTERNATIVE_CFG(...) ALTERNATIVE_CFG __VA_ARGS__

0 commit comments

Comments
 (0)