Skip to content

Commit 5e5a29b

Browse files
anderskIngo Molnar
authored andcommitted
x86, 64-bit: patch paravirt inline replacements when loading modules
small speedup. Paravirt replacements were added to the i386 module loader by commit 139ec7c. This adds the same code to the x86_64 module loader. Signed-off-by: Anders Kaseorg <andersk@mit.edu> Acked-by: "H. Peter Anvin" <hpa@zytor.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
1 parent 543cf4c commit 5e5a29b

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

arch/x86/kernel/module_64.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,8 @@ int module_finalize(const Elf_Ehdr *hdr,
150150
const Elf_Shdr *sechdrs,
151151
struct module *me)
152152
{
153-
const Elf_Shdr *s, *text = NULL, *alt = NULL, *locks = NULL;
153+
const Elf_Shdr *s, *text = NULL, *alt = NULL, *locks = NULL,
154+
*para = NULL;
154155
char *secstrings = (void *)hdr + sechdrs[hdr->e_shstrndx].sh_offset;
155156

156157
for (s = sechdrs; s < sechdrs + hdr->e_shnum; s++) {
@@ -160,6 +161,8 @@ int module_finalize(const Elf_Ehdr *hdr,
160161
alt = s;
161162
if (!strcmp(".smp_locks", secstrings + s->sh_name))
162163
locks= s;
164+
if (!strcmp(".parainstructions", secstrings + s->sh_name))
165+
para = s;
163166
}
164167

165168
if (alt) {
@@ -175,6 +178,11 @@ int module_finalize(const Elf_Ehdr *hdr,
175178
tseg, tseg + text->sh_size);
176179
}
177180

181+
if (para) {
182+
void *pseg = (void *)para->sh_addr;
183+
apply_paravirt(pseg, pseg + para->sh_size);
184+
}
185+
178186
return module_bug_finalize(hdr, sechdrs, me);
179187
}
180188

0 commit comments

Comments
 (0)