mirror of
https://github.com/hardkernel/linux.git
synced 2026-03-25 03:50:24 +09:00
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>
This commit is contained in:
@@ -245,7 +245,10 @@ struct kfunc_btf_id_set {
|
||||
struct module *owner;
|
||||
};
|
||||
|
||||
struct kfunc_btf_id_list;
|
||||
struct kfunc_btf_id_list {
|
||||
struct list_head list;
|
||||
struct mutex mutex;
|
||||
};
|
||||
|
||||
#ifdef CONFIG_DEBUG_INFO_BTF_MODULES
|
||||
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,
|
||||
struct kfunc_btf_id_set *s);
|
||||
bool bpf_check_mod_kfunc_call(struct kfunc_btf_id_list *klist, u32 kfunc_id,
|
||||
struct module *owner);
|
||||
|
||||
extern struct kfunc_btf_id_list bpf_tcp_ca_kfunc_list;
|
||||
extern struct kfunc_btf_id_list prog_test_kfunc_list;
|
||||
#else
|
||||
static inline void register_kfunc_btf_id_set(struct kfunc_btf_id_list *l,
|
||||
struct kfunc_btf_id_set *s)
|
||||
@@ -268,13 +274,13 @@ static inline bool bpf_check_mod_kfunc_call(struct kfunc_btf_id_list *klist,
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
static struct kfunc_btf_id_list bpf_tcp_ca_kfunc_list __maybe_unused;
|
||||
static struct kfunc_btf_id_list prog_test_kfunc_list __maybe_unused;
|
||||
#endif
|
||||
|
||||
#define DEFINE_KFUNC_BTF_ID_SET(set, name) \
|
||||
struct kfunc_btf_id_set name = { LIST_HEAD_INIT(name.list), (set), \
|
||||
THIS_MODULE }
|
||||
|
||||
extern struct kfunc_btf_id_list bpf_tcp_ca_kfunc_list;
|
||||
extern struct kfunc_btf_id_list prog_test_kfunc_list;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -6346,11 +6346,6 @@ BTF_ID_LIST_GLOBAL_SINGLE(btf_task_struct_ids, struct, task_struct)
|
||||
|
||||
/* BTF ID set registration API for modules */
|
||||
|
||||
struct kfunc_btf_id_list {
|
||||
struct list_head list;
|
||||
struct mutex mutex;
|
||||
};
|
||||
|
||||
#ifdef CONFIG_DEBUG_INFO_BTF_MODULES
|
||||
|
||||
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,
|
||||
{
|
||||
struct kfunc_btf_id_set *s;
|
||||
|
||||
if (!owner)
|
||||
return false;
|
||||
mutex_lock(&klist->mutex);
|
||||
list_for_each_entry(s, &klist->list, list) {
|
||||
if (s->owner == owner && btf_id_set_contains(s->set, kfunc_id)) {
|
||||
@@ -6389,8 +6382,6 @@ bool bpf_check_mod_kfunc_call(struct kfunc_btf_id_list *klist, u32 kfunc_id,
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#define DEFINE_KFUNC_BTF_ID_LIST(name) \
|
||||
struct kfunc_btf_id_list name = { LIST_HEAD_INIT(name.list), \
|
||||
__MUTEX_INITIALIZER(name.mutex) }; \
|
||||
@@ -6398,3 +6389,5 @@ bool bpf_check_mod_kfunc_call(struct kfunc_btf_id_list *klist, u32 kfunc_id,
|
||||
|
||||
DEFINE_KFUNC_BTF_ID_LIST(bpf_tcp_ca_kfunc_list);
|
||||
DEFINE_KFUNC_BTF_ID_LIST(prog_test_kfunc_list);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -316,6 +316,7 @@ config DEBUG_INFO_BTF
|
||||
bool "Generate BTF typeinfo"
|
||||
depends on !DEBUG_INFO_SPLIT && !DEBUG_INFO_REDUCED
|
||||
depends on !GCC_PLUGIN_RANDSTRUCT || COMPILE_TEST
|
||||
depends on BPF_SYSCALL
|
||||
help
|
||||
Generate deduplicated BTF type information from DWARF debug info.
|
||||
Turning this on expects presence of pahole tool, which will convert
|
||||
|
||||
@@ -83,6 +83,7 @@ struct btf_id {
|
||||
int cnt;
|
||||
};
|
||||
int addr_cnt;
|
||||
bool is_set;
|
||||
Elf64_Addr addr[ADDR_CNT];
|
||||
};
|
||||
|
||||
@@ -451,8 +452,10 @@ static int symbols_collect(struct object *obj)
|
||||
* in symbol's size, together with 'cnt' field hence
|
||||
* that - 1.
|
||||
*/
|
||||
if (id)
|
||||
if (id) {
|
||||
id->cnt = sym.st_size / sizeof(int) - 1;
|
||||
id->is_set = true;
|
||||
}
|
||||
} else {
|
||||
pr_err("FAILED unsupported prefix %s\n", prefix);
|
||||
return -1;
|
||||
@@ -568,9 +571,8 @@ static int id_patch(struct object *obj, struct btf_id *id)
|
||||
int *ptr = data->d_buf;
|
||||
int i;
|
||||
|
||||
if (!id->id) {
|
||||
if (!id->id && !id->is_set)
|
||||
pr_err("WARN: resolve_btfids: unresolved symbol %s\n", id->name);
|
||||
}
|
||||
|
||||
for (i = 0; i < id->addr_cnt; i++) {
|
||||
unsigned long addr = id->addr[i];
|
||||
|
||||
Reference in New Issue
Block a user