diff options
author | Ralf Baechle <ralf@linux-mips.org> | 2012-10-09 15:16:07 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2012-10-14 19:31:30 -0400 |
commit | baf9ff74eda9f0efcc8a68e8a9c9d183be13a810 (patch) | |
tree | 4edd32d85cae4ef850973214a922c376537991c3 | |
parent | 8f54bcacbc39f883bde2210cf2754e5d198f55a4 (diff) |
MIPS: Switch over to generic sys_execve and kernel_execve.
This version contains a few updates by David Daney, in particular it's
now using __builtin_frame_address() instead of asm() which depending
on personal taste, is slightly more appealing.
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
-rw-r--r-- | arch/mips/include/asm/ptrace.h | 6 | ||||
-rw-r--r-- | arch/mips/include/asm/unistd.h | 2 | ||||
-rw-r--r-- | arch/mips/kernel/entry.S | 9 | ||||
-rw-r--r-- | arch/mips/kernel/linux32.c | 21 | ||||
-rw-r--r-- | arch/mips/kernel/scall64-n32.S | 2 | ||||
-rw-r--r-- | arch/mips/kernel/scall64-o32.S | 2 | ||||
-rw-r--r-- | arch/mips/kernel/syscall.c | 53 |
7 files changed, 19 insertions, 76 deletions
diff --git a/arch/mips/include/asm/ptrace.h b/arch/mips/include/asm/ptrace.h index 4f5da948a777..cec5e125f7e4 100644 --- a/arch/mips/include/asm/ptrace.h +++ b/arch/mips/include/asm/ptrace.h | |||
@@ -61,4 +61,10 @@ static inline void die_if_kernel(const char *str, struct pt_regs *regs) | |||
61 | die(str, regs); | 61 | die(str, regs); |
62 | } | 62 | } |
63 | 63 | ||
64 | #define current_pt_regs() \ | ||
65 | ({ \ | ||
66 | unsigned long sp = (unsigned long)__builtin_frame_address(0); \ | ||
67 | (struct pt_regs *)((sp | (THREAD_SIZE - 1)) + 1 - 32) - 1; \ | ||
68 | }) | ||
69 | |||
64 | #endif /* _ASM_PTRACE_H */ | 70 | #endif /* _ASM_PTRACE_H */ |
diff --git a/arch/mips/include/asm/unistd.h b/arch/mips/include/asm/unistd.h index 9e47cc11aa26..8ae908c66e59 100644 --- a/arch/mips/include/asm/unistd.h +++ b/arch/mips/include/asm/unistd.h | |||
@@ -18,8 +18,10 @@ | |||
18 | #ifndef __ASSEMBLY__ | 18 | #ifndef __ASSEMBLY__ |
19 | 19 | ||
20 | #define __ARCH_OMIT_COMPAT_SYS_GETDENTS64 | 20 | #define __ARCH_OMIT_COMPAT_SYS_GETDENTS64 |
21 | #define __ARCH_WANT_KERNEL_EXECVE | ||
21 | #define __ARCH_WANT_OLD_READDIR | 22 | #define __ARCH_WANT_OLD_READDIR |
22 | #define __ARCH_WANT_SYS_ALARM | 23 | #define __ARCH_WANT_SYS_ALARM |
24 | #define __ARCH_WANT_SYS_EXECVE | ||
23 | #define __ARCH_WANT_SYS_GETHOSTNAME | 25 | #define __ARCH_WANT_SYS_GETHOSTNAME |
24 | #define __ARCH_WANT_SYS_IPC | 26 | #define __ARCH_WANT_SYS_IPC |
25 | #define __ARCH_WANT_SYS_PAUSE | 27 | #define __ARCH_WANT_SYS_PAUSE |
diff --git a/arch/mips/kernel/entry.S b/arch/mips/kernel/entry.S index aab6997b8f47..5dcb5fbbbd53 100644 --- a/arch/mips/kernel/entry.S +++ b/arch/mips/kernel/entry.S | |||
@@ -192,6 +192,15 @@ syscall_exit_work: | |||
192 | jal syscall_trace_leave | 192 | jal syscall_trace_leave |
193 | b resume_userspace | 193 | b resume_userspace |
194 | 194 | ||
195 | LEAF(ret_from_kernel_execve) | ||
196 | move sp, a0 | ||
197 | ori $28, sp, _THREAD_SIZE - 1 | ||
198 | xori $28, $28, _THREAD_SIZE - 1 | ||
199 | li v0, 0 | ||
200 | li a3, 0 | ||
201 | j syscall_exit_partial | ||
202 | END(ret_from_kernel_execve) | ||
203 | |||
195 | #if defined(CONFIG_CPU_MIPSR2) || defined(CONFIG_MIPS_MT) | 204 | #if defined(CONFIG_CPU_MIPSR2) || defined(CONFIG_MIPS_MT) |
196 | 205 | ||
197 | /* | 206 | /* |
diff --git a/arch/mips/kernel/linux32.c b/arch/mips/kernel/linux32.c index 3a21acedf882..8796dbc7e358 100644 --- a/arch/mips/kernel/linux32.c +++ b/arch/mips/kernel/linux32.c | |||
@@ -3,7 +3,6 @@ | |||
3 | * | 3 | * |
4 | * Copyright (C) 2000 Silicon Graphics, Inc. | 4 | * Copyright (C) 2000 Silicon Graphics, Inc. |
5 | * Written by Ulf Carlsson (ulfc@engr.sgi.com) | 5 | * Written by Ulf Carlsson (ulfc@engr.sgi.com) |
6 | * sys32_execve from ia64/ia32 code, Feb 2000, Kanoj Sarcar (kanoj@sgi.com) | ||
7 | */ | 6 | */ |
8 | #include <linux/compiler.h> | 7 | #include <linux/compiler.h> |
9 | #include <linux/mm.h> | 8 | #include <linux/mm.h> |
@@ -77,26 +76,6 @@ out: | |||
77 | return error; | 76 | return error; |
78 | } | 77 | } |
79 | 78 | ||
80 | /* | ||
81 | * sys_execve() executes a new program. | ||
82 | */ | ||
83 | asmlinkage int sys32_execve(nabi_no_regargs struct pt_regs regs) | ||
84 | { | ||
85 | int error; | ||
86 | struct filename *filename; | ||
87 | |||
88 | filename = getname(compat_ptr(regs.regs[4])); | ||
89 | error = PTR_ERR(filename); | ||
90 | if (IS_ERR(filename)) | ||
91 | goto out; | ||
92 | error = compat_do_execve(filename->name, compat_ptr(regs.regs[5]), | ||
93 | compat_ptr(regs.regs[6]), ®s); | ||
94 | putname(filename); | ||
95 | |||
96 | out: | ||
97 | return error; | ||
98 | } | ||
99 | |||
100 | #define RLIM_INFINITY32 0x7fffffff | 79 | #define RLIM_INFINITY32 0x7fffffff |
101 | #define RESOURCE32(x) ((x > RLIM_INFINITY32) ? RLIM_INFINITY32 : x) | 80 | #define RESOURCE32(x) ((x > RLIM_INFINITY32) ? RLIM_INFINITY32 : x) |
102 | 81 | ||
diff --git a/arch/mips/kernel/scall64-n32.S b/arch/mips/kernel/scall64-n32.S index f6ba8381ee01..d27ca340d46d 100644 --- a/arch/mips/kernel/scall64-n32.S +++ b/arch/mips/kernel/scall64-n32.S | |||
@@ -167,7 +167,7 @@ EXPORT(sysn32_call_table) | |||
167 | PTR sys_getsockopt | 167 | PTR sys_getsockopt |
168 | PTR sys_clone /* 6055 */ | 168 | PTR sys_clone /* 6055 */ |
169 | PTR sys_fork | 169 | PTR sys_fork |
170 | PTR sys32_execve | 170 | PTR compat_sys_execve |
171 | PTR sys_exit | 171 | PTR sys_exit |
172 | PTR compat_sys_wait4 | 172 | PTR compat_sys_wait4 |
173 | PTR sys_kill /* 6060 */ | 173 | PTR sys_kill /* 6060 */ |
diff --git a/arch/mips/kernel/scall64-o32.S b/arch/mips/kernel/scall64-o32.S index 53c2d7245764..9601be6afa3d 100644 --- a/arch/mips/kernel/scall64-o32.S +++ b/arch/mips/kernel/scall64-o32.S | |||
@@ -203,7 +203,7 @@ sys_call_table: | |||
203 | PTR sys_creat | 203 | PTR sys_creat |
204 | PTR sys_link | 204 | PTR sys_link |
205 | PTR sys_unlink /* 4010 */ | 205 | PTR sys_unlink /* 4010 */ |
206 | PTR sys32_execve | 206 | PTR compat_sys_execve |
207 | PTR sys_chdir | 207 | PTR sys_chdir |
208 | PTR compat_sys_time | 208 | PTR compat_sys_time |
209 | PTR sys_mknod | 209 | PTR sys_mknod |
diff --git a/arch/mips/kernel/syscall.c b/arch/mips/kernel/syscall.c index 2bd561bc05ae..c611e2df7767 100644 --- a/arch/mips/kernel/syscall.c +++ b/arch/mips/kernel/syscall.c | |||
@@ -127,28 +127,6 @@ _sys_clone(nabi_no_regargs struct pt_regs regs) | |||
127 | parent_tidptr, child_tidptr); | 127 | parent_tidptr, child_tidptr); |
128 | } | 128 | } |
129 | 129 | ||
130 | /* | ||
131 | * sys_execve() executes a new program. | ||
132 | */ | ||
133 | asmlinkage int sys_execve(nabi_no_regargs struct pt_regs regs) | ||
134 | { | ||
135 | int error; | ||
136 | struct filename *filename; | ||
137 | |||
138 | filename = getname((const char __user *) (long)regs.regs[4]); | ||
139 | error = PTR_ERR(filename); | ||
140 | if (IS_ERR(filename)) | ||
141 | goto out; | ||
142 | error = do_execve(filename->name, | ||
143 | (const char __user *const __user *) (long)regs.regs[5], | ||
144 | (const char __user *const __user *) (long)regs.regs[6], | ||
145 | ®s); | ||
146 | putname(filename); | ||
147 | |||
148 | out: | ||
149 | return error; | ||
150 | } | ||
151 | |||
152 | SYSCALL_DEFINE1(set_thread_area, unsigned long, addr) | 130 | SYSCALL_DEFINE1(set_thread_area, unsigned long, addr) |
153 | { | 131 | { |
154 | struct thread_info *ti = task_thread_info(current); | 132 | struct thread_info *ti = task_thread_info(current); |
@@ -313,34 +291,3 @@ asmlinkage void bad_stack(void) | |||
313 | { | 291 | { |
314 | do_exit(SIGSEGV); | 292 | do_exit(SIGSEGV); |
315 | } | 293 | } |
316 | |||
317 | /* | ||
318 | * Do a system call from kernel instead of calling sys_execve so we | ||
319 | * end up with proper pt_regs. | ||
320 | */ | ||
321 | int kernel_execve(const char *filename, | ||
322 | const char *const argv[], | ||
323 | const char *const envp[]) | ||
324 | { | ||
325 | register unsigned long __a0 asm("$4") = (unsigned long) filename; | ||
326 | register unsigned long __a1 asm("$5") = (unsigned long) argv; | ||
327 | register unsigned long __a2 asm("$6") = (unsigned long) envp; | ||
328 | register unsigned long __a3 asm("$7"); | ||
329 | unsigned long __v0; | ||
330 | |||
331 | __asm__ volatile (" \n" | ||
332 | " .set noreorder \n" | ||
333 | " li $2, %5 # __NR_execve \n" | ||
334 | " syscall \n" | ||
335 | " move %0, $2 \n" | ||
336 | " .set reorder \n" | ||
337 | : "=&r" (__v0), "=r" (__a3) | ||
338 | : "r" (__a0), "r" (__a1), "r" (__a2), "i" (__NR_execve) | ||
339 | : "$2", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", | ||
340 | "memory"); | ||
341 | |||
342 | if (__a3 == 0) | ||
343 | return __v0; | ||
344 | |||
345 | return -__v0; | ||
346 | } | ||