[jolsa-perf:bpf/batch 17/27] kernel/bpf/syscall.c:2937:15: warning: assignment to 'struct bpf_trampoline_multi *' from 'int' makes pointer from integer without a cast

From: kernel test robot
Date: Thu Aug 26 2021 - 23:45:08 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git bpf/batch
head: b81b17307e02f8e6d4abf87e7ec2d7e5aea1e0b5
commit: 66743c721839b670923e1cae1dc5ae502c0a545d [17/27] bpf: Add multi trampoline attach support
config: arc-allyesconfig (attached as .config)
compiler: arceb-elf-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git/commit/?id=66743c721839b670923e1cae1dc5ae502c0a545d
git remote add jolsa-perf https://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git
git fetch --no-tags jolsa-perf bpf/batch
git checkout 66743c721839b670923e1cae1dc5ae502c0a545d
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross ARCH=arc

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>

All warnings (new ones prefixed by >>):

In file included from include/linux/perf_event.h:49,
from include/linux/trace_events.h:10,
from include/trace/syscall.h:7,
from include/linux/syscalls.h:87,
from kernel/bpf/syscall.c:9:
include/linux/ftrace.h:353:41: warning: 'struct ftrace_ops' declared inside parameter list will not be visible outside of this definition or declaration
353 | int register_ftrace_direct_multi(struct ftrace_ops *ops, unsigned long addr)
| ^~~~~~~~~~
include/linux/ftrace.h:353:5: warning: no previous prototype for 'register_ftrace_direct_multi' [-Wmissing-prototypes]
353 | int register_ftrace_direct_multi(struct ftrace_ops *ops, unsigned long addr)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/ftrace.h:357:43: warning: 'struct ftrace_ops' declared inside parameter list will not be visible outside of this definition or declaration
357 | int unregister_ftrace_direct_multi(struct ftrace_ops *ops)
| ^~~~~~~~~~
include/linux/ftrace.h:357:5: warning: no previous prototype for 'unregister_ftrace_direct_multi' [-Wmissing-prototypes]
357 | int unregister_ftrace_direct_multi(struct ftrace_ops *ops)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/ftrace.h:361:39: warning: 'struct ftrace_ops' declared inside parameter list will not be visible outside of this definition or declaration
361 | int modify_ftrace_direct_multi(struct ftrace_ops *ops, unsigned long addr)
| ^~~~~~~~~~
include/linux/ftrace.h:361:5: warning: no previous prototype for 'modify_ftrace_direct_multi' [-Wmissing-prototypes]
361 | int modify_ftrace_direct_multi(struct ftrace_ops *ops, unsigned long addr)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
kernel/bpf/syscall.c: In function 'bpf_tracing_multi_link_release':
kernel/bpf/syscall.c:2866:9: error: implicit declaration of function 'bpf_trampoline_multi_unlink_prog'; did you mean 'bpf_trampoline_unlink_prog'? [-Werror=implicit-function-declaration]
2866 | bpf_trampoline_multi_unlink_prog(link->prog, tr_link->multi);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| bpf_trampoline_unlink_prog
kernel/bpf/syscall.c: In function 'bpf_tracing_multi_link_dealloc':
kernel/bpf/syscall.c:2874:9: error: implicit declaration of function 'bpf_trampoline_multi_put'; did you mean 'bpf_trampoline_put'? [-Werror=implicit-function-declaration]
2874 | bpf_trampoline_multi_put(tr_link->multi);
| ^~~~~~~~~~~~~~~~~~~~~~~~
| bpf_trampoline_put
kernel/bpf/syscall.c: In function 'bpf_tracing_multi_attach':
kernel/bpf/syscall.c:2937:17: error: implicit declaration of function 'bpf_trampoline_multi_get'; did you mean 'bpf_trampoline_get'? [-Werror=implicit-function-declaration]
2937 | multi = bpf_trampoline_multi_get(prog, btf_ids, cnt);
| ^~~~~~~~~~~~~~~~~~~~~~~~
| bpf_trampoline_get
>> kernel/bpf/syscall.c:2937:15: warning: assignment to 'struct bpf_trampoline_multi *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
2937 | multi = bpf_trampoline_multi_get(prog, btf_ids, cnt);
| ^
kernel/bpf/syscall.c:2957:15: error: implicit declaration of function 'bpf_trampoline_multi_link_prog'; did you mean 'bpf_trampoline_unlink_prog'? [-Werror=implicit-function-declaration]
2957 | err = bpf_trampoline_multi_link_prog(prog, multi);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| bpf_trampoline_unlink_prog
In file included from include/linux/perf_event.h:25,
from include/linux/trace_events.h:10,
from include/trace/syscall.h:7,
from include/linux/syscalls.h:87,
from kernel/bpf/syscall.c:9:
At top level:
arch/arc/include/asm/perf_event.h:126:27: warning: 'arc_pmu_cache_map' defined but not used [-Wunused-const-variable=]
126 | static const unsigned int arc_pmu_cache_map[C(MAX)][C(OP_MAX)][C(RESULT_MAX)] = {
| ^~~~~~~~~~~~~~~~~
arch/arc/include/asm/perf_event.h:91:27: warning: 'arc_pmu_ev_hw_map' defined but not used [-Wunused-const-variable=]
91 | static const char * const arc_pmu_ev_hw_map[] = {
| ^~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors


vim +2937 kernel/bpf/syscall.c

2868
2869 static void bpf_tracing_multi_link_dealloc(struct bpf_link *link)
2870 {
2871 struct bpf_tracing_multi_link *tr_link =
2872 container_of(link, struct bpf_tracing_multi_link, link);
2873
> 2874 bpf_trampoline_multi_put(tr_link->multi);
2875 kfree(tr_link);
2876 }
2877
2878 static void bpf_tracing_multi_link_show_fdinfo(const struct bpf_link *link,
2879 struct seq_file *seq)
2880 {
2881 struct bpf_tracing_multi_link *tr_link =
2882 container_of(link, struct bpf_tracing_multi_link, link);
2883
2884 seq_printf(seq, "attach_type:\t%d\n", tr_link->attach_type);
2885 }
2886
2887 static int bpf_tracing_multi_link_fill_link_info(const struct bpf_link *link,
2888 struct bpf_link_info *info)
2889 {
2890 struct bpf_tracing_multi_link *tr_link =
2891 container_of(link, struct bpf_tracing_multi_link, link);
2892
2893 info->tracing.attach_type = tr_link->attach_type;
2894 return 0;
2895 }
2896
2897 static int check_multi_prog_type(struct bpf_prog *prog)
2898 {
2899 if (prog->expected_attach_type != BPF_TRACE_FENTRY &&
2900 prog->expected_attach_type != BPF_TRACE_FEXIT)
2901 return -EINVAL;
2902 return 0;
2903 }
2904
2905 static const struct bpf_link_ops bpf_tracing_multi_link_lops = {
2906 .release = bpf_tracing_multi_link_release,
2907 .dealloc = bpf_tracing_multi_link_dealloc,
2908 .show_fdinfo = bpf_tracing_multi_link_show_fdinfo,
2909 .fill_link_info = bpf_tracing_multi_link_fill_link_info,
2910 };
2911
2912 static int bpf_tracing_multi_attach(struct bpf_prog *prog,
2913 const union bpf_attr *attr)
2914 {
2915 void __user *ubtf_ids = u64_to_user_ptr(attr->link_create.multi_btf_ids);
2916 u32 size, cnt = attr->link_create.multi_btf_ids_cnt;
2917 struct bpf_tracing_multi_link *link = NULL;
2918 struct bpf_link_primer link_primer;
2919 struct bpf_trampoline_multi *multi = NULL;
2920 int err = -EINVAL;
2921 u32 *btf_ids;
2922
2923 if (check_multi_prog_type(prog))
2924 return -EINVAL;
2925 if (!cnt)
2926 return -EINVAL;
2927
2928 size = cnt * sizeof(*btf_ids);
2929 btf_ids = kmalloc(size, GFP_USER | __GFP_NOWARN);
2930 if (!btf_ids)
2931 return -ENOMEM;
2932
2933 err = -EFAULT;
2934 if (ubtf_ids && copy_from_user(btf_ids, ubtf_ids, size))
2935 goto out_free_ids;
2936
> 2937 multi = bpf_trampoline_multi_get(prog, btf_ids, cnt);
2938 if (IS_ERR(multi)) {
2939 err = PTR_ERR(multi);
2940 goto out_free_ids;
2941 }
2942
2943 link = kzalloc(sizeof(*link), GFP_USER);
2944 if (!link) {
2945 err = -ENOMEM;
2946 goto out_free;
2947 }
2948
2949 bpf_link_init(&link->link, BPF_LINK_TYPE_TRACING_MULTI,
2950 &bpf_tracing_multi_link_lops, prog);
2951 link->attach_type = prog->expected_attach_type;
2952 link->multi = multi;
2953
2954 err = bpf_link_prime(&link->link, &link_primer);
2955 if (err)
2956 goto out_free;
2957 err = bpf_trampoline_multi_link_prog(prog, multi);
2958 if (err)
2959 goto out_free;
2960 return bpf_link_settle(&link_primer);
2961
2962 out_free:
2963 bpf_trampoline_multi_put(multi);
2964 kfree(link);
2965 out_free_ids:
2966 kfree(btf_ids);
2967 return err;
2968 }
2969

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx

Attachment: .config.gz
Description: application/gzip