@@ -1403,23 +1403,21 @@ static inline void emit_ar_r(const u8 rd, const u8 rt, const u8 rm,
14031403 }
14041404}
14051405
1406- static int out_offset = -1 ; /* initialized on the first pass of build_body() */
14071406
1407+ /* Helper bpf_tail_call(void *prog_ctx, struct bpf_array *array, u32 index) */
1408+ #define cur_offset (ctx->idx - idx0)
1409+ #define jmp_offset (out_offset - (cur_offset) - 2)
14081410static int emit_bpf_tail_call (struct jit_ctx * ctx )
14091411{
1410-
1411- /* bpf_tail_call(void *prog_ctx, struct bpf_array *array, u64 index) */
14121412 const s8 * r2 = bpf2a32 [BPF_REG_2 ];
14131413 const s8 * r3 = bpf2a32 [BPF_REG_3 ];
14141414 const s8 * tmp = bpf2a32 [TMP_REG_1 ];
14151415 const s8 * tmp2 = bpf2a32 [TMP_REG_2 ];
14161416 const s8 * tcc = bpf2a32 [TCALL_CNT ];
1417- const s8 * tc ;
1417+ static int out_offset = -1 ; /* initialized on JIT 1st pass */
14181418 const int idx0 = ctx -> idx ;
1419- #define cur_offset (ctx->idx - idx0)
1420- #define jmp_offset (out_offset - (cur_offset) - 2)
1421- u32 lo , hi ;
1422- s8 r_array , r_index ;
1419+ u32 tc_max ;
1420+ s8 tc , r_array , r_index ;
14231421 int off ;
14241422
14251423 /* if (index >= array->map.max_entries)
@@ -1444,15 +1442,12 @@ static int emit_bpf_tail_call(struct jit_ctx *ctx)
14441442 * goto out;
14451443 * tail_call_cnt++;
14461444 */
1447- lo = (u32 )MAX_TAIL_CALL_CNT ;
1448- hi = (u32 )((u64 )MAX_TAIL_CALL_CNT >> 32 );
1449- tc = arm_bpf_get_reg64 (tcc , tmp , ctx );
1450- emit (ARM_CMP_I (tc [0 ], hi ), ctx );
1451- _emit (ARM_COND_EQ , ARM_CMP_I (tc [1 ], lo ), ctx );
1445+ tc_max = (u32 )MAX_TAIL_CALL_CNT ;
1446+ tc = arm_bpf_get_reg32 (tcc [1 ], tmp [1 ], ctx );
1447+ emit (ARM_CMP_I (tc , tc_max ), ctx );
14521448 _emit (ARM_COND_CS , ARM_B (jmp_offset ), ctx );
1453- emit (ARM_ADDS_I (tc [1 ], tc [1 ], 1 ), ctx );
1454- emit (ARM_ADC_I (tc [0 ], tc [0 ], 0 ), ctx );
1455- arm_bpf_put_reg64 (tcc , tmp , ARM_LR , ctx );
1449+ emit (ARM_ADD_I (tc , tc , 1 ), ctx );
1450+ arm_bpf_put_reg32 (tcc [1 ], tc , tmp [0 ], ctx );
14561451
14571452 /* prog = array->ptrs[index]
14581453 * if (prog == NULL)
@@ -1485,9 +1480,9 @@ static int emit_bpf_tail_call(struct jit_ctx *ctx)
14851480 return -1 ;
14861481 }
14871482 return 0 ;
1483+ }
14881484#undef cur_offset
14891485#undef jmp_offset
1490- }
14911486
14921487/* 0xabcd => 0xcdab */
14931488static inline void emit_rev16 (const u8 rd , const u8 rn , struct jit_ctx * ctx )
0 commit comments