diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-12-12 15:22:13 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-12-12 15:22:13 -0500 |
commit | 9977d9b379cb77e0f67bd6f4563618106e58e11d (patch) | |
tree | 0191accfddf578edb52c69c933d64521e3dce297 /arch/h8300 | |
parent | cf4af01221579a4e895f43dbfc47598fbfc5a731 (diff) | |
parent | 541880d9a2c7871f6370071d55aa6662d329c51e (diff) |
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/signal
Pull big execve/kernel_thread/fork unification series from Al Viro:
"All architectures are converted to new model. Quite a bit of that
stuff is actually shared with architecture trees; in such cases it's
literally shared branch pulled by both, not a cherry-pick.
A lot of ugliness and black magic is gone (-3KLoC total in this one):
- kernel_thread()/kernel_execve()/sys_execve() redesign.
We don't do syscalls from kernel anymore for either kernel_thread()
or kernel_execve():
kernel_thread() is essentially clone(2) with callback run before we
return to userland, the callbacks either never return or do
successful do_execve() before returning.
kernel_execve() is a wrapper for do_execve() - it doesn't need to
do transition to user mode anymore.
As a result kernel_thread() and kernel_execve() are
arch-independent now - they live in kernel/fork.c and fs/exec.c
resp. sys_execve() is also in fs/exec.c and it's completely
architecture-independent.
- daemonize() is gone, along with its parts in fs/*.c
- struct pt_regs * is no longer passed to do_fork/copy_process/
copy_thread/do_execve/search_binary_handler/->load_binary/do_coredump.
- sys_fork()/sys_vfork()/sys_clone() unified; some architectures
still need wrappers (ones with callee-saved registers not saved in
pt_regs on syscall entry), but the main part of those suckers is in
kernel/fork.c now."
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/signal: (113 commits)
do_coredump(): get rid of pt_regs argument
print_fatal_signal(): get rid of pt_regs argument
ptrace_signal(): get rid of unused arguments
get rid of ptrace_signal_deliver() arguments
new helper: signal_pt_regs()
unify default ptrace_signal_deliver
flagday: kill pt_regs argument of do_fork()
death to idle_regs()
don't pass regs to copy_process()
flagday: don't pass regs to copy_thread()
bfin: switch to generic vfork, get rid of pointless wrappers
xtensa: switch to generic clone()
openrisc: switch to use of generic fork and clone
unicore32: switch to generic clone(2)
score: switch to generic fork/vfork/clone
c6x: sanitize copy_thread(), get rid of clone(2) wrapper, switch to generic clone()
take sys_fork/sys_vfork/sys_clone prototypes to linux/syscalls.h
mn10300: switch to generic fork/vfork/clone
h8300: switch to generic fork/vfork/clone
tile: switch to generic clone()
...
Conflicts:
arch/microblaze/include/asm/Kbuild
Diffstat (limited to 'arch/h8300')
-rw-r--r-- | arch/h8300/Kconfig | 2 | ||||
-rw-r--r-- | arch/h8300/include/asm/processor.h | 2 | ||||
-rw-r--r-- | arch/h8300/include/asm/ptrace.h | 3 | ||||
-rw-r--r-- | arch/h8300/include/asm/signal.h | 2 | ||||
-rw-r--r-- | arch/h8300/include/asm/unistd.h | 4 | ||||
-rw-r--r-- | arch/h8300/kernel/entry.S | 9 | ||||
-rw-r--r-- | arch/h8300/kernel/h8300_ksyms.c | 1 | ||||
-rw-r--r-- | arch/h8300/kernel/process.c | 100 | ||||
-rw-r--r-- | arch/h8300/kernel/sys_h8300.c | 26 | ||||
-rw-r--r-- | arch/h8300/kernel/syscalls.S | 9 |
10 files changed, 29 insertions, 129 deletions
diff --git a/arch/h8300/Kconfig b/arch/h8300/Kconfig index 98fabd10e95f..04bef4d25b4a 100644 --- a/arch/h8300/Kconfig +++ b/arch/h8300/Kconfig | |||
@@ -8,6 +8,8 @@ config H8300 | |||
8 | select GENERIC_IRQ_SHOW | 8 | select GENERIC_IRQ_SHOW |
9 | select GENERIC_CPU_DEVICES | 9 | select GENERIC_CPU_DEVICES |
10 | select MODULES_USE_ELF_RELA | 10 | select MODULES_USE_ELF_RELA |
11 | select GENERIC_KERNEL_THREAD | ||
12 | select GENERIC_KERNEL_EXECVE | ||
11 | 13 | ||
12 | config SYMBOL_PREFIX | 14 | config SYMBOL_PREFIX |
13 | string | 15 | string |
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) | |||
107 | { | 107 | { |
108 | } | 108 | } |
109 | 109 | ||
110 | extern int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags); | ||
111 | |||
112 | /* | 110 | /* |
113 | * Free current thread data structures etc.. | 111 | * Free current thread data structures etc.. |
114 | */ | 112 | */ |
diff --git a/arch/h8300/include/asm/ptrace.h b/arch/h8300/include/asm/ptrace.h index d09c440bdba7..7468589a128b 100644 --- a/arch/h8300/include/asm/ptrace.h +++ b/arch/h8300/include/asm/ptrace.h | |||
@@ -60,6 +60,9 @@ struct pt_regs { | |||
60 | #define user_mode(regs) (!((regs)->ccr & PS_S)) | 60 | #define user_mode(regs) (!((regs)->ccr & PS_S)) |
61 | #define instruction_pointer(regs) ((regs)->pc) | 61 | #define instruction_pointer(regs) ((regs)->pc) |
62 | #define profile_pc(regs) instruction_pointer(regs) | 62 | #define profile_pc(regs) instruction_pointer(regs) |
63 | #define current_pt_regs() ((struct pt_regs *) \ | ||
64 | (THREAD_SIZE + (unsigned long)current_thread_info()) - 1) | ||
65 | #define signal_pt_regs() ((struct pt_regs *)current->thread.esp0) | ||
63 | #endif /* __KERNEL__ */ | 66 | #endif /* __KERNEL__ */ |
64 | #endif /* __ASSEMBLY__ */ | 67 | #endif /* __ASSEMBLY__ */ |
65 | #endif /* _H8300_PTRACE_H */ | 68 | #endif /* _H8300_PTRACE_H */ |
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 { | |||
154 | #include <asm/sigcontext.h> | 154 | #include <asm/sigcontext.h> |
155 | #undef __HAVE_ARCH_SIG_BITOPS | 155 | #undef __HAVE_ARCH_SIG_BITOPS |
156 | 156 | ||
157 | #define ptrace_signal_deliver(regs, cookie) do { } while (0) | ||
158 | |||
159 | #endif /* __KERNEL__ */ | 157 | #endif /* __KERNEL__ */ |
160 | 158 | ||
161 | #endif /* _H8300_SIGNAL_H */ | 159 | #endif /* _H8300_SIGNAL_H */ |
diff --git a/arch/h8300/include/asm/unistd.h b/arch/h8300/include/asm/unistd.h index 5cd882801d79..c2c2f5c7d6bf 100644 --- a/arch/h8300/include/asm/unistd.h +++ b/arch/h8300/include/asm/unistd.h | |||
@@ -356,6 +356,10 @@ | |||
356 | #define __ARCH_WANT_SYS_SIGPROCMASK | 356 | #define __ARCH_WANT_SYS_SIGPROCMASK |
357 | #define __ARCH_WANT_SYS_RT_SIGACTION | 357 | #define __ARCH_WANT_SYS_RT_SIGACTION |
358 | #define __ARCH_WANT_SYS_RT_SIGSUSPEND | 358 | #define __ARCH_WANT_SYS_RT_SIGSUSPEND |
359 | #define __ARCH_WANT_SYS_EXECVE | ||
360 | #define __ARCH_WANT_SYS_FORK | ||
361 | #define __ARCH_WANT_SYS_VFORK | ||
362 | #define __ARCH_WANT_SYS_CLONE | ||
359 | 363 | ||
360 | /* | 364 | /* |
361 | * "Conditional" syscalls | 365 | * "Conditional" syscalls |
diff --git a/arch/h8300/kernel/entry.S b/arch/h8300/kernel/entry.S index ca7431690300..617a6878787f 100644 --- a/arch/h8300/kernel/entry.S +++ b/arch/h8300/kernel/entry.S | |||
@@ -158,6 +158,7 @@ INTERRUPTS = 128 | |||
158 | .globl SYMBOL_NAME(system_call) | 158 | .globl SYMBOL_NAME(system_call) |
159 | .globl SYMBOL_NAME(ret_from_exception) | 159 | .globl SYMBOL_NAME(ret_from_exception) |
160 | .globl SYMBOL_NAME(ret_from_fork) | 160 | .globl SYMBOL_NAME(ret_from_fork) |
161 | .globl SYMBOL_NAME(ret_from_kernel_thread) | ||
161 | .globl SYMBOL_NAME(ret_from_interrupt) | 162 | .globl SYMBOL_NAME(ret_from_interrupt) |
162 | .globl SYMBOL_NAME(interrupt_redirect_table) | 163 | .globl SYMBOL_NAME(interrupt_redirect_table) |
163 | .globl SYMBOL_NAME(sw_ksp),SYMBOL_NAME(sw_usp) | 164 | .globl SYMBOL_NAME(sw_ksp),SYMBOL_NAME(sw_usp) |
@@ -330,6 +331,14 @@ SYMBOL_NAME_LABEL(ret_from_fork) | |||
330 | jsr @SYMBOL_NAME(schedule_tail) | 331 | jsr @SYMBOL_NAME(schedule_tail) |
331 | jmp @SYMBOL_NAME(ret_from_exception) | 332 | jmp @SYMBOL_NAME(ret_from_exception) |
332 | 333 | ||
334 | SYMBOL_NAME_LABEL(ret_from_kernel_thread) | ||
335 | mov.l er2,er0 | ||
336 | jsr @SYMBOL_NAME(schedule_tail) | ||
337 | mov.l @(LER4:16,sp),er0 | ||
338 | mov.l @(LER5:16,sp),er1 | ||
339 | jsr @er1 | ||
340 | jmp @SYMBOL_NAME(ret_from_exception) | ||
341 | |||
333 | SYMBOL_NAME_LABEL(resume) | 342 | SYMBOL_NAME_LABEL(resume) |
334 | /* | 343 | /* |
335 | * Beware - when entering resume, offset of tss is in d1, | 344 | * Beware - when entering resume, offset of tss is in d1, |
diff --git a/arch/h8300/kernel/h8300_ksyms.c b/arch/h8300/kernel/h8300_ksyms.c index 6866bd9c7fb4..53d7c0e4bd83 100644 --- a/arch/h8300/kernel/h8300_ksyms.c +++ b/arch/h8300/kernel/h8300_ksyms.c | |||
@@ -33,7 +33,6 @@ EXPORT_SYMBOL(strncmp); | |||
33 | 33 | ||
34 | EXPORT_SYMBOL(ip_fast_csum); | 34 | EXPORT_SYMBOL(ip_fast_csum); |
35 | 35 | ||
36 | EXPORT_SYMBOL(kernel_thread); | ||
37 | EXPORT_SYMBOL(enable_irq); | 36 | EXPORT_SYMBOL(enable_irq); |
38 | EXPORT_SYMBOL(disable_irq); | 37 | EXPORT_SYMBOL(disable_irq); |
39 | 38 | ||
diff --git a/arch/h8300/kernel/process.c b/arch/h8300/kernel/process.c index e8dc1393a13a..b609f63f1590 100644 --- a/arch/h8300/kernel/process.c +++ b/arch/h8300/kernel/process.c | |||
@@ -47,6 +47,7 @@ void (*pm_power_off)(void) = NULL; | |||
47 | EXPORT_SYMBOL(pm_power_off); | 47 | EXPORT_SYMBOL(pm_power_off); |
48 | 48 | ||
49 | asmlinkage void ret_from_fork(void); | 49 | asmlinkage void ret_from_fork(void); |
50 | asmlinkage void ret_from_kernel_thread(void); | ||
50 | 51 | ||
51 | /* | 52 | /* |
52 | * The idle loop on an H8/300.. | 53 | * The idle loop on an H8/300.. |
@@ -122,113 +123,34 @@ void show_regs(struct pt_regs * regs) | |||
122 | printk("\n"); | 123 | printk("\n"); |
123 | } | 124 | } |
124 | 125 | ||
125 | /* | ||
126 | * Create a kernel thread | ||
127 | */ | ||
128 | int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags) | ||
129 | { | ||
130 | long retval; | ||
131 | long clone_arg; | ||
132 | mm_segment_t fs; | ||
133 | |||
134 | fs = get_fs(); | ||
135 | set_fs (KERNEL_DS); | ||
136 | clone_arg = flags | CLONE_VM; | ||
137 | __asm__("mov.l sp,er3\n\t" | ||
138 | "sub.l er2,er2\n\t" | ||
139 | "mov.l %2,er1\n\t" | ||
140 | "mov.l %1,er0\n\t" | ||
141 | "trapa #0\n\t" | ||
142 | "cmp.l sp,er3\n\t" | ||
143 | "beq 1f\n\t" | ||
144 | "mov.l %4,er0\n\t" | ||
145 | "mov.l %3,er1\n\t" | ||
146 | "jsr @er1\n\t" | ||
147 | "mov.l %5,er0\n\t" | ||
148 | "trapa #0\n" | ||
149 | "1:\n\t" | ||
150 | "mov.l er0,%0" | ||
151 | :"=r"(retval) | ||
152 | :"i"(__NR_clone),"g"(clone_arg),"g"(fn),"g"(arg),"i"(__NR_exit) | ||
153 | :"er0","er1","er2","er3"); | ||
154 | set_fs (fs); | ||
155 | return retval; | ||
156 | } | ||
157 | |||
158 | void flush_thread(void) | 126 | void flush_thread(void) |
159 | { | 127 | { |
160 | } | 128 | } |
161 | 129 | ||
162 | /* | ||
163 | * "h8300_fork()".. By the time we get here, the | ||
164 | * non-volatile registers have also been saved on the | ||
165 | * stack. We do some ugly pointer stuff here.. (see | ||
166 | * also copy_thread) | ||
167 | */ | ||
168 | |||
169 | asmlinkage int h8300_fork(struct pt_regs *regs) | ||
170 | { | ||
171 | return -EINVAL; | ||
172 | } | ||
173 | |||
174 | asmlinkage int h8300_vfork(struct pt_regs *regs) | ||
175 | { | ||
176 | return do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, rdusp(), regs, 0, NULL, NULL); | ||
177 | } | ||
178 | |||
179 | asmlinkage int h8300_clone(struct pt_regs *regs) | ||
180 | { | ||
181 | unsigned long clone_flags; | ||
182 | unsigned long newsp; | ||
183 | |||
184 | /* syscall2 puts clone_flags in er1 and usp in er2 */ | ||
185 | clone_flags = regs->er1; | ||
186 | newsp = regs->er2; | ||
187 | if (!newsp) | ||
188 | newsp = rdusp(); | ||
189 | return do_fork(clone_flags, newsp, regs, 0, NULL, NULL); | ||
190 | |||
191 | } | ||
192 | |||
193 | int copy_thread(unsigned long clone_flags, | 130 | int copy_thread(unsigned long clone_flags, |
194 | unsigned long usp, unsigned long topstk, | 131 | unsigned long usp, unsigned long topstk, |
195 | struct task_struct * p, struct pt_regs * regs) | 132 | struct task_struct * p) |
196 | { | 133 | { |
197 | struct pt_regs * childregs; | 134 | struct pt_regs * childregs; |
198 | 135 | ||
199 | childregs = (struct pt_regs *) (THREAD_SIZE + task_stack_page(p)) - 1; | 136 | childregs = (struct pt_regs *) (THREAD_SIZE + task_stack_page(p)) - 1; |
200 | 137 | ||
201 | *childregs = *regs; | 138 | if (unlikely(p->flags & PF_KTHREAD)) { |
139 | memset(childregs, 0, sizeof(struct pt_regs)); | ||
140 | childregs->retpc = (unsigned long) ret_from_kernel_thread; | ||
141 | childregs->er4 = topstk; /* arg */ | ||
142 | childregs->er5 = usp; /* fn */ | ||
143 | p->thread.ksp = (unsigned long)childregs; | ||
144 | } | ||
145 | *childregs = *current_pt_regs(); | ||
202 | childregs->retpc = (unsigned long) ret_from_fork; | 146 | childregs->retpc = (unsigned long) ret_from_fork; |
203 | childregs->er0 = 0; | 147 | childregs->er0 = 0; |
204 | 148 | p->thread.usp = usp ?: rdusp(); | |
205 | p->thread.usp = usp; | ||
206 | p->thread.ksp = (unsigned long)childregs; | 149 | p->thread.ksp = (unsigned long)childregs; |
207 | 150 | ||
208 | return 0; | 151 | return 0; |
209 | } | 152 | } |
210 | 153 | ||
211 | /* | ||
212 | * sys_execve() executes a new program. | ||
213 | */ | ||
214 | asmlinkage int sys_execve(const char *name, | ||
215 | const char *const *argv, | ||
216 | const char *const *envp, | ||
217 | int dummy, ...) | ||
218 | { | ||
219 | int error; | ||
220 | struct filename *filename; | ||
221 | struct pt_regs *regs = (struct pt_regs *) ((unsigned char *)&dummy-4); | ||
222 | |||
223 | filename = getname(name); | ||
224 | error = PTR_ERR(filename); | ||
225 | if (IS_ERR(filename)) | ||
226 | return error; | ||
227 | error = do_execve(filename->name, argv, envp, regs); | ||
228 | putname(filename); | ||
229 | return error; | ||
230 | } | ||
231 | |||
232 | unsigned long thread_saved_pc(struct task_struct *tsk) | 154 | unsigned long thread_saved_pc(struct task_struct *tsk) |
233 | { | 155 | { |
234 | return ((struct pt_regs *)tsk->thread.esp0)->pc; | 156 | return ((struct pt_regs *)tsk->thread.esp0)->pc; |
diff --git a/arch/h8300/kernel/sys_h8300.c b/arch/h8300/kernel/sys_h8300.c index 4bdc7311784e..bf350cb7f597 100644 --- a/arch/h8300/kernel/sys_h8300.c +++ b/arch/h8300/kernel/sys_h8300.c | |||
@@ -46,29 +46,3 @@ asmlinkage void syscall_print(void *dummy,...) | |||
46 | ((regs->pc)&0xffffff)-2,regs->orig_er0,regs->er1,regs->er2,regs->er3,regs->er0); | 46 | ((regs->pc)&0xffffff)-2,regs->orig_er0,regs->er1,regs->er2,regs->er3,regs->er0); |
47 | } | 47 | } |
48 | #endif | 48 | #endif |
49 | |||
50 | /* | ||
51 | * Do a system call from kernel instead of calling sys_execve so we | ||
52 | * end up with proper pt_regs. | ||
53 | */ | ||
54 | asmlinkage | ||
55 | int kernel_execve(const char *filename, | ||
56 | const char *const argv[], | ||
57 | const char *const envp[]) | ||
58 | { | ||
59 | register long res __asm__("er0"); | ||
60 | register const char *const *_c __asm__("er3") = envp; | ||
61 | register const char *const *_b __asm__("er2") = argv; | ||
62 | register const char * _a __asm__("er1") = filename; | ||
63 | __asm__ __volatile__ ("mov.l %1,er0\n\t" | ||
64 | "trapa #0\n\t" | ||
65 | : "=r" (res) | ||
66 | : "g" (__NR_execve), | ||
67 | "g" (_a), | ||
68 | "g" (_b), | ||
69 | "g" (_c) | ||
70 | : "cc", "memory"); | ||
71 | return res; | ||
72 | } | ||
73 | |||
74 | |||
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) | |||
340 | bra SYMBOL_NAME(syscall_trampoline):8 | 340 | bra SYMBOL_NAME(syscall_trampoline):8 |
341 | .endm | 341 | .endm |
342 | 342 | ||
343 | SYMBOL_NAME_LABEL(sys_clone) | ||
344 | call_sp h8300_clone | ||
345 | |||
346 | SYMBOL_NAME_LABEL(sys_sigreturn) | 343 | SYMBOL_NAME_LABEL(sys_sigreturn) |
347 | call_sp do_sigreturn | 344 | call_sp do_sigreturn |
348 | 345 | ||
349 | SYMBOL_NAME_LABEL(sys_rt_sigreturn) | 346 | SYMBOL_NAME_LABEL(sys_rt_sigreturn) |
350 | call_sp do_rt_sigreturn | 347 | call_sp do_rt_sigreturn |
351 | 348 | ||
352 | SYMBOL_NAME_LABEL(sys_fork) | ||
353 | call_sp h8300_fork | ||
354 | |||
355 | SYMBOL_NAME_LABEL(sys_vfork) | ||
356 | call_sp h8300_vfork | ||
357 | |||
358 | SYMBOL_NAME_LABEL(syscall_trampoline) | 349 | SYMBOL_NAME_LABEL(syscall_trampoline) |
359 | mov.l sp,er0 | 350 | mov.l sp,er0 |
360 | jmp @er6 | 351 | jmp @er6 |