linux_exec.c revision 1.83.8.2 1 1.83.8.2 yamt /* $NetBSD: linux_exec.c,v 1.83.8.2 2006/09/03 15:23:41 yamt Exp $ */
2 1.29 christos
3 1.29 christos /*-
4 1.44 mycroft * Copyright (c) 1994, 1995, 1998, 2000 The NetBSD Foundation, Inc.
5 1.29 christos * All rights reserved.
6 1.29 christos *
7 1.29 christos * This code is derived from software contributed to The NetBSD Foundation
8 1.33 fvdl * by Christos Zoulas, Frank van der Linden, Eric Haszlakiewicz and
9 1.33 fvdl * Thor Lancelot Simon.
10 1.29 christos *
11 1.29 christos * Redistribution and use in source and binary forms, with or without
12 1.29 christos * modification, are permitted provided that the following conditions
13 1.29 christos * are met:
14 1.29 christos * 1. Redistributions of source code must retain the above copyright
15 1.29 christos * notice, this list of conditions and the following disclaimer.
16 1.29 christos * 2. Redistributions in binary form must reproduce the above copyright
17 1.29 christos * notice, this list of conditions and the following disclaimer in the
18 1.29 christos * documentation and/or other materials provided with the distribution.
19 1.29 christos * 3. All advertising materials mentioning features or use of this software
20 1.29 christos * must display the following acknowledgement:
21 1.29 christos * This product includes software developed by the NetBSD
22 1.29 christos * Foundation, Inc. and its contributors.
23 1.29 christos * 4. Neither the name of The NetBSD Foundation nor the names of its
24 1.29 christos * contributors may be used to endorse or promote products derived
25 1.29 christos * from this software without specific prior written permission.
26 1.29 christos *
27 1.29 christos * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
28 1.29 christos * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
29 1.29 christos * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
30 1.29 christos * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
31 1.29 christos * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32 1.29 christos * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33 1.29 christos * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34 1.29 christos * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35 1.29 christos * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36 1.29 christos * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37 1.29 christos * POSSIBILITY OF SUCH DAMAGE.
38 1.1 fvdl */
39 1.54 lukem
40 1.54 lukem #include <sys/cdefs.h>
41 1.83.8.2 yamt __KERNEL_RCSID(0, "$NetBSD: linux_exec.c,v 1.83.8.2 2006/09/03 15:23:41 yamt Exp $");
42 1.1 fvdl
43 1.1 fvdl #include <sys/param.h>
44 1.1 fvdl #include <sys/systm.h>
45 1.1 fvdl #include <sys/kernel.h>
46 1.1 fvdl #include <sys/proc.h>
47 1.1 fvdl #include <sys/malloc.h>
48 1.1 fvdl #include <sys/namei.h>
49 1.1 fvdl #include <sys/vnode.h>
50 1.13 christos #include <sys/mount.h>
51 1.25 christos #include <sys/exec.h>
52 1.8 fvdl #include <sys/exec_elf.h>
53 1.1 fvdl
54 1.1 fvdl #include <sys/mman.h>
55 1.61 thorpej #include <sys/sa.h>
56 1.13 christos #include <sys/syscallargs.h>
57 1.1 fvdl
58 1.83.8.2 yamt #include <sys/ptrace.h> /* For proc_reparent() */
59 1.83.8.2 yamt
60 1.73 fvdl #include <uvm/uvm_extern.h>
61 1.73 fvdl
62 1.1 fvdl #include <machine/cpu.h>
63 1.1 fvdl #include <machine/reg.h>
64 1.1 fvdl
65 1.32 christos #include <compat/linux/common/linux_types.h>
66 1.32 christos #include <compat/linux/common/linux_signal.h>
67 1.32 christos #include <compat/linux/common/linux_util.h>
68 1.83.8.2 yamt #include <compat/linux/common/linux_sched.h>
69 1.32 christos #include <compat/linux/common/linux_machdep.h>
70 1.83.8.2 yamt #include <compat/linux/common/linux_exec.h>
71 1.78 manu #include <compat/linux/common/linux_futex.h>
72 1.32 christos
73 1.32 christos #include <compat/linux/linux_syscallargs.h>
74 1.4 christos #include <compat/linux/linux_syscall.h>
75 1.38 jdolecek #include <compat/linux/common/linux_misc.h>
76 1.38 jdolecek #include <compat/linux/common/linux_errno.h>
77 1.39 jdolecek #include <compat/linux/common/linux_emuldata.h>
78 1.8 fvdl
79 1.38 jdolecek extern struct sysent linux_sysent[];
80 1.38 jdolecek extern const char * const linux_syscallnames[];
81 1.38 jdolecek extern char linux_sigcode[], linux_esigcode[];
82 1.1 fvdl
83 1.39 jdolecek static void linux_e_proc_exec __P((struct proc *, struct exec_package *));
84 1.71 jdolecek static void linux_e_proc_fork __P((struct proc *, struct proc *, int));
85 1.39 jdolecek static void linux_e_proc_exit __P((struct proc *));
86 1.71 jdolecek static void linux_e_proc_init __P((struct proc *, struct proc *, int));
87 1.39 jdolecek
88 1.79 manu #ifdef LINUX_NPTL
89 1.83.8.2 yamt void linux_userret __P((struct lwp *, void *));
90 1.79 manu #endif
91 1.77 manu
92 1.1 fvdl /*
93 1.1 fvdl * Execve(2). Just check the alternate emulation path, and pass it on
94 1.1 fvdl * to the NetBSD execve().
95 1.1 fvdl */
96 1.1 fvdl int
97 1.61 thorpej linux_sys_execve(l, v, retval)
98 1.61 thorpej struct lwp *l;
99 1.11 thorpej void *v;
100 1.11 thorpej register_t *retval;
101 1.11 thorpej {
102 1.12 mycroft struct linux_sys_execve_args /* {
103 1.35 christos syscallarg(const char *) path;
104 1.1 fvdl syscallarg(char **) argv;
105 1.1 fvdl syscallarg(char **) envp;
106 1.11 thorpej } */ *uap = v;
107 1.61 thorpej struct proc *p = l->l_proc;
108 1.16 mycroft struct sys_execve_args ap;
109 1.1 fvdl caddr_t sg;
110 1.1 fvdl
111 1.57 christos sg = stackgap_init(p, 0);
112 1.83 christos CHECK_ALT_EXIST(l, &sg, SCARG(uap, path));
113 1.1 fvdl
114 1.16 mycroft SCARG(&ap, path) = SCARG(uap, path);
115 1.16 mycroft SCARG(&ap, argp) = SCARG(uap, argp);
116 1.16 mycroft SCARG(&ap, envp) = SCARG(uap, envp);
117 1.16 mycroft
118 1.61 thorpej return sys_execve(l, &ap, retval);
119 1.1 fvdl }
120 1.38 jdolecek
121 1.38 jdolecek /*
122 1.38 jdolecek * Emulation switch.
123 1.38 jdolecek */
124 1.65 chs
125 1.65 chs struct uvm_object *emul_linux_object;
126 1.65 chs
127 1.38 jdolecek const struct emul emul_linux = {
128 1.38 jdolecek "linux",
129 1.40 jdolecek "/emul/linux",
130 1.44 mycroft #ifndef __HAVE_MINIMAL_EMUL
131 1.51 manu 0,
132 1.76 tsutsui (const int *)native_to_linux_errno,
133 1.38 jdolecek LINUX_SYS_syscall,
134 1.60 jdolecek LINUX_SYS_NSYSENT,
135 1.44 mycroft #endif
136 1.38 jdolecek linux_sysent,
137 1.38 jdolecek linux_syscallnames,
138 1.44 mycroft linux_sendsig,
139 1.52 christos linux_trapsignal,
140 1.70 fvdl NULL,
141 1.38 jdolecek linux_sigcode,
142 1.38 jdolecek linux_esigcode,
143 1.65 chs &emul_linux_object,
144 1.53 jdolecek linux_setregs,
145 1.39 jdolecek linux_e_proc_exec,
146 1.39 jdolecek linux_e_proc_fork,
147 1.39 jdolecek linux_e_proc_exit,
148 1.69 manu NULL,
149 1.69 manu NULL,
150 1.44 mycroft #ifdef __HAVE_SYSCALL_INTERN
151 1.44 mycroft linux_syscall_intern,
152 1.42 jdolecek #else
153 1.62 thorpej #error Implement __HAVE_SYSCALL_INTERN for this platform
154 1.41 jdolecek #endif
155 1.67 atatat NULL,
156 1.59 manu NULL,
157 1.73 fvdl
158 1.74 christos uvm_default_mapaddr,
159 1.75 fvdl
160 1.75 fvdl linux_usertrap,
161 1.83.8.2 yamt NULL,
162 1.38 jdolecek };
163 1.39 jdolecek
164 1.39 jdolecek static void
165 1.71 jdolecek linux_e_proc_init(p, parent, forkflags)
166 1.71 jdolecek struct proc *p, *parent;
167 1.71 jdolecek int forkflags;
168 1.39 jdolecek {
169 1.71 jdolecek struct linux_emuldata *e = p->p_emuldata;
170 1.71 jdolecek struct linux_emuldata_shared *s;
171 1.77 manu struct linux_emuldata *ep = NULL;
172 1.71 jdolecek
173 1.71 jdolecek if (!e) {
174 1.39 jdolecek /* allocate new Linux emuldata */
175 1.71 jdolecek MALLOC(e, void *, sizeof(struct linux_emuldata),
176 1.71 jdolecek M_EMULDATA, M_WAITOK);
177 1.71 jdolecek } else {
178 1.72 jdolecek e->s->refs--;
179 1.71 jdolecek if (e->s->refs == 0)
180 1.71 jdolecek FREE(e->s, M_EMULDATA);
181 1.71 jdolecek }
182 1.71 jdolecek
183 1.71 jdolecek memset(e, '\0', sizeof(struct linux_emuldata));
184 1.71 jdolecek
185 1.83.8.1 yamt e->proc = p;
186 1.83.8.1 yamt
187 1.77 manu if (parent)
188 1.77 manu ep = parent->p_emuldata;
189 1.77 manu
190 1.72 jdolecek if (forkflags & FORK_SHAREVM) {
191 1.77 manu #ifdef DIAGNOSTIC
192 1.77 manu if (ep == NULL) {
193 1.77 manu killproc(p, "FORK_SHAREVM while emuldata is NULL\n");
194 1.77 manu return;
195 1.77 manu }
196 1.77 manu #endif
197 1.77 manu s = ep->s;
198 1.71 jdolecek s->refs++;
199 1.71 jdolecek } else {
200 1.71 jdolecek struct vmspace *vm;
201 1.71 jdolecek
202 1.71 jdolecek MALLOC(s, void *, sizeof(struct linux_emuldata_shared),
203 1.39 jdolecek M_EMULDATA, M_WAITOK);
204 1.71 jdolecek s->refs = 1;
205 1.71 jdolecek
206 1.71 jdolecek /*
207 1.71 jdolecek * Set the process idea of the break to the real value.
208 1.71 jdolecek * For fork, we use parent's vmspace since our's
209 1.71 jdolecek * is not setup at the time of this call and is going
210 1.71 jdolecek * to be copy of parent's anyway. For exec, just
211 1.71 jdolecek * use our own vmspace.
212 1.71 jdolecek */
213 1.71 jdolecek vm = (parent) ? parent->p_vmspace : p->p_vmspace;
214 1.71 jdolecek s->p_break = vm->vm_daddr + ctob(vm->vm_dsize);
215 1.71 jdolecek
216 1.77 manu /*
217 1.77 manu * Linux threads are emulated as NetBSD processes (not lwp)
218 1.77 manu * We use native PID for Linux TID. The Linux TID is the
219 1.77 manu * PID of the first process in the group. It is stored
220 1.77 manu * here
221 1.77 manu */
222 1.77 manu s->group_pid = p->p_pid;
223 1.83.8.1 yamt
224 1.83.8.1 yamt /*
225 1.83.8.1 yamt * Initialize the list of threads in the group
226 1.83.8.1 yamt */
227 1.83.8.1 yamt LIST_INIT(&s->threads);
228 1.83.8.2 yamt
229 1.83.8.2 yamt s->xstat = 0;
230 1.83.8.2 yamt s->flags = 0;
231 1.39 jdolecek }
232 1.39 jdolecek
233 1.71 jdolecek e->s = s;
234 1.77 manu
235 1.83.8.1 yamt /*
236 1.83.8.1 yamt * Add this thread in the group thread list
237 1.83.8.1 yamt */
238 1.83.8.1 yamt LIST_INSERT_HEAD(&s->threads, e, threads);
239 1.83.8.1 yamt
240 1.79 manu #ifdef LINUX_NPTL
241 1.77 manu if (ep != NULL) {
242 1.83.8.2 yamt e->parent_tidptr = ep->parent_tidptr;
243 1.83.8.2 yamt e->child_tidptr = ep->child_tidptr;
244 1.83.8.2 yamt e->clone_flags = ep->clone_flags;
245 1.77 manu }
246 1.79 manu #endif /* LINUX_NPTL */
247 1.77 manu
248 1.71 jdolecek p->p_emuldata = e;
249 1.48 jdolecek }
250 1.48 jdolecek
251 1.48 jdolecek /*
252 1.71 jdolecek * Allocate new per-process structures. Called when executing Linux
253 1.48 jdolecek * process. We can reuse the old emuldata - if it's not null,
254 1.48 jdolecek * the executed process is of same emulation as original forked one.
255 1.48 jdolecek */
256 1.48 jdolecek static void
257 1.48 jdolecek linux_e_proc_exec(p, epp)
258 1.48 jdolecek struct proc *p;
259 1.48 jdolecek struct exec_package *epp;
260 1.48 jdolecek {
261 1.48 jdolecek /* exec, use our vmspace */
262 1.71 jdolecek linux_e_proc_init(p, NULL, 0);
263 1.39 jdolecek }
264 1.39 jdolecek
265 1.39 jdolecek /*
266 1.39 jdolecek * Emulation per-process exit hook.
267 1.39 jdolecek */
268 1.39 jdolecek static void
269 1.39 jdolecek linux_e_proc_exit(p)
270 1.39 jdolecek struct proc *p;
271 1.39 jdolecek {
272 1.71 jdolecek struct linux_emuldata *e = p->p_emuldata;
273 1.71 jdolecek
274 1.79 manu #ifdef LINUX_NPTL
275 1.83.8.2 yamt linux_nptl_proc_exit(p);
276 1.83.8.1 yamt #endif
277 1.83.8.1 yamt /* Remove the thread for the group thread list */
278 1.83.8.1 yamt LIST_REMOVE(e, threads);
279 1.83.8.1 yamt
280 1.39 jdolecek /* free Linux emuldata and set the pointer to null */
281 1.71 jdolecek e->s->refs--;
282 1.71 jdolecek if (e->s->refs == 0)
283 1.71 jdolecek FREE(e->s, M_EMULDATA);
284 1.71 jdolecek FREE(e, M_EMULDATA);
285 1.39 jdolecek p->p_emuldata = NULL;
286 1.39 jdolecek }
287 1.39 jdolecek
288 1.39 jdolecek /*
289 1.39 jdolecek * Emulation fork hook.
290 1.39 jdolecek */
291 1.39 jdolecek static void
292 1.71 jdolecek linux_e_proc_fork(p, parent, forkflags)
293 1.39 jdolecek struct proc *p, *parent;
294 1.71 jdolecek int forkflags;
295 1.39 jdolecek {
296 1.39 jdolecek /*
297 1.71 jdolecek * The new process might share some vmspace-related stuff
298 1.71 jdolecek * with parent, depending on fork flags (CLONE_VM et.al).
299 1.71 jdolecek * Force allocation of new base emuldata, and share the
300 1.71 jdolecek * VM-related parts only if necessary.
301 1.39 jdolecek */
302 1.39 jdolecek p->p_emuldata = NULL;
303 1.71 jdolecek linux_e_proc_init(p, parent, forkflags);
304 1.77 manu
305 1.79 manu #ifdef LINUX_NPTL
306 1.83.8.2 yamt linux_nptl_proc_fork(p, parent, (*linux_userret));
307 1.79 manu #endif
308 1.77 manu
309 1.77 manu return;
310 1.77 manu }
311 1.77 manu
312 1.79 manu #ifdef LINUX_NPTL
313 1.83.8.2 yamt void
314 1.79 manu linux_userret(l, arg)
315 1.77 manu struct lwp *l;
316 1.77 manu void *arg;
317 1.77 manu {
318 1.77 manu struct proc *p = l->l_proc;
319 1.77 manu struct linux_emuldata *led = p->p_emuldata;
320 1.77 manu int error;
321 1.77 manu
322 1.77 manu p->p_userret = NULL;
323 1.77 manu
324 1.83.8.2 yamt /* LINUX_CLONE_CHILD_SETTID: copy child's TID to child's memory */
325 1.83.8.2 yamt if (led->clone_flags & LINUX_CLONE_CHILD_SETTID) {
326 1.83.8.2 yamt if ((error = copyout(&l->l_proc->p_pid,
327 1.83.8.2 yamt led->child_tidptr, sizeof(l->l_proc->p_pid))) != 0)
328 1.83.8.2 yamt printf("linux_userret: LINUX_CLONE_CHILD_SETTID "
329 1.83.8.2 yamt "failed (led->child_tidptr = %p, p->p_pid = %d)\n",
330 1.83.8.2 yamt led->child_tidptr, p->p_pid);
331 1.79 manu }
332 1.79 manu
333 1.83.8.2 yamt /* LINUX_CLONE_SETTLS: allocate a new TLS */
334 1.83.8.2 yamt if (led->clone_flags & LINUX_CLONE_SETTLS) {
335 1.83.8.2 yamt if (linux_set_newtls(l, linux_get_newtls(l)) != 0)
336 1.83.8.2 yamt printf("linux_userret: linux_set_tls failed");
337 1.77 manu }
338 1.77 manu
339 1.77 manu return;
340 1.39 jdolecek }
341 1.83.8.2 yamt
342 1.83.8.2 yamt void
343 1.83.8.2 yamt linux_nptl_proc_exit(p)
344 1.83.8.2 yamt struct proc *p;
345 1.83.8.2 yamt {
346 1.83.8.2 yamt struct linux_emuldata *e = p->p_emuldata;
347 1.83.8.2 yamt int s;
348 1.83.8.2 yamt
349 1.83.8.2 yamt /*
350 1.83.8.2 yamt * Check if we are a thread group leader victim of another
351 1.83.8.2 yamt * thread doing exit_group(). If we are, change the exit code.
352 1.83.8.2 yamt */
353 1.83.8.2 yamt if ((e->s->group_pid == p->p_pid) &&
354 1.83.8.2 yamt (e->s->flags & LINUX_LES_INEXITGROUP)) {
355 1.83.8.2 yamt p->p_xstat = e->s->xstat;
356 1.83.8.2 yamt }
357 1.83.8.2 yamt
358 1.83.8.2 yamt /*
359 1.83.8.2 yamt * Members of the thread groups others than the leader should
360 1.83.8.2 yamt * exit quietely: no zombie stage, no signal. We do that by
361 1.83.8.2 yamt * reparenting to init. init will collect us and nobody will
362 1.83.8.2 yamt * notice what happened.
363 1.83.8.2 yamt */
364 1.83.8.2 yamt #ifdef DEBUG_LINUX
365 1.83.8.2 yamt printf("%s:%d e->s->group_pid = %d, p->p_pid = %d, flags = 0x%x\n",
366 1.83.8.2 yamt __func__, __LINE__, e->s->group_pid, p->p_pid, e->s->flags);
367 1.83.8.2 yamt #endif
368 1.83.8.2 yamt if (e->s->group_pid != p->p_pid) {
369 1.83.8.2 yamt wakeup(initproc);
370 1.83.8.2 yamt SCHED_LOCK(s);
371 1.83.8.2 yamt proc_reparent(p, initproc);
372 1.83.8.2 yamt SCHED_UNLOCK(s);
373 1.83.8.2 yamt }
374 1.83.8.2 yamt
375 1.83.8.2 yamt /* Emulate LINUX_CLONE_CHILD_CLEARTID */
376 1.83.8.2 yamt if (e->clear_tid != NULL) {
377 1.83.8.2 yamt int error;
378 1.83.8.2 yamt int null = 0;
379 1.83.8.2 yamt struct linux_sys_futex_args cup;
380 1.83.8.2 yamt register_t retval;
381 1.83.8.2 yamt struct lwp *l;
382 1.83.8.2 yamt
383 1.83.8.2 yamt error = copyout(&null, e->clear_tid, sizeof(null));
384 1.83.8.2 yamt #ifdef DEBUG_LINUX
385 1.83.8.2 yamt if (error != 0)
386 1.83.8.2 yamt printf("%s: cannot clear TID\n", __func__);
387 1.83.8.2 yamt #endif
388 1.83.8.2 yamt
389 1.83.8.2 yamt l = proc_representative_lwp(p);
390 1.83.8.2 yamt SCARG(&cup, uaddr) = e->clear_tid;
391 1.83.8.2 yamt SCARG(&cup, op) = LINUX_FUTEX_WAKE;
392 1.83.8.2 yamt SCARG(&cup, val) = 0x7fffffff; /* Awake everyone */
393 1.83.8.2 yamt SCARG(&cup, timeout) = NULL;
394 1.83.8.2 yamt SCARG(&cup, uaddr2) = NULL;
395 1.83.8.2 yamt SCARG(&cup, val3) = 0;
396 1.83.8.2 yamt if ((error = linux_sys_futex(l, &cup, &retval)) != 0)
397 1.83.8.2 yamt printf("%s: linux_sys_futex failed\n", __func__);
398 1.83.8.2 yamt }
399 1.83.8.2 yamt
400 1.83.8.2 yamt return;
401 1.83.8.2 yamt }
402 1.83.8.2 yamt
403 1.83.8.2 yamt void
404 1.83.8.2 yamt linux_nptl_proc_fork(p, parent, luserret)
405 1.83.8.2 yamt struct proc *p;
406 1.83.8.2 yamt struct proc *parent;
407 1.83.8.2 yamt void (luserret)(struct lwp *, void *);
408 1.83.8.2 yamt {
409 1.83.8.2 yamt #ifdef LINUX_NPTL
410 1.83.8.2 yamt struct linux_emuldata *e;
411 1.83.8.2 yamt #endif
412 1.83.8.2 yamt e = p->p_emuldata;
413 1.83.8.2 yamt
414 1.83.8.2 yamt /* LINUX_CLONE_CHILD_CLEARTID: clear TID in child's memory on exit() */
415 1.83.8.2 yamt if (e->clone_flags & LINUX_CLONE_CHILD_CLEARTID)
416 1.83.8.2 yamt e->clear_tid = e->child_tidptr;
417 1.83.8.2 yamt
418 1.83.8.2 yamt /* LINUX_CLONE_PARENT_SETTID: set child's TID in parent's memory */
419 1.83.8.2 yamt if (e->clone_flags & LINUX_CLONE_PARENT_SETTID) {
420 1.83.8.2 yamt if (copyout_proc(parent, &p->p_pid,
421 1.83.8.2 yamt e->parent_tidptr, sizeof(p->p_pid)) != 0)
422 1.83.8.2 yamt printf("%s: LINUX_CLONE_PARENT_SETTID "
423 1.83.8.2 yamt "failed (e->parent_tidptr = %p, "
424 1.83.8.2 yamt "parent->p_pid = %d, p->p_pid = %d)\n",
425 1.83.8.2 yamt __func__, e->parent_tidptr,
426 1.83.8.2 yamt parent->p_pid, p->p_pid);
427 1.83.8.2 yamt }
428 1.83.8.2 yamt
429 1.83.8.2 yamt /*
430 1.83.8.2 yamt * CLONE_CHILD_SETTID and LINUX_CLONE_SETTLS require child's VM
431 1.83.8.2 yamt * setup to be completed, we postpone them until userret time.
432 1.83.8.2 yamt */
433 1.83.8.2 yamt if (e->clone_flags &
434 1.83.8.2 yamt (LINUX_CLONE_CHILD_CLEARTID | LINUX_CLONE_SETTLS))
435 1.83.8.2 yamt p->p_userret = (*luserret);
436 1.83.8.2 yamt
437 1.83.8.2 yamt return;
438 1.83.8.2 yamt }
439 1.83.8.2 yamt
440 1.83.8.2 yamt void
441 1.83.8.2 yamt linux_nptl_proc_init(p, parent)
442 1.83.8.2 yamt struct proc *p;
443 1.83.8.2 yamt struct proc *parent;
444 1.83.8.2 yamt {
445 1.83.8.2 yamt struct linux_emuldata *e = p->p_emuldata;
446 1.83.8.2 yamt struct linux_emuldata *ep;
447 1.83.8.2 yamt
448 1.83.8.2 yamt if ((parent != NULL) && (parent->p_emuldata != NULL)) {
449 1.83.8.2 yamt ep = parent->p_emuldata;
450 1.83.8.2 yamt
451 1.83.8.2 yamt e->parent_tidptr = ep->parent_tidptr;
452 1.83.8.2 yamt e->child_tidptr = ep->child_tidptr;
453 1.83.8.2 yamt e->clone_flags = ep->clone_flags;
454 1.83.8.2 yamt }
455 1.83.8.2 yamt
456 1.83.8.2 yamt return;
457 1.83.8.2 yamt }
458 1.83.8.2 yamt
459 1.83.8.2 yamt
460 1.79 manu #endif /* LINUX_NPTL */
461