@@ -1452,6 +1452,10 @@ static int build_insn(const struct bpf_insn *insn, struct jit_ctx *ctx,
14521452 emit (A64_ASR (is64 , dst , dst , imm ), ctx );
14531453 break ;
14541454
1455+ /* JUMP reg */
1456+ case BPF_JMP | BPF_JA | BPF_X :
1457+ emit (A64_BR (dst ), ctx );
1458+ break ;
14551459 /* JUMP off */
14561460 case BPF_JMP | BPF_JA :
14571461 case BPF_JMP32 | BPF_JA :
@@ -2231,6 +2235,13 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog)
22312235 for (i = 0 ; i <= prog -> len ; i ++ )
22322236 ctx .offset [i ] *= AARCH64_INSN_SIZE ;
22332237 bpf_prog_fill_jited_linfo (prog , ctx .offset + 1 );
2238+ /*
2239+ * The bpf_prog_update_insn_ptrs function expects offsets to
2240+ * point to the first byte of the jitted instruction (unlike
2241+ * the bpf_prog_fill_jited_linfo above, which, for historical
2242+ * reasons, expects to point to the next instruction)
2243+ */
2244+ bpf_prog_update_insn_ptrs (prog , ctx .offset , ctx .ro_image );
22342245out_off :
22352246 if (!ro_header && priv_stack_ptr ) {
22362247 free_percpu (priv_stack_ptr );
@@ -2923,8 +2934,9 @@ static int gen_branch_or_nop(enum aarch64_insn_branch_type type, void *ip,
29232934 * The dummy_tramp is used to prevent another CPU from jumping to unknown
29242935 * locations during the patching process, making the patching process easier.
29252936 */
2926- int bpf_arch_text_poke (void * ip , enum bpf_text_poke_type poke_type ,
2927- void * old_addr , void * new_addr )
2937+ int bpf_arch_text_poke (void * ip , enum bpf_text_poke_type old_t ,
2938+ enum bpf_text_poke_type new_t , void * old_addr ,
2939+ void * new_addr )
29282940{
29292941 int ret ;
29302942 u32 old_insn ;
@@ -2968,14 +2980,13 @@ int bpf_arch_text_poke(void *ip, enum bpf_text_poke_type poke_type,
29682980 !poking_bpf_entry ))
29692981 return - EINVAL ;
29702982
2971- if (poke_type == BPF_MOD_CALL )
2972- branch_type = AARCH64_INSN_BRANCH_LINK ;
2973- else
2974- branch_type = AARCH64_INSN_BRANCH_NOLINK ;
2975-
2983+ branch_type = old_t == BPF_MOD_CALL ? AARCH64_INSN_BRANCH_LINK :
2984+ AARCH64_INSN_BRANCH_NOLINK ;
29762985 if (gen_branch_or_nop (branch_type , ip , old_addr , plt , & old_insn ) < 0 )
29772986 return - EFAULT ;
29782987
2988+ branch_type = new_t == BPF_MOD_CALL ? AARCH64_INSN_BRANCH_LINK :
2989+ AARCH64_INSN_BRANCH_NOLINK ;
29792990 if (gen_branch_or_nop (branch_type , ip , new_addr , plt , & new_insn ) < 0 )
29802991 return - EFAULT ;
29812992
0 commit comments