Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'Fixes for kfunc-mod regressions and warnings'

Kumar Kartikeya says:

====================

This set includes fixes for two regressions and one build warning introduced by
the kfunc for modules series.

Changelog:
----------

v1 -> v2:
v1: https://lore.kernel.org/bpf/20211115191840.496263-1-memxor@gmail.com

* Instead of demoting resolve_btfids warning to debug, only skip in case of
set->cnt == 0.
====================

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>

+18 -16
+10 -4
include/linux/btf.h
··· 245 245 struct module *owner; 246 246 }; 247 247 248 - struct kfunc_btf_id_list; 248 + struct kfunc_btf_id_list { 249 + struct list_head list; 250 + struct mutex mutex; 251 + }; 249 252 250 253 #ifdef CONFIG_DEBUG_INFO_BTF_MODULES 251 254 void register_kfunc_btf_id_set(struct kfunc_btf_id_list *l, ··· 257 254 struct kfunc_btf_id_set *s); 258 255 bool bpf_check_mod_kfunc_call(struct kfunc_btf_id_list *klist, u32 kfunc_id, 259 256 struct module *owner); 257 + 258 + extern struct kfunc_btf_id_list bpf_tcp_ca_kfunc_list; 259 + extern struct kfunc_btf_id_list prog_test_kfunc_list; 260 260 #else 261 261 static inline void register_kfunc_btf_id_set(struct kfunc_btf_id_list *l, 262 262 struct kfunc_btf_id_set *s) ··· 274 268 { 275 269 return false; 276 270 } 271 + 272 + static struct kfunc_btf_id_list bpf_tcp_ca_kfunc_list __maybe_unused; 273 + static struct kfunc_btf_id_list prog_test_kfunc_list __maybe_unused; 277 274 #endif 278 275 279 276 #define DEFINE_KFUNC_BTF_ID_SET(set, name) \ 280 277 struct kfunc_btf_id_set name = { LIST_HEAD_INIT(name.list), (set), \ 281 278 THIS_MODULE } 282 - 283 - extern struct kfunc_btf_id_list bpf_tcp_ca_kfunc_list; 284 - extern struct kfunc_btf_id_list prog_test_kfunc_list; 285 279 286 280 #endif
+2 -9
kernel/bpf/btf.c
··· 6346 6346 6347 6347 /* BTF ID set registration API for modules */ 6348 6348 6349 - struct kfunc_btf_id_list { 6350 - struct list_head list; 6351 - struct mutex mutex; 6352 - }; 6353 - 6354 6349 #ifdef CONFIG_DEBUG_INFO_BTF_MODULES 6355 6350 6356 6351 void register_kfunc_btf_id_set(struct kfunc_btf_id_list *l, ··· 6371 6376 { 6372 6377 struct kfunc_btf_id_set *s; 6373 6378 6374 - if (!owner) 6375 - return false; 6376 6379 mutex_lock(&klist->mutex); 6377 6380 list_for_each_entry(s, &klist->list, list) { 6378 6381 if (s->owner == owner && btf_id_set_contains(s->set, kfunc_id)) { ··· 6382 6389 return false; 6383 6390 } 6384 6391 6385 - #endif 6386 - 6387 6392 #define DEFINE_KFUNC_BTF_ID_LIST(name) \ 6388 6393 struct kfunc_btf_id_list name = { LIST_HEAD_INIT(name.list), \ 6389 6394 __MUTEX_INITIALIZER(name.mutex) }; \ ··· 6389 6398 6390 6399 DEFINE_KFUNC_BTF_ID_LIST(bpf_tcp_ca_kfunc_list); 6391 6400 DEFINE_KFUNC_BTF_ID_LIST(prog_test_kfunc_list); 6401 + 6402 + #endif
+1
lib/Kconfig.debug
··· 316 316 bool "Generate BTF typeinfo" 317 317 depends on !DEBUG_INFO_SPLIT && !DEBUG_INFO_REDUCED 318 318 depends on !GCC_PLUGIN_RANDSTRUCT || COMPILE_TEST 319 + depends on BPF_SYSCALL 319 320 help 320 321 Generate deduplicated BTF type information from DWARF debug info. 321 322 Turning this on expects presence of pahole tool, which will convert
+5 -3
tools/bpf/resolve_btfids/main.c
··· 83 83 int cnt; 84 84 }; 85 85 int addr_cnt; 86 + bool is_set; 86 87 Elf64_Addr addr[ADDR_CNT]; 87 88 }; 88 89 ··· 452 451 * in symbol's size, together with 'cnt' field hence 453 452 * that - 1. 454 453 */ 455 - if (id) 454 + if (id) { 456 455 id->cnt = sym.st_size / sizeof(int) - 1; 456 + id->is_set = true; 457 + } 457 458 } else { 458 459 pr_err("FAILED unsupported prefix %s\n", prefix); 459 460 return -1; ··· 571 568 int *ptr = data->d_buf; 572 569 int i; 573 570 574 - if (!id->id) { 571 + if (!id->id && !id->is_set) 575 572 pr_err("WARN: resolve_btfids: unresolved symbol %s\n", id->name); 576 - } 577 573 578 574 for (i = 0; i < id->addr_cnt; i++) { 579 575 unsigned long addr = id->addr[i];