aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/vdso
diff options
context:
space:
mode:
authorAndy Lutomirski <luto@mit.edu>2011-07-13 09:24:11 -0400
committerH. Peter Anvin <hpa@linux.intel.com>2011-07-13 14:23:07 -0400
commit1b3f2a72bbcfdf92e368a44448c45eb639b05b5e (patch)
tree99932e5554b80458fd6769f433c96fea8cbab1de /arch/x86/vdso
parent59e97e4d6fbcd5b74a94cb48bcbfc6f8478a5e93 (diff)
x86-64: Allow alternative patching in the vDSO
This code is short enough and different enough from the module loader that it's not worth trying to share anything. Signed-off-by: Andy Lutomirski <luto@mit.edu> Link: http://lkml.kernel.org/r/e73112e4381fff29e31b882c2d0856822edaea53.1310563276.git.luto@mit.edu Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Diffstat (limited to 'arch/x86/vdso')
-rw-r--r--arch/x86/vdso/vma.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/arch/x86/vdso/vma.c b/arch/x86/vdso/vma.c
index 7abd2be0f9b9..c39938d1332f 100644
--- a/arch/x86/vdso/vma.c
+++ b/arch/x86/vdso/vma.c
@@ -23,11 +23,44 @@ extern unsigned short vdso_sync_cpuid;
23static struct page **vdso_pages; 23static struct page **vdso_pages;
24static unsigned vdso_size; 24static unsigned vdso_size;
25 25
26static void __init patch_vdso(void *vdso, size_t len)
27{
28 Elf64_Ehdr *hdr = vdso;
29 Elf64_Shdr *sechdrs, *alt_sec = 0;
30 char *secstrings;
31 void *alt_data;
32 int i;
33
34 BUG_ON(len < sizeof(Elf64_Ehdr));
35 BUG_ON(memcmp(hdr->e_ident, ELFMAG, SELFMAG) != 0);
36
37 sechdrs = (void *)hdr + hdr->e_shoff;
38 secstrings = (void *)hdr + sechdrs[hdr->e_shstrndx].sh_offset;
39
40 for (i = 1; i < hdr->e_shnum; i++) {
41 Elf64_Shdr *shdr = &sechdrs[i];
42 if (!strcmp(secstrings + shdr->sh_name, ".altinstructions")) {
43 alt_sec = shdr;
44 goto found;
45 }
46 }
47
48 /* If we get here, it's probably a bug. */
49 pr_warning("patch_vdso: .altinstructions not found\n");
50 return; /* nothing to patch */
51
52found:
53 alt_data = (void *)hdr + alt_sec->sh_offset;
54 apply_alternatives(alt_data, alt_data + alt_sec->sh_size);
55}
56
26static int __init init_vdso_vars(void) 57static int __init init_vdso_vars(void)
27{ 58{
28 int npages = (vdso_end - vdso_start + PAGE_SIZE - 1) / PAGE_SIZE; 59 int npages = (vdso_end - vdso_start + PAGE_SIZE - 1) / PAGE_SIZE;
29 int i; 60 int i;
30 61
62 patch_vdso(vdso_start, vdso_end - vdso_start);
63
31 vdso_size = npages << PAGE_SHIFT; 64 vdso_size = npages << PAGE_SHIFT;
32 vdso_pages = kmalloc(sizeof(struct page *) * npages, GFP_KERNEL); 65 vdso_pages = kmalloc(sizeof(struct page *) * npages, GFP_KERNEL);
33 if (!vdso_pages) 66 if (!vdso_pages)