Le 22/02/2022 à 15:12, Aaron Tomlin a écrit : > No functional change. > > This patch makes it possible to move non-essential code > out of core module code. > > Signed-off-by: Aaron Tomlin <atomlin@xxxxxxxxxx> Reviewed-by: Christophe Leroy <christophe.leroy@xxxxxxxxxx> > --- > kernel/module/internal.h | 21 +++++++++++++++++++++ > kernel/module/main.c | 22 ++-------------------- > 2 files changed, 23 insertions(+), 20 deletions(-) > > diff --git a/kernel/module/internal.h b/kernel/module/internal.h > index 8c381c99062f..ea8c4c02614c 100644 > --- a/kernel/module/internal.h > +++ b/kernel/module/internal.h > @@ -7,6 +7,27 @@ > > #include <linux/elf.h> > #include <asm/module.h> > +#include <linux/mutex.h> > + > +#ifndef ARCH_SHF_SMALL > +#define ARCH_SHF_SMALL 0 > +#endif > + > +/* If this is set, the section belongs in the init part of the module */ > +#define INIT_OFFSET_MASK (1UL << (BITS_PER_LONG - 1)) > +/* Maximum number of characters written by module_flags() */ > +#define MODULE_FLAGS_BUF_SIZE (TAINT_FLAGS_COUNT + 4) > + > +extern struct mutex module_mutex; > +extern struct list_head modules; > + > +/* Provided by the linker */ > +extern const struct kernel_symbol __start___ksymtab[]; > +extern const struct kernel_symbol __stop___ksymtab[]; > +extern const struct kernel_symbol __start___ksymtab_gpl[]; > +extern const struct kernel_symbol __stop___ksymtab_gpl[]; > +extern const s32 __start___kcrctab[]; > +extern const s32 __start___kcrctab_gpl[]; > > struct load_info { > const char *name; > diff --git a/kernel/module/main.c b/kernel/module/main.c > index 34a2b0cf3c3e..5f5e21f972dd 100644 > --- a/kernel/module/main.c > +++ b/kernel/module/main.c > @@ -63,10 +63,6 @@ > #define CREATE_TRACE_POINTS > #include <trace/events/module.h> > > -#ifndef ARCH_SHF_SMALL > -#define ARCH_SHF_SMALL 0 > -#endif > - > /* > * Modules' sections will be aligned on page boundaries > * to ensure complete separation of code and data, but > @@ -78,9 +74,6 @@ > # define debug_align(X) (X) > #endif > > -/* If this is set, the section belongs in the init part of the module */ > -#define INIT_OFFSET_MASK (1UL << (BITS_PER_LONG-1)) > - > /* > * Mutex protects: > * 1) List of modules (also safely readable with preempt_disable), > @@ -88,8 +81,8 @@ > * 3) module_addr_min/module_addr_max. > * (delete and add uses RCU list operations). > */ > -static DEFINE_MUTEX(module_mutex); > -static LIST_HEAD(modules); > +DEFINE_MUTEX(module_mutex); > +LIST_HEAD(modules); > > /* Work queue for freeing init sections in success case */ > static void do_free_init(struct work_struct *w); > @@ -408,14 +401,6 @@ static __maybe_unused void *any_section_objs(const struct load_info *info, > return (void *)info->sechdrs[sec].sh_addr; > } > > -/* Provided by the linker */ > -extern const struct kernel_symbol __start___ksymtab[]; > -extern const struct kernel_symbol __stop___ksymtab[]; > -extern const struct kernel_symbol __start___ksymtab_gpl[]; > -extern const struct kernel_symbol __stop___ksymtab_gpl[]; > -extern const s32 __start___kcrctab[]; > -extern const s32 __start___kcrctab_gpl[]; > - > #ifndef CONFIG_MODVERSIONS > #define symversion(base, idx) NULL > #else > @@ -4542,9 +4527,6 @@ static void cfi_cleanup(struct module *mod) > #endif > } > > -/* Maximum number of characters written by module_flags() */ > -#define MODULE_FLAGS_BUF_SIZE (TAINT_FLAGS_COUNT + 4) > - > /* Keep in sync with MODULE_FLAGS_BUF_SIZE !!! */ > static char *module_flags(struct module *mod, char *buf) > {