diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-12-12 15:22:13 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-12-12 15:22:13 -0500 |
commit | 9977d9b379cb77e0f67bd6f4563618106e58e11d (patch) | |
tree | 0191accfddf578edb52c69c933d64521e3dce297 /arch/m32r | |
parent | cf4af01221579a4e895f43dbfc47598fbfc5a731 (diff) | |
parent | 541880d9a2c7871f6370071d55aa6662d329c51e (diff) |
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/signal
Pull big execve/kernel_thread/fork unification series from Al Viro:
"All architectures are converted to new model. Quite a bit of that
stuff is actually shared with architecture trees; in such cases it's
literally shared branch pulled by both, not a cherry-pick.
A lot of ugliness and black magic is gone (-3KLoC total in this one):
- kernel_thread()/kernel_execve()/sys_execve() redesign.
We don't do syscalls from kernel anymore for either kernel_thread()
or kernel_execve():
kernel_thread() is essentially clone(2) with callback run before we
return to userland, the callbacks either never return or do
successful do_execve() before returning.
kernel_execve() is a wrapper for do_execve() - it doesn't need to
do transition to user mode anymore.
As a result kernel_thread() and kernel_execve() are
arch-independent now - they live in kernel/fork.c and fs/exec.c
resp. sys_execve() is also in fs/exec.c and it's completely
architecture-independent.
- daemonize() is gone, along with its parts in fs/*.c
- struct pt_regs * is no longer passed to do_fork/copy_process/
copy_thread/do_execve/search_binary_handler/->load_binary/do_coredump.
- sys_fork()/sys_vfork()/sys_clone() unified; some architectures
still need wrappers (ones with callee-saved registers not saved in
pt_regs on syscall entry), but the main part of those suckers is in
kernel/fork.c now."
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/signal: (113 commits)
do_coredump(): get rid of pt_regs argument
print_fatal_signal(): get rid of pt_regs argument
ptrace_signal(): get rid of unused arguments
get rid of ptrace_signal_deliver() arguments
new helper: signal_pt_regs()
unify default ptrace_signal_deliver
flagday: kill pt_regs argument of do_fork()
death to idle_regs()
don't pass regs to copy_process()
flagday: don't pass regs to copy_thread()
bfin: switch to generic vfork, get rid of pointless wrappers
xtensa: switch to generic clone()
openrisc: switch to use of generic fork and clone
unicore32: switch to generic clone(2)
score: switch to generic fork/vfork/clone
c6x: sanitize copy_thread(), get rid of clone(2) wrapper, switch to generic clone()
take sys_fork/sys_vfork/sys_clone prototypes to linux/syscalls.h
mn10300: switch to generic fork/vfork/clone
h8300: switch to generic fork/vfork/clone
tile: switch to generic clone()
...
Conflicts:
arch/microblaze/include/asm/Kbuild
Diffstat (limited to 'arch/m32r')
-rw-r--r-- | arch/m32r/Kconfig | 2 | ||||
-rw-r--r-- | arch/m32r/include/asm/processor.h | 5 | ||||
-rw-r--r-- | arch/m32r/include/asm/ptrace.h | 2 | ||||
-rw-r--r-- | arch/m32r/include/asm/signal.h | 4 | ||||
-rw-r--r-- | arch/m32r/include/asm/unistd.h | 4 | ||||
-rw-r--r-- | arch/m32r/kernel/entry.S | 9 | ||||
-rw-r--r-- | arch/m32r/kernel/m32r_ksyms.c | 1 | ||||
-rw-r--r-- | arch/m32r/kernel/process.c | 126 | ||||
-rw-r--r-- | arch/m32r/kernel/sys_m32r.c | 21 |
9 files changed, 34 insertions, 140 deletions
diff --git a/arch/m32r/Kconfig b/arch/m32r/Kconfig index f807721e19a5..5183f43a2cf7 100644 --- a/arch/m32r/Kconfig +++ b/arch/m32r/Kconfig | |||
@@ -15,6 +15,8 @@ config M32R | |||
15 | select GENERIC_ATOMIC64 | 15 | select GENERIC_ATOMIC64 |
16 | select ARCH_USES_GETTIMEOFFSET | 16 | select ARCH_USES_GETTIMEOFFSET |
17 | select MODULES_USE_ELF_RELA | 17 | select MODULES_USE_ELF_RELA |
18 | select GENERIC_KERNEL_THREAD | ||
19 | select GENERIC_KERNEL_EXECVE | ||
18 | 20 | ||
19 | config SBUS | 21 | config SBUS |
20 | bool | 22 | bool |
diff --git a/arch/m32r/include/asm/processor.h b/arch/m32r/include/asm/processor.h index da17253b5735..5767367550c6 100644 --- a/arch/m32r/include/asm/processor.h +++ b/arch/m32r/include/asm/processor.h | |||
@@ -118,11 +118,6 @@ struct mm_struct; | |||
118 | /* Free all resources held by a thread. */ | 118 | /* Free all resources held by a thread. */ |
119 | extern void release_thread(struct task_struct *); | 119 | extern void release_thread(struct task_struct *); |
120 | 120 | ||
121 | /* | ||
122 | * create a kernel thread without removing it from tasklists | ||
123 | */ | ||
124 | extern int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags); | ||
125 | |||
126 | /* Copy and release all segment info associated with a VM */ | 121 | /* Copy and release all segment info associated with a VM */ |
127 | extern void copy_segments(struct task_struct *p, struct mm_struct * mm); | 122 | extern void copy_segments(struct task_struct *p, struct mm_struct * mm); |
128 | extern void release_segments(struct mm_struct * mm); | 123 | extern void release_segments(struct mm_struct * mm); |
diff --git a/arch/m32r/include/asm/ptrace.h b/arch/m32r/include/asm/ptrace.h index 4313aa62b51b..c4432f1fb2cf 100644 --- a/arch/m32r/include/asm/ptrace.h +++ b/arch/m32r/include/asm/ptrace.h | |||
@@ -139,6 +139,8 @@ extern void withdraw_debug_trap(struct pt_regs *regs); | |||
139 | 139 | ||
140 | #define task_pt_regs(task) \ | 140 | #define task_pt_regs(task) \ |
141 | ((struct pt_regs *)(task_stack_page(task) + THREAD_SIZE) - 1) | 141 | ((struct pt_regs *)(task_stack_page(task) + THREAD_SIZE) - 1) |
142 | #define current_pt_regs() ((struct pt_regs *) \ | ||
143 | ((unsigned long)current_thread_info() + THREAD_SIZE) - 1) | ||
142 | 144 | ||
143 | #endif /* __KERNEL */ | 145 | #endif /* __KERNEL */ |
144 | 146 | ||
diff --git a/arch/m32r/include/asm/signal.h b/arch/m32r/include/asm/signal.h index ea5f95e4079e..e4d2e2ad5f1e 100644 --- a/arch/m32r/include/asm/signal.h +++ b/arch/m32r/include/asm/signal.h | |||
@@ -149,10 +149,6 @@ typedef struct sigaltstack { | |||
149 | 149 | ||
150 | #undef __HAVE_ARCH_SIG_BITOPS | 150 | #undef __HAVE_ARCH_SIG_BITOPS |
151 | 151 | ||
152 | struct pt_regs; | ||
153 | |||
154 | #define ptrace_signal_deliver(regs, cookie) do { } while (0) | ||
155 | |||
156 | #endif /* __KERNEL__ */ | 152 | #endif /* __KERNEL__ */ |
157 | 153 | ||
158 | #endif /* _ASM_M32R_SIGNAL_H */ | 154 | #endif /* _ASM_M32R_SIGNAL_H */ |
diff --git a/arch/m32r/include/asm/unistd.h b/arch/m32r/include/asm/unistd.h index d5e66a480782..d9e7351af2a4 100644 --- a/arch/m32r/include/asm/unistd.h +++ b/arch/m32r/include/asm/unistd.h | |||
@@ -352,6 +352,10 @@ | |||
352 | #define __ARCH_WANT_SYS_OLDUMOUNT | 352 | #define __ARCH_WANT_SYS_OLDUMOUNT |
353 | #define __ARCH_WANT_SYS_RT_SIGACTION | 353 | #define __ARCH_WANT_SYS_RT_SIGACTION |
354 | #define __ARCH_WANT_SYS_RT_SIGSUSPEND | 354 | #define __ARCH_WANT_SYS_RT_SIGSUSPEND |
355 | #define __ARCH_WANT_SYS_EXECVE | ||
356 | #define __ARCH_WANT_SYS_CLONE | ||
357 | #define __ARCH_WANT_SYS_FORK | ||
358 | #define __ARCH_WANT_SYS_VFORK | ||
355 | 359 | ||
356 | #define __IGNORE_lchown | 360 | #define __IGNORE_lchown |
357 | #define __IGNORE_setuid | 361 | #define __IGNORE_setuid |
diff --git a/arch/m32r/kernel/entry.S b/arch/m32r/kernel/entry.S index 225412bc227e..0c01543f10cd 100644 --- a/arch/m32r/kernel/entry.S +++ b/arch/m32r/kernel/entry.S | |||
@@ -125,6 +125,15 @@ | |||
125 | and \reg, sp | 125 | and \reg, sp |
126 | .endm | 126 | .endm |
127 | 127 | ||
128 | ENTRY(ret_from_kernel_thread) | ||
129 | pop r0 | ||
130 | bl schedule_tail | ||
131 | GET_THREAD_INFO(r8) | ||
132 | ld r0, R0(r8) | ||
133 | ld r1, R1(r8) | ||
134 | jl r1 | ||
135 | bra syscall_exit | ||
136 | |||
128 | ENTRY(ret_from_fork) | 137 | ENTRY(ret_from_fork) |
129 | pop r0 | 138 | pop r0 |
130 | bl schedule_tail | 139 | bl schedule_tail |
diff --git a/arch/m32r/kernel/m32r_ksyms.c b/arch/m32r/kernel/m32r_ksyms.c index 700570747a90..b727e693c805 100644 --- a/arch/m32r/kernel/m32r_ksyms.c +++ b/arch/m32r/kernel/m32r_ksyms.c | |||
@@ -21,7 +21,6 @@ EXPORT_SYMBOL(boot_cpu_data); | |||
21 | EXPORT_SYMBOL(dump_fpu); | 21 | EXPORT_SYMBOL(dump_fpu); |
22 | EXPORT_SYMBOL(__ioremap); | 22 | EXPORT_SYMBOL(__ioremap); |
23 | EXPORT_SYMBOL(iounmap); | 23 | EXPORT_SYMBOL(iounmap); |
24 | EXPORT_SYMBOL(kernel_thread); | ||
25 | 24 | ||
26 | EXPORT_SYMBOL(strncpy_from_user); | 25 | EXPORT_SYMBOL(strncpy_from_user); |
27 | EXPORT_SYMBOL(__strncpy_from_user); | 26 | EXPORT_SYMBOL(__strncpy_from_user); |
diff --git a/arch/m32r/kernel/process.c b/arch/m32r/kernel/process.c index e7366276ef30..765d0f57c787 100644 --- a/arch/m32r/kernel/process.c +++ b/arch/m32r/kernel/process.c | |||
@@ -165,41 +165,6 @@ void show_regs(struct pt_regs * regs) | |||
165 | } | 165 | } |
166 | 166 | ||
167 | /* | 167 | /* |
168 | * Create a kernel thread | ||
169 | */ | ||
170 | |||
171 | /* | ||
172 | * This is the mechanism for creating a new kernel thread. | ||
173 | * | ||
174 | * NOTE! Only a kernel-only process(ie the swapper or direct descendants | ||
175 | * who haven't done an "execve()") should use this: it will work within | ||
176 | * a system call from a "real" process, but the process memory space will | ||
177 | * not be free'd until both the parent and the child have exited. | ||
178 | */ | ||
179 | static void kernel_thread_helper(void *nouse, int (*fn)(void *), void *arg) | ||
180 | { | ||
181 | fn(arg); | ||
182 | do_exit(-1); | ||
183 | } | ||
184 | |||
185 | int kernel_thread(int (*fn)(void *), void *arg, unsigned long flags) | ||
186 | { | ||
187 | struct pt_regs regs; | ||
188 | |||
189 | memset(®s, 0, sizeof (regs)); | ||
190 | regs.r1 = (unsigned long)fn; | ||
191 | regs.r2 = (unsigned long)arg; | ||
192 | |||
193 | regs.bpc = (unsigned long)kernel_thread_helper; | ||
194 | |||
195 | regs.psw = M32R_PSW_BIE; | ||
196 | |||
197 | /* Ok, create the new process. */ | ||
198 | return do_fork(flags | CLONE_VM | CLONE_UNTRACED, 0, ®s, 0, NULL, | ||
199 | NULL); | ||
200 | } | ||
201 | |||
202 | /* | ||
203 | * Free current thread data structures etc.. | 168 | * Free current thread data structures etc.. |
204 | */ | 169 | */ |
205 | void exit_thread(void) | 170 | void exit_thread(void) |
@@ -227,88 +192,31 @@ int dump_fpu(struct pt_regs *regs, elf_fpregset_t *fpu) | |||
227 | } | 192 | } |
228 | 193 | ||
229 | int copy_thread(unsigned long clone_flags, unsigned long spu, | 194 | int copy_thread(unsigned long clone_flags, unsigned long spu, |
230 | unsigned long unused, struct task_struct *tsk, struct pt_regs *regs) | 195 | unsigned long arg, struct task_struct *tsk) |
231 | { | 196 | { |
232 | struct pt_regs *childregs = task_pt_regs(tsk); | 197 | struct pt_regs *childregs = task_pt_regs(tsk); |
233 | extern void ret_from_fork(void); | 198 | extern void ret_from_fork(void); |
234 | 199 | extern void ret_from_kernel_thread(void); | |
235 | /* Copy registers */ | 200 | |
236 | *childregs = *regs; | 201 | if (unlikely(tsk->flags & PF_KTHREAD)) { |
237 | 202 | memset(childregs, 0, sizeof(struct pt_regs)); | |
238 | childregs->spu = spu; | 203 | childregs->psw = M32R_PSW_BIE; |
239 | childregs->r0 = 0; /* Child gets zero as return value */ | 204 | childregs->r1 = spu; /* fn */ |
240 | regs->r0 = tsk->pid; | 205 | childregs->r0 = arg; |
206 | tsk->thread.lr = (unsigned long)ret_from_kernel_thread; | ||
207 | } else { | ||
208 | /* Copy registers */ | ||
209 | *childregs = *current_pt_regs(); | ||
210 | if (spu) | ||
211 | childregs->spu = spu; | ||
212 | childregs->r0 = 0; /* Child gets zero as return value */ | ||
213 | tsk->thread.lr = (unsigned long)ret_from_fork; | ||
214 | } | ||
241 | tsk->thread.sp = (unsigned long)childregs; | 215 | tsk->thread.sp = (unsigned long)childregs; |
242 | tsk->thread.lr = (unsigned long)ret_from_fork; | ||
243 | 216 | ||
244 | return 0; | 217 | return 0; |
245 | } | 218 | } |
246 | 219 | ||
247 | asmlinkage int sys_fork(unsigned long r0, unsigned long r1, unsigned long r2, | ||
248 | unsigned long r3, unsigned long r4, unsigned long r5, unsigned long r6, | ||
249 | struct pt_regs regs) | ||
250 | { | ||
251 | #ifdef CONFIG_MMU | ||
252 | return do_fork(SIGCHLD, regs.spu, ®s, 0, NULL, NULL); | ||
253 | #else | ||
254 | return -EINVAL; | ||
255 | #endif /* CONFIG_MMU */ | ||
256 | } | ||
257 | |||
258 | asmlinkage int sys_clone(unsigned long clone_flags, unsigned long newsp, | ||
259 | unsigned long parent_tidptr, | ||
260 | unsigned long child_tidptr, | ||
261 | unsigned long r4, unsigned long r5, unsigned long r6, | ||
262 | struct pt_regs regs) | ||
263 | { | ||
264 | if (!newsp) | ||
265 | newsp = regs.spu; | ||
266 | |||
267 | return do_fork(clone_flags, newsp, ®s, 0, | ||
268 | (int __user *)parent_tidptr, (int __user *)child_tidptr); | ||
269 | } | ||
270 | |||
271 | /* | ||
272 | * This is trivial, and on the face of it looks like it | ||
273 | * could equally well be done in user mode. | ||
274 | * | ||
275 | * Not so, for quite unobvious reasons - register pressure. | ||
276 | * In user mode vfork() cannot have a stack frame, and if | ||
277 | * done by calling the "clone()" system call directly, you | ||
278 | * do not have enough call-clobbered registers to hold all | ||
279 | * the information you need. | ||
280 | */ | ||
281 | asmlinkage int sys_vfork(unsigned long r0, unsigned long r1, unsigned long r2, | ||
282 | unsigned long r3, unsigned long r4, unsigned long r5, unsigned long r6, | ||
283 | struct pt_regs regs) | ||
284 | { | ||
285 | return do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, regs.spu, ®s, 0, | ||
286 | NULL, NULL); | ||
287 | } | ||
288 | |||
289 | /* | ||
290 | * sys_execve() executes a new program. | ||
291 | */ | ||
292 | asmlinkage int sys_execve(const char __user *ufilename, | ||
293 | const char __user *const __user *uargv, | ||
294 | const char __user *const __user *uenvp, | ||
295 | unsigned long r3, unsigned long r4, unsigned long r5, | ||
296 | unsigned long r6, struct pt_regs regs) | ||
297 | { | ||
298 | int error; | ||
299 | struct filename *filename; | ||
300 | |||
301 | filename = getname(ufilename); | ||
302 | error = PTR_ERR(filename); | ||
303 | if (IS_ERR(filename)) | ||
304 | goto out; | ||
305 | |||
306 | error = do_execve(filename->name, uargv, uenvp, ®s); | ||
307 | putname(filename); | ||
308 | out: | ||
309 | return error; | ||
310 | } | ||
311 | |||
312 | /* | 220 | /* |
313 | * These bracket the sleeping functions.. | 221 | * These bracket the sleeping functions.. |
314 | */ | 222 | */ |
diff --git a/arch/m32r/kernel/sys_m32r.c b/arch/m32r/kernel/sys_m32r.c index d841fb6cc703..c3fdd632fba7 100644 --- a/arch/m32r/kernel/sys_m32r.c +++ b/arch/m32r/kernel/sys_m32r.c | |||
@@ -88,24 +88,3 @@ asmlinkage int sys_cachectl(char *addr, int nbytes, int op) | |||
88 | /* Not implemented yet. */ | 88 | /* Not implemented yet. */ |
89 | return -ENOSYS; | 89 | return -ENOSYS; |
90 | } | 90 | } |
91 | |||
92 | /* | ||
93 | * Do a system call from kernel instead of calling sys_execve so we | ||
94 | * end up with proper pt_regs. | ||
95 | */ | ||
96 | int kernel_execve(const char *filename, | ||
97 | const char *const argv[], | ||
98 | const char *const envp[]) | ||
99 | { | ||
100 | register long __scno __asm__ ("r7") = __NR_execve; | ||
101 | register long __arg3 __asm__ ("r2") = (long)(envp); | ||
102 | register long __arg2 __asm__ ("r1") = (long)(argv); | ||
103 | register long __res __asm__ ("r0") = (long)(filename); | ||
104 | __asm__ __volatile__ ( | ||
105 | "trap #" SYSCALL_VECTOR "|| nop" | ||
106 | : "=r" (__res) | ||
107 | : "r" (__scno), "0" (__res), "r" (__arg2), | ||
108 | "r" (__arg3) | ||
109 | : "memory"); | ||
110 | return __res; | ||
111 | } | ||