diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-12-12 12:22:13 -0800 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-12-12 12:22:13 -0800 |
commit | 9977d9b379cb77e0f67bd6f4563618106e58e11d (patch) | |
tree | 0191accfddf578edb52c69c933d64521e3dce297 /arch/m68k | |
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/m68k')
-rw-r--r-- | arch/m68k/Kconfig | 1 | ||||
-rw-r--r-- | arch/m68k/include/asm/signal.h | 8 | ||||
-rw-r--r-- | arch/m68k/include/asm/unistd.h | 3 | ||||
-rw-r--r-- | arch/m68k/kernel/entry.S | 30 | ||||
-rw-r--r-- | arch/m68k/kernel/process.c | 87 | ||||
-rw-r--r-- | arch/m68k/kernel/signal.c | 3 | ||||
-rw-r--r-- | arch/m68k/kernel/syscalltable.S | 6 |
7 files changed, 52 insertions, 86 deletions
diff --git a/arch/m68k/Kconfig b/arch/m68k/Kconfig index e7c161433eae..953a7ba5d050 100644 --- a/arch/m68k/Kconfig +++ b/arch/m68k/Kconfig @@ -16,6 +16,7 @@ config M68K select ARCH_WANT_IPC_PARSE_VERSION select ARCH_USES_GETTIMEOFFSET if MMU && !COLDFIRE select GENERIC_KERNEL_THREAD + select GENERIC_KERNEL_EXECVE select HAVE_MOD_ARCH_SPECIFIC select MODULES_USE_ELF_REL select MODULES_USE_ELF_RELA diff --git a/arch/m68k/include/asm/signal.h b/arch/m68k/include/asm/signal.h index 2df26b57c26a..9c8c46b06b0c 100644 --- a/arch/m68k/include/asm/signal.h +++ b/arch/m68k/include/asm/signal.h @@ -86,11 +86,9 @@ static inline int sigfindinword(unsigned long word) #endif /* !CONFIG_CPU_HAS_NO_BITFIELDS */ -#ifdef __uClinux__ -#define ptrace_signal_deliver(regs, cookie) do { } while (0) -#else -struct pt_regs; -extern void ptrace_signal_deliver(struct pt_regs *regs, void *cookie); +#ifndef __uClinux__ +extern void ptrace_signal_deliver(void); +#define ptrace_signal_deliver ptrace_signal_deliver #endif /* __uClinux__ */ #endif /* _M68K_SIGNAL_H */ diff --git a/arch/m68k/include/asm/unistd.h b/arch/m68k/include/asm/unistd.h index 5fc7f7bec1c8..a021d67cdd72 100644 --- a/arch/m68k/include/asm/unistd.h +++ b/arch/m68k/include/asm/unistd.h @@ -32,7 +32,8 @@ #define __ARCH_WANT_SYS_RT_SIGACTION #define __ARCH_WANT_SYS_RT_SIGSUSPEND #define __ARCH_WANT_SYS_EXECVE -#define __ARCH_WANT_KERNEL_EXECVE +#define __ARCH_WANT_SYS_FORK +#define __ARCH_WANT_SYS_VFORK /* * "Conditional" syscalls diff --git a/arch/m68k/kernel/entry.S b/arch/m68k/kernel/entry.S index 946cb0187751..a78f5649e8de 100644 --- a/arch/m68k/kernel/entry.S +++ b/arch/m68k/kernel/entry.S @@ -44,34 +44,29 @@ .globl system_call, buserr, trap, resume .globl sys_call_table -.globl sys_fork, sys_clone, sys_vfork +.globl __sys_fork, __sys_clone, __sys_vfork .globl ret_from_interrupt, bad_interrupt .globl auto_irqhandler_fixup .globl user_irqvec_fixup .text -ENTRY(sys_fork) +ENTRY(__sys_fork) SAVE_SWITCH_STACK - pea %sp@(SWITCH_STACK_SIZE) - jbsr m68k_fork - addql #4,%sp - RESTORE_SWITCH_STACK + jbsr sys_fork + lea %sp@(24),%sp rts -ENTRY(sys_clone) +ENTRY(__sys_clone) SAVE_SWITCH_STACK pea %sp@(SWITCH_STACK_SIZE) jbsr m68k_clone - addql #4,%sp - RESTORE_SWITCH_STACK + lea %sp@(28),%sp rts -ENTRY(sys_vfork) +ENTRY(__sys_vfork) SAVE_SWITCH_STACK - pea %sp@(SWITCH_STACK_SIZE) - jbsr m68k_vfork - addql #4,%sp - RESTORE_SWITCH_STACK + jbsr sys_vfork + lea %sp@(24),%sp rts ENTRY(sys_sigreturn) @@ -115,16 +110,9 @@ ENTRY(ret_from_kernel_thread) | a3 contains the kernel thread payload, d7 - its argument movel %d1,%sp@- jsr schedule_tail - GET_CURRENT(%d0) movel %d7,(%sp) jsr %a3@ addql #4,%sp - movel %d0,(%sp) - jra sys_exit - -ENTRY(ret_from_kernel_execve) - movel 4(%sp), %sp - GET_CURRENT(%d0) jra ret_from_exception #if defined(CONFIG_COLDFIRE) || !defined(CONFIG_MMU) diff --git a/arch/m68k/kernel/process.c b/arch/m68k/kernel/process.c index c51bb172e14d..d538694ad208 100644 --- a/arch/m68k/kernel/process.c +++ b/arch/m68k/kernel/process.c @@ -136,57 +136,35 @@ void flush_thread(void) } /* - * "m68k_fork()".. By the time we get here, the - * non-volatile registers have also been saved on the - * stack. We do some ugly pointer stuff here.. (see - * also copy_thread) + * Why not generic sys_clone, you ask? m68k passes all arguments on stack. + * And we need all registers saved, which means a bunch of stuff pushed + * on top of pt_regs, which means that sys_clone() arguments would be + * buried. We could, of course, copy them, but it's too costly for no + * good reason - generic clone() would have to copy them *again* for + * do_fork() anyway. So in this case it's actually better to pass pt_regs * + * and extract arguments for do_fork() from there. Eventually we might + * go for calling do_fork() directly from the wrapper, but only after we + * are finished with do_fork() prototype conversion. */ - -asmlinkage int m68k_fork(struct pt_regs *regs) -{ -#ifdef CONFIG_MMU - return do_fork(SIGCHLD, rdusp(), regs, 0, NULL, NULL); -#else - return -EINVAL; -#endif -} - -asmlinkage int m68k_vfork(struct pt_regs *regs) -{ - return do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, rdusp(), regs, 0, - NULL, NULL); -} - asmlinkage int m68k_clone(struct pt_regs *regs) { - unsigned long clone_flags; - unsigned long newsp; - int __user *parent_tidptr, *child_tidptr; - - /* syscall2 puts clone_flags in d1 and usp in d2 */ - clone_flags = regs->d1; - newsp = regs->d2; - parent_tidptr = (int __user *)regs->d3; - child_tidptr = (int __user *)regs->d4; - if (!newsp) - newsp = rdusp(); - return do_fork(clone_flags, newsp, regs, 0, - parent_tidptr, child_tidptr); + /* regs will be equal to current_pt_regs() */ + return do_fork(regs->d1, regs->d2, 0, + (int __user *)regs->d3, (int __user *)regs->d4); } int copy_thread(unsigned long clone_flags, unsigned long usp, - unsigned long arg, - struct task_struct * p, struct pt_regs * regs) + unsigned long arg, struct task_struct *p) { - struct pt_regs * childregs; - struct switch_stack *childstack; + struct fork_frame { + struct switch_stack sw; + struct pt_regs regs; + } *frame; - childregs = (struct pt_regs *) (task_stack_page(p) + THREAD_SIZE) - 1; - childstack = ((struct switch_stack *) childregs) - 1; + frame = (struct fork_frame *) (task_stack_page(p) + THREAD_SIZE) - 1; - p->thread.usp = usp; - p->thread.ksp = (unsigned long)childstack; - p->thread.esp0 = (unsigned long)childregs; + p->thread.ksp = (unsigned long)frame; + p->thread.esp0 = (unsigned long)&frame->regs; /* * Must save the current SFC/DFC value, NOT the value when @@ -194,25 +172,24 @@ int copy_thread(unsigned long clone_flags, unsigned long usp, */ p->thread.fs = get_fs().seg; - if (unlikely(!regs)) { + if (unlikely(p->flags & PF_KTHREAD)) { /* kernel thread */ - memset(childstack, 0, - sizeof(struct switch_stack) + sizeof(struct pt_regs)); - childregs->sr = PS_S; - childstack->a3 = usp; /* function */ - childstack->d7 = arg; - childstack->retpc = (unsigned long)ret_from_kernel_thread; + memset(frame, 0, sizeof(struct fork_frame)); + frame->regs.sr = PS_S; + frame->sw.a3 = usp; /* function */ + frame->sw.d7 = arg; + frame->sw.retpc = (unsigned long)ret_from_kernel_thread; p->thread.usp = 0; return 0; } - *childregs = *regs; - childregs->d0 = 0; - - *childstack = ((struct switch_stack *) regs)[-1]; - childstack->retpc = (unsigned long)ret_from_fork; + memcpy(frame, container_of(current_pt_regs(), struct fork_frame, regs), + sizeof(struct fork_frame)); + frame->regs.d0 = 0; + frame->sw.retpc = (unsigned long)ret_from_fork; + p->thread.usp = usp ?: rdusp(); if (clone_flags & CLONE_SETTLS) - task_thread_info(p)->tp_value = regs->d5; + task_thread_info(p)->tp_value = frame->regs.d5; #ifdef CONFIG_FPU if (!FPU_IS_EMU) { diff --git a/arch/m68k/kernel/signal.c b/arch/m68k/kernel/signal.c index 710a528b928b..9a396cda3147 100644 --- a/arch/m68k/kernel/signal.c +++ b/arch/m68k/kernel/signal.c @@ -108,8 +108,9 @@ int handle_kernel_fault(struct pt_regs *regs) return 1; } -void ptrace_signal_deliver(struct pt_regs *regs, void *cookie) +void ptrace_signal_deliver(void) { + struct pt_regs *regs = signal_pt_regs(); if (regs->orig_d0 < 0) return; switch (regs->d0) { diff --git a/arch/m68k/kernel/syscalltable.S b/arch/m68k/kernel/syscalltable.S index 4fc2e29b771b..c30da5b3f2db 100644 --- a/arch/m68k/kernel/syscalltable.S +++ b/arch/m68k/kernel/syscalltable.S @@ -22,7 +22,7 @@ ALIGN ENTRY(sys_call_table) .long sys_restart_syscall /* 0 - old "setup()" system call, used for restarting */ .long sys_exit - .long sys_fork + .long __sys_fork .long sys_read .long sys_write .long sys_open /* 5 */ @@ -140,7 +140,7 @@ ENTRY(sys_call_table) .long sys_ipc .long sys_fsync .long sys_sigreturn - .long sys_clone /* 120 */ + .long __sys_clone /* 120 */ .long sys_setdomainname .long sys_newuname .long sys_cacheflush /* modify_ldt for i386 */ @@ -210,7 +210,7 @@ ENTRY(sys_call_table) .long sys_sendfile .long sys_ni_syscall /* streams1 */ .long sys_ni_syscall /* streams2 */ - .long sys_vfork /* 190 */ + .long __sys_vfork /* 190 */ .long sys_getrlimit .long sys_mmap2 .long sys_truncate64 |