Commit | Line | Data |
---|---|---|
3dd681d9 WD |
1 | /* |
2 | * Based on arch/arm/kernel/sys_arm.c | |
3 | * | |
4 | * Copyright (C) People who wrote linux/arch/i386/kernel/sys_i386.c | |
5 | * Copyright (C) 1995, 1996 Russell King. | |
6 | * Copyright (C) 2012 ARM Ltd. | |
7 | * | |
8 | * This program is free software; you can redistribute it and/or modify | |
9 | * it under the terms of the GNU General Public License version 2 as | |
10 | * published by the Free Software Foundation. | |
11 | * | |
12 | * This program is distributed in the hope that it will be useful, | |
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | * GNU General Public License for more details. | |
16 | * | |
17 | * You should have received a copy of the GNU General Public License | |
18 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
19 | */ | |
20 | ||
3dd681d9 WD |
21 | #include <linux/compat.h> |
22 | #include <linux/personality.h> | |
23 | #include <linux/sched.h> | |
24 | #include <linux/slab.h> | |
25 | #include <linux/syscalls.h> | |
26 | #include <linux/uaccess.h> | |
27 | ||
28 | #include <asm/cacheflush.h> | |
f3d447a9 | 29 | #include <asm/unistd32.h> |
3dd681d9 WD |
30 | |
31 | asmlinkage int compat_sys_fork(struct pt_regs *regs) | |
32 | { | |
33 | return do_fork(SIGCHLD, regs->compat_sp, regs, 0, NULL, NULL); | |
34 | } | |
35 | ||
36 | asmlinkage int compat_sys_clone(unsigned long clone_flags, unsigned long newsp, | |
37 | int __user *parent_tidptr, int tls_val, | |
38 | int __user *child_tidptr, struct pt_regs *regs) | |
39 | { | |
40 | if (!newsp) | |
41 | newsp = regs->compat_sp; | |
42 | ||
43 | return do_fork(clone_flags, newsp, regs, 0, parent_tidptr, child_tidptr); | |
44 | } | |
45 | ||
46 | asmlinkage int compat_sys_vfork(struct pt_regs *regs) | |
47 | { | |
48 | return do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, regs->compat_sp, | |
49 | regs, 0, NULL, NULL); | |
50 | } | |
51 | ||
52 | asmlinkage int compat_sys_execve(const char __user *filenamei, | |
53 | compat_uptr_t argv, compat_uptr_t envp, | |
54 | struct pt_regs *regs) | |
55 | { | |
56 | int error; | |
57 | char * filename; | |
58 | ||
59 | filename = getname(filenamei); | |
60 | error = PTR_ERR(filename); | |
61 | if (IS_ERR(filename)) | |
62 | goto out; | |
63 | error = compat_do_execve(filename, compat_ptr(argv), compat_ptr(envp), | |
64 | regs); | |
65 | putname(filename); | |
66 | out: | |
67 | return error; | |
68 | } | |
69 | ||
70 | asmlinkage int compat_sys_sched_rr_get_interval(compat_pid_t pid, | |
71 | struct compat_timespec __user *interval) | |
72 | { | |
73 | struct timespec t; | |
74 | int ret; | |
75 | mm_segment_t old_fs = get_fs(); | |
76 | ||
77 | set_fs(KERNEL_DS); | |
78 | ret = sys_sched_rr_get_interval(pid, (struct timespec __user *)&t); | |
79 | set_fs(old_fs); | |
80 | if (put_compat_timespec(&t, interval)) | |
81 | return -EFAULT; | |
82 | return ret; | |
83 | } | |
84 | ||
3dd681d9 WD |
85 | static inline void |
86 | do_compat_cache_op(unsigned long start, unsigned long end, int flags) | |
87 | { | |
88 | struct mm_struct *mm = current->active_mm; | |
89 | struct vm_area_struct *vma; | |
90 | ||
91 | if (end < start || flags) | |
92 | return; | |
93 | ||
94 | down_read(&mm->mmap_sem); | |
95 | vma = find_vma(mm, start); | |
96 | if (vma && vma->vm_start < end) { | |
97 | if (start < vma->vm_start) | |
98 | start = vma->vm_start; | |
99 | if (end > vma->vm_end) | |
100 | end = vma->vm_end; | |
101 | up_read(&mm->mmap_sem); | |
102 | __flush_cache_user_range(start & PAGE_MASK, PAGE_ALIGN(end)); | |
103 | return; | |
104 | } | |
105 | up_read(&mm->mmap_sem); | |
106 | } | |
107 | ||
108 | /* | |
109 | * Handle all unrecognised system calls. | |
110 | */ | |
111 | long compat_arm_syscall(struct pt_regs *regs) | |
112 | { | |
113 | unsigned int no = regs->regs[7]; | |
114 | ||
115 | switch (no) { | |
116 | /* | |
117 | * Flush a region from virtual address 'r0' to virtual address 'r1' | |
118 | * _exclusive_. There is no alignment requirement on either address; | |
119 | * user space does not need to know the hardware cache layout. | |
120 | * | |
121 | * r2 contains flags. It should ALWAYS be passed as ZERO until it | |
122 | * is defined to be something else. For now we ignore it, but may | |
123 | * the fires of hell burn in your belly if you break this rule. ;) | |
124 | * | |
125 | * (at a later date, we may want to allow this call to not flush | |
126 | * various aspects of the cache. Passing '0' will guarantee that | |
127 | * everything necessary gets flushed to maintain consistency in | |
128 | * the specified region). | |
129 | */ | |
130 | case __ARM_NR_compat_cacheflush: | |
131 | do_compat_cache_op(regs->regs[0], regs->regs[1], regs->regs[2]); | |
132 | return 0; | |
133 | ||
134 | case __ARM_NR_compat_set_tls: | |
135 | current->thread.tp_value = regs->regs[0]; | |
136 | asm ("msr tpidrro_el0, %0" : : "r" (regs->regs[0])); | |
137 | return 0; | |
138 | ||
139 | default: | |
140 | return -ENOSYS; | |
141 | } | |
142 | } |