From ddd03a1f7591827906d63dbe3ee003f832bb584f Mon Sep 17 00:00:00 2001 From: Al Viro Date: Fri, 3 Aug 2012 12:12:38 +0400 Subject: get rid of generic instances of asm/exec.h Signed-off-by: Al Viro --- arch/alpha/include/asm/Kbuild | 1 + arch/alpha/include/asm/exec.h | 6 ------ 2 files changed, 1 insertion(+), 6 deletions(-) delete mode 100644 arch/alpha/include/asm/exec.h (limited to 'arch/alpha/include') diff --git a/arch/alpha/include/asm/Kbuild b/arch/alpha/include/asm/Kbuild index e423defed91e..3bae7c9a0477 100644 --- a/arch/alpha/include/asm/Kbuild +++ b/arch/alpha/include/asm/Kbuild @@ -8,3 +8,4 @@ header-y += pal.h header-y += reg.h header-y += regdef.h header-y += sysinfo.h +generic-y += exec.h diff --git a/arch/alpha/include/asm/exec.h b/arch/alpha/include/asm/exec.h deleted file mode 100644 index 4a5a41f30779..000000000000 --- a/arch/alpha/include/asm/exec.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef __ALPHA_EXEC_H -#define __ALPHA_EXEC_H - -#define arch_align_stack(x) (x) - -#endif /* __ALPHA_EXEC_H */ -- cgit v1.2.3-55-g7522 From 756144f8ea2e4fccbbf1a5644f3e1e889a48f765 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 2 Aug 2012 12:53:03 +0400 Subject: alpha: switch to generic sys_execve() get rid of sys_execve() wrapper, while we are at it Signed-off-by: Al Viro --- arch/alpha/include/asm/unistd.h | 1 + arch/alpha/kernel/entry.S | 9 --------- arch/alpha/kernel/process.c | 21 --------------------- 3 files changed, 1 insertion(+), 30 deletions(-) (limited to 'arch/alpha/include') diff --git a/arch/alpha/include/asm/unistd.h b/arch/alpha/include/asm/unistd.h index a31a78eac9b9..7826e227e4d0 100644 --- a/arch/alpha/include/asm/unistd.h +++ b/arch/alpha/include/asm/unistd.h @@ -481,6 +481,7 @@ #define __ARCH_WANT_SYS_OLDUMOUNT #define __ARCH_WANT_SYS_SIGPENDING #define __ARCH_WANT_SYS_RT_SIGSUSPEND +#define __ARCH_WANT_SYS_EXECVE /* "Conditional" syscalls. What we want is diff --git a/arch/alpha/kernel/entry.S b/arch/alpha/kernel/entry.S index ec0da0567ab5..61ff145cab6e 100644 --- a/arch/alpha/kernel/entry.S +++ b/arch/alpha/kernel/entry.S @@ -744,15 +744,6 @@ sys_rt_sigreturn: br ret_from_sys_call .end sys_rt_sigreturn - .align 4 - .globl sys_execve - .ent sys_execve -sys_execve: - .prologue 0 - mov $sp, $19 - jmp $31, do_sys_execve -.end sys_execve - .align 4 .globl alpha_ni_syscall .ent alpha_ni_syscall diff --git a/arch/alpha/kernel/process.c b/arch/alpha/kernel/process.c index d6fde98b74b3..145473909199 100644 --- a/arch/alpha/kernel/process.c +++ b/arch/alpha/kernel/process.c @@ -381,27 +381,6 @@ dump_elf_task_fp(elf_fpreg_t *dest, struct task_struct *task) } EXPORT_SYMBOL(dump_elf_task_fp); -/* - * sys_execve() executes a new program. - */ -asmlinkage int -do_sys_execve(const char __user *ufilename, - const char __user *const __user *argv, - const char __user *const __user *envp, struct pt_regs *regs) -{ - int error; - char *filename; - - filename = getname(ufilename); - error = PTR_ERR(filename); - if (IS_ERR(filename)) - goto out; - error = do_execve(filename, argv, envp, regs); - putname(filename); -out: - return error; -} - /* * Return saved PC of a blocked thread. This assumes the frame * pointer is the 6th saved long on the kernel stack and that the -- cgit v1.2.3-55-g7522 From cba1ec7e88a0257eb13e84d170a93cd52b702562 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sun, 9 Sep 2012 22:03:42 -0400 Subject: alpha: switch to generic kernel_thread() Signed-off-by: Al Viro --- arch/alpha/Kconfig | 1 + arch/alpha/include/asm/processor.h | 3 -- arch/alpha/kernel/alpha_ksyms.c | 3 -- arch/alpha/kernel/entry.S | 57 +++++++------------------------------- arch/alpha/kernel/process.c | 39 +++++++++++++------------- 5 files changed, 31 insertions(+), 72 deletions(-) (limited to 'arch/alpha/include') diff --git a/arch/alpha/Kconfig b/arch/alpha/Kconfig index 9944dedee5b1..7da91246e279 100644 --- a/arch/alpha/Kconfig +++ b/arch/alpha/Kconfig @@ -20,6 +20,7 @@ config ALPHA select GENERIC_CMOS_UPDATE select GENERIC_STRNCPY_FROM_USER select GENERIC_STRNLEN_USER + select GENERIC_KERNEL_THREAD help The Alpha is a 64-bit general-purpose processor designed and marketed by the Digital Equipment Corporation of blessed memory, diff --git a/arch/alpha/include/asm/processor.h b/arch/alpha/include/asm/processor.h index e37b887b3d9f..6cb7fe85c4b5 100644 --- a/arch/alpha/include/asm/processor.h +++ b/arch/alpha/include/asm/processor.h @@ -49,9 +49,6 @@ extern void start_thread(struct pt_regs *, unsigned long, unsigned long); /* Free all resources held by a thread. */ extern void release_thread(struct task_struct *); -/* Create a kernel thread without removing it from tasklists. */ -extern long kernel_thread(int (*fn)(void *), void *arg, unsigned long flags); - unsigned long get_wchan(struct task_struct *p); #define KSTK_EIP(tsk) (task_pt_regs(tsk)->pc) diff --git a/arch/alpha/kernel/alpha_ksyms.c b/arch/alpha/kernel/alpha_ksyms.c index 15fa821d09cd..89566b346c0f 100644 --- a/arch/alpha/kernel/alpha_ksyms.c +++ b/arch/alpha/kernel/alpha_ksyms.c @@ -50,9 +50,6 @@ EXPORT_SYMBOL(alpha_read_fp_reg_s); EXPORT_SYMBOL(alpha_write_fp_reg); EXPORT_SYMBOL(alpha_write_fp_reg_s); -/* entry.S */ -EXPORT_SYMBOL(kernel_thread); - /* Networking helper routines. */ EXPORT_SYMBOL(csum_tcpudp_magic); EXPORT_SYMBOL(ip_compute_csum); diff --git a/arch/alpha/kernel/entry.S b/arch/alpha/kernel/entry.S index 61ff145cab6e..421dccf273eb 100644 --- a/arch/alpha/kernel/entry.S +++ b/arch/alpha/kernel/entry.S @@ -609,59 +609,22 @@ ret_from_fork: .end ret_from_fork /* - * kernel_thread(fn, arg, clone_flags) + * ... and new kernel threads - here */ .align 4 - .globl kernel_thread - .ent kernel_thread -kernel_thread: - /* We can be called from a module. */ - ldgp $gp, 0($27) - .prologue 1 - subq $sp, SP_OFF+6*8, $sp - br $1, 2f /* load start address */ - - /* We've now "returned" from a fake system call. */ - unop - blt $0, 1f /* error? */ - ldi $1, 0x3fff - beq $20, 1f /* parent or child? */ - - bic $sp, $1, $8 /* in child. */ - jsr $26, ($27) + .globl ret_from_kernel_thread + .ent ret_from_kernel_thread +ret_from_kernel_thread: + mov $17, $16 + jsr $26, schedule_tail + mov $9, $27 + mov $10, $16 + jsr $26, ($9) ldgp $gp, 0($26) mov $0, $16 mov $31, $26 jmp $31, sys_exit - -1: ret /* in parent. */ - - .align 4 -2: /* Fake a system call stack frame, as we can't do system calls - from kernel space. Note that we store FN and ARG as they - need to be set up in the child for the call. Also store $8 - and $26 for use in the parent. */ - stq $31, SP_OFF($sp) /* ps */ - stq $1, SP_OFF+8($sp) /* pc */ - stq $gp, SP_OFF+16($sp) /* gp */ - stq $16, 136($sp) /* $27; FN for child */ - stq $17, SP_OFF+24($sp) /* $16; ARG for child */ - stq $8, 64($sp) /* $8 */ - stq $26, 128($sp) /* $26 */ - /* Avoid the HAE being gratuitously wrong, to avoid restoring it. */ - ldq $2, alpha_mv+HAE_CACHE - stq $2, 152($sp) /* HAE */ - - /* Shuffle FLAGS to the front; add CLONE_VM. */ - ldi $1, CLONE_VM|CLONE_UNTRACED - or $18, $1, $16 - bsr $26, sys_clone - - /* We don't actually care for a3 success widgetry in the kernel. - Not for positive errno values. */ - stq $0, 0($sp) /* $0 */ - br ret_to_kernel -.end kernel_thread +.end ret_from_kernel_thread /* diff --git a/arch/alpha/kernel/process.c b/arch/alpha/kernel/process.c index 145473909199..6b33ecdbc534 100644 --- a/arch/alpha/kernel/process.c +++ b/arch/alpha/kernel/process.c @@ -259,33 +259,35 @@ alpha_vfork(struct pt_regs *regs) /* * Copy an alpha thread.. - * - * Note the "stack_offset" stuff: when returning to kernel mode, we need - * to have some extra stack-space for the kernel stack that still exists - * after the "ret_from_fork". When returning to user mode, we only want - * the space needed by the syscall stack frame (ie "struct pt_regs"). - * Use the passed "regs" pointer to determine how much space we need - * for a kernel fork(). */ int copy_thread(unsigned long clone_flags, unsigned long usp, - unsigned long unused, + unsigned long arg, struct task_struct * p, struct pt_regs * regs) { extern void ret_from_fork(void); + extern void ret_from_kernel_thread(void); struct thread_info *childti = task_thread_info(p); - struct pt_regs * childregs; - struct switch_stack * childstack, *stack; - unsigned long stack_offset, settls; - - stack_offset = PAGE_SIZE - sizeof(struct pt_regs); - if (!(regs->ps & 8)) - stack_offset = (PAGE_SIZE-1) & (unsigned long) regs; - childregs = (struct pt_regs *) - (stack_offset + PAGE_SIZE + task_stack_page(p)); - + struct pt_regs *childregs = task_pt_regs(p); + struct switch_stack *childstack, *stack; + unsigned long settls; + + childstack = ((struct switch_stack *) childregs) - 1; + if (unlikely(!regs)) { + /* kernel thread */ + memset(childstack, 0, + sizeof(struct switch_stack) + sizeof(struct pt_regs)); + childstack->r26 = (unsigned long) ret_from_kernel_thread; + childstack->r9 = usp; /* function */ + childstack->r10 = arg; + childregs->hae = alpha_mv.hae_cache, + childti->pcb.usp = 0; + childti->pcb.ksp = (unsigned long) childstack; + childti->pcb.flags = 1; /* set FEN, clear everything else */ + return 0; + } *childregs = *regs; settls = regs->r20; childregs->r0 = 0; @@ -293,7 +295,6 @@ copy_thread(unsigned long clone_flags, unsigned long usp, childregs->r20 = 1; /* OSF/1 has some strange fork() semantics. */ regs->r20 = 0; stack = ((struct switch_stack *) regs) - 1; - childstack = ((struct switch_stack *) childregs) - 1; *childstack = *stack; childstack->r26 = (unsigned long) ret_from_fork; childti->pcb.usp = usp; -- cgit v1.2.3-55-g7522 From 44f4b56b54d2ab5d06c1726f2cde8ca15c8fac47 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 31 May 2012 22:22:52 -0400 Subject: alpha: introduce ret_from_kernel_execve(), switch to generic kernel_execve() Signed-off-by: Al Viro --- arch/alpha/include/asm/unistd.h | 1 + arch/alpha/kernel/entry.S | 13 +++++++++++++ arch/alpha/kernel/process.c | 19 ------------------- 3 files changed, 14 insertions(+), 19 deletions(-) (limited to 'arch/alpha/include') diff --git a/arch/alpha/include/asm/unistd.h b/arch/alpha/include/asm/unistd.h index 7826e227e4d0..3cb6c1188984 100644 --- a/arch/alpha/include/asm/unistd.h +++ b/arch/alpha/include/asm/unistd.h @@ -482,6 +482,7 @@ #define __ARCH_WANT_SYS_SIGPENDING #define __ARCH_WANT_SYS_RT_SIGSUSPEND #define __ARCH_WANT_SYS_EXECVE +#define __ARCH_WANT_KERNEL_EXECVE /* "Conditional" syscalls. What we want is diff --git a/arch/alpha/kernel/entry.S b/arch/alpha/kernel/entry.S index 421dccf273eb..7e43e1156d10 100644 --- a/arch/alpha/kernel/entry.S +++ b/arch/alpha/kernel/entry.S @@ -626,6 +626,19 @@ ret_from_kernel_thread: jmp $31, sys_exit .end ret_from_kernel_thread + .globl ret_from_kernel_execve + .align 4 + .ent ret_from_kernel_execve +ret_from_kernel_execve: + mov $16, $sp + /* Avoid the HAE being gratuitously wrong, to avoid restoring it. */ + ldq $2, alpha_mv+HAE_CACHE + stq $2, 152($sp) /* HAE */ + mov $31, $19 /* to disable syscall restarts */ + br $31, ret_to_user + +.end ret_from_kernel_execve + /* * Special system calls. Most of these are special in that they either diff --git a/arch/alpha/kernel/process.c b/arch/alpha/kernel/process.c index 6b33ecdbc534..f47d764eaa11 100644 --- a/arch/alpha/kernel/process.c +++ b/arch/alpha/kernel/process.c @@ -435,22 +435,3 @@ get_wchan(struct task_struct *p) } return pc; } - -int kernel_execve(const char *path, const char *const argv[], const char *const envp[]) -{ - /* Avoid the HAE being gratuitously wrong, which would cause us - to do the whole turn off interrupts thing and restore it. */ - struct pt_regs regs = {.hae = alpha_mv.hae_cache}; - int err = do_execve(path, argv, envp, ®s); - if (!err) { - struct pt_regs *p = current_pt_regs(); - /* copy regs to normal position and off to userland we go... */ - *p = regs; - __asm__ __volatile__ ( - "mov %0, $sp;" - "br $31, ret_from_sys_call" - : : "r"(p)); - } - return err; -} -EXPORT_SYMBOL(kernel_execve); -- cgit v1.2.3-55-g7522