Commit 0b2f658f authored by Andrew Jones's avatar Andrew Jones Committed by Palmer Dabbelt

RISC-V: alternatives: Support patching multiple insns in assembly

As pointed out in commit d374a165 ("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: default avatarAndrew Jones <ajones@ventanamicro.com>
Reviewed-by: default avatarConor Dooley <conor.dooley@microchip.com>
Link: https://lore.kernel.org/r/20230224162631.405473-2-ajones@ventanamicro.comSigned-off-by: default avatarPalmer Dabbelt <palmer@rivosinc.com>
parent 816a6974
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
.4byte \patch_id .4byte \patch_id
.endm .endm
.macro ALT_NEW_CONTENT vendor_id, patch_id, enable = 1, new_c : vararg .macro ALT_NEW_CONTENT vendor_id, patch_id, enable = 1, new_c
.if \enable .if \enable
.pushsection .alternative, "a" .pushsection .alternative, "a"
ALT_ENTRY 886b, 888f, \vendor_id, \patch_id, 889f - 888f ALT_ENTRY 886b, 888f, \vendor_id, \patch_id, 889f - 888f
...@@ -41,13 +41,13 @@ ...@@ -41,13 +41,13 @@
\old_c \old_c
.option pop .option pop
887 : 887 :
ALT_NEW_CONTENT \vendor_id, \patch_id, \enable, \new_c ALT_NEW_CONTENT \vendor_id, \patch_id, \enable, "\new_c"
.endm .endm
.macro ALTERNATIVE_CFG_2 old_c, new_c_1, vendor_id_1, patch_id_1, enable_1, \ .macro ALTERNATIVE_CFG_2 old_c, new_c_1, vendor_id_1, patch_id_1, enable_1, \
new_c_2, vendor_id_2, patch_id_2, enable_2 new_c_2, vendor_id_2, patch_id_2, enable_2
ALTERNATIVE_CFG "\old_c", "\new_c_1", \vendor_id_1, \patch_id_1, \enable_1 ALTERNATIVE_CFG "\old_c", "\new_c_1", \vendor_id_1, \patch_id_1, \enable_1
ALT_NEW_CONTENT \vendor_id_2, \patch_id_2, \enable_2, \new_c_2 ALT_NEW_CONTENT \vendor_id_2, \patch_id_2, \enable_2, "\new_c_2"
.endm .endm
#define __ALTERNATIVE_CFG(...) ALTERNATIVE_CFG __VA_ARGS__ #define __ALTERNATIVE_CFG(...) ALTERNATIVE_CFG __VA_ARGS__
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment