Commit d4e48e3d authored by Alan Maguire's avatar Alan Maguire Committed by Andrii Nakryiko

module, bpf: Store BTF base pointer in struct module

...as this will allow split BTF modules with a base BTF
representation (rather than the full vmlinux BTF at time of
BTF encoding) to resolve their references to kernel types in a
way that is more resilient to small changes in kernel types.

This will allow modules that are not built every time the kernel
is to provide more resilient BTF, rather than have it invalidated
every time BTF ids for core kernel types change.

Fields are ordered to avoid holes in struct module.
Signed-off-by: default avatarAlan Maguire <alan.maguire@oracle.com>
Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
Reviewed-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
Acked-by: default avatarAndrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20240620091733.1967885-3-alan.maguire@oracle.com
parent d1cf8408
...@@ -509,7 +509,9 @@ struct module { ...@@ -509,7 +509,9 @@ struct module {
#endif #endif
#ifdef CONFIG_DEBUG_INFO_BTF_MODULES #ifdef CONFIG_DEBUG_INFO_BTF_MODULES
unsigned int btf_data_size; unsigned int btf_data_size;
unsigned int btf_base_data_size;
void *btf_data; void *btf_data;
void *btf_base_data;
#endif #endif
#ifdef CONFIG_JUMP_LABEL #ifdef CONFIG_JUMP_LABEL
struct jump_entry *jump_entries; struct jump_entry *jump_entries;
......
...@@ -2166,6 +2166,8 @@ static int find_module_sections(struct module *mod, struct load_info *info) ...@@ -2166,6 +2166,8 @@ static int find_module_sections(struct module *mod, struct load_info *info)
#endif #endif
#ifdef CONFIG_DEBUG_INFO_BTF_MODULES #ifdef CONFIG_DEBUG_INFO_BTF_MODULES
mod->btf_data = any_section_objs(info, ".BTF", 1, &mod->btf_data_size); mod->btf_data = any_section_objs(info, ".BTF", 1, &mod->btf_data_size);
mod->btf_base_data = any_section_objs(info, ".BTF.base", 1,
&mod->btf_base_data_size);
#endif #endif
#ifdef CONFIG_JUMP_LABEL #ifdef CONFIG_JUMP_LABEL
mod->jump_entries = section_objs(info, "__jump_table", mod->jump_entries = section_objs(info, "__jump_table",
...@@ -2590,8 +2592,9 @@ static noinline int do_init_module(struct module *mod) ...@@ -2590,8 +2592,9 @@ static noinline int do_init_module(struct module *mod)
} }
#ifdef CONFIG_DEBUG_INFO_BTF_MODULES #ifdef CONFIG_DEBUG_INFO_BTF_MODULES
/* .BTF is not SHF_ALLOC and will get removed, so sanitize pointer */ /* .BTF is not SHF_ALLOC and will get removed, so sanitize pointers */
mod->btf_data = NULL; mod->btf_data = NULL;
mod->btf_base_data = NULL;
#endif #endif
/* /*
* We want to free module_init, but be aware that kallsyms may be * We want to free module_init, but be aware that kallsyms may be
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment