From: Ben Hutchings Date: Wed, 2 Mar 2022 20:22:28 +0000 (+0100) Subject: module: Avoid ABI changes when debug info is disabled X-Git-Tag: archive/raspbian/5.17.3-1+rpi1^2~61 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=0922bcda3b0fe20cf1da5b32f387155607179755;p=linux.git module: Avoid ABI changes when debug info is disabled Forwarded: not-needed CI builds are done with debug info disabled, but this removes some members from struct module and replaces some BTF-related exports with static definitions. This causes builds to fail if there is an ABI reference for the current ABI. - Add a new config symbol DEBUG_INFO_BTF_MODULES_NOOP which can be enabled when DEBUG_INFO is not enabled - When the symbol is enabled: - Define the BTF-related members of struct module - Export the no-op definitions of BTF-related functions - Define and export the same BTF-related static lists Gbp-Pq: Topic debian Gbp-Pq: Name module-avoid-abi-changes-when-debug-info-is-disabled.patch --- diff --git a/include/linux/btf.h b/include/linux/btf.h index 0c74348cbc9..f5b09fac74f 100644 --- a/include/linux/btf.h +++ b/include/linux/btf.h @@ -331,7 +331,7 @@ struct kfunc_btf_id_list { struct mutex mutex; }; -#ifdef CONFIG_DEBUG_INFO_BTF_MODULES +#if defined(CONFIG_DEBUG_INFO_BTF_MODULES) || defined(CONFIG_DEBUG_INFO_BTF_MODULES_NOOP) void register_kfunc_btf_id_set(struct kfunc_btf_id_list *l, struct kfunc_btf_id_set *s); void unregister_kfunc_btf_id_set(struct kfunc_btf_id_list *l, diff --git a/include/linux/module.h b/include/linux/module.h index 1e135fd5c07..29e23658c2d 100644 --- a/include/linux/module.h +++ b/include/linux/module.h @@ -471,7 +471,7 @@ struct module { unsigned int num_bpf_raw_events; struct bpf_raw_event_map *bpf_raw_events; #endif -#ifdef CONFIG_DEBUG_INFO_BTF_MODULES +#if defined(CONFIG_DEBUG_INFO_BTF_MODULES) || defined(CONFIG_DEBUG_INFO_BTF_MODULES_NOOP) unsigned int btf_data_size; void *btf_data; #endif diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c index ac89e65d169..b48f948c05f 100644 --- a/kernel/bpf/btf.c +++ b/kernel/bpf/btf.c @@ -6490,6 +6490,30 @@ bool bpf_check_mod_kfunc_call(struct kfunc_btf_id_list *klist, u32 kfunc_id, return false; } +#elif defined(CONFIG_DEBUG_INFO_BTF_MODULES_NOOP) + +void register_kfunc_btf_id_set(struct kfunc_btf_id_list *l, + struct kfunc_btf_id_set *s) +{ +} +EXPORT_SYMBOL_GPL(register_kfunc_btf_id_set); + +void unregister_kfunc_btf_id_set(struct kfunc_btf_id_list *l, + struct kfunc_btf_id_set *s) +{ +} +EXPORT_SYMBOL_GPL(unregister_kfunc_btf_id_set); + +bool bpf_check_mod_kfunc_call(struct kfunc_btf_id_list *klist, u32 kfunc_id, + struct module *owner) +{ + return false; +} + +#endif /* CONFIG_DEBUG_INFO_BTF_MODULES */ + +#if defined(CONFIG_DEBUG_INFO_BTF_MODULES) || defined(CONFIG_DEBUG_INFO_BTF_MODULES_NOOP) + #define DEFINE_KFUNC_BTF_ID_LIST(name) \ struct kfunc_btf_id_list name = { LIST_HEAD_INIT(name.list), \ __MUTEX_INITIALIZER(name.mutex) }; \ diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index 440fd666c16..28773ef72fd 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -343,6 +343,16 @@ config GDB_SCRIPTS endif # DEBUG_INFO +if !DEBUG_INFO + +config DEBUG_INFO_BTF_MODULES_NOOP + bool "Provide no-op BTF ABI to modules" + help + Enable this option instead of DEBUG_INFO_BTF to avoid an ABI + change when debug info is disabled. + +endif + config FRAME_WARN int "Warn for stack frames larger than" range 0 8192