Passing image struct to reg/unreg/modify fentry functions as a preparation for following change, where we need to use the whole image in the update logic. Signed-off-by: Jiri Olsa <jolsa@xxxxxxxxxx> --- kernel/bpf/trampoline.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/kernel/bpf/trampoline.c b/kernel/bpf/trampoline.c index c0983ff5aa3a..d28070247fa3 100644 --- a/kernel/bpf/trampoline.c +++ b/kernel/bpf/trampoline.c @@ -244,8 +244,9 @@ static void bpf_trampoline_module_put(struct bpf_trampoline *tr) tr->mod = NULL; } -static int unregister_fentry(struct bpf_trampoline *tr, void *old_addr) +static int unregister_fentry(struct bpf_trampoline *tr, struct bpf_tramp_image *im) { + void *old_addr = im->image; void *ip = tr->func.addr; int ret; @@ -259,9 +260,11 @@ static int unregister_fentry(struct bpf_trampoline *tr, void *old_addr) return ret; } -static int modify_fentry(struct bpf_trampoline *tr, void *old_addr, void *new_addr, +static int modify_fentry(struct bpf_trampoline *tr, struct bpf_tramp_image *im, bool lock_direct_mutex) { + void *old_addr = tr->cur_image->image; + void *new_addr = im->image; void *ip = tr->func.addr; int ret; @@ -277,8 +280,9 @@ static int modify_fentry(struct bpf_trampoline *tr, void *old_addr, void *new_ad } /* first time registering */ -static int register_fentry(struct bpf_trampoline *tr, void *new_addr) +static int register_fentry(struct bpf_trampoline *tr, struct bpf_tramp_image *im) { + void *new_addr = im->image; void *ip = tr->func.addr; unsigned long faddr; int ret; @@ -486,7 +490,7 @@ static int bpf_trampoline_update(struct bpf_trampoline *tr, bool lock_direct_mut return PTR_ERR(tprogs); if (total == 0) { - err = unregister_fentry(tr, tr->cur_image->image); + err = unregister_fentry(tr, tr->cur_image); bpf_tramp_image_put(tr->cur_image); tr->cur_image = NULL; tr->selector = 0; @@ -532,10 +536,10 @@ static int bpf_trampoline_update(struct bpf_trampoline *tr, bool lock_direct_mut WARN_ON(!tr->cur_image && tr->selector); if (tr->cur_image) /* progs already running at this address */ - err = modify_fentry(tr, tr->cur_image->image, im->image, lock_direct_mutex); + err = modify_fentry(tr, im, lock_direct_mutex); else /* first time registering */ - err = register_fentry(tr, im->image); + err = register_fentry(tr, im); #ifdef CONFIG_DYNAMIC_FTRACE_WITH_DIRECT_CALLS if (err == -EAGAIN) { -- 2.37.1