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>
Mon, 18 Apr 2022 12:36:36 +0000 (13:36 +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 0c74348cbc9dc23e04e5ca36e90f834b2fb2373e..f5b09fac74f509b18d46a08a2d5af60b428451e8 100644 (file)
@@ -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,
index 1e135fd5c076ade36fd42bd4a324b2f9ea8cf7fc..29e23658c2d45821ec0f14ca98945e87fe7c6449 100644 (file)
@@ -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
index ac89e65d1692e89243043c37b667b5653eb631f0..b48f948c05f909733d442c67e8ebca6af1aed4dc 100644 (file)
@@ -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) };   \
index 440fd666c16d1977d3ef1c59af23372516b38ec7..28773ef72fdfbd148f6587a3a5e4ba76637aa36f 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