Building the Linux kernel with Clang and LLVM
 help / color / mirror / Atom feed
* [bpf-next:master 9/12] kernel/bpf/btf.c:8251:22: error: call to undeclared function 'btf_relocate_id'; ISO C99 and later do not support implicit function declarations
@ 2024-06-22  9:32 kernel test robot
  0 siblings, 0 replies; only message in thread
From: kernel test robot @ 2024-06-22  9:32 UTC (permalink / raw)
  To: Alan Maguire; +Cc: llvm, oe-kbuild-all, Andrii Nakryiko

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git master
head:   93265a0b79e48fde8ee23fb6e1195d7d99717063
commit: 8646db238997df36c6ad71a9d7e0b52ceee221b2 [9/12] libbpf,bpf: Share BTF relocate-related code with kernel
config: i386-buildonly-randconfig-003-20240622 (https://download.01.org/0day-ci/archive/20240622/202406221742.d2srFLVI-lkp@intel.com/config)
compiler: clang version 18.1.5 (https://github.com/llvm/llvm-project 617a15a9eac96088ae5e9134248d8236e34b91b1)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240622/202406221742.d2srFLVI-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202406221742.d2srFLVI-lkp@intel.com/

All error/warnings (new ones prefixed by >>):

>> kernel/bpf/btf.c:8251:22: error: call to undeclared function 'btf_relocate_id'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
    8251 |                 set->pairs[i].id = btf_relocate_id(btf, set->pairs[i].id);
         |                                    ^
   kernel/bpf/btf.c:8251:22: note: did you mean 'btf_relocate'?
   include/linux/btf.h:556:5: note: 'btf_relocate' declared here
     556 | int btf_relocate(struct btf *btf, const struct btf *base_btf, __u32 **map_ids);
         |     ^
   kernel/bpf/btf.c:8376:37: error: call to undeclared function 'btf_relocate_id'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
    8376 |                 ret = btf_check_kfunc_protos(btf, btf_relocate_id(btf, kset->set->pairs[i].id),
         |                                                   ^
   kernel/bpf/btf.c:8440:17: error: call to undeclared function 'btf_relocate_id'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
    8440 |                 dtor_btf_id = btf_relocate_id(btf, dtors[i].kfunc_btf_id);
         |                               ^
   kernel/bpf/btf.c:8529:26: error: call to undeclared function 'btf_relocate_id'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
    8529 |                 tab->dtors[i].btf_id = btf_relocate_id(btf, tab->dtors[i].btf_id);
         |                                        ^
   4 errors generated.
--
>> tools/lib/bpf/btf_relocate.c:206:23: warning: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Wsingle-bit-bitfield-constant-conversion]
     206 |                 info[id].needs_size = true;
         |                                     ^ ~~~~
   tools/lib/bpf/btf_relocate.c:256:25: warning: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Wsingle-bit-bitfield-constant-conversion]
     256 |                         base_info.needs_size = true;
         |                                              ^ ~~~~
   2 warnings generated.


vim +/btf_relocate_id +8251 kernel/bpf/btf.c

  8155	
  8156	static int btf_populate_kfunc_set(struct btf *btf, enum btf_kfunc_hook hook,
  8157					  const struct btf_kfunc_id_set *kset)
  8158	{
  8159		struct btf_kfunc_hook_filter *hook_filter;
  8160		struct btf_id_set8 *add_set = kset->set;
  8161		bool vmlinux_set = !btf_is_module(btf);
  8162		bool add_filter = !!kset->filter;
  8163		struct btf_kfunc_set_tab *tab;
  8164		struct btf_id_set8 *set;
  8165		u32 set_cnt, i;
  8166		int ret;
  8167	
  8168		if (hook >= BTF_KFUNC_HOOK_MAX) {
  8169			ret = -EINVAL;
  8170			goto end;
  8171		}
  8172	
  8173		if (!add_set->cnt)
  8174			return 0;
  8175	
  8176		tab = btf->kfunc_set_tab;
  8177	
  8178		if (tab && add_filter) {
  8179			u32 i;
  8180	
  8181			hook_filter = &tab->hook_filters[hook];
  8182			for (i = 0; i < hook_filter->nr_filters; i++) {
  8183				if (hook_filter->filters[i] == kset->filter) {
  8184					add_filter = false;
  8185					break;
  8186				}
  8187			}
  8188	
  8189			if (add_filter && hook_filter->nr_filters == BTF_KFUNC_FILTER_MAX_CNT) {
  8190				ret = -E2BIG;
  8191				goto end;
  8192			}
  8193		}
  8194	
  8195		if (!tab) {
  8196			tab = kzalloc(sizeof(*tab), GFP_KERNEL | __GFP_NOWARN);
  8197			if (!tab)
  8198				return -ENOMEM;
  8199			btf->kfunc_set_tab = tab;
  8200		}
  8201	
  8202		set = tab->sets[hook];
  8203		/* Warn when register_btf_kfunc_id_set is called twice for the same hook
  8204		 * for module sets.
  8205		 */
  8206		if (WARN_ON_ONCE(set && !vmlinux_set)) {
  8207			ret = -EINVAL;
  8208			goto end;
  8209		}
  8210	
  8211		/* In case of vmlinux sets, there may be more than one set being
  8212		 * registered per hook. To create a unified set, we allocate a new set
  8213		 * and concatenate all individual sets being registered. While each set
  8214		 * is individually sorted, they may become unsorted when concatenated,
  8215		 * hence re-sorting the final set again is required to make binary
  8216		 * searching the set using btf_id_set8_contains function work.
  8217		 *
  8218		 * For module sets, we need to allocate as we may need to relocate
  8219		 * BTF ids.
  8220		 */
  8221		set_cnt = set ? set->cnt : 0;
  8222	
  8223		if (set_cnt > U32_MAX - add_set->cnt) {
  8224			ret = -EOVERFLOW;
  8225			goto end;
  8226		}
  8227	
  8228		if (set_cnt + add_set->cnt > BTF_KFUNC_SET_MAX_CNT) {
  8229			ret = -E2BIG;
  8230			goto end;
  8231		}
  8232	
  8233		/* Grow set */
  8234		set = krealloc(tab->sets[hook],
  8235			       offsetof(struct btf_id_set8, pairs[set_cnt + add_set->cnt]),
  8236			       GFP_KERNEL | __GFP_NOWARN);
  8237		if (!set) {
  8238			ret = -ENOMEM;
  8239			goto end;
  8240		}
  8241	
  8242		/* For newly allocated set, initialize set->cnt to 0 */
  8243		if (!tab->sets[hook])
  8244			set->cnt = 0;
  8245		tab->sets[hook] = set;
  8246	
  8247		/* Concatenate the two sets */
  8248		memcpy(set->pairs + set->cnt, add_set->pairs, add_set->cnt * sizeof(set->pairs[0]));
  8249		/* Now that the set is copied, update with relocated BTF ids */
  8250		for (i = set->cnt; i < set->cnt + add_set->cnt; i++)
> 8251			set->pairs[i].id = btf_relocate_id(btf, set->pairs[i].id);
  8252	
  8253		set->cnt += add_set->cnt;
  8254	
  8255		sort(set->pairs, set->cnt, sizeof(set->pairs[0]), btf_id_cmp_func, NULL);
  8256	
  8257		if (add_filter) {
  8258			hook_filter = &tab->hook_filters[hook];
  8259			hook_filter->filters[hook_filter->nr_filters++] = kset->filter;
  8260		}
  8261		return 0;
  8262	end:
  8263		btf_free_kfunc_set_tab(btf);
  8264		return ret;
  8265	}
  8266	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-06-22  9:32 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-22  9:32 [bpf-next:master 9/12] kernel/bpf/btf.c:8251:22: error: call to undeclared function 'btf_relocate_id'; ISO C99 and later do not support implicit function declarations kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox