Merge tag 'locking-urgent-2020-12-27' of git://git.kernel.org/pub/scm/linux/kernel...
[linux/fpc-iii.git] / arch / csky / kernel / vdso.c
blobabc3dbc658d4979aa9260561a73b60225796561a
1 // SPDX-License-Identifier: GPL-2.0
2 // Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
4 #include <linux/kernel.h>
5 #include <linux/err.h>
6 #include <linux/sched.h>
7 #include <linux/mm.h>
8 #include <linux/init.h>
9 #include <linux/binfmts.h>
10 #include <linux/elf.h>
11 #include <linux/vmalloc.h>
12 #include <linux/unistd.h>
13 #include <linux/uaccess.h>
15 #include <asm/vdso.h>
16 #include <asm/cacheflush.h>
18 static struct page *vdso_page;
20 static int __init init_vdso(void)
22 struct csky_vdso *vdso;
23 int err = 0;
25 vdso_page = alloc_page(GFP_KERNEL);
26 if (!vdso_page)
27 panic("Cannot allocate vdso");
29 vdso = vmap(&vdso_page, 1, 0, PAGE_KERNEL);
30 if (!vdso)
31 panic("Cannot map vdso");
33 clear_page(vdso);
35 err = setup_vdso_page(vdso->rt_signal_retcode);
36 if (err)
37 panic("Cannot set signal return code, err: %x.", err);
39 dcache_wb_range((unsigned long)vdso, (unsigned long)vdso + 16);
41 vunmap(vdso);
43 return 0;
45 subsys_initcall(init_vdso);
47 int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
49 int ret;
50 unsigned long addr;
51 struct mm_struct *mm = current->mm;
53 mmap_write_lock(mm);
55 addr = get_unmapped_area(NULL, STACK_TOP, PAGE_SIZE, 0, 0);
56 if (IS_ERR_VALUE(addr)) {
57 ret = addr;
58 goto up_fail;
61 ret = install_special_mapping(
62 mm,
63 addr,
64 PAGE_SIZE,
65 VM_READ|VM_EXEC|VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC,
66 &vdso_page);
67 if (ret)
68 goto up_fail;
70 mm->context.vdso = (void *)addr;
72 up_fail:
73 mmap_write_unlock(mm);
74 return ret;
77 const char *arch_vma_name(struct vm_area_struct *vma)
79 if (vma->vm_mm == NULL)
80 return NULL;
82 if (vma->vm_start == (long)vma->vm_mm->context.vdso)
83 return "[vdso]";
84 else
85 return NULL;