Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: 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

authored by

Alan Maguire and committed by
Andrii Nakryiko
d4e48e3d d1cf8408

+6 -1
+2
include/linux/module.h
··· 509 509 #endif 510 510 #ifdef CONFIG_DEBUG_INFO_BTF_MODULES 511 511 unsigned int btf_data_size; 512 + unsigned int btf_base_data_size; 512 513 void *btf_data; 514 + void *btf_base_data; 513 515 #endif 514 516 #ifdef CONFIG_JUMP_LABEL 515 517 struct jump_entry *jump_entries;
+4 -1
kernel/module/main.c
··· 2166 2166 #endif 2167 2167 #ifdef CONFIG_DEBUG_INFO_BTF_MODULES 2168 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 2171 #endif 2170 2172 #ifdef CONFIG_JUMP_LABEL 2171 2173 mod->jump_entries = section_objs(info, "__jump_table", ··· 2592 2590 } 2593 2591 2594 2592 #ifdef CONFIG_DEBUG_INFO_BTF_MODULES 2595 - /* .BTF is not SHF_ALLOC and will get removed, so sanitize pointer */ 2593 + /* .BTF is not SHF_ALLOC and will get removed, so sanitize pointers */ 2596 2594 mod->btf_data = NULL; 2595 + mod->btf_base_data = NULL; 2597 2596 #endif 2598 2597 /* 2599 2598 * We want to free module_init, but be aware that kallsyms may be