aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2012-08-02 03:46:39 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2012-09-30 22:21:36 -0400
commit583d632fb3f6d7e9d133a7260829dd7565f8cc99 (patch)
tree57760f02b8f9aa876a08e309f0ff258442bfa639 /arch
parent9e14f828ee4a7a4a98703e380d180717a579fb35 (diff)
arm: introduce ret_from_kernel_execve(), switch to generic kernel_execve()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'arch')
-rw-r--r--arch/arm/include/asm/unistd.h1
-rw-r--r--arch/arm/kernel/entry-common.S12
-rw-r--r--arch/arm/kernel/sys_arm.c42
3 files changed, 13 insertions, 42 deletions
diff --git a/arch/arm/include/asm/unistd.h b/arch/arm/include/asm/unistd.h
index 0cab47d4a83f..2c9b7a87e64b 100644
--- a/arch/arm/include/asm/unistd.h
+++ b/arch/arm/include/asm/unistd.h
@@ -469,6 +469,7 @@
469#define __ARCH_WANT_OLD_READDIR 469#define __ARCH_WANT_OLD_READDIR
470#define __ARCH_WANT_SYS_SOCKETCALL 470#define __ARCH_WANT_SYS_SOCKETCALL
471#endif 471#endif
472#define __ARCH_WANT_KERNEL_EXECVE
472 473
473/* 474/*
474 * "Conditional" syscalls 475 * "Conditional" syscalls
diff --git a/arch/arm/kernel/entry-common.S b/arch/arm/kernel/entry-common.S
index 9a48b7a577e7..4a6e46a9a3d7 100644
--- a/arch/arm/kernel/entry-common.S
+++ b/arch/arm/kernel/entry-common.S
@@ -103,6 +103,18 @@ ENTRY(ret_from_kernel_thread)
103 UNWIND(.fnend) 103 UNWIND(.fnend)
104ENDPROC(ret_from_kernel_thread) 104ENDPROC(ret_from_kernel_thread)
105 105
106/*
107 * turn a kernel thread into userland process
108 * use: ret_from_kernel_execve(struct pt_regs *normal)
109 */
110ENTRY(ret_from_kernel_execve)
111 mov why, #0 @ not a syscall
112 str why, [r0, #S_R0] @ ... and we want 0 in ->ARM_r0 as well
113 get_thread_info tsk @ thread structure
114 mov sp, r0 @ stack pointer just under pt_regs
115 b ret_slow_syscall
116ENDPROC(ret_from_kernel_execve)
117
106 .equ NR_syscalls,0 118 .equ NR_syscalls,0
107#define CALL(x) .equ NR_syscalls,NR_syscalls+1 119#define CALL(x) .equ NR_syscalls,NR_syscalls+1
108#include "calls.S" 120#include "calls.S"
diff --git a/arch/arm/kernel/sys_arm.c b/arch/arm/kernel/sys_arm.c
index 3ba62e3cd1a2..c8e729efc187 100644
--- a/arch/arm/kernel/sys_arm.c
+++ b/arch/arm/kernel/sys_arm.c
@@ -79,48 +79,6 @@ out:
79 return error; 79 return error;
80} 80}
81 81
82int kernel_execve(const char *filename,
83 const char *const argv[],
84 const char *const envp[])
85{
86 struct pt_regs regs;
87 int ret;
88
89 memset(&regs, 0, sizeof(struct pt_regs));
90 ret = do_execve(filename,
91 (const char __user *const __user *)argv,
92 (const char __user *const __user *)envp, &regs);
93 if (ret < 0)
94 goto out;
95
96 /*
97 * Save argc to the register structure for userspace.
98 */
99 regs.ARM_r0 = ret;
100
101 /*
102 * We were successful. We won't be returning to our caller, but
103 * instead to user space by manipulating the kernel stack.
104 */
105 asm( "add r0, %0, %1\n\t"
106 "mov r1, %2\n\t"
107 "mov r2, %3\n\t"
108 "bl memmove\n\t" /* copy regs to top of stack */
109 "mov r8, #0\n\t" /* not a syscall */
110 "mov r9, %0\n\t" /* thread structure */
111 "mov sp, r0\n\t" /* reposition stack pointer */
112 "b ret_to_user"
113 :
114 : "r" (current_thread_info()),
115 "Ir" (THREAD_START_SP - sizeof(regs)),
116 "r" (&regs),
117 "Ir" (sizeof(regs))
118 : "r0", "r1", "r2", "r3", "r8", "r9", "ip", "lr", "memory");
119
120 out:
121 return ret;
122}
123
124/* 82/*
125 * Since loff_t is a 64 bit type we avoid a lot of ABI hassle 83 * Since loff_t is a 64 bit type we avoid a lot of ABI hassle
126 * with a different argument ordering. 84 * with a different argument ordering.