module.c (a976c2951d8f376112361830aa7762beff83a205) module.c (ee9f8fce99640811b2b8e79d0d1dbe8bab69ba67)
1/* Kernel module help for x86.
2 Copyright (C) 2001 Rusty Russell.
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
8

--- 21 unchanged lines hidden (view full) ---

30#include <linux/gfp.h>
31#include <linux/jump_label.h>
32#include <linux/random.h>
33
34#include <asm/text-patching.h>
35#include <asm/page.h>
36#include <asm/pgtable.h>
37#include <asm/setup.h>
1/* Kernel module help for x86.
2 Copyright (C) 2001 Rusty Russell.
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
8

--- 21 unchanged lines hidden (view full) ---

30#include <linux/gfp.h>
31#include <linux/jump_label.h>
32#include <linux/random.h>
33
34#include <asm/text-patching.h>
35#include <asm/page.h>
36#include <asm/pgtable.h>
37#include <asm/setup.h>
38#include <asm/unwind.h>
38
39#if 0
40#define DEBUGP(fmt, ...) \
41 printk(KERN_DEBUG fmt, ##__VA_ARGS__)
42#else
43#define DEBUGP(fmt, ...) \
44do { \
45 if (0) \

--- 162 unchanged lines hidden (view full) ---

208}
209#endif
210
211int module_finalize(const Elf_Ehdr *hdr,
212 const Elf_Shdr *sechdrs,
213 struct module *me)
214{
215 const Elf_Shdr *s, *text = NULL, *alt = NULL, *locks = NULL,
39
40#if 0
41#define DEBUGP(fmt, ...) \
42 printk(KERN_DEBUG fmt, ##__VA_ARGS__)
43#else
44#define DEBUGP(fmt, ...) \
45do { \
46 if (0) \

--- 162 unchanged lines hidden (view full) ---

209}
210#endif
211
212int module_finalize(const Elf_Ehdr *hdr,
213 const Elf_Shdr *sechdrs,
214 struct module *me)
215{
216 const Elf_Shdr *s, *text = NULL, *alt = NULL, *locks = NULL,
216 *para = NULL;
217 *para = NULL, *orc = NULL, *orc_ip = NULL;
217 char *secstrings = (void *)hdr + sechdrs[hdr->e_shstrndx].sh_offset;
218
219 for (s = sechdrs; s < sechdrs + hdr->e_shnum; s++) {
220 if (!strcmp(".text", secstrings + s->sh_name))
221 text = s;
222 if (!strcmp(".altinstructions", secstrings + s->sh_name))
223 alt = s;
224 if (!strcmp(".smp_locks", secstrings + s->sh_name))
225 locks = s;
226 if (!strcmp(".parainstructions", secstrings + s->sh_name))
227 para = s;
218 char *secstrings = (void *)hdr + sechdrs[hdr->e_shstrndx].sh_offset;
219
220 for (s = sechdrs; s < sechdrs + hdr->e_shnum; s++) {
221 if (!strcmp(".text", secstrings + s->sh_name))
222 text = s;
223 if (!strcmp(".altinstructions", secstrings + s->sh_name))
224 alt = s;
225 if (!strcmp(".smp_locks", secstrings + s->sh_name))
226 locks = s;
227 if (!strcmp(".parainstructions", secstrings + s->sh_name))
228 para = s;
229 if (!strcmp(".orc_unwind", secstrings + s->sh_name))
230 orc = s;
231 if (!strcmp(".orc_unwind_ip", secstrings + s->sh_name))
232 orc_ip = s;
228 }
229
230 if (alt) {
231 /* patch .altinstructions */
232 void *aseg = (void *)alt->sh_addr;
233 apply_alternatives(aseg, aseg + alt->sh_size);
234 }
235 if (locks && text) {

--- 7 unchanged lines hidden (view full) ---

243 if (para) {
244 void *pseg = (void *)para->sh_addr;
245 apply_paravirt(pseg, pseg + para->sh_size);
246 }
247
248 /* make jump label nops */
249 jump_label_apply_nops(me);
250
233 }
234
235 if (alt) {
236 /* patch .altinstructions */
237 void *aseg = (void *)alt->sh_addr;
238 apply_alternatives(aseg, aseg + alt->sh_size);
239 }
240 if (locks && text) {

--- 7 unchanged lines hidden (view full) ---

248 if (para) {
249 void *pseg = (void *)para->sh_addr;
250 apply_paravirt(pseg, pseg + para->sh_size);
251 }
252
253 /* make jump label nops */
254 jump_label_apply_nops(me);
255
256 if (orc && orc_ip)
257 unwind_module_init(me, (void *)orc_ip->sh_addr, orc_ip->sh_size,
258 (void *)orc->sh_addr, orc->sh_size);
259
251 return 0;
252}
253
254void module_arch_cleanup(struct module *mod)
255{
256 alternatives_smp_module_del(mod);
257}
260 return 0;
261}
262
263void module_arch_cleanup(struct module *mod)
264{
265 alternatives_smp_module_del(mod);
266}