[PATCH v1 1/2] riscv: introduce assembly version of jump table
Andy Chiu
tchiu at tenstorrent.com
Fri Sep 11 11:23:59 PDT 2026
This is the introductary patch for us to call the user copy that
supports fast unaligned access after the runtime detection.
Signed-off-by: Andy Chiu <tchiu at tenstorrent.com>
---
arch/riscv/include/asm/jump_label.h | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/arch/riscv/include/asm/jump_label.h b/arch/riscv/include/asm/jump_label.h
index 3ab5f2e3212b..d75961ed3324 100644
--- a/arch/riscv/include/asm/jump_label.h
+++ b/arch/riscv/include/asm/jump_label.h
@@ -65,6 +65,32 @@ static __always_inline bool arch_static_branch_jump(struct static_key * const ke
label:
return true;
}
+#else
+#include <asm/asm.h>
+
+#define JUMP_TABLE_ENTRY(key, label) \
+ .pushsection __jump_table, "aw"; \
+ .align RISCV_LGPTR; \
+ .long 1b - ., label - .; \
+ RISCV_PTR key - .; \
+ .popsection
+
+#define ARCH_STATIC_BRANCH_ASM(key, label) \
+ .align 2; \
+ .option push; \
+ .option norelax; \
+ .option norvc; \
+1: nop; \
+ .option pop; \
+ JUMP_TABLE_ENTRY(key, label)
+#define ARCH_STATIC_BRANCH_JUMP_ASM(key, label) \
+ .align 2; \
+ .option push; \
+ .option norelax; \
+ .option norvc; \
+1: j label; \
+ .option pop; \
+ JUMP_TABLE_ENTRY(key, label)
#endif /* __ASSEMBLER__ */
#endif /* __ASM_JUMP_LABEL_H */
--
2.43.0
More information about the linux-riscv
mailing list