diff options
Diffstat (limited to 'arch/i386/kernel/module.c')
-rw-r--r-- | arch/i386/kernel/module.c | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/arch/i386/kernel/module.c b/arch/i386/kernel/module.c index 5149c8a621f0..470cf97e7cd3 100644 --- a/arch/i386/kernel/module.c +++ b/arch/i386/kernel/module.c | |||
@@ -104,26 +104,38 @@ int apply_relocate_add(Elf32_Shdr *sechdrs, | |||
104 | return -ENOEXEC; | 104 | return -ENOEXEC; |
105 | } | 105 | } |
106 | 106 | ||
107 | extern void apply_alternatives(void *start, void *end); | ||
108 | |||
109 | int module_finalize(const Elf_Ehdr *hdr, | 107 | int module_finalize(const Elf_Ehdr *hdr, |
110 | const Elf_Shdr *sechdrs, | 108 | const Elf_Shdr *sechdrs, |
111 | struct module *me) | 109 | struct module *me) |
112 | { | 110 | { |
113 | const Elf_Shdr *s; | 111 | const Elf_Shdr *s, *text = NULL, *alt = NULL, *locks = NULL; |
114 | char *secstrings = (void *)hdr + sechdrs[hdr->e_shstrndx].sh_offset; | 112 | char *secstrings = (void *)hdr + sechdrs[hdr->e_shstrndx].sh_offset; |
115 | 113 | ||
116 | /* look for .altinstructions to patch */ | ||
117 | for (s = sechdrs; s < sechdrs + hdr->e_shnum; s++) { | 114 | for (s = sechdrs; s < sechdrs + hdr->e_shnum; s++) { |
118 | void *seg; | 115 | if (!strcmp(".text", secstrings + s->sh_name)) |
119 | if (strcmp(".altinstructions", secstrings + s->sh_name)) | 116 | text = s; |
120 | continue; | 117 | if (!strcmp(".altinstructions", secstrings + s->sh_name)) |
121 | seg = (void *)s->sh_addr; | 118 | alt = s; |
122 | apply_alternatives(seg, seg + s->sh_size); | 119 | if (!strcmp(".smp_locks", secstrings + s->sh_name)) |
123 | } | 120 | locks= s; |
121 | } | ||
122 | |||
123 | if (alt) { | ||
124 | /* patch .altinstructions */ | ||
125 | void *aseg = (void *)alt->sh_addr; | ||
126 | apply_alternatives(aseg, aseg + alt->sh_size); | ||
127 | } | ||
128 | if (locks && text) { | ||
129 | void *lseg = (void *)locks->sh_addr; | ||
130 | void *tseg = (void *)text->sh_addr; | ||
131 | alternatives_smp_module_add(me, me->name, | ||
132 | lseg, lseg + locks->sh_size, | ||
133 | tseg, tseg + text->sh_size); | ||
134 | } | ||
124 | return 0; | 135 | return 0; |
125 | } | 136 | } |
126 | 137 | ||
127 | void module_arch_cleanup(struct module *mod) | 138 | void module_arch_cleanup(struct module *mod) |
128 | { | 139 | { |
140 | alternatives_smp_module_del(mod); | ||
129 | } | 141 | } |