@@ -2284,24 +2284,23 @@ bool bpf_jit_supports_subprog_tailcalls(void)
22842284 return true;
22852285}
22862286
2287- static void invoke_bpf_prog (struct jit_ctx * ctx , struct bpf_tramp_link * l ,
2287+ static void invoke_bpf_prog (struct jit_ctx * ctx , struct bpf_prog * p , u64 cookie ,
22882288 int bargs_off , int retval_off , int run_ctx_off ,
22892289 bool save_ret )
22902290{
22912291 __le32 * branch ;
22922292 u64 enter_prog ;
22932293 u64 exit_prog ;
2294- struct bpf_prog * p = l -> link .prog ;
22952294 int cookie_off = offsetof(struct bpf_tramp_run_ctx , bpf_cookie );
22962295
22972296 enter_prog = (u64 )bpf_trampoline_enter (p );
22982297 exit_prog = (u64 )bpf_trampoline_exit (p );
22992298
2300- if (l -> cookie == 0 ) {
2299+ if (cookie == 0 ) {
23012300 /* if cookie is zero, one instruction is enough to store it */
23022301 emit (A64_STR64I (A64_ZR , A64_SP , run_ctx_off + cookie_off ), ctx );
23032302 } else {
2304- emit_a64_mov_i64 (A64_R (10 ), l -> cookie , ctx );
2303+ emit_a64_mov_i64 (A64_R (10 ), cookie , ctx );
23052304 emit (A64_STR64I (A64_R (10 ), A64_SP , run_ctx_off + cookie_off ),
23062305 ctx );
23072306 }
@@ -2362,7 +2361,8 @@ static void invoke_bpf_mod_ret(struct jit_ctx *ctx, struct bpf_tramp_links *tl,
23622361 */
23632362 emit (A64_STR64I (A64_ZR , A64_SP , retval_off ), ctx );
23642363 for (i = 0 ; i < tl -> nr_links ; i ++ ) {
2365- invoke_bpf_prog (ctx , tl -> links [i ], bargs_off , retval_off ,
2364+ invoke_bpf_prog (ctx , bpf_tramp_links_prog (tl , i ),
2365+ tl -> links [i ]-> cookie , bargs_off , retval_off ,
23662366 run_ctx_off , true);
23672367 /* if (*(u64 *)(sp + retval_off) != 0)
23682368 * goto do_fexit;
@@ -2656,8 +2656,9 @@ static int prepare_trampoline(struct jit_ctx *ctx, struct bpf_tramp_image *im,
26562656 }
26572657
26582658 for (i = 0 ; i < fentry -> nr_links ; i ++ )
2659- invoke_bpf_prog (ctx , fentry -> links [i ], bargs_off ,
2660- retval_off , run_ctx_off ,
2659+ invoke_bpf_prog (ctx , bpf_tramp_links_prog (fentry , i ),
2660+ fentry -> links [i ]-> cookie , bargs_off , retval_off ,
2661+ run_ctx_off ,
26612662 flags & BPF_TRAMP_F_RET_FENTRY_RET );
26622663
26632664 if (fmod_ret -> nr_links ) {
@@ -2691,7 +2692,8 @@ static int prepare_trampoline(struct jit_ctx *ctx, struct bpf_tramp_image *im,
26912692 }
26922693
26932694 for (i = 0 ; i < fexit -> nr_links ; i ++ )
2694- invoke_bpf_prog (ctx , fexit -> links [i ], bargs_off , retval_off ,
2695+ invoke_bpf_prog (ctx , bpf_tramp_links_prog (fexit , i ),
2696+ fexit -> links [i ]-> cookie , bargs_off , retval_off ,
26952697 run_ctx_off , false);
26962698
26972699 if (flags & BPF_TRAMP_F_CALL_ORIG ) {
@@ -2829,6 +2831,11 @@ int arch_prepare_bpf_trampoline(struct bpf_tramp_image *im, void *ro_image,
28292831 return ret ;
28302832}
28312833
2834+ bool bpf_trampoline_supports_update_prog (void )
2835+ {
2836+ return true;
2837+ }
2838+
28322839static bool is_long_jump (void * ip , void * target )
28332840{
28342841 long offset ;
0 commit comments