diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2012-10-15 16:26:03 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2012-10-31 22:59:31 -0400 |
commit | ea4a1da9b2e6f419526b5fde15cd5563096368eb (patch) | |
tree | 470d747b0ea28293467292ac88f083e6b2370a29 /arch/m32r | |
parent | ddffeb8c4d0331609ef2581d84de4d763607bd37 (diff) |
m32r: switch to generic kernel_thread()/kernel_execve()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'arch/m32r')
-rw-r--r-- | arch/m32r/Kconfig | 2 | ||||
-rw-r--r-- | arch/m32r/include/asm/processor.h | 5 | ||||
-rw-r--r-- | arch/m32r/kernel/entry.S | 9 | ||||
-rw-r--r-- | arch/m32r/kernel/process.c | 60 | ||||
-rw-r--r-- | arch/m32r/kernel/sys_m32r.c | 21 |
5 files changed, 27 insertions, 70 deletions
diff --git a/arch/m32r/Kconfig b/arch/m32r/Kconfig index f807721e19a5..5183f43a2cf7 100644 --- a/arch/m32r/Kconfig +++ b/arch/m32r/Kconfig | |||
@@ -15,6 +15,8 @@ config M32R | |||
15 | select GENERIC_ATOMIC64 | 15 | select GENERIC_ATOMIC64 |
16 | select ARCH_USES_GETTIMEOFFSET | 16 | select ARCH_USES_GETTIMEOFFSET |
17 | select MODULES_USE_ELF_RELA | 17 | select MODULES_USE_ELF_RELA |
18 | select GENERIC_KERNEL_THREAD | ||
19 | select GENERIC_KERNEL_EXECVE | ||
18 | 20 | ||
19 | config SBUS | 21 | config SBUS |
20 | bool | 22 | bool |
diff --git a/arch/m32r/include/asm/processor.h b/arch/m32r/include/asm/processor.h index da17253b5735..5767367550c6 100644 --- a/arch/m32r/include/asm/processor.h +++ b/arch/m32r/include/asm/processor.h | |||
@@ -118,11 +118,6 @@ struct mm_struct; | |||
118 | /* Free all resources held by a thread. */ | 118 | /* Free all resources held by a thread. */ |
119 | extern void release_thread(struct task_struct *); | 119 | extern void release_thread(struct task_struct *); |
120 | 120 | ||
121 | /* | ||
122 | * create a kernel thread without removing it from tasklists | ||
123 | */ | ||
124 | extern int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags); | ||
125 | |||
126 | /* Copy and release all segment info associated with a VM */ | 121 | /* Copy and release all segment info associated with a VM */ |
127 | extern void copy_segments(struct task_struct *p, struct mm_struct * mm); | 122 | extern void copy_segments(struct task_struct *p, struct mm_struct * mm); |
128 | extern void release_segments(struct mm_struct * mm); | 123 | extern void release_segments(struct mm_struct * mm); |
diff --git a/arch/m32r/kernel/entry.S b/arch/m32r/kernel/entry.S index 225412bc227e..0c01543f10cd 100644 --- a/arch/m32r/kernel/entry.S +++ b/arch/m32r/kernel/entry.S | |||
@@ -125,6 +125,15 @@ | |||
125 | and \reg, sp | 125 | and \reg, sp |
126 | .endm | 126 | .endm |
127 | 127 | ||
128 | ENTRY(ret_from_kernel_thread) | ||
129 | pop r0 | ||
130 | bl schedule_tail | ||
131 | GET_THREAD_INFO(r8) | ||
132 | ld r0, R0(r8) | ||
133 | ld r1, R1(r8) | ||
134 | jl r1 | ||
135 | bra syscall_exit | ||
136 | |||
128 | ENTRY(ret_from_fork) | 137 | ENTRY(ret_from_fork) |
129 | pop r0 | 138 | pop r0 |
130 | bl schedule_tail | 139 | bl schedule_tail |
diff --git a/arch/m32r/kernel/process.c b/arch/m32r/kernel/process.c index e7366276ef30..fa89f027c04a 100644 --- a/arch/m32r/kernel/process.c +++ b/arch/m32r/kernel/process.c | |||
@@ -165,41 +165,6 @@ void show_regs(struct pt_regs * regs) | |||
165 | } | 165 | } |
166 | 166 | ||
167 | /* | 167 | /* |
168 | * Create a kernel thread | ||
169 | */ | ||
170 | |||
171 | /* | ||
172 | * This is the mechanism for creating a new kernel thread. | ||
173 | * | ||
174 | * NOTE! Only a kernel-only process(ie the swapper or direct descendants | ||
175 | * who haven't done an "execve()") should use this: it will work within | ||
176 | * a system call from a "real" process, but the process memory space will | ||
177 | * not be free'd until both the parent and the child have exited. | ||
178 | */ | ||
179 | static void kernel_thread_helper(void *nouse, int (*fn)(void *), void *arg) | ||
180 | { | ||
181 | fn(arg); | ||
182 | do_exit(-1); | ||
183 | } | ||
184 | |||
185 | int kernel_thread(int (*fn)(void *), void *arg, unsigned long flags) | ||
186 | { | ||
187 | struct pt_regs regs; | ||
188 | |||
189 | memset(®s, 0, sizeof (regs)); | ||
190 | regs.r1 = (unsigned long)fn; | ||
191 | regs.r2 = (unsigned long)arg; | ||
192 | |||
193 | regs.bpc = (unsigned long)kernel_thread_helper; | ||
194 | |||
195 | regs.psw = M32R_PSW_BIE; | ||
196 | |||
197 | /* Ok, create the new process. */ | ||
198 | return do_fork(flags | CLONE_VM | CLONE_UNTRACED, 0, ®s, 0, NULL, | ||
199 | NULL); | ||
200 | } | ||
201 | |||
202 | /* | ||
203 | * Free current thread data structures etc.. | 168 | * Free current thread data structures etc.. |
204 | */ | 169 | */ |
205 | void exit_thread(void) | 170 | void exit_thread(void) |
@@ -227,19 +192,26 @@ int dump_fpu(struct pt_regs *regs, elf_fpregset_t *fpu) | |||
227 | } | 192 | } |
228 | 193 | ||
229 | int copy_thread(unsigned long clone_flags, unsigned long spu, | 194 | int copy_thread(unsigned long clone_flags, unsigned long spu, |
230 | unsigned long unused, struct task_struct *tsk, struct pt_regs *regs) | 195 | unsigned long arg, struct task_struct *tsk, struct pt_regs *regs) |
231 | { | 196 | { |
232 | struct pt_regs *childregs = task_pt_regs(tsk); | 197 | struct pt_regs *childregs = task_pt_regs(tsk); |
233 | extern void ret_from_fork(void); | 198 | extern void ret_from_fork(void); |
234 | 199 | extern void ret_from_kernel_thread(void); | |
235 | /* Copy registers */ | 200 | |
236 | *childregs = *regs; | 201 | if (unlikely(tsk->flags & PF_KTHREAD)) { |
237 | 202 | memset(childregs, 0, sizeof(struct pt_regs)); | |
238 | childregs->spu = spu; | 203 | childregs->psw = M32R_PSW_BIE; |
239 | childregs->r0 = 0; /* Child gets zero as return value */ | 204 | childregs->r1 = spu; /* fn */ |
240 | regs->r0 = tsk->pid; | 205 | childregs->r0 = arg; |
206 | tsk->thread.lr = (unsigned long)ret_from_kernel_thread; | ||
207 | } else { | ||
208 | /* Copy registers */ | ||
209 | *childregs = *regs; | ||
210 | childregs->spu = spu; | ||
211 | childregs->r0 = 0; /* Child gets zero as return value */ | ||
212 | tsk->thread.lr = (unsigned long)ret_from_fork; | ||
213 | } | ||
241 | tsk->thread.sp = (unsigned long)childregs; | 214 | tsk->thread.sp = (unsigned long)childregs; |
242 | tsk->thread.lr = (unsigned long)ret_from_fork; | ||
243 | 215 | ||
244 | return 0; | 216 | return 0; |
245 | } | 217 | } |
diff --git a/arch/m32r/kernel/sys_m32r.c b/arch/m32r/kernel/sys_m32r.c index d841fb6cc703..c3fdd632fba7 100644 --- a/arch/m32r/kernel/sys_m32r.c +++ b/arch/m32r/kernel/sys_m32r.c | |||
@@ -88,24 +88,3 @@ asmlinkage int sys_cachectl(char *addr, int nbytes, int op) | |||
88 | /* Not implemented yet. */ | 88 | /* Not implemented yet. */ |
89 | return -ENOSYS; | 89 | return -ENOSYS; |
90 | } | 90 | } |
91 | |||
92 | /* | ||
93 | * Do a system call from kernel instead of calling sys_execve so we | ||
94 | * end up with proper pt_regs. | ||
95 | */ | ||
96 | int kernel_execve(const char *filename, | ||
97 | const char *const argv[], | ||
98 | const char *const envp[]) | ||
99 | { | ||
100 | register long __scno __asm__ ("r7") = __NR_execve; | ||
101 | register long __arg3 __asm__ ("r2") = (long)(envp); | ||
102 | register long __arg2 __asm__ ("r1") = (long)(argv); | ||
103 | register long __res __asm__ ("r0") = (long)(filename); | ||
104 | __asm__ __volatile__ ( | ||
105 | "trap #" SYSCALL_VECTOR "|| nop" | ||
106 | : "=r" (__res) | ||
107 | : "r" (__scno), "0" (__res), "r" (__arg2), | ||
108 | "r" (__arg3) | ||
109 | : "memory"); | ||
110 | return __res; | ||
111 | } | ||