2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
6 * Copyright (C) 2009, 2010 Cavium Networks, Inc.
10 #include <linux/kernel.h>
11 #include <linux/err.h>
12 #include <linux/sched.h>
14 #include <linux/init.h>
15 #include <linux/binfmts.h>
16 #include <linux/elf.h>
17 #include <linux/vmalloc.h>
18 #include <linux/unistd.h>
24 * Including <asm/unistd.h> would give use the 64-bit syscall numbers ...
26 #define __NR_O32_sigreturn 4119
27 #define __NR_O32_rt_sigreturn 4193
28 #define __NR_N32_rt_sigreturn 6211
30 static struct page *vdso_page;
32 static void __init install_trampoline(u32 *tramp, unsigned int sigreturn)
34 uasm_i_addiu(&tramp, 2, 0, sigreturn); /* li v0, sigreturn */
35 uasm_i_syscall(&tramp, 0);
38 static int __init init_vdso(void)
40 struct mips_vdso *vdso;
42 vdso_page = alloc_page(GFP_KERNEL);
44 panic("Cannot allocate vdso");
46 vdso = vmap(&vdso_page, 1, 0, PAGE_KERNEL);
48 panic("Cannot map vdso");
51 install_trampoline(vdso->rt_signal_trampoline, __NR_rt_sigreturn);
53 install_trampoline(vdso->signal_trampoline, __NR_sigreturn);
55 install_trampoline(vdso->n32_rt_signal_trampoline,
56 __NR_N32_rt_sigreturn);
57 install_trampoline(vdso->o32_signal_trampoline, __NR_O32_sigreturn);
58 install_trampoline(vdso->o32_rt_signal_trampoline,
59 __NR_O32_rt_sigreturn);
66 subsys_initcall(init_vdso);
68 static unsigned long vdso_addr(unsigned long start)
73 int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
77 struct mm_struct *mm = current->mm;
79 down_write(&mm->mmap_sem);
81 addr = vdso_addr(mm->start_stack);
83 addr = get_unmapped_area(NULL, addr, PAGE_SIZE, 0, 0);
84 if (IS_ERR_VALUE(addr)) {
89 ret = install_special_mapping(mm, addr, PAGE_SIZE,
91 VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC,
97 mm->context.vdso = (void *)addr;
100 up_write(&mm->mmap_sem);
104 const char *arch_vma_name(struct vm_area_struct *vma)
106 if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)