module: Avoid ABI changes when debug info is disabled
authorBen Hutchings <benh@debian.org>
Wed, 2 Mar 2022 20:22:28 +0000 (21:22 +0100)
committerSalvatore Bonaccorso <carnil@debian.org>
Tue, 29 Mar 2022 20:46:53 +0000 (21:46 +0100)
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

include/linux/btf.h
include/linux/module.h
kernel/bpf/btf.c
lib/Kconfig.debug

index 0e1b6281fd8f6af0b9358e26bc814c83fc392921..eee42c114a92a14edcacff9387d9b26295f4d55e 100644 (file)
@@ -250,7 +250,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,
index c9f1200b23121a4199ca9fad1d97ce0d6a6c84ad..5a7bea7348b4961b243c4351b658e4cb665c829a 100644 (file)
@@ -470,7 +470,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
index c9da250fee38c68b704eb43be978c88a03f75fb7..58e52de4554fe3fff94871b435a04b4c07c328cb 100644 (file)
@@ -6436,6 +6436,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) };   \
index 5e14e32056add21469af2c9c77d17cfb25e2976f..a7cad165c81368c415ff707e8c722f5f3533bfdd 100644 (file)
@@ -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