x86/speculation/mds: Fix documentation typo
[linux/fpc-iii.git] / arch / x86 / um / vdso / vma.c
blob6be22f991b59cd2959bf3aa01ddafef94b96b985
1 /*
2 * Copyright (C) 2011 Richard Weinberger <richrd@nod.at>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 */
9 #include <linux/slab.h>
10 #include <linux/sched.h>
11 #include <linux/mm.h>
12 #include <asm/page.h>
13 #include <asm/elf.h>
14 #include <linux/init.h>
16 static unsigned int __read_mostly vdso_enabled = 1;
17 unsigned long um_vdso_addr;
19 extern unsigned long task_size;
20 extern char vdso_start[], vdso_end[];
22 static struct page **vdsop;
24 static int __init init_vdso(void)
26 struct page *um_vdso;
28 BUG_ON(vdso_end - vdso_start > PAGE_SIZE);
30 um_vdso_addr = task_size - PAGE_SIZE;
32 vdsop = kmalloc(sizeof(struct page *), GFP_KERNEL);
33 if (!vdsop)
34 goto oom;
36 um_vdso = alloc_page(GFP_KERNEL);
37 if (!um_vdso) {
38 kfree(vdsop);
40 goto oom;
43 copy_page(page_address(um_vdso), vdso_start);
44 *vdsop = um_vdso;
46 return 0;
48 oom:
49 printk(KERN_ERR "Cannot allocate vdso\n");
50 vdso_enabled = 0;
52 return -ENOMEM;
54 subsys_initcall(init_vdso);
56 int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
58 int err;
59 struct mm_struct *mm = current->mm;
61 if (!vdso_enabled)
62 return 0;
64 if (down_write_killable(&mm->mmap_sem))
65 return -EINTR;
67 err = install_special_mapping(mm, um_vdso_addr, PAGE_SIZE,
68 VM_READ|VM_EXEC|
69 VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC,
70 vdsop);
72 up_write(&mm->mmap_sem);
74 return err;