History

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.

Alan Maguire committed 2 years ago

Commit d4e48e31 parent d1cf8402 files · +6 −1Browse files

Unified · Split

2 files
  1. include/linux/module.h +2 −0
  2. kernel/module/main.c +4 −1
include/linux/module.h+2−0
@@ -509,7 +509,9 @@ struct module { · 508 unmodified lines
509#endif509#endif
510#ifdef CONFIG_DEBUG_INFO_BTF_MODULES510#ifdef CONFIG_DEBUG_INFO_BTF_MODULES
511 unsigned int btf_data_size;511 unsigned int btf_data_size;
512 unsigned int btf_base_data_size;
512 void *btf_data;513 void *btf_data;
514 void *btf_base_data;
513#endif515#endif
514#ifdef CONFIG_JUMP_LABEL516#ifdef CONFIG_JUMP_LABEL
515 struct jump_entry *jump_entries;517 struct jump_entry *jump_entries;
kernel/module/main.c+4−1
@@ -2166,6 +2166,8 @@ static int find_module_sections(struct module *mod, struct load_info *info) · 2165 unmodified lines
2166#endif2166#endif
2167#ifdef CONFIG_DEBUG_INFO_BTF_MODULES2167#ifdef CONFIG_DEBUG_INFO_BTF_MODULES
2168 mod->btf_data = any_section_objs(info, ".BTF", 1, &mod->btf_data_size);2168 mod->btf_data = any_section_objs(info, ".BTF", 1, &mod->btf_data_size);
2169 mod->btf_base_data = any_section_objs(info, ".BTF.base", 1,
2170 &mod->btf_base_data_size);
2169#endif2171#endif
2170#ifdef CONFIG_JUMP_LABEL2172#ifdef CONFIG_JUMP_LABEL
2171 mod->jump_entries = section_objs(info, "__jump_table",2173 mod->jump_entries = section_objs(info, "__jump_table",
@@ -2590,8 +2592,9 @@ static noinline int do_init_module(struct module *mod) · 418 unmodified lines
2590 }2592 }
2591 2593
2592#ifdef CONFIG_DEBUG_INFO_BTF_MODULES2594#ifdef CONFIG_DEBUG_INFO_BTF_MODULES
2593 /* .BTF is not SHF_ALLOC and will get removed, so sanitize pointer */2595 /* .BTF is not SHF_ALLOC and will get removed, so sanitize pointers */
2594 mod->btf_data = NULL;2596 mod->btf_data = NULL;
2597 mod->btf_base_data = NULL;
2595#endif2598#endif
2596 /*2599 /*
2597 * We want to free module_init, but be aware that kallsyms may be2600 * We want to free module_init, but be aware that kallsyms may be