1313#include <linux/filter.h>
1414#include <asm/cacheflush.h>
1515
16+ /* verify runtime detection extension status */
17+ #define rv_ext_enabled (ext ) \
18+ (IS_ENABLED(CONFIG_RISCV_ISA_##ext) && riscv_has_extension_likely(RISCV_ISA_EXT_##ext))
19+
1620static inline bool rvc_enabled (void )
1721{
1822 return IS_ENABLED (CONFIG_RISCV_ISA_C );
1923}
2024
21- static inline bool rvzba_enabled (void )
22- {
23- return IS_ENABLED (CONFIG_RISCV_ISA_ZBA ) && riscv_has_extension_likely (RISCV_ISA_EXT_ZBA );
24- }
25-
26- static inline bool rvzbb_enabled (void )
27- {
28- return IS_ENABLED (CONFIG_RISCV_ISA_ZBB ) && riscv_has_extension_likely (RISCV_ISA_EXT_ZBB );
29- }
30-
3125enum {
3226 RV_REG_ZERO = 0 , /* The constant value 0 */
3327 RV_REG_RA = 1 , /* Return address */
@@ -1123,7 +1117,7 @@ static inline void emit_sw(u8 rs1, s32 off, u8 rs2, struct rv_jit_context *ctx)
11231117
11241118static inline void emit_sh2add (u8 rd , u8 rs1 , u8 rs2 , struct rv_jit_context * ctx )
11251119{
1126- if (rvzba_enabled ( )) {
1120+ if (rv_ext_enabled ( ZBA )) {
11271121 emit (rvzba_sh2add (rd , rs1 , rs2 ), ctx );
11281122 return ;
11291123 }
@@ -1134,7 +1128,7 @@ static inline void emit_sh2add(u8 rd, u8 rs1, u8 rs2, struct rv_jit_context *ctx
11341128
11351129static inline void emit_sh3add (u8 rd , u8 rs1 , u8 rs2 , struct rv_jit_context * ctx )
11361130{
1137- if (rvzba_enabled ( )) {
1131+ if (rv_ext_enabled ( ZBA )) {
11381132 emit (rvzba_sh3add (rd , rs1 , rs2 ), ctx );
11391133 return ;
11401134 }
@@ -1184,7 +1178,7 @@ static inline void emit_subw(u8 rd, u8 rs1, u8 rs2, struct rv_jit_context *ctx)
11841178
11851179static inline void emit_sextb (u8 rd , u8 rs , struct rv_jit_context * ctx )
11861180{
1187- if (rvzbb_enabled ( )) {
1181+ if (rv_ext_enabled ( ZBB )) {
11881182 emit (rvzbb_sextb (rd , rs ), ctx );
11891183 return ;
11901184 }
@@ -1195,7 +1189,7 @@ static inline void emit_sextb(u8 rd, u8 rs, struct rv_jit_context *ctx)
11951189
11961190static inline void emit_sexth (u8 rd , u8 rs , struct rv_jit_context * ctx )
11971191{
1198- if (rvzbb_enabled ( )) {
1192+ if (rv_ext_enabled ( ZBB )) {
11991193 emit (rvzbb_sexth (rd , rs ), ctx );
12001194 return ;
12011195 }
@@ -1211,7 +1205,7 @@ static inline void emit_sextw(u8 rd, u8 rs, struct rv_jit_context *ctx)
12111205
12121206static inline void emit_zexth (u8 rd , u8 rs , struct rv_jit_context * ctx )
12131207{
1214- if (rvzbb_enabled ( )) {
1208+ if (rv_ext_enabled ( ZBB )) {
12151209 emit (rvzbb_zexth (rd , rs ), ctx );
12161210 return ;
12171211 }
@@ -1222,7 +1216,7 @@ static inline void emit_zexth(u8 rd, u8 rs, struct rv_jit_context *ctx)
12221216
12231217static inline void emit_zextw (u8 rd , u8 rs , struct rv_jit_context * ctx )
12241218{
1225- if (rvzba_enabled ( )) {
1219+ if (rv_ext_enabled ( ZBA )) {
12261220 emit (rvzba_zextw (rd , rs ), ctx );
12271221 return ;
12281222 }
@@ -1233,7 +1227,7 @@ static inline void emit_zextw(u8 rd, u8 rs, struct rv_jit_context *ctx)
12331227
12341228static inline void emit_bswap (u8 rd , s32 imm , struct rv_jit_context * ctx )
12351229{
1236- if (rvzbb_enabled ( )) {
1230+ if (rv_ext_enabled ( ZBB )) {
12371231 int bits = 64 - imm ;
12381232
12391233 emit (rvzbb_rev8 (rd , rd ), ctx );
0 commit comments