]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
module, bpf: Store BTF base pointer in struct module
authorAlan Maguire <alan.maguire@oracle.com>
Thu, 20 Jun 2024 09:17:29 +0000 (10:17 +0100)
committerAndrii Nakryiko <andrii@kernel.org>
Fri, 21 Jun 2024 21:45:07 +0000 (14:45 -0700)
...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: Alan Maguire <alan.maguire@oracle.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Reviewed-by: Luis Chamberlain <mcgrof@kernel.org>
Acked-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20240620091733.1967885-3-alan.maguire@oracle.com
include/linux/module.h
kernel/module/main.c

index ffa1c603163c29e6da27f2cb7ccea90c99206720..b79d926cae8a909054fdf1c952df68803af55f13 100644 (file)
@@ -509,7 +509,9 @@ struct module {
 #endif
 #ifdef CONFIG_DEBUG_INFO_BTF_MODULES
        unsigned int btf_data_size;
+       unsigned int btf_base_data_size;
        void *btf_data;
+       void *btf_base_data;
 #endif
 #ifdef CONFIG_JUMP_LABEL
        struct jump_entry *jump_entries;
index d18a94b973e1027a7ab4459dfee8050e5be6e524..d9592195c5bbb4261ab6993a4ad56e7513f6331d 100644 (file)
@@ -2166,6 +2166,8 @@ static int find_module_sections(struct module *mod, struct load_info *info)
 #endif
 #ifdef CONFIG_DEBUG_INFO_BTF_MODULES
        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
 #ifdef CONFIG_JUMP_LABEL
        mod->jump_entries = section_objs(info, "__jump_table",
@@ -2590,8 +2592,9 @@ static noinline int do_init_module(struct module *mod)
        }
 
 #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_base_data = NULL;
 #endif
        /*
         * We want to free module_init, but be aware that kallsyms may be