Skip to content

Commit

Permalink
module: Simple refactor in preparation for split
Browse files Browse the repository at this point in the history
No functional change.

This patch makes it possible to move non-essential code
out of core module code.

Signed-off-by: Aaron Tomlin <atomlin@redhat.com>
  • Loading branch information
Aaron Tomlin authored and chleroy committed Feb 22, 2022
1 parent 649a8dc commit 5403572
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 20 deletions.
21 changes: 21 additions & 0 deletions kernel/module/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
22 changes: 2 additions & 20 deletions kernel/module/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -78,18 +74,15 @@
# 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),
* 2) module_use links,
* 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);
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
{
Expand Down

0 comments on commit 5403572

Please sign in to comment.