diff options
Diffstat (limited to 'include/linux/module.h')
-rw-r--r-- | include/linux/module.h | 64 |
1 files changed, 29 insertions, 35 deletions
diff --git a/include/linux/module.h b/include/linux/module.h index 3a19c79918e0..6e68e8cf4d0d 100644 --- a/include/linux/module.h +++ b/include/linux/module.h | |||
@@ -302,6 +302,28 @@ struct mod_tree_node { | |||
302 | struct latch_tree_node node; | 302 | struct latch_tree_node node; |
303 | }; | 303 | }; |
304 | 304 | ||
305 | struct module_layout { | ||
306 | /* The actual code + data. */ | ||
307 | void *base; | ||
308 | /* Total size. */ | ||
309 | unsigned int size; | ||
310 | /* The size of the executable code. */ | ||
311 | unsigned int text_size; | ||
312 | /* Size of RO section of the module (text+rodata) */ | ||
313 | unsigned int ro_size; | ||
314 | |||
315 | #ifdef CONFIG_MODULES_TREE_LOOKUP | ||
316 | struct mod_tree_node mtn; | ||
317 | #endif | ||
318 | }; | ||
319 | |||
320 | #ifdef CONFIG_MODULES_TREE_LOOKUP | ||
321 | /* Only touch one cacheline for common rbtree-for-core-layout case. */ | ||
322 | #define __module_layout_align ____cacheline_aligned | ||
323 | #else | ||
324 | #define __module_layout_align | ||
325 | #endif | ||
326 | |||
305 | struct module { | 327 | struct module { |
306 | enum module_state state; | 328 | enum module_state state; |
307 | 329 | ||
@@ -366,37 +388,9 @@ struct module { | |||
366 | /* Startup function. */ | 388 | /* Startup function. */ |
367 | int (*init)(void); | 389 | int (*init)(void); |
368 | 390 | ||
369 | /* | 391 | /* Core layout: rbtree is accessed frequently, so keep together. */ |
370 | * If this is non-NULL, vfree() after init() returns. | 392 | struct module_layout core_layout __module_layout_align; |
371 | * | 393 | struct module_layout init_layout; |
372 | * Cacheline align here, such that: | ||
373 | * module_init, module_core, init_size, core_size, | ||
374 | * init_text_size, core_text_size and mtn_core::{mod,node[0]} | ||
375 | * are on the same cacheline. | ||
376 | */ | ||
377 | void *module_init ____cacheline_aligned; | ||
378 | |||
379 | /* Here is the actual code + data, vfree'd on unload. */ | ||
380 | void *module_core; | ||
381 | |||
382 | /* Here are the sizes of the init and core sections */ | ||
383 | unsigned int init_size, core_size; | ||
384 | |||
385 | /* The size of the executable code in each section. */ | ||
386 | unsigned int init_text_size, core_text_size; | ||
387 | |||
388 | #ifdef CONFIG_MODULES_TREE_LOOKUP | ||
389 | /* | ||
390 | * We want mtn_core::{mod,node[0]} to be in the same cacheline as the | ||
391 | * above entries such that a regular lookup will only touch one | ||
392 | * cacheline. | ||
393 | */ | ||
394 | struct mod_tree_node mtn_core; | ||
395 | struct mod_tree_node mtn_init; | ||
396 | #endif | ||
397 | |||
398 | /* Size of RO sections of the module (text+rodata) */ | ||
399 | unsigned int init_ro_size, core_ro_size; | ||
400 | 394 | ||
401 | /* Arch-specific module values */ | 395 | /* Arch-specific module values */ |
402 | struct mod_arch_specific arch; | 396 | struct mod_arch_specific arch; |
@@ -505,15 +499,15 @@ bool is_module_text_address(unsigned long addr); | |||
505 | static inline bool within_module_core(unsigned long addr, | 499 | static inline bool within_module_core(unsigned long addr, |
506 | const struct module *mod) | 500 | const struct module *mod) |
507 | { | 501 | { |
508 | return (unsigned long)mod->module_core <= addr && | 502 | return (unsigned long)mod->core_layout.base <= addr && |
509 | addr < (unsigned long)mod->module_core + mod->core_size; | 503 | addr < (unsigned long)mod->core_layout.base + mod->core_layout.size; |
510 | } | 504 | } |
511 | 505 | ||
512 | static inline bool within_module_init(unsigned long addr, | 506 | static inline bool within_module_init(unsigned long addr, |
513 | const struct module *mod) | 507 | const struct module *mod) |
514 | { | 508 | { |
515 | return (unsigned long)mod->module_init <= addr && | 509 | return (unsigned long)mod->init_layout.base <= addr && |
516 | addr < (unsigned long)mod->module_init + mod->init_size; | 510 | addr < (unsigned long)mod->init_layout.base + mod->init_layout.size; |
517 | } | 511 | } |
518 | 512 | ||
519 | static inline bool within_module(unsigned long addr, const struct module *mod) | 513 | static inline bool within_module(unsigned long addr, const struct module *mod) |