1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21#include <linux/err.h>
22#include <linux/mm.h>
23#include <linux/vmalloc.h>
24#include <linux/binfmts.h>
25
26#include <asm/vdso.h>
27
28static struct page *vdso_page;
29
30
31
32
33static int __init vdso_init(void)
34{
35 struct hexagon_vdso *vdso;
36
37 vdso_page = alloc_page(GFP_KERNEL);
38 if (!vdso_page)
39 panic("Cannot allocate vdso");
40
41 vdso = vmap(&vdso_page, 1, 0, PAGE_KERNEL);
42 if (!vdso)
43 panic("Cannot map vdso");
44 clear_page(vdso);
45
46
47
48
49
50 vdso->rt_signal_trampoline[0] = __rt_sigtramp_template[0];
51 vdso->rt_signal_trampoline[1] = __rt_sigtramp_template[1];
52
53 vunmap(vdso);
54
55 return 0;
56}
57arch_initcall(vdso_init);
58
59
60
61
62int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
63{
64 int ret;
65 unsigned long vdso_base;
66 struct mm_struct *mm = current->mm;
67
68 down_write(&mm->mmap_sem);
69
70
71 vdso_base = STACK_TOP;
72
73 vdso_base = get_unmapped_area(NULL, vdso_base, PAGE_SIZE, 0, 0);
74 if (IS_ERR_VALUE(vdso_base)) {
75 ret = vdso_base;
76 goto up_fail;
77 }
78
79
80 ret = install_special_mapping(mm, vdso_base, PAGE_SIZE,
81 VM_READ|VM_EXEC|
82 VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC,
83 &vdso_page);
84
85 if (ret)
86 goto up_fail;
87
88 mm->context.vdso = (void *)vdso_base;
89
90up_fail:
91 up_write(&mm->mmap_sem);
92 return ret;
93}
94
95const char *arch_vma_name(struct vm_area_struct *vma)
96{
97 if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
98 return "[vdso]";
99 return NULL;
100}
101