Skip to content

Commit 7d9b3ad

Browse files
committed
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/[email protected] * Instead of demoting resolve_btfids warning to debug, only skip in case of set->cnt == 0. ==================== Signed-off-by: Andrii Nakryiko <[email protected]>
2 parents 099f83a + 3345193 commit 7d9b3ad

File tree

4 files changed

+18
-16
lines changed

4 files changed

+18
-16
lines changed

include/linux/btf.h

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,10 @@ struct kfunc_btf_id_set {
245245
struct module *owner;
246246
};
247247

248-
struct kfunc_btf_id_list;
248+
struct kfunc_btf_id_list {
249+
struct list_head list;
250+
struct mutex mutex;
251+
};
249252

250253
#ifdef CONFIG_DEBUG_INFO_BTF_MODULES
251254
void register_kfunc_btf_id_set(struct kfunc_btf_id_list *l,
@@ -254,6 +257,9 @@ void unregister_kfunc_btf_id_set(struct kfunc_btf_id_list *l,
254257
struct kfunc_btf_id_set *s);
255258
bool bpf_check_mod_kfunc_call(struct kfunc_btf_id_list *klist, u32 kfunc_id,
256259
struct module *owner);
260+
261+
extern struct kfunc_btf_id_list bpf_tcp_ca_kfunc_list;
262+
extern struct kfunc_btf_id_list prog_test_kfunc_list;
257263
#else
258264
static inline void register_kfunc_btf_id_set(struct kfunc_btf_id_list *l,
259265
struct kfunc_btf_id_set *s)
@@ -268,13 +274,13 @@ static inline bool bpf_check_mod_kfunc_call(struct kfunc_btf_id_list *klist,
268274
{
269275
return false;
270276
}
277+
278+
static struct kfunc_btf_id_list bpf_tcp_ca_kfunc_list __maybe_unused;
279+
static struct kfunc_btf_id_list prog_test_kfunc_list __maybe_unused;
271280
#endif
272281

273282
#define DEFINE_KFUNC_BTF_ID_SET(set, name) \
274283
struct kfunc_btf_id_set name = { LIST_HEAD_INIT(name.list), (set), \
275284
THIS_MODULE }
276285

277-
extern struct kfunc_btf_id_list bpf_tcp_ca_kfunc_list;
278-
extern struct kfunc_btf_id_list prog_test_kfunc_list;
279-
280286
#endif

kernel/bpf/btf.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6346,11 +6346,6 @@ BTF_ID_LIST_GLOBAL_SINGLE(btf_task_struct_ids, struct, task_struct)
63466346

63476347
/* BTF ID set registration API for modules */
63486348

6349-
struct kfunc_btf_id_list {
6350-
struct list_head list;
6351-
struct mutex mutex;
6352-
};
6353-
63546349
#ifdef CONFIG_DEBUG_INFO_BTF_MODULES
63556350

63566351
void register_kfunc_btf_id_set(struct kfunc_btf_id_list *l,
@@ -6376,8 +6371,6 @@ bool bpf_check_mod_kfunc_call(struct kfunc_btf_id_list *klist, u32 kfunc_id,
63766371
{
63776372
struct kfunc_btf_id_set *s;
63786373

6379-
if (!owner)
6380-
return false;
63816374
mutex_lock(&klist->mutex);
63826375
list_for_each_entry(s, &klist->list, list) {
63836376
if (s->owner == owner && btf_id_set_contains(s->set, kfunc_id)) {
@@ -6389,12 +6382,12 @@ bool bpf_check_mod_kfunc_call(struct kfunc_btf_id_list *klist, u32 kfunc_id,
63896382
return false;
63906383
}
63916384

6392-
#endif
6393-
63946385
#define DEFINE_KFUNC_BTF_ID_LIST(name) \
63956386
struct kfunc_btf_id_list name = { LIST_HEAD_INIT(name.list), \
63966387
__MUTEX_INITIALIZER(name.mutex) }; \
63976388
EXPORT_SYMBOL_GPL(name)
63986389

63996390
DEFINE_KFUNC_BTF_ID_LIST(bpf_tcp_ca_kfunc_list);
64006391
DEFINE_KFUNC_BTF_ID_LIST(prog_test_kfunc_list);
6392+
6393+
#endif

lib/Kconfig.debug

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,7 @@ config DEBUG_INFO_BTF
316316
bool "Generate BTF typeinfo"
317317
depends on !DEBUG_INFO_SPLIT && !DEBUG_INFO_REDUCED
318318
depends on !GCC_PLUGIN_RANDSTRUCT || COMPILE_TEST
319+
depends on BPF_SYSCALL
319320
help
320321
Generate deduplicated BTF type information from DWARF debug info.
321322
Turning this on expects presence of pahole tool, which will convert

tools/bpf/resolve_btfids/main.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ struct btf_id {
8383
int cnt;
8484
};
8585
int addr_cnt;
86+
bool is_set;
8687
Elf64_Addr addr[ADDR_CNT];
8788
};
8889

@@ -451,8 +452,10 @@ static int symbols_collect(struct object *obj)
451452
* in symbol's size, together with 'cnt' field hence
452453
* that - 1.
453454
*/
454-
if (id)
455+
if (id) {
455456
id->cnt = sym.st_size / sizeof(int) - 1;
457+
id->is_set = true;
458+
}
456459
} else {
457460
pr_err("FAILED unsupported prefix %s\n", prefix);
458461
return -1;
@@ -568,9 +571,8 @@ static int id_patch(struct object *obj, struct btf_id *id)
568571
int *ptr = data->d_buf;
569572
int i;
570573

571-
if (!id->id) {
574+
if (!id->id && !id->is_set)
572575
pr_err("WARN: resolve_btfids: unresolved symbol %s\n", id->name);
573-
}
574576

575577
for (i = 0; i < id->addr_cnt; i++) {
576578
unsigned long addr = id->addr[i];

0 commit comments

Comments
 (0)