aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/module.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/module.c')
-rw-r--r--kernel/module.c199
1 files changed, 92 insertions, 107 deletions
diff --git a/kernel/module.c b/kernel/module.c
index 14b224967e7b..a0a3d6d9d5e8 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -108,13 +108,6 @@ static LIST_HEAD(modules);
108 * Use a latched RB-tree for __module_address(); this allows us to use 108 * Use a latched RB-tree for __module_address(); this allows us to use
109 * RCU-sched lookups of the address from any context. 109 * RCU-sched lookups of the address from any context.
110 * 110 *
111 * Because modules have two address ranges: init and core, we need two
112 * latch_tree_nodes entries. Therefore we need the back-pointer from
113 * mod_tree_node.
114 *
115 * Because init ranges are short lived we mark them unlikely and have placed
116 * them outside the critical cacheline in struct module.
117 *
118 * This is conditional on PERF_EVENTS || TRACING because those can really hit 111 * This is conditional on PERF_EVENTS || TRACING because those can really hit
119 * __module_address() hard by doing a lot of stack unwinding; potentially from 112 * __module_address() hard by doing a lot of stack unwinding; potentially from
120 * NMI context. 113 * NMI context.
@@ -122,24 +115,16 @@ static LIST_HEAD(modules);
122 115
123static __always_inline unsigned long __mod_tree_val(struct latch_tree_node *n) 116static __always_inline unsigned long __mod_tree_val(struct latch_tree_node *n)
124{ 117{
125 struct mod_tree_node *mtn = container_of(n, struct mod_tree_node, node); 118 struct module_layout *layout = container_of(n, struct module_layout, mtn.node);
126 struct module *mod = mtn->mod;
127 119
128 if (unlikely(mtn == &mod->mtn_init)) 120 return (unsigned long)layout->base;
129 return (unsigned long)mod->module_init;
130
131 return (unsigned long)mod->module_core;
132} 121}
133 122
134static __always_inline unsigned long __mod_tree_size(struct latch_tree_node *n) 123static __always_inline unsigned long __mod_tree_size(struct latch_tree_node *n)
135{ 124{
136 struct mod_tree_node *mtn = container_of(n, struct mod_tree_node, node); 125 struct module_layout *layout = container_of(n, struct module_layout, mtn.node);
137 struct module *mod = mtn->mod;
138
139 if (unlikely(mtn == &mod->mtn_init))
140 return (unsigned long)mod->init_size;
141 126
142 return (unsigned long)mod->core_size; 127 return (unsigned long)layout->size;
143} 128}
144 129
145static __always_inline bool 130static __always_inline bool
@@ -197,23 +182,23 @@ static void __mod_tree_remove(struct mod_tree_node *node)
197 */ 182 */
198static void mod_tree_insert(struct module *mod) 183static void mod_tree_insert(struct module *mod)
199{ 184{
200 mod->mtn_core.mod = mod; 185 mod->core_layout.mtn.mod = mod;
201 mod->mtn_init.mod = mod; 186 mod->init_layout.mtn.mod = mod;
202 187
203 __mod_tree_insert(&mod->mtn_core); 188 __mod_tree_insert(&mod->core_layout.mtn);
204 if (mod->init_size) 189 if (mod->init_layout.size)
205 __mod_tree_insert(&mod->mtn_init); 190 __mod_tree_insert(&mod->init_layout.mtn);
206} 191}
207 192
208static void mod_tree_remove_init(struct module *mod) 193static void mod_tree_remove_init(struct module *mod)
209{ 194{
210 if (mod->init_size) 195 if (mod->init_layout.size)
211 __mod_tree_remove(&mod->mtn_init); 196 __mod_tree_remove(&mod->init_layout.mtn);
212} 197}
213 198
214static void mod_tree_remove(struct module *mod) 199static void mod_tree_remove(struct module *mod)
215{ 200{
216 __mod_tree_remove(&mod->mtn_core); 201 __mod_tree_remove(&mod->core_layout.mtn);
217 mod_tree_remove_init(mod); 202 mod_tree_remove_init(mod);
218} 203}
219 204
@@ -267,9 +252,9 @@ static void __mod_update_bounds(void *base, unsigned int size)
267 252
268static void mod_update_bounds(struct module *mod) 253static void mod_update_bounds(struct module *mod)
269{ 254{
270 __mod_update_bounds(mod->module_core, mod->core_size); 255 __mod_update_bounds(mod->core_layout.base, mod->core_layout.size);
271 if (mod->init_size) 256 if (mod->init_layout.size)
272 __mod_update_bounds(mod->module_init, mod->init_size); 257 __mod_update_bounds(mod->init_layout.base, mod->init_layout.size);
273} 258}
274 259
275#ifdef CONFIG_KGDB_KDB 260#ifdef CONFIG_KGDB_KDB
@@ -1214,7 +1199,7 @@ struct module_attribute module_uevent =
1214static ssize_t show_coresize(struct module_attribute *mattr, 1199static ssize_t show_coresize(struct module_attribute *mattr,
1215 struct module_kobject *mk, char *buffer) 1200 struct module_kobject *mk, char *buffer)
1216{ 1201{
1217 return sprintf(buffer, "%u\n", mk->mod->core_size); 1202 return sprintf(buffer, "%u\n", mk->mod->core_layout.size);
1218} 1203}
1219 1204
1220static struct module_attribute modinfo_coresize = 1205static struct module_attribute modinfo_coresize =
@@ -1223,7 +1208,7 @@ static struct module_attribute modinfo_coresize =
1223static ssize_t show_initsize(struct module_attribute *mattr, 1208static ssize_t show_initsize(struct module_attribute *mattr,
1224 struct module_kobject *mk, char *buffer) 1209 struct module_kobject *mk, char *buffer)
1225{ 1210{
1226 return sprintf(buffer, "%u\n", mk->mod->init_size); 1211 return sprintf(buffer, "%u\n", mk->mod->init_layout.size);
1227} 1212}
1228 1213
1229static struct module_attribute modinfo_initsize = 1214static struct module_attribute modinfo_initsize =
@@ -1917,29 +1902,29 @@ static void set_section_ro_nx(void *base,
1917 1902
1918static void set_module_core_ro_nx(struct module *mod) 1903static void set_module_core_ro_nx(struct module *mod)
1919{ 1904{
1920 set_section_ro_nx(mod->module_core, mod->core_text_size, 1905 set_section_ro_nx(mod->core_layout.base, mod->core_layout.text_size,
1921 mod->core_ro_size, mod->core_size, 1906 mod->core_layout.ro_size, mod->core_layout.size,
1922 set_memory_ro, set_memory_nx); 1907 set_memory_ro, set_memory_nx);
1923} 1908}
1924 1909
1925static void unset_module_core_ro_nx(struct module *mod) 1910static void unset_module_core_ro_nx(struct module *mod)
1926{ 1911{
1927 set_section_ro_nx(mod->module_core, mod->core_text_size, 1912 set_section_ro_nx(mod->core_layout.base, mod->core_layout.text_size,
1928 mod->core_ro_size, mod->core_size, 1913 mod->core_layout.ro_size, mod->core_layout.size,
1929 set_memory_rw, set_memory_x); 1914 set_memory_rw, set_memory_x);
1930} 1915}
1931 1916
1932static void set_module_init_ro_nx(struct module *mod) 1917static void set_module_init_ro_nx(struct module *mod)
1933{ 1918{
1934 set_section_ro_nx(mod->module_init, mod->init_text_size, 1919 set_section_ro_nx(mod->init_layout.base, mod->init_layout.text_size,
1935 mod->init_ro_size, mod->init_size, 1920 mod->init_layout.ro_size, mod->init_layout.size,
1936 set_memory_ro, set_memory_nx); 1921 set_memory_ro, set_memory_nx);
1937} 1922}
1938 1923
1939static void unset_module_init_ro_nx(struct module *mod) 1924static void unset_module_init_ro_nx(struct module *mod)
1940{ 1925{
1941 set_section_ro_nx(mod->module_init, mod->init_text_size, 1926 set_section_ro_nx(mod->init_layout.base, mod->init_layout.text_size,
1942 mod->init_ro_size, mod->init_size, 1927 mod->init_layout.ro_size, mod->init_layout.size,
1943 set_memory_rw, set_memory_x); 1928 set_memory_rw, set_memory_x);
1944} 1929}
1945 1930
@@ -1952,14 +1937,14 @@ void set_all_modules_text_rw(void)
1952 list_for_each_entry_rcu(mod, &modules, list) { 1937 list_for_each_entry_rcu(mod, &modules, list) {
1953 if (mod->state == MODULE_STATE_UNFORMED) 1938 if (mod->state == MODULE_STATE_UNFORMED)
1954 continue; 1939 continue;
1955 if ((mod->module_core) && (mod->core_text_size)) { 1940 if ((mod->core_layout.base) && (mod->core_layout.text_size)) {
1956 set_page_attributes(mod->module_core, 1941 set_page_attributes(mod->core_layout.base,
1957 mod->module_core + mod->core_text_size, 1942 mod->core_layout.base + mod->core_layout.text_size,
1958 set_memory_rw); 1943 set_memory_rw);
1959 } 1944 }
1960 if ((mod->module_init) && (mod->init_text_size)) { 1945 if ((mod->init_layout.base) && (mod->init_layout.text_size)) {
1961 set_page_attributes(mod->module_init, 1946 set_page_attributes(mod->init_layout.base,
1962 mod->module_init + mod->init_text_size, 1947 mod->init_layout.base + mod->init_layout.text_size,
1963 set_memory_rw); 1948 set_memory_rw);
1964 } 1949 }
1965 } 1950 }
@@ -1975,14 +1960,14 @@ void set_all_modules_text_ro(void)
1975 list_for_each_entry_rcu(mod, &modules, list) { 1960 list_for_each_entry_rcu(mod, &modules, list) {
1976 if (mod->state == MODULE_STATE_UNFORMED) 1961 if (mod->state == MODULE_STATE_UNFORMED)
1977 continue; 1962 continue;
1978 if ((mod->module_core) && (mod->core_text_size)) { 1963 if ((mod->core_layout.base) && (mod->core_layout.text_size)) {
1979 set_page_attributes(mod->module_core, 1964 set_page_attributes(mod->core_layout.base,
1980 mod->module_core + mod->core_text_size, 1965 mod->core_layout.base + mod->core_layout.text_size,
1981 set_memory_ro); 1966 set_memory_ro);
1982 } 1967 }
1983 if ((mod->module_init) && (mod->init_text_size)) { 1968 if ((mod->init_layout.base) && (mod->init_layout.text_size)) {
1984 set_page_attributes(mod->module_init, 1969 set_page_attributes(mod->init_layout.base,
1985 mod->module_init + mod->init_text_size, 1970 mod->init_layout.base + mod->init_layout.text_size,
1986 set_memory_ro); 1971 set_memory_ro);
1987 } 1972 }
1988 } 1973 }
@@ -2047,16 +2032,16 @@ static void free_module(struct module *mod)
2047 /* This may be NULL, but that's OK */ 2032 /* This may be NULL, but that's OK */
2048 unset_module_init_ro_nx(mod); 2033 unset_module_init_ro_nx(mod);
2049 module_arch_freeing_init(mod); 2034 module_arch_freeing_init(mod);
2050 module_memfree(mod->module_init); 2035 module_memfree(mod->init_layout.base);
2051 kfree(mod->args); 2036 kfree(mod->args);
2052 percpu_modfree(mod); 2037 percpu_modfree(mod);
2053 2038
2054 /* Free lock-classes; relies on the preceding sync_rcu(). */ 2039 /* Free lock-classes; relies on the preceding sync_rcu(). */
2055 lockdep_free_key_range(mod->module_core, mod->core_size); 2040 lockdep_free_key_range(mod->core_layout.base, mod->core_layout.size);
2056 2041
2057 /* Finally, free the core (containing the module structure) */ 2042 /* Finally, free the core (containing the module structure) */
2058 unset_module_core_ro_nx(mod); 2043 unset_module_core_ro_nx(mod);
2059 module_memfree(mod->module_core); 2044 module_memfree(mod->core_layout.base);
2060 2045
2061#ifdef CONFIG_MPU 2046#ifdef CONFIG_MPU
2062 update_protections(current->mm); 2047 update_protections(current->mm);
@@ -2259,20 +2244,20 @@ static void layout_sections(struct module *mod, struct load_info *info)
2259 || s->sh_entsize != ~0UL 2244 || s->sh_entsize != ~0UL
2260 || strstarts(sname, ".init")) 2245 || strstarts(sname, ".init"))
2261 continue; 2246 continue;
2262 s->sh_entsize = get_offset(mod, &mod->core_size, s, i); 2247 s->sh_entsize = get_offset(mod, &mod->core_layout.size, s, i);
2263 pr_debug("\t%s\n", sname); 2248 pr_debug("\t%s\n", sname);
2264 } 2249 }
2265 switch (m) { 2250 switch (m) {
2266 case 0: /* executable */ 2251 case 0: /* executable */
2267 mod->core_size = debug_align(mod->core_size); 2252 mod->core_layout.size = debug_align(mod->core_layout.size);
2268 mod->core_text_size = mod->core_size; 2253 mod->core_layout.text_size = mod->core_layout.size;
2269 break; 2254 break;
2270 case 1: /* RO: text and ro-data */ 2255 case 1: /* RO: text and ro-data */
2271 mod->core_size = debug_align(mod->core_size); 2256 mod->core_layout.size = debug_align(mod->core_layout.size);
2272 mod->core_ro_size = mod->core_size; 2257 mod->core_layout.ro_size = mod->core_layout.size;
2273 break; 2258 break;
2274 case 3: /* whole core */ 2259 case 3: /* whole core */
2275 mod->core_size = debug_align(mod->core_size); 2260 mod->core_layout.size = debug_align(mod->core_layout.size);
2276 break; 2261 break;
2277 } 2262 }
2278 } 2263 }
@@ -2288,21 +2273,21 @@ static void layout_sections(struct module *mod, struct load_info *info)
2288 || s->sh_entsize != ~0UL 2273 || s->sh_entsize != ~0UL
2289 || !strstarts(sname, ".init")) 2274 || !strstarts(sname, ".init"))
2290 continue; 2275 continue;
2291 s->sh_entsize = (get_offset(mod, &mod->init_size, s, i) 2276 s->sh_entsize = (get_offset(mod, &mod->init_layout.size, s, i)
2292 | INIT_OFFSET_MASK); 2277 | INIT_OFFSET_MASK);
2293 pr_debug("\t%s\n", sname); 2278 pr_debug("\t%s\n", sname);
2294 } 2279 }
2295 switch (m) { 2280 switch (m) {
2296 case 0: /* executable */ 2281 case 0: /* executable */
2297 mod->init_size = debug_align(mod->init_size); 2282 mod->init_layout.size = debug_align(mod->init_layout.size);
2298 mod->init_text_size = mod->init_size; 2283 mod->init_layout.text_size = mod->init_layout.size;
2299 break; 2284 break;
2300 case 1: /* RO: text and ro-data */ 2285 case 1: /* RO: text and ro-data */
2301 mod->init_size = debug_align(mod->init_size); 2286 mod->init_layout.size = debug_align(mod->init_layout.size);
2302 mod->init_ro_size = mod->init_size; 2287 mod->init_layout.ro_size = mod->init_layout.size;
2303 break; 2288 break;
2304 case 3: /* whole init */ 2289 case 3: /* whole init */
2305 mod->init_size = debug_align(mod->init_size); 2290 mod->init_layout.size = debug_align(mod->init_layout.size);
2306 break; 2291 break;
2307 } 2292 }
2308 } 2293 }
@@ -2477,7 +2462,7 @@ static void layout_symtab(struct module *mod, struct load_info *info)
2477 2462
2478 /* Put symbol section at end of init part of module. */ 2463 /* Put symbol section at end of init part of module. */
2479 symsect->sh_flags |= SHF_ALLOC; 2464 symsect->sh_flags |= SHF_ALLOC;
2480 symsect->sh_entsize = get_offset(mod, &mod->init_size, symsect, 2465 symsect->sh_entsize = get_offset(mod, &mod->init_layout.size, symsect,
2481 info->index.sym) | INIT_OFFSET_MASK; 2466 info->index.sym) | INIT_OFFSET_MASK;
2482 pr_debug("\t%s\n", info->secstrings + symsect->sh_name); 2467 pr_debug("\t%s\n", info->secstrings + symsect->sh_name);
2483 2468
@@ -2494,16 +2479,16 @@ static void layout_symtab(struct module *mod, struct load_info *info)
2494 } 2479 }
2495 2480
2496 /* Append room for core symbols at end of core part. */ 2481 /* Append room for core symbols at end of core part. */
2497 info->symoffs = ALIGN(mod->core_size, symsect->sh_addralign ?: 1); 2482 info->symoffs = ALIGN(mod->core_layout.size, symsect->sh_addralign ?: 1);
2498 info->stroffs = mod->core_size = info->symoffs + ndst * sizeof(Elf_Sym); 2483 info->stroffs = mod->core_layout.size = info->symoffs + ndst * sizeof(Elf_Sym);
2499 mod->core_size += strtab_size; 2484 mod->core_layout.size += strtab_size;
2500 mod->core_size = debug_align(mod->core_size); 2485 mod->core_layout.size = debug_align(mod->core_layout.size);
2501 2486
2502 /* Put string table section at end of init part of module. */ 2487 /* Put string table section at end of init part of module. */
2503 strsect->sh_flags |= SHF_ALLOC; 2488 strsect->sh_flags |= SHF_ALLOC;
2504 strsect->sh_entsize = get_offset(mod, &mod->init_size, strsect, 2489 strsect->sh_entsize = get_offset(mod, &mod->init_layout.size, strsect,
2505 info->index.str) | INIT_OFFSET_MASK; 2490 info->index.str) | INIT_OFFSET_MASK;
2506 mod->init_size = debug_align(mod->init_size); 2491 mod->init_layout.size = debug_align(mod->init_layout.size);
2507 pr_debug("\t%s\n", info->secstrings + strsect->sh_name); 2492 pr_debug("\t%s\n", info->secstrings + strsect->sh_name);
2508} 2493}
2509 2494
@@ -2524,8 +2509,8 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
2524 for (i = 0; i < mod->num_symtab; i++) 2509 for (i = 0; i < mod->num_symtab; i++)
2525 mod->symtab[i].st_info = elf_type(&mod->symtab[i], info); 2510 mod->symtab[i].st_info = elf_type(&mod->symtab[i], info);
2526 2511
2527 mod->core_symtab = dst = mod->module_core + info->symoffs; 2512 mod->core_symtab = dst = mod->core_layout.base + info->symoffs;
2528 mod->core_strtab = s = mod->module_core + info->stroffs; 2513 mod->core_strtab = s = mod->core_layout.base + info->stroffs;
2529 src = mod->symtab; 2514 src = mod->symtab;
2530 for (ndst = i = 0; i < mod->num_symtab; i++) { 2515 for (ndst = i = 0; i < mod->num_symtab; i++) {
2531 if (i == 0 || 2516 if (i == 0 ||
@@ -2975,7 +2960,7 @@ static int move_module(struct module *mod, struct load_info *info)
2975 void *ptr; 2960 void *ptr;
2976 2961
2977 /* Do the allocs. */ 2962 /* Do the allocs. */
2978 ptr = module_alloc(mod->core_size); 2963 ptr = module_alloc(mod->core_layout.size);
2979 /* 2964 /*
2980 * The pointer to this block is stored in the module structure 2965 * The pointer to this block is stored in the module structure
2981 * which is inside the block. Just mark it as not being a 2966 * which is inside the block. Just mark it as not being a
@@ -2985,11 +2970,11 @@ static int move_module(struct module *mod, struct load_info *info)
2985 if (!ptr) 2970 if (!ptr)
2986 return -ENOMEM; 2971 return -ENOMEM;
2987 2972
2988 memset(ptr, 0, mod->core_size); 2973 memset(ptr, 0, mod->core_layout.size);
2989 mod->module_core = ptr; 2974 mod->core_layout.base = ptr;
2990 2975
2991 if (mod->init_size) { 2976 if (mod->init_layout.size) {
2992 ptr = module_alloc(mod->init_size); 2977 ptr = module_alloc(mod->init_layout.size);
2993 /* 2978 /*
2994 * The pointer to this block is stored in the module structure 2979 * The pointer to this block is stored in the module structure
2995 * which is inside the block. This block doesn't need to be 2980 * which is inside the block. This block doesn't need to be
@@ -2998,13 +2983,13 @@ static int move_module(struct module *mod, struct load_info *info)
2998 */ 2983 */
2999 kmemleak_ignore(ptr); 2984 kmemleak_ignore(ptr);
3000 if (!ptr) { 2985 if (!ptr) {
3001 module_memfree(mod->module_core); 2986 module_memfree(mod->core_layout.base);
3002 return -ENOMEM; 2987 return -ENOMEM;
3003 } 2988 }
3004 memset(ptr, 0, mod->init_size); 2989 memset(ptr, 0, mod->init_layout.size);
3005 mod->module_init = ptr; 2990 mod->init_layout.base = ptr;
3006 } else 2991 } else
3007 mod->module_init = NULL; 2992 mod->init_layout.base = NULL;
3008 2993
3009 /* Transfer each section which specifies SHF_ALLOC */ 2994 /* Transfer each section which specifies SHF_ALLOC */
3010 pr_debug("final section addresses:\n"); 2995 pr_debug("final section addresses:\n");
@@ -3016,10 +3001,10 @@ static int move_module(struct module *mod, struct load_info *info)
3016 continue; 3001 continue;
3017 3002
3018 if (shdr->sh_entsize & INIT_OFFSET_MASK) 3003 if (shdr->sh_entsize & INIT_OFFSET_MASK)
3019 dest = mod->module_init 3004 dest = mod->init_layout.base
3020 + (shdr->sh_entsize & ~INIT_OFFSET_MASK); 3005 + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
3021 else 3006 else
3022 dest = mod->module_core + shdr->sh_entsize; 3007 dest = mod->core_layout.base + shdr->sh_entsize;
3023 3008
3024 if (shdr->sh_type != SHT_NOBITS) 3009 if (shdr->sh_type != SHT_NOBITS)
3025 memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size); 3010 memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
@@ -3081,12 +3066,12 @@ static void flush_module_icache(const struct module *mod)
3081 * Do it before processing of module parameters, so the module 3066 * Do it before processing of module parameters, so the module
3082 * can provide parameter accessor functions of its own. 3067 * can provide parameter accessor functions of its own.
3083 */ 3068 */
3084 if (mod->module_init) 3069 if (mod->init_layout.base)
3085 flush_icache_range((unsigned long)mod->module_init, 3070 flush_icache_range((unsigned long)mod->init_layout.base,
3086 (unsigned long)mod->module_init 3071 (unsigned long)mod->init_layout.base
3087 + mod->init_size); 3072 + mod->init_layout.size);
3088 flush_icache_range((unsigned long)mod->module_core, 3073 flush_icache_range((unsigned long)mod->core_layout.base,
3089 (unsigned long)mod->module_core + mod->core_size); 3074 (unsigned long)mod->core_layout.base + mod->core_layout.size);
3090 3075
3091 set_fs(old_fs); 3076 set_fs(old_fs);
3092} 3077}
@@ -3144,8 +3129,8 @@ static void module_deallocate(struct module *mod, struct load_info *info)
3144{ 3129{
3145 percpu_modfree(mod); 3130 percpu_modfree(mod);
3146 module_arch_freeing_init(mod); 3131 module_arch_freeing_init(mod);
3147 module_memfree(mod->module_init); 3132 module_memfree(mod->init_layout.base);
3148 module_memfree(mod->module_core); 3133 module_memfree(mod->core_layout.base);
3149} 3134}
3150 3135
3151int __weak module_finalize(const Elf_Ehdr *hdr, 3136int __weak module_finalize(const Elf_Ehdr *hdr,
@@ -3232,7 +3217,7 @@ static noinline int do_init_module(struct module *mod)
3232 ret = -ENOMEM; 3217 ret = -ENOMEM;
3233 goto fail; 3218 goto fail;
3234 } 3219 }
3235 freeinit->module_init = mod->module_init; 3220 freeinit->module_init = mod->init_layout.base;
3236 3221
3237 /* 3222 /*
3238 * We want to find out whether @mod uses async during init. Clear 3223 * We want to find out whether @mod uses async during init. Clear
@@ -3292,10 +3277,10 @@ static noinline int do_init_module(struct module *mod)
3292 mod_tree_remove_init(mod); 3277 mod_tree_remove_init(mod);
3293 unset_module_init_ro_nx(mod); 3278 unset_module_init_ro_nx(mod);
3294 module_arch_freeing_init(mod); 3279 module_arch_freeing_init(mod);
3295 mod->module_init = NULL; 3280 mod->init_layout.base = NULL;
3296 mod->init_size = 0; 3281 mod->init_layout.size = 0;
3297 mod->init_ro_size = 0; 3282 mod->init_layout.ro_size = 0;
3298 mod->init_text_size = 0; 3283 mod->init_layout.text_size = 0;
3299 /* 3284 /*
3300 * We want to free module_init, but be aware that kallsyms may be 3285 * We want to free module_init, but be aware that kallsyms may be
3301 * walking this with preempt disabled. In all the failure paths, we 3286 * walking this with preempt disabled. In all the failure paths, we
@@ -3575,7 +3560,7 @@ static int load_module(struct load_info *info, const char __user *uargs,
3575 mutex_unlock(&module_mutex); 3560 mutex_unlock(&module_mutex);
3576 free_module: 3561 free_module:
3577 /* Free lock-classes; relies on the preceding sync_rcu() */ 3562 /* Free lock-classes; relies on the preceding sync_rcu() */
3578 lockdep_free_key_range(mod->module_core, mod->core_size); 3563 lockdep_free_key_range(mod->core_layout.base, mod->core_layout.size);
3579 3564
3580 module_deallocate(mod, info); 3565 module_deallocate(mod, info);
3581 free_copy: 3566 free_copy:
@@ -3653,9 +3638,9 @@ static const char *get_ksymbol(struct module *mod,
3653 3638
3654 /* At worse, next value is at end of module */ 3639 /* At worse, next value is at end of module */
3655 if (within_module_init(addr, mod)) 3640 if (within_module_init(addr, mod))
3656 nextval = (unsigned long)mod->module_init+mod->init_text_size; 3641 nextval = (unsigned long)mod->init_layout.base+mod->init_layout.text_size;
3657 else 3642 else
3658 nextval = (unsigned long)mod->module_core+mod->core_text_size; 3643 nextval = (unsigned long)mod->core_layout.base+mod->core_layout.text_size;
3659 3644
3660 /* Scan for closest preceding symbol, and next symbol. (ELF 3645 /* Scan for closest preceding symbol, and next symbol. (ELF
3661 starts real symbols at 1). */ 3646 starts real symbols at 1). */
@@ -3902,7 +3887,7 @@ static int m_show(struct seq_file *m, void *p)
3902 return 0; 3887 return 0;
3903 3888
3904 seq_printf(m, "%s %u", 3889 seq_printf(m, "%s %u",
3905 mod->name, mod->init_size + mod->core_size); 3890 mod->name, mod->init_layout.size + mod->core_layout.size);
3906 print_unload_info(m, mod); 3891 print_unload_info(m, mod);
3907 3892
3908 /* Informative for users. */ 3893 /* Informative for users. */
@@ -3911,7 +3896,7 @@ static int m_show(struct seq_file *m, void *p)
3911 mod->state == MODULE_STATE_COMING ? "Loading" : 3896 mod->state == MODULE_STATE_COMING ? "Loading" :
3912 "Live"); 3897 "Live");
3913 /* Used by oprofile and other similar tools. */ 3898 /* Used by oprofile and other similar tools. */
3914 seq_printf(m, " 0x%pK", mod->module_core); 3899 seq_printf(m, " 0x%pK", mod->core_layout.base);
3915 3900
3916 /* Taints info */ 3901 /* Taints info */
3917 if (mod->taints) 3902 if (mod->taints)
@@ -4054,8 +4039,8 @@ struct module *__module_text_address(unsigned long addr)
4054 struct module *mod = __module_address(addr); 4039 struct module *mod = __module_address(addr);
4055 if (mod) { 4040 if (mod) {
4056 /* Make sure it's within the text section. */ 4041 /* Make sure it's within the text section. */
4057 if (!within(addr, mod->module_init, mod->init_text_size) 4042 if (!within(addr, mod->init_layout.base, mod->init_layout.text_size)
4058 && !within(addr, mod->module_core, mod->core_text_size)) 4043 && !within(addr, mod->core_layout.base, mod->core_layout.text_size))
4059 mod = NULL; 4044 mod = NULL;
4060 } 4045 }
4061 return mod; 4046 return mod;