1 // SPDX-License-Identifier: GPL-2.0
2 // Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
4 #include <linux/kernel.h>
6 #include <linux/sched.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>
16 #include <asm/cacheflush.h>
18 static struct page
*vdso_page
;
20 static int __init
init_vdso(void)
22 struct csky_vdso
*vdso
;
25 vdso_page
= alloc_page(GFP_KERNEL
);
27 panic("Cannot allocate vdso");
29 vdso
= vmap(&vdso_page
, 1, 0, PAGE_KERNEL
);
31 panic("Cannot map vdso");
35 err
= setup_vdso_page(vdso
->rt_signal_retcode
);
37 panic("Cannot set signal return code, err: %x.", err
);
39 dcache_wb_range((unsigned long)vdso
, (unsigned long)vdso
+ 16);
45 subsys_initcall(init_vdso
);
47 int arch_setup_additional_pages(struct linux_binprm
*bprm
, int uses_interp
)
51 struct mm_struct
*mm
= current
->mm
;
55 addr
= get_unmapped_area(NULL
, STACK_TOP
, PAGE_SIZE
, 0, 0);
56 if (IS_ERR_VALUE(addr
)) {
61 ret
= install_special_mapping(
65 VM_READ
|VM_EXEC
|VM_MAYREAD
|VM_MAYWRITE
|VM_MAYEXEC
,
70 mm
->context
.vdso
= (void *)addr
;
73 mmap_write_unlock(mm
);
77 const char *arch_vma_name(struct vm_area_struct
*vma
)
79 if (vma
->vm_mm
== NULL
)
82 if (vma
->vm_start
== (long)vma
->vm_mm
->context
.vdso
)