aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorJiri Kosina <jkosina@suse.cz>2015-12-04 16:48:30 -0500
committerJiri Kosina <jkosina@suse.cz>2015-12-04 16:48:30 -0500
commitfc284d631894d8673d229fad92762b66c9875cab (patch)
tree7b530667b9f7c5c4899c024abda518283abf80b4 /kernel
parent444f9e99a840c4050c0530cfef81801a21a59f4c (diff)
parente0224418516b4d8a6c2160574bac18447c354ef0 (diff)
Merge branch 'from-rusty/modules-next' into for-4.5/core
As agreed with Rusty, we're taking a current module-next pile through livepatching.git, as it contains solely patches that are pre-requisity for module page protection cleanups in livepatching. Rusty will be restarting module-next from scratch. Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/debug/kdb/kdb_main.c4
-rw-r--r--kernel/gcov/base.c7
-rw-r--r--kernel/module.c349
-rw-r--r--kernel/panic.c5
-rw-r--r--kernel/pid.c4
-rw-r--r--kernel/signal.c2
6 files changed, 175 insertions, 196 deletions
diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
index 4121345498e0..2a20c0dfdafc 100644
--- a/kernel/debug/kdb/kdb_main.c
+++ b/kernel/debug/kdb/kdb_main.c
@@ -2021,7 +2021,7 @@ static int kdb_lsmod(int argc, const char **argv)
2021 continue; 2021 continue;
2022 2022
2023 kdb_printf("%-20s%8u 0x%p ", mod->name, 2023 kdb_printf("%-20s%8u 0x%p ", mod->name,
2024 mod->core_size, (void *)mod); 2024 mod->core_layout.size, (void *)mod);
2025#ifdef CONFIG_MODULE_UNLOAD 2025#ifdef CONFIG_MODULE_UNLOAD
2026 kdb_printf("%4d ", module_refcount(mod)); 2026 kdb_printf("%4d ", module_refcount(mod));
2027#endif 2027#endif
@@ -2031,7 +2031,7 @@ static int kdb_lsmod(int argc, const char **argv)
2031 kdb_printf(" (Loading)"); 2031 kdb_printf(" (Loading)");
2032 else 2032 else
2033 kdb_printf(" (Live)"); 2033 kdb_printf(" (Live)");
2034 kdb_printf(" 0x%p", mod->module_core); 2034 kdb_printf(" 0x%p", mod->core_layout.base);
2035 2035
2036#ifdef CONFIG_MODULE_UNLOAD 2036#ifdef CONFIG_MODULE_UNLOAD
2037 { 2037 {
diff --git a/kernel/gcov/base.c b/kernel/gcov/base.c
index 7080ae1eb6c1..2f9df37940a0 100644
--- a/kernel/gcov/base.c
+++ b/kernel/gcov/base.c
@@ -123,11 +123,6 @@ void gcov_enable_events(void)
123} 123}
124 124
125#ifdef CONFIG_MODULES 125#ifdef CONFIG_MODULES
126static inline int within(void *addr, void *start, unsigned long size)
127{
128 return ((addr >= start) && (addr < start + size));
129}
130
131/* Update list and generate events when modules are unloaded. */ 126/* Update list and generate events when modules are unloaded. */
132static int gcov_module_notifier(struct notifier_block *nb, unsigned long event, 127static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
133 void *data) 128 void *data)
@@ -142,7 +137,7 @@ static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
142 137
143 /* Remove entries located in module from linked list. */ 138 /* Remove entries located in module from linked list. */
144 while ((info = gcov_info_next(info))) { 139 while ((info = gcov_info_next(info))) {
145 if (within(info, mod->module_core, mod->core_size)) { 140 if (within_module((unsigned long)info, mod)) {
146 gcov_info_unlink(prev, info); 141 gcov_info_unlink(prev, info);
147 if (gcov_events_enabled) 142 if (gcov_events_enabled)
148 gcov_event(GCOV_REMOVE, info); 143 gcov_event(GCOV_REMOVE, info);
diff --git a/kernel/module.c b/kernel/module.c
index 8f051a106676..912e891e0e2f 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -80,15 +80,6 @@
80# define debug_align(X) (X) 80# define debug_align(X) (X)
81#endif 81#endif
82 82
83/*
84 * Given BASE and SIZE this macro calculates the number of pages the
85 * memory regions occupies
86 */
87#define MOD_NUMBER_OF_PAGES(BASE, SIZE) (((SIZE) > 0) ? \
88 (PFN_DOWN((unsigned long)(BASE) + (SIZE) - 1) - \
89 PFN_DOWN((unsigned long)BASE) + 1) \
90 : (0UL))
91
92/* If this is set, the section belongs in the init part of the module */ 83/* If this is set, the section belongs in the init part of the module */
93#define INIT_OFFSET_MASK (1UL << (BITS_PER_LONG-1)) 84#define INIT_OFFSET_MASK (1UL << (BITS_PER_LONG-1))
94 85
@@ -108,13 +99,6 @@ static LIST_HEAD(modules);
108 * Use a latched RB-tree for __module_address(); this allows us to use 99 * Use a latched RB-tree for __module_address(); this allows us to use
109 * RCU-sched lookups of the address from any context. 100 * RCU-sched lookups of the address from any context.
110 * 101 *
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 102 * 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 103 * __module_address() hard by doing a lot of stack unwinding; potentially from
120 * NMI context. 104 * NMI context.
@@ -122,24 +106,16 @@ static LIST_HEAD(modules);
122 106
123static __always_inline unsigned long __mod_tree_val(struct latch_tree_node *n) 107static __always_inline unsigned long __mod_tree_val(struct latch_tree_node *n)
124{ 108{
125 struct mod_tree_node *mtn = container_of(n, struct mod_tree_node, node); 109 struct module_layout *layout = container_of(n, struct module_layout, mtn.node);
126 struct module *mod = mtn->mod;
127 110
128 if (unlikely(mtn == &mod->mtn_init)) 111 return (unsigned long)layout->base;
129 return (unsigned long)mod->module_init;
130
131 return (unsigned long)mod->module_core;
132} 112}
133 113
134static __always_inline unsigned long __mod_tree_size(struct latch_tree_node *n) 114static __always_inline unsigned long __mod_tree_size(struct latch_tree_node *n)
135{ 115{
136 struct mod_tree_node *mtn = container_of(n, struct mod_tree_node, node); 116 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 117
142 return (unsigned long)mod->core_size; 118 return (unsigned long)layout->size;
143} 119}
144 120
145static __always_inline bool 121static __always_inline bool
@@ -197,23 +173,23 @@ static void __mod_tree_remove(struct mod_tree_node *node)
197 */ 173 */
198static void mod_tree_insert(struct module *mod) 174static void mod_tree_insert(struct module *mod)
199{ 175{
200 mod->mtn_core.mod = mod; 176 mod->core_layout.mtn.mod = mod;
201 mod->mtn_init.mod = mod; 177 mod->init_layout.mtn.mod = mod;
202 178
203 __mod_tree_insert(&mod->mtn_core); 179 __mod_tree_insert(&mod->core_layout.mtn);
204 if (mod->init_size) 180 if (mod->init_layout.size)
205 __mod_tree_insert(&mod->mtn_init); 181 __mod_tree_insert(&mod->init_layout.mtn);
206} 182}
207 183
208static void mod_tree_remove_init(struct module *mod) 184static void mod_tree_remove_init(struct module *mod)
209{ 185{
210 if (mod->init_size) 186 if (mod->init_layout.size)
211 __mod_tree_remove(&mod->mtn_init); 187 __mod_tree_remove(&mod->init_layout.mtn);
212} 188}
213 189
214static void mod_tree_remove(struct module *mod) 190static void mod_tree_remove(struct module *mod)
215{ 191{
216 __mod_tree_remove(&mod->mtn_core); 192 __mod_tree_remove(&mod->core_layout.mtn);
217 mod_tree_remove_init(mod); 193 mod_tree_remove_init(mod);
218} 194}
219 195
@@ -267,9 +243,9 @@ static void __mod_update_bounds(void *base, unsigned int size)
267 243
268static void mod_update_bounds(struct module *mod) 244static void mod_update_bounds(struct module *mod)
269{ 245{
270 __mod_update_bounds(mod->module_core, mod->core_size); 246 __mod_update_bounds(mod->core_layout.base, mod->core_layout.size);
271 if (mod->init_size) 247 if (mod->init_layout.size)
272 __mod_update_bounds(mod->module_init, mod->init_size); 248 __mod_update_bounds(mod->init_layout.base, mod->init_layout.size);
273} 249}
274 250
275#ifdef CONFIG_KGDB_KDB 251#ifdef CONFIG_KGDB_KDB
@@ -1214,7 +1190,7 @@ struct module_attribute module_uevent =
1214static ssize_t show_coresize(struct module_attribute *mattr, 1190static ssize_t show_coresize(struct module_attribute *mattr,
1215 struct module_kobject *mk, char *buffer) 1191 struct module_kobject *mk, char *buffer)
1216{ 1192{
1217 return sprintf(buffer, "%u\n", mk->mod->core_size); 1193 return sprintf(buffer, "%u\n", mk->mod->core_layout.size);
1218} 1194}
1219 1195
1220static struct module_attribute modinfo_coresize = 1196static struct module_attribute modinfo_coresize =
@@ -1223,7 +1199,7 @@ static struct module_attribute modinfo_coresize =
1223static ssize_t show_initsize(struct module_attribute *mattr, 1199static ssize_t show_initsize(struct module_attribute *mattr,
1224 struct module_kobject *mk, char *buffer) 1200 struct module_kobject *mk, char *buffer)
1225{ 1201{
1226 return sprintf(buffer, "%u\n", mk->mod->init_size); 1202 return sprintf(buffer, "%u\n", mk->mod->init_layout.size);
1227} 1203}
1228 1204
1229static struct module_attribute modinfo_initsize = 1205static struct module_attribute modinfo_initsize =
@@ -1873,64 +1849,75 @@ static void mod_sysfs_teardown(struct module *mod)
1873/* 1849/*
1874 * LKM RO/NX protection: protect module's text/ro-data 1850 * LKM RO/NX protection: protect module's text/ro-data
1875 * from modification and any data from execution.