From 557e1995a92d318206910d8b5c62075fe02b37e0 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Wed, 10 Oct 2012 13:17:31 -0400 Subject: h8300: generic kernel_thread() Signed-off-by: Al Viro --- arch/h8300/include/asm/processor.h | 2 -- arch/h8300/include/asm/ptrace.h | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'arch/h8300/include') diff --git a/arch/h8300/include/asm/processor.h b/arch/h8300/include/asm/processor.h index 4c9f6f87b617..4b0ca49bb463 100644 --- a/arch/h8300/include/asm/processor.h +++ b/arch/h8300/include/asm/processor.h @@ -107,8 +107,6 @@ static inline void release_thread(struct task_struct *dead_task) { } -extern int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags); - /* * Free current thread data structures etc.. */ diff --git a/arch/h8300/include/asm/ptrace.h b/arch/h8300/include/asm/ptrace.h index d09c440bdba7..00502a61bf0a 100644 --- a/arch/h8300/include/asm/ptrace.h +++ b/arch/h8300/include/asm/ptrace.h @@ -60,6 +60,8 @@ struct pt_regs { #define user_mode(regs) (!((regs)->ccr & PS_S)) #define instruction_pointer(regs) ((regs)->pc) #define profile_pc(regs) instruction_pointer(regs) +#define current_pt_regs() ((struct pt_regs *) \ + (THREAD_SIZE + (unsigned long)current_thread_info()) - 1) #endif /* __KERNEL__ */ #endif /* __ASSEMBLY__ */ #endif /* _H8300_PTRACE_H */ -- cgit v1.2.3 From 71915d21e59c153c1202e3198916817c2d18da32 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Wed, 10 Oct 2012 13:31:13 -0400 Subject: h8300: generic sys_execve() Signed-off-by: Al Viro --- arch/h8300/include/asm/unistd.h | 1 + arch/h8300/kernel/process.c | 21 --------------------- 2 files changed, 1 insertion(+), 21 deletions(-) (limited to 'arch/h8300/include') diff --git a/arch/h8300/include/asm/unistd.h b/arch/h8300/include/asm/unistd.h index 5cd882801d79..07afcfaec995 100644 --- a/arch/h8300/include/asm/unistd.h +++ b/arch/h8300/include/asm/unistd.h @@ -356,6 +356,7 @@ #define __ARCH_WANT_SYS_SIGPROCMASK #define __ARCH_WANT_SYS_RT_SIGACTION #define __ARCH_WANT_SYS_RT_SIGSUSPEND +#define __ARCH_WANT_SYS_EXECVE /* * "Conditional" syscalls diff --git a/arch/h8300/kernel/process.c b/arch/h8300/kernel/process.c index e3dfea71c15f..2a45718cc5e8 100644 --- a/arch/h8300/kernel/process.c +++ b/arch/h8300/kernel/process.c @@ -183,27 +183,6 @@ int copy_thread(unsigned long clone_flags, return 0; } -/* - * sys_execve() executes a new program. - */ -asmlinkage int sys_execve(const char *name, - const char *const *argv, - const char *const *envp, - int dummy, ...) -{ - int error; - struct filename *filename; - struct pt_regs *regs = (struct pt_regs *) ((unsigned char *)&dummy-4); - - filename = getname(name); - error = PTR_ERR(filename); - if (IS_ERR(filename)) - return error; - error = do_execve(filename->name, argv, envp, regs); - putname(filename); - return error; -} - unsigned long thread_saved_pc(struct task_struct *tsk) { return ((struct pt_regs *)tsk->thread.esp0)->pc; -- cgit v1.2.3 From 3416e8098aa4c0eea1b2e5c4efc68cf61a848864 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sat, 27 Oct 2012 00:07:24 -0400 Subject: h8300: switch to generic fork/vfork/clone Signed-off-by: Al Viro --- arch/h8300/include/asm/unistd.h | 3 +++ arch/h8300/kernel/process.c | 38 +++----------------------------------- arch/h8300/kernel/syscalls.S | 9 --------- 3 files changed, 6 insertions(+), 44 deletions(-) (limited to 'arch/h8300/include') diff --git a/arch/h8300/include/asm/unistd.h b/arch/h8300/include/asm/unistd.h index 07afcfaec995..c2c2f5c7d6bf 100644 --- a/arch/h8300/include/asm/unistd.h +++ b/arch/h8300/include/asm/unistd.h @@ -357,6 +357,9 @@ #define __ARCH_WANT_SYS_RT_SIGACTION #define __ARCH_WANT_SYS_RT_SIGSUSPEND #define __ARCH_WANT_SYS_EXECVE +#define __ARCH_WANT_SYS_FORK +#define __ARCH_WANT_SYS_VFORK +#define __ARCH_WANT_SYS_CLONE /* * "Conditional" syscalls diff --git a/arch/h8300/kernel/process.c b/arch/h8300/kernel/process.c index 2a45718cc5e8..b0fb4054aee5 100644 --- a/arch/h8300/kernel/process.c +++ b/arch/h8300/kernel/process.c @@ -127,40 +127,9 @@ void flush_thread(void) { } -/* - * "h8300_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) - */ - -asmlinkage int h8300_fork(struct pt_regs *regs) -{ - return -EINVAL; -} - -asmlinkage int h8300_vfork(struct pt_regs *regs) -{ - return do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, rdusp(), regs, 0, NULL, NULL); -} - -asmlinkage int h8300_clone(struct pt_regs *regs) -{ - unsigned long clone_flags; - unsigned long newsp; - - /* syscall2 puts clone_flags in er1 and usp in er2 */ - clone_flags = regs->er1; - newsp = regs->er2; - if (!newsp) - newsp = rdusp(); - return do_fork(clone_flags, newsp, regs, 0, NULL, NULL); - -} - int copy_thread(unsigned long clone_flags, unsigned long usp, unsigned long topstk, - struct task_struct * p, struct pt_regs * regs) + struct task_struct * p, struct pt_regs *unused) { struct pt_regs * childregs; @@ -173,11 +142,10 @@ int copy_thread(unsigned long clone_flags, childregs->er5 = usp; /* fn */ p->thread.ksp = (unsigned long)childregs; } - *childregs = *regs; + *childregs = *current_pt_regs(); childregs->retpc = (unsigned long) ret_from_fork; childregs->er0 = 0; - - p->thread.usp = usp; + p->thread.usp = usp ?: rdusp(); p->thread.ksp = (unsigned long)childregs; return 0; diff --git a/arch/h8300/kernel/syscalls.S b/arch/h8300/kernel/syscalls.S index 9d77e715a2ed..b74dd0ade58d 100644 --- a/arch/h8300/kernel/syscalls.S +++ b/arch/h8300/kernel/syscalls.S @@ -340,21 +340,12 @@ SYMBOL_NAME_LABEL(sys_call_table) bra SYMBOL_NAME(syscall_trampoline):8 .endm -SYMBOL_NAME_LABEL(sys_clone) - call_sp h8300_clone - SYMBOL_NAME_LABEL(sys_sigreturn) call_sp do_sigreturn SYMBOL_NAME_LABEL(sys_rt_sigreturn) call_sp do_rt_sigreturn -SYMBOL_NAME_LABEL(sys_fork) - call_sp h8300_fork - -SYMBOL_NAME_LABEL(sys_vfork) - call_sp h8300_vfork - SYMBOL_NAME_LABEL(syscall_trampoline) mov.l sp,er0 jmp @er6 -- cgit v1.2.3 From 4f4202fe5ae9a43e59303f20d700571f695d7b1b Mon Sep 17 00:00:00 2001 From: Al Viro Date: Mon, 5 Nov 2012 12:59:15 -0500 Subject: unify default ptrace_signal_deliver Signed-off-by: Al Viro --- arch/alpha/include/asm/signal.h | 3 --- arch/arm/include/asm/signal.h | 1 - arch/avr32/include/asm/signal.h | 2 -- arch/cris/include/asm/signal.h | 6 ------ arch/h8300/include/asm/signal.h | 2 -- arch/ia64/include/asm/signal.h | 2 -- arch/m32r/include/asm/signal.h | 4 ---- arch/m68k/include/asm/signal.h | 5 ++--- arch/mips/include/asm/signal.h | 2 -- arch/mn10300/include/asm/signal.h | 4 ---- arch/parisc/include/asm/signal.h | 2 -- arch/powerpc/include/asm/signal.h | 2 -- arch/s390/include/asm/signal.h | 2 -- arch/sparc/include/asm/signal.h | 2 -- arch/x86/include/asm/signal.h | 2 -- arch/xtensa/include/asm/signal.h | 1 - include/asm-generic/signal.h | 2 -- include/linux/ptrace.h | 4 ++++ 18 files changed, 6 insertions(+), 42 deletions(-) (limited to 'arch/h8300/include') diff --git a/arch/alpha/include/asm/signal.h b/arch/alpha/include/asm/signal.h index a9388300abb1..45552862cc10 100644 --- a/arch/alpha/include/asm/signal.h +++ b/arch/alpha/include/asm/signal.h @@ -164,9 +164,6 @@ struct sigstack { #ifdef __KERNEL__ #include - -#define ptrace_signal_deliver(regs, cookie) do { } while (0) - #endif #endif diff --git a/arch/arm/include/asm/signal.h b/arch/arm/include/asm/signal.h index 5a7963dbd3fb..9a0ea6ab988f 100644 --- a/arch/arm/include/asm/signal.h +++ b/arch/arm/include/asm/signal.h @@ -35,5 +35,4 @@ struct k_sigaction { }; #include -#define ptrace_signal_deliver(regs, cookie) do { } while (0) #endif diff --git a/arch/avr32/include/asm/signal.h b/arch/avr32/include/asm/signal.h index 4d502fd6bad3..9326d182e9e5 100644 --- a/arch/avr32/include/asm/signal.h +++ b/arch/avr32/include/asm/signal.h @@ -37,6 +37,4 @@ struct k_sigaction { #include #undef __HAVE_ARCH_SIG_BITOPS -#define ptrace_signal_deliver(regs, cookie) do { } while (0) - #endif diff --git a/arch/cris/include/asm/signal.h b/arch/cris/include/asm/signal.h index ea6af9aad76c..72dbbf59dfae 100644 --- a/arch/cris/include/asm/signal.h +++ b/arch/cris/include/asm/signal.h @@ -152,12 +152,6 @@ typedef struct sigaltstack { #ifdef __KERNEL__ #include - -/* here we could define asm-optimized sigaddset, sigdelset etc. operations. - * if we don't, generic ones are used from linux/signal.h - */ -#define ptrace_signal_deliver(regs, cookie) do { } while (0) - #endif /* __KERNEL__ */ #endif diff --git a/arch/h8300/include/asm/signal.h b/arch/h8300/include/asm/signal.h index fd8b66e40dca..c43c0a7d2c2e 100644 --- a/arch/h8300/include/asm/signal.h +++ b/arch/h8300/include/asm/signal.h @@ -154,8 +154,6 @@ typedef struct sigaltstack { #include #undef __HAVE_ARCH_SIG_BITOPS -#define ptrace_signal_deliver(regs, cookie) do { } while (0) - #endif /* __KERNEL__ */ #endif /* _H8300_SIGNAL_H */ diff --git a/arch/ia64/include/asm/signal.h b/arch/ia64/include/asm/signal.h index aecda5b9eb4e..3a1b20e74c5c 100644 --- a/arch/ia64/include/asm/signal.h +++ b/arch/ia64/include/asm/signal.h @@ -38,7 +38,5 @@ struct k_sigaction { # include -#define ptrace_signal_deliver(regs, cookie) do { } while (0) - # endif /* !__ASSEMBLY__ */ #endif /* _ASM_IA64_SIGNAL_H */ 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 { #undef __HAVE_ARCH_SIG_BITOPS -struct pt_regs; - -#define ptrace_signal_deliver(regs, cookie) do { } while (0) - #endif /* __KERNEL__ */ #endif /* _ASM_M32R_SIGNAL_H */ diff --git a/arch/m68k/include/asm/signal.h b/arch/m68k/include/asm/signal.h index 2df26b57c26a..eb51a5241187 100644 --- a/arch/m68k/include/asm/signal.h +++ b/arch/m68k/include/asm/signal.h @@ -86,11 +86,10 @@ 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 +#ifndef __uClinux__ struct pt_regs; extern void ptrace_signal_deliver(struct pt_regs *regs, void *cookie); +#define ptrace_signal_deliver ptrace_signal_deliver #endif /* __uClinux__ */ #endif /* _M68K_SIGNAL_H */ diff --git a/arch/mips/include/asm/signal.h b/arch/mips/include/asm/signal.h index 880240dff8b7..cf4a08062d1d 100644 --- a/arch/mips/include/asm/signal.h +++ b/arch/mips/include/asm/signal.h @@ -21,6 +21,4 @@ #include #include -#define ptrace_signal_deliver(regs, cookie) do { } while (0) - #endif /* _ASM_SIGNAL_H */ diff --git a/arch/mn10300/include/asm/signal.h b/arch/mn10300/include/asm/signal.h index f9668ec3040c..d280e9780793 100644 --- a/arch/mn10300/include/asm/signal.h +++ b/arch/mn10300/include/asm/signal.h @@ -45,8 +45,4 @@ struct k_sigaction { }; #include - -struct pt_regs; -#define ptrace_signal_deliver(regs, cookie) do { } while (0) - #endif /* _ASM_SIGNAL_H */ diff --git a/arch/parisc/include/asm/signal.h b/arch/parisc/include/asm/signal.h index 21abf4fc169a..0fdb3c835952 100644 --- a/arch/parisc/include/asm/signal.h +++ b/arch/parisc/include/asm/signal.h @@ -34,8 +34,6 @@ struct k_sigaction { struct sigaction sa; }; -#define ptrace_signal_deliver(regs, cookie) do { } while (0) - #include #endif /* !__ASSEMBLY */ diff --git a/arch/powerpc/include/asm/signal.h b/arch/powerpc/include/asm/signal.h index 189998bb61c4..a101637725a2 100644 --- a/arch/powerpc/include/asm/signal.h +++ b/arch/powerpc/include/asm/signal.h @@ -3,6 +3,4 @@ #include -struct pt_regs; -#define ptrace_signal_deliver(regs, cookie) do { } while (0) #endif /* _ASM_POWERPC_SIGNAL_H */ diff --git a/arch/s390/include/asm/signal.h b/arch/s390/include/asm/signal.h index bffdbdd5b3d7..db7ddfaf5b79 100644 --- a/arch/s390/include/asm/signal.h +++ b/arch/s390/include/asm/signal.h @@ -39,6 +39,4 @@ struct k_sigaction { struct sigaction sa; }; -#define ptrace_signal_deliver(regs, cookie) do { } while (0) - #endif diff --git a/arch/sparc/include/asm/signal.h b/arch/sparc/include/asm/signal.h index d243c2ae02d2..77b85850d543 100644 --- a/arch/sparc/include/asm/signal.h +++ b/arch/sparc/include/asm/signal.h @@ -26,7 +26,5 @@ struct k_sigaction { void __user *ka_restorer; }; -#define ptrace_signal_deliver(regs, cookie) do { } while (0) - #endif /* !(__ASSEMBLY__) */ #endif /* !(__SPARC_SIGNAL_H) */ diff --git a/arch/x86/include/asm/signal.h b/arch/x86/include/asm/signal.h index 323973f4abf1..0dba8b7a6ac7 100644 --- a/arch/x86/include/asm/signal.h +++ b/arch/x86/include/asm/signal.h @@ -260,8 +260,6 @@ struct pt_regs; #endif /* !__i386__ */ -#define ptrace_signal_deliver(regs, cookie) do { } while (0) - #endif /* __KERNEL__ */ #endif /* __ASSEMBLY__ */ diff --git a/arch/xtensa/include/asm/signal.h b/arch/xtensa/include/asm/signal.h index 72fd44c85b70..6f586bd90e18 100644 --- a/arch/xtensa/include/asm/signal.h +++ b/arch/xtensa/include/asm/signal.h @@ -27,7 +27,6 @@ struct k_sigaction { }; #include -#define ptrace_signal_deliver(regs, cookie) do { } while (0) #endif /* __ASSEMBLY__ */ #endif /* _XTENSA_SIGNAL_H */ diff --git a/include/asm-generic/signal.h b/include/asm-generic/signal.h index 98caa306122a..d840c90a157a 100644 --- a/include/asm-generic/signal.h +++ b/include/asm-generic/signal.h @@ -10,7 +10,5 @@ #include #undef __HAVE_ARCH_SIG_BITOPS -#define ptrace_signal_deliver(regs, cookie) do { } while (0) - #endif /* __ASSEMBLY__ */ #endif /* _ASM_GENERIC_SIGNAL_H */ diff --git a/include/linux/ptrace.h b/include/linux/ptrace.h index e0ff4689d35a..7aefbae2452e 100644 --- a/include/linux/ptrace.h +++ b/include/linux/ptrace.h @@ -329,6 +329,10 @@ static inline void user_single_step_siginfo(struct task_struct *tsk, #define current_pt_regs() task_pt_regs(current) #endif +#ifndef ptrace_signal_deliver +#define ptrace_signal_deliver(regs, cookie) do { } while (0) +#endif + extern int task_current_syscall(struct task_struct *target, long *callno, unsigned long args[6], unsigned int maxargs, unsigned long *sp, unsigned long *pc); -- cgit v1.2.3 From 22062a96300dabfef93368a28c34bdf35c9b8308 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Mon, 5 Nov 2012 13:00:27 -0500 Subject: new helper: signal_pt_regs() Always equal to task_pt_regs(current); defined only when we are in signal delivery. It may be different from current_pt_regs() - e.g. architectures like m68k may have pt_regs location on exception different from that on a syscall and signals (just as ptrace handling) may happen on exceptions as well as on syscalls. When they are equal, it's often better to have signal_pt_regs defined (in asm/ptrace.h) as current_pt_regs - that tends to be optimized better than default would be. However, optimisation is the only reason why we might want an arch-specific definition; if current_pt_regs() and task_pt_regs(current) have different values, the latter one is right. Signed-off-by: Al Viro --- arch/alpha/include/asm/ptrace.h | 1 + arch/h8300/include/asm/ptrace.h | 1 + include/linux/ptrace.h | 9 +++++++++ 3 files changed, 11 insertions(+) (limited to 'arch/h8300/include') diff --git a/arch/alpha/include/asm/ptrace.h b/arch/alpha/include/asm/ptrace.h index b87755a19554..b4c5b2fbb647 100644 --- a/arch/alpha/include/asm/ptrace.h +++ b/arch/alpha/include/asm/ptrace.h @@ -78,6 +78,7 @@ struct switch_stack { #define current_pt_regs() \ ((struct pt_regs *) ((char *)current_thread_info() + 2*PAGE_SIZE) - 1) +#define signal_pt_regs current_pt_regs #define force_successful_syscall_return() (current_pt_regs()->r0 = 0) diff --git a/arch/h8300/include/asm/ptrace.h b/arch/h8300/include/asm/ptrace.h index 00502a61bf0a..7468589a128b 100644 --- a/arch/h8300/include/asm/ptrace.h +++ b/arch/h8300/include/asm/ptrace.h @@ -62,6 +62,7 @@ struct pt_regs { #define profile_pc(regs) instruction_pointer(regs) #define current_pt_regs() ((struct pt_regs *) \ (THREAD_SIZE + (unsigned long)current_thread_info()) - 1) +#define signal_pt_regs() ((struct pt_regs *)current->thread.esp0) #endif /* __KERNEL__ */ #endif /* __ASSEMBLY__ */ #endif /* _H8300_PTRACE_H */ diff --git a/include/linux/ptrace.h b/include/linux/ptrace.h index 7aefbae2452e..b8e6dcec78ae 100644 --- a/include/linux/ptrace.h +++ b/include/linux/ptrace.h @@ -333,6 +333,15 @@ static inline void user_single_step_siginfo(struct task_struct *tsk, #define ptrace_signal_deliver(regs, cookie) do { } while (0) #endif +/* + * unlike current_pt_regs(), this one is equal to task_pt_regs(current) + * on *all* architectures; the only reason to have a per-arch definition + * is optimisation. + */ +#ifndef signal_pt_regs +#define signal_pt_regs() task_pt_regs(current) +#endif + extern int task_current_syscall(struct task_struct *target, long *callno, unsigned long args[6], unsigned int maxargs, unsigned long *sp, unsigned long *pc); -- cgit v1.2.3