From 8f54bcacbc39f883bde2210cf2754e5d198f55a4 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Tue, 9 Oct 2012 16:27:45 -0400 Subject: mips: switch to generic kernel_thread() Signed-off-by: Al Viro --- arch/mips/kernel/entry.S | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'arch/mips/kernel/entry.S') diff --git a/arch/mips/kernel/entry.S b/arch/mips/kernel/entry.S index a6c133212003..aab6997b8f47 100644 --- a/arch/mips/kernel/entry.S +++ b/arch/mips/kernel/entry.S @@ -65,6 +65,13 @@ need_resched: b need_resched #endif +FEXPORT(ret_from_kernel_thread) + jal schedule_tail # a0 = struct task_struct *prev + move a0, s1 + jal s0 + li a0, 0 + j sys_exit + FEXPORT(ret_from_fork) jal schedule_tail # a0 = struct task_struct *prev -- cgit v1.2.3 From baf9ff74eda9f0efcc8a68e8a9c9d183be13a810 Mon Sep 17 00:00:00 2001 From: Ralf Baechle Date: Tue, 9 Oct 2012 21:16:07 +0200 Subject: 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 --- arch/mips/include/asm/ptrace.h | 6 +++++ arch/mips/include/asm/unistd.h | 2 ++ arch/mips/kernel/entry.S | 9 +++++++ arch/mips/kernel/linux32.c | 21 ----------------- arch/mips/kernel/scall64-n32.S | 2 +- arch/mips/kernel/scall64-o32.S | 2 +- arch/mips/kernel/syscall.c | 53 ------------------------------------------ 7 files changed, 19 insertions(+), 76 deletions(-) (limited to 'arch/mips/kernel/entry.S') 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) die(str, regs); } +#define current_pt_regs() \ +({ \ + unsigned long sp = (unsigned long)__builtin_frame_address(0); \ + (struct pt_regs *)((sp | (THREAD_SIZE - 1)) + 1 - 32) - 1; \ +}) + #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 @@ #ifndef __ASSEMBLY__ #define __ARCH_OMIT_COMPAT_SYS_GETDENTS64 +#define __ARCH_WANT_KERNEL_EXECVE #define __ARCH_WANT_OLD_READDIR #define __ARCH_WANT_SYS_ALARM +#define __ARCH_WANT_SYS_EXECVE #define __ARCH_WANT_SYS_GETHOSTNAME #define __ARCH_WANT_SYS_IPC #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: jal syscall_trace_leave b resume_userspace +LEAF(ret_from_kernel_execve) + move sp, a0 + ori $28, sp, _THREAD_SIZE - 1 + xori $28, $28, _THREAD_SIZE - 1 + li v0, 0 + li a3, 0 + j syscall_exit_partial + END(ret_from_kernel_execve) + #if defined(CONFIG_CPU_MIPSR2) || defined(CONFIG_MIPS_MT) /* 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 @@ * * Copyright (C) 2000 Silicon Graphics, Inc. * Written by Ulf Carlsson (ulfc@engr.sgi.com) - * sys32_execve from ia64/ia32 code, Feb 2000, Kanoj Sarcar (kanoj@sgi.com) */ #include #include @@ -77,26 +76,6 @@ out: return error; } -/* - * sys_execve() executes a new program. - */ -asmlinkage int sys32_execve(nabi_no_regargs struct pt_regs regs) -{ - int error; - struct filename *filename; - - filename = getname(compat_ptr(regs.regs[4])); - error = PTR_ERR(filename); - if (IS_ERR(filename)) - goto out; - error = compat_do_execve(filename->name, compat_ptr(regs.regs[5]), - compat_ptr(regs.regs[6]), ®s); - putname(filename); - -out: - return error; -} - #define RLIM_INFINITY32 0x7fffffff #define RESOURCE32(x) ((x > RLIM_INFINITY32) ? RLIM_INFINITY32 : x) 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) PTR sys_getsockopt PTR sys_clone /* 6055 */ PTR sys_fork - PTR sys32_execve + PTR compat_sys_execve PTR sys_exit PTR compat_sys_wait4 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: PTR sys_creat PTR sys_link PTR sys_unlink /* 4010 */ - PTR sys32_execve + PTR compat_sys_execve PTR sys_chdir PTR compat_sys_time 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) parent_tidptr, child_tidptr); } -/* - * sys_execve() executes a new program. - */ -asmlinkage int sys_execve(nabi_no_regargs struct pt_regs regs) -{ - int error; - struct filename *filename; - - filename = getname((const char __user *) (long)regs.regs[4]); - error = PTR_ERR(filename); - if (IS_ERR(filename)) - goto out; - error = do_execve(filename->name, - (const char __user *const __user *) (long)regs.regs[5], - (const char __user *const __user *) (long)regs.regs[6], - ®s); - putname(filename); - -out: - return error; -} - SYSCALL_DEFINE1(set_thread_area, unsigned long, addr) { struct thread_info *ti = task_thread_info(current); @@ -313,34 +291,3 @@ asmlinkage void bad_stack(void) { do_exit(SIGSEGV); } - -/* - * Do a system call from kernel instead of calling sys_execve so we - * end up with proper pt_regs. - */ -int kernel_execve(const char *filename, - const char *const argv[], - const char *const envp[]) -{ - register unsigned long __a0 asm("$4") = (unsigned long) filename; - register unsigned long __a1 asm("$5") = (unsigned long) argv; - register unsigned long __a2 asm("$6") = (unsigned long) envp; - register unsigned long __a3 asm("$7"); - unsigned long __v0; - - __asm__ volatile (" \n" - " .set noreorder \n" - " li $2, %5 # __NR_execve \n" - " syscall \n" - " move %0, $2 \n" - " .set reorder \n" - : "=&r" (__v0), "=r" (__a3) - : "r" (__a0), "r" (__a1), "r" (__a2), "i" (__NR_execve) - : "$2", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", - "memory"); - - if (__a3 == 0) - return __v0; - - return -__v0; -} -- cgit v1.2.3 From 9b0e5d42d9a66621fce83a22987d33325debb588 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 11 Oct 2012 16:01:20 -0400 Subject: mips: switch to saner kernel_execve() semantics Acked-by: Ralf Baechle Signed-off-by: Al Viro --- arch/mips/Kconfig | 1 + arch/mips/include/asm/unistd.h | 1 - arch/mips/kernel/entry.S | 12 +----------- 3 files changed, 2 insertions(+), 12 deletions(-) (limited to 'arch/mips/kernel/entry.S') diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index ede301f9c88b..4183e62f178c 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig @@ -41,6 +41,7 @@ config MIPS select MODULES_USE_ELF_REL select MODULES_USE_ELF_RELA if 64BIT select GENERIC_KERNEL_THREAD + select GENERIC_KERNEL_EXECVE menu "Machine selection" diff --git a/arch/mips/include/asm/unistd.h b/arch/mips/include/asm/unistd.h index 8ae908c66e59..b306e2081cad 100644 --- a/arch/mips/include/asm/unistd.h +++ b/arch/mips/include/asm/unistd.h @@ -18,7 +18,6 @@ #ifndef __ASSEMBLY__ #define __ARCH_OMIT_COMPAT_SYS_GETDENTS64 -#define __ARCH_WANT_KERNEL_EXECVE #define __ARCH_WANT_OLD_READDIR #define __ARCH_WANT_SYS_ALARM #define __ARCH_WANT_SYS_EXECVE diff --git a/arch/mips/kernel/entry.S b/arch/mips/kernel/entry.S index 5dcb5fbbbd53..3320cb4ac1d4 100644 --- a/arch/mips/kernel/entry.S +++ b/arch/mips/kernel/entry.S @@ -69,8 +69,7 @@ FEXPORT(ret_from_kernel_thread) jal schedule_tail # a0 = struct task_struct *prev move a0, s1 jal s0 - li a0, 0 - j sys_exit + j syscall_exit FEXPORT(ret_from_fork) jal schedule_tail # a0 = struct task_struct *prev @@ -192,15 +191,6 @@ syscall_exit_work: jal syscall_trace_leave b resume_userspace -LEAF(ret_from_kernel_execve) - move sp, a0 - ori $28, sp, _THREAD_SIZE - 1 - xori $28, $28, _THREAD_SIZE - 1 - li v0, 0 - li a3, 0 - j syscall_exit_partial - END(ret_from_kernel_execve) - #if defined(CONFIG_CPU_MIPSR2) || defined(CONFIG_MIPS_MT) /* -- cgit v1.2.3