diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2012-10-26 15:15:13 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2012-11-28 22:36:46 -0500 |
commit | 27d892fb27f492921cfd6df15ab4153f1badbb46 (patch) | |
tree | a5097f8bfe9614ec86db50a84b538afb8399033d | |
parent | 584271bcb45b50027c8d87b51634750780c92437 (diff) |
cris: switch to generic fork/vfork/clone
same braindamage as on s390 - the first two arguments of clone(2) in the
wrong order.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r-- | arch/cris/Kconfig | 1 | ||||
-rw-r--r-- | arch/cris/arch-v10/kernel/process.c | 32 | ||||
-rw-r--r-- | arch/cris/arch-v32/kernel/process.c | 37 | ||||
-rw-r--r-- | arch/cris/include/asm/unistd.h | 3 |
4 files changed, 13 insertions, 60 deletions
diff --git a/arch/cris/Kconfig b/arch/cris/Kconfig index 81b59d18867e..0cac6a49f230 100644 --- a/arch/cris/Kconfig +++ b/arch/cris/Kconfig | |||
@@ -51,6 +51,7 @@ config CRIS | |||
51 | select MODULES_USE_ELF_RELA | 51 | select MODULES_USE_ELF_RELA |
52 | select GENERIC_KERNEL_THREAD | 52 | select GENERIC_KERNEL_THREAD |
53 | select GENERIC_KERNEL_EXECVE | 53 | select GENERIC_KERNEL_EXECVE |
54 | select CLONE_BACKWARDS2 | ||
54 | 55 | ||
55 | config HZ | 56 | config HZ |
56 | int | 57 | int |
diff --git a/arch/cris/arch-v10/kernel/process.c b/arch/cris/arch-v10/kernel/process.c index 1d6458287f38..520547c8b196 100644 --- a/arch/cris/arch-v10/kernel/process.c +++ b/arch/cris/arch-v10/kernel/process.c | |||
@@ -17,7 +17,7 @@ | |||
17 | #include <arch/svinto.h> | 17 | #include <arch/svinto.h> |
18 | #include <linux/init.h> | 18 | #include <linux/init.h> |
19 | #include <arch/system.h> | 19 | #include <arch/system.h> |
20 | #include <asm/ptrace.h> | 20 | #include <linux/ptrace.h> |
21 | 21 | ||
22 | #ifdef CONFIG_ETRAX_GPIO | 22 | #ifdef CONFIG_ETRAX_GPIO |
23 | void etrax_gpio_wake_up_check(void); /* drivers/gpio.c */ | 23 | void etrax_gpio_wake_up_check(void); /* drivers/gpio.c */ |
@@ -95,7 +95,7 @@ asmlinkage void ret_from_kernel_thread(void); | |||
95 | 95 | ||
96 | int copy_thread(unsigned long clone_flags, unsigned long usp, | 96 | int copy_thread(unsigned long clone_flags, unsigned long usp, |
97 | unsigned long arg, | 97 | unsigned long arg, |
98 | struct task_struct *p, struct pt_regs *regs) | 98 | struct task_struct *p, struct pt_regs *unused) |
99 | { | 99 | { |
100 | struct pt_regs *childregs = task_pt_regs(p); | 100 | struct pt_regs *childregs = task_pt_regs(p); |
101 | struct switch_stack *swstack = ((struct switch_stack *)childregs) - 1; | 101 | struct switch_stack *swstack = ((struct switch_stack *)childregs) - 1; |
@@ -115,7 +115,7 @@ int copy_thread(unsigned long clone_flags, unsigned long usp, | |||
115 | p->thread.usp = 0; | 115 | p->thread.usp = 0; |
116 | return 0; | 116 | return 0; |
117 | } | 117 | } |
118 | *childregs = *regs; /* struct copy of pt_regs */ | 118 | *childregs = *current_pt_regs(); /* struct copy of pt_regs */ |
119 | 119 | ||
120 | childregs->r10 = 0; /* child returns 0 after a fork/clone */ | 120 | childregs->r10 = 0; /* child returns 0 after a fork/clone */ |
121 | 121 | ||
@@ -129,7 +129,7 @@ int copy_thread(unsigned long clone_flags, unsigned long usp, | |||
129 | 129 | ||
130 | /* fix the user-mode stackpointer */ | 130 | /* fix the user-mode stackpointer */ |
131 | 131 | ||
132 | p->thread.usp = usp; | 132 | p->thread.usp = usp ?: rdusp(); |
133 | 133 | ||
134 | /* and the kernel-mode one */ | 134 | /* and the kernel-mode one */ |
135 | 135 | ||
@@ -143,30 +143,6 @@ int copy_thread(unsigned long clone_flags, unsigned long usp, | |||
143 | return 0; | 143 | return 0; |
144 | } | 144 | } |
145 | 145 | ||
146 | asmlinkage int sys_fork(void) | ||
147 | { | ||
148 | return do_fork(SIGCHLD, rdusp(), current_pt_regs(), 0, NULL, NULL); | ||
149 | } | ||
150 | |||
151 | /* if newusp is 0, we just grab the old usp */ | ||
152 | /* FIXME: Is parent_tid/child_tid really third/fourth argument? Update lib? */ | ||
153 | asmlinkage int sys_clone(unsigned long newusp, unsigned long flags, | ||
154 | int* parent_tid, int* child_tid) | ||
155 | { | ||
156 | if (!newusp) | ||
157 | newusp = rdusp(); | ||
158 | return do_fork(flags, newusp, current_pt_regs(), 0, parent_tid, child_tid); | ||
159 | } | ||
160 | |||
161 | /* vfork is a system call in i386 because of register-pressure - maybe | ||
162 | * we can remove it and handle it in libc but we put it here until then. | ||
163 | */ | ||
164 | |||
165 | asmlinkage int sys_vfork(void) | ||
166 | { | ||
167 | return do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, rdusp(), current_pt_regs(), 0, NULL, NULL); | ||
168 | } | ||
169 | |||
170 | unsigned long get_wchan(struct task_struct *p) | 146 | unsigned long get_wchan(struct task_struct *p) |
171 | { | 147 | { |
172 | #if 0 | 148 | #if 0 |
diff --git a/arch/cris/arch-v32/kernel/process.c b/arch/cris/arch-v32/kernel/process.c index fe465401b6ec..331e70252df0 100644 --- a/arch/cris/arch-v32/kernel/process.c +++ b/arch/cris/arch-v32/kernel/process.c | |||
@@ -16,7 +16,7 @@ | |||
16 | #include <hwregs/reg_map.h> | 16 | #include <hwregs/reg_map.h> |
17 | #include <hwregs/timer_defs.h> | 17 | #include <hwregs/timer_defs.h> |
18 | #include <hwregs/intr_vect_defs.h> | 18 | #include <hwregs/intr_vect_defs.h> |
19 | #include <asm/ptrace.h> | 19 | #include <linux/ptrace.h> |
20 | 20 | ||
21 | extern void stop_watchdog(void); | 21 | extern void stop_watchdog(void); |
22 | 22 | ||
@@ -110,7 +110,7 @@ extern asmlinkage void ret_from_kernel_thread(void); | |||
110 | int | 110 | int |
111 | copy_thread(unsigned long clone_flags, unsigned long usp, | 111 | copy_thread(unsigned long clone_flags, unsigned long usp, |
112 | unsigned long arg, | 112 | unsigned long arg, |
113 | struct task_struct *p, struct pt_regs *regs) | 113 | struct task_struct *p, struct pt_regs *unused) |
114 | { | 114 | { |
115 | struct pt_regs *childregs = task_pt_regs(p); | 115 | struct pt_regs *childregs = task_pt_regs(p); |
116 | struct switch_stack *swstack = ((struct switch_stack *) childregs) - 1; | 116 | struct switch_stack *swstack = ((struct switch_stack *) childregs) - 1; |
@@ -131,14 +131,14 @@ copy_thread(unsigned long clone_flags, unsigned long usp, | |||
131 | p->thread.usp = 0; | 131 | p->thread.usp = 0; |
132 | return 0; | 132 | return 0; |
133 | } | 133 | } |
134 | *childregs = *regs; /* Struct copy of pt_regs. */ | 134 | *childregs = *current_pt_regs(); /* Struct copy of pt_regs. */ |
135 | childregs->r10 = 0; /* Child returns 0 after a fork/clone. */ | 135 | childregs->r10 = 0; /* Child returns 0 after a fork/clone. */ |
136 | 136 | ||
137 | /* Set a new TLS ? | 137 | /* Set a new TLS ? |
138 | * The TLS is in $mof because it is the 5th argument to sys_clone. | 138 | * The TLS is in $mof because it is the 5th argument to sys_clone. |
139 | */ | 139 | */ |
140 | if (p->mm && (clone_flags & CLONE_SETTLS)) { | 140 | if (p->mm && (clone_flags & CLONE_SETTLS)) { |
141 | task_thread_info(p)->tls = regs->mof; | 141 | task_thread_info(p)->tls = childregs->mof; |
142 | } | 142 | } |
143 | 143 | ||
144 | /* Put the switch stack right below the pt_regs. */ | 144 | /* Put the switch stack right below the pt_regs. */ |
@@ -153,39 +153,12 @@ copy_thread(unsigned long clone_flags, unsigned long usp, | |||
153 | swstack->return_ip = (unsigned long) ret_from_fork; | 153 | swstack->return_ip = (unsigned long) ret_from_fork; |
154 | 154 | ||
155 | /* Fix the user-mode and kernel-mode stackpointer. */ | 155 | /* Fix the user-mode and kernel-mode stackpointer. */ |
156 | p->thread.usp = usp; | 156 | p->thread.usp = usp ?: rdusp(); |
157 | p->thread.ksp = (unsigned long) swstack; | 157 | p->thread.ksp = (unsigned long) swstack; |
158 | 158 | ||
159 | return 0; | 159 | return 0; |
160 | } | 160 | } |
161 | 161 | ||
162 | asmlinkage int | ||
163 | sys_fork(void) | ||
164 | { | ||
165 | return do_fork(SIGCHLD, rdusp(), current_pt_regs(), 0, NULL, NULL); | ||
166 | } | ||
167 | |||
168 | /* FIXME: Is parent_tid/child_tid really third/fourth argument? Update lib? */ | ||
169 | asmlinkage int | ||
170 | sys_clone(unsigned long newusp, unsigned long flags, int *parent_tid, int *child_tid, | ||
171 | unsigned long tls) | ||
172 | { | ||
173 | if (!newusp) | ||
174 | newusp = rdusp(); | ||
175 | |||
176 | return do_fork(flags, newusp, current_pt_regs(), 0, parent_tid, child_tid); | ||
177 | } | ||
178 | |||
179 | /* | ||
180 | * vfork is a system call in i386 because of register-pressure - maybe | ||
181 | * we can remove it and handle it in libc but we put it here until then. | ||
182 | */ | ||
183 | asmlinkage int | ||
184 | sys_vfork(void) | ||
185 | { | ||
186 | return do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, rdusp(), current_pt_regs(), 0, NULL, NULL); | ||
187 | } | ||
188 | |||
189 | unsigned long | 162 | unsigned long |
190 | get_wchan(struct task_struct *p) | 163 | get_wchan(struct task_struct *p) |
191 | { | 164 | { |
diff --git a/arch/cris/include/asm/unistd.h b/arch/cris/include/asm/unistd.h index f181d1fc7632..f27b542e0ebc 100644 --- a/arch/cris/include/asm/unistd.h +++ b/arch/cris/include/asm/unistd.h | |||
@@ -372,6 +372,9 @@ | |||
372 | #define __ARCH_WANT_SYS_RT_SIGACTION | 372 | #define __ARCH_WANT_SYS_RT_SIGACTION |
373 | #define __ARCH_WANT_SYS_RT_SIGSUSPEND | 373 | #define __ARCH_WANT_SYS_RT_SIGSUSPEND |
374 | #define __ARCH_WANT_SYS_EXECVE | 374 | #define __ARCH_WANT_SYS_EXECVE |
375 | #define __ARCH_WANT_SYS_FORK | ||
376 | #define __ARCH_WANT_SYS_VFORK | ||
377 | #define __ARCH_WANT_SYS_CLONE | ||
375 | 378 | ||
376 | /* | 379 | /* |
377 | * "Conditional" syscalls | 380 | * "Conditional" syscalls |