1 // SPDX-License-Identifier: GPL-2.0-only
3 * vDSO implementation for Hexagon
5 * Copyright (c) 2011, The Linux Foundation. All rights reserved.
10 #include <linux/vmalloc.h>
11 #include <linux/binfmts.h>
15 static struct page *vdso_page;
17 /* Create a vDSO page holding the signal trampoline.
18 * We want this for a non-executable stack.
20 static int __init vdso_init(void)
22 struct hexagon_vdso *vdso;
24 vdso_page = alloc_page(GFP_KERNEL);
26 panic("Cannot allocate vdso");
28 vdso = vmap(&vdso_page, 1, 0, PAGE_KERNEL);
30 panic("Cannot map vdso");
33 /* Install the signal trampoline; currently looks like this:
34 * r6 = #__NR_rt_sigreturn;
37 vdso->rt_signal_trampoline[0] = __rt_sigtramp_template[0];
38 vdso->rt_signal_trampoline[1] = __rt_sigtramp_template[1];
44 arch_initcall(vdso_init);
47 * Called from binfmt_elf. Create a VMA for the vDSO page.
49 int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
52 unsigned long vdso_base;
53 struct mm_struct *mm = current->mm;
55 if (mmap_write_lock_killable(mm))
58 /* Try to get it loaded right near ld.so/glibc. */
59 vdso_base = STACK_TOP;
61 vdso_base = get_unmapped_area(NULL, vdso_base, PAGE_SIZE, 0, 0);
62 if (IS_ERR_VALUE(vdso_base)) {
67 /* MAYWRITE to allow gdb to COW and set breakpoints. */
68 ret = install_special_mapping(mm, vdso_base, PAGE_SIZE,
70 VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC,
76 mm->context.vdso = (void *)vdso_base;
79 mmap_write_unlock(mm);
83 const char *arch_vma_name(struct vm_area_struct *vma)
85 if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)