linux_emul.c (70d8f36aa445e4556ead4de32f9b7b4687d95098) linux_emul.c (19e252baebe7a7466b33c27560420b7d95fe294d)
1/*-
2 * Copyright (c) 2006 Roman Divacky
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 16 unchanged lines hidden (view full) ---

25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#include <sys/cdefs.h>
30__FBSDID("$FreeBSD$");
31
32#include "opt_compat.h"
1/*-
2 * Copyright (c) 2006 Roman Divacky
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 16 unchanged lines hidden (view full) ---

25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#include <sys/cdefs.h>
30__FBSDID("$FreeBSD$");
31
32#include "opt_compat.h"
33#include "opt_kdtrace.h"
33
34#include <sys/param.h>
35#include <sys/systm.h>
36#include <sys/imgact.h>
37#include <sys/kernel.h>
38#include <sys/lock.h>
39#include <sys/malloc.h>
40#include <sys/mutex.h>
34
35#include <sys/param.h>
36#include <sys/systm.h>
37#include <sys/imgact.h>
38#include <sys/kernel.h>
39#include <sys/lock.h>
40#include <sys/malloc.h>
41#include <sys/mutex.h>
42#include <sys/sdt.h>
41#include <sys/sx.h>
42#include <sys/proc.h>
43#include <sys/syscallsubr.h>
44#include <sys/sysent.h>
45#include <sys/sysproto.h>
46#include <sys/unistd.h>
47
48#ifdef COMPAT_LINUX32
49#include <machine/../linux32/linux.h>
50#include <machine/../linux32/linux32_proto.h>
51#else
52#include <machine/../linux/linux.h>
53#include <machine/../linux/linux_proto.h>
54#endif
55
43#include <sys/sx.h>
44#include <sys/proc.h>
45#include <sys/syscallsubr.h>
46#include <sys/sysent.h>
47#include <sys/sysproto.h>
48#include <sys/unistd.h>
49
50#ifdef COMPAT_LINUX32
51#include <machine/../linux32/linux.h>
52#include <machine/../linux32/linux32_proto.h>
53#else
54#include <machine/../linux/linux.h>
55#include <machine/../linux/linux_proto.h>
56#endif
57
58#include <compat/linux/linux_dtrace.h>
56#include <compat/linux/linux_emul.h>
57#include <compat/linux/linux_futex.h>
58
59#include <compat/linux/linux_emul.h>
60#include <compat/linux/linux_futex.h>
61
62/**
63 * Special DTrace provider for the linuxulator.
64 *
65 * In this file we define the provider for the entire linuxulator. All
66 * modules (= files of the linuxulator) use it.
67 *
68 * We define a different name depending on the emulated bitsize, see
69 * ../../<ARCH>/linux{,32}/linux.h, e.g.:
70 * native bitsize = linuxulator
71 * amd64, 32bit emulation = linuxulator32
72 */
73LIN_SDT_PROVIDER_DEFINE(LINUX_DTRACE);
74
75/**
76 * Special DTrace module "locks", it covers some linuxulator internal
77 * locks.
78 */
79LIN_SDT_PROBE_DEFINE1(locks, emul_lock, locked, "struct mtx *");
80LIN_SDT_PROBE_DEFINE1(locks, emul_lock, unlock, "struct mtx *");
81LIN_SDT_PROBE_DEFINE1(locks, emul_shared_rlock, locked, "struct sx *");
82LIN_SDT_PROBE_DEFINE1(locks, emul_shared_rlock, unlock, "struct sx *");
83LIN_SDT_PROBE_DEFINE1(locks, emul_shared_wlock, locked, "struct sx *");
84LIN_SDT_PROBE_DEFINE1(locks, emul_shared_wlock, unlock, "struct sx *");
85
86/**
87 * DTrace probes in this module.
88 */
89LIN_SDT_PROBE_DEFINE2(emul, em_find, entry, "struct proc *", "int");
90LIN_SDT_PROBE_DEFINE0(emul, em_find, return);
91LIN_SDT_PROBE_DEFINE3(emul, proc_init, entry, "struct thread *", "pid_t",
92 "int");
93LIN_SDT_PROBE_DEFINE0(emul, proc_init, create_thread);
94LIN_SDT_PROBE_DEFINE0(emul, proc_init, fork);
95LIN_SDT_PROBE_DEFINE0(emul, proc_init, exec);
96LIN_SDT_PROBE_DEFINE0(emul, proc_init, return);
97LIN_SDT_PROBE_DEFINE1(emul, proc_exit, entry, "struct proc *");
98LIN_SDT_PROBE_DEFINE0(emul, proc_exit, futex_failed);
99LIN_SDT_PROBE_DEFINE3(emul, proc_exit, reparent, "pid_t", "pid_t",
100 "struct proc *");
101LIN_SDT_PROBE_DEFINE1(emul, proc_exit, child_clear_tid_error, "int");
102LIN_SDT_PROBE_DEFINE0(emul, proc_exit, return);
103LIN_SDT_PROBE_DEFINE2(emul, proc_exec, entry, "struct proc *",
104 "struct image_params *");
105LIN_SDT_PROBE_DEFINE0(emul, proc_exec, return);
106LIN_SDT_PROBE_DEFINE0(emul, linux_schedtail, entry);
107LIN_SDT_PROBE_DEFINE1(emul, linux_schedtail, copyout_error, "int");
108LIN_SDT_PROBE_DEFINE0(emul, linux_schedtail, return);
109LIN_SDT_PROBE_DEFINE1(emul, linux_set_tid_address, entry, "int *");
110LIN_SDT_PROBE_DEFINE0(emul, linux_set_tid_address, return);
111LIN_SDT_PROBE_DEFINE2(emul, linux_kill_threads, entry, "struct thread *",
112 "int");
113LIN_SDT_PROBE_DEFINE1(emul, linux_kill_threads, kill, "pid_t");
114LIN_SDT_PROBE_DEFINE0(emul, linux_kill_threads, return);
115
59struct sx emul_shared_lock;
60struct mtx emul_lock;
61
62/* this returns locked reference to the emuldata entry (if found) */
63struct linux_emuldata *
64em_find(struct proc *p, int locked)
65{
66 struct linux_emuldata *em;
67
116struct sx emul_shared_lock;
117struct mtx emul_lock;
118
119/* this returns locked reference to the emuldata entry (if found) */
120struct linux_emuldata *
121em_find(struct proc *p, int locked)
122{
123 struct linux_emuldata *em;
124
125 LIN_SDT_PROBE2(emul, em_find, entry, p, locked);
126
68 if (locked == EMUL_DOLOCK)
69 EMUL_LOCK(&emul_lock);
70
71 em = p->p_emuldata;
72
73 if (em == NULL && locked == EMUL_DOLOCK)
74 EMUL_UNLOCK(&emul_lock);
75
127 if (locked == EMUL_DOLOCK)
128 EMUL_LOCK(&emul_lock);
129
130 em = p->p_emuldata;
131
132 if (em == NULL && locked == EMUL_DOLOCK)
133 EMUL_UNLOCK(&emul_lock);
134
135 LIN_SDT_PROBE1(emul, em_find, return, em);
76 return (em);
77}
78
79int
80linux_proc_init(struct thread *td, pid_t child, int flags)
81{
82 struct linux_emuldata *em, *p_em;
83 struct proc *p;
84
136 return (em);
137}
138
139int
140linux_proc_init(struct thread *td, pid_t child, int flags)
141{
142 struct linux_emuldata *em, *p_em;
143 struct proc *p;
144
145 LIN_SDT_PROBE3(emul, proc_init, entry, td, child, flags);
146
85 if (child != 0) {
147 if (child != 0) {
86 /* non-exec call */
148 /* fork or create a thread */
87 em = malloc(sizeof *em, M_LINUX, M_WAITOK | M_ZERO);
88 em->pid = child;
89 em->pdeath_signal = 0;
90 em->flags = 0;
91 em->robust_futexes = NULL;
92 if (flags & LINUX_CLONE_THREAD) {
93 /* handled later in the code */
149 em = malloc(sizeof *em, M_LINUX, M_WAITOK | M_ZERO);
150 em->pid = child;
151 em->pdeath_signal = 0;
152 em->flags = 0;
153 em->robust_futexes = NULL;
154 if (flags & LINUX_CLONE_THREAD) {
155 /* handled later in the code */
156 LIN_SDT_PROBE0(emul, proc_init, create_thread);
94 } else {
95 struct linux_emuldata_shared *s;
96
157 } else {
158 struct linux_emuldata_shared *s;
159
160 LIN_SDT_PROBE0(emul, proc_init, fork);
161
97 s = malloc(sizeof *s, M_LINUX, M_WAITOK | M_ZERO);
98 s->refs = 1;
99 s->group_pid = child;
100
101 LIST_INIT(&s->threads);
102 em->shared = s;
103 }
104 } else {
162 s = malloc(sizeof *s, M_LINUX, M_WAITOK | M_ZERO);
163 s->refs = 1;
164 s->group_pid = child;
165
166 LIST_INIT(&s->threads);
167 em->shared = s;
168 }
169 } else {
170 /* exec */
171 LIN_SDT_PROBE0(emul, proc_init, exec);
172
105 /* lookup the old one */
106 em = em_find(td->td_proc, EMUL_DOLOCK);
107 KASSERT(em != NULL, ("proc_init: emuldata not found in exec case.\n"));
108 }
109
110 em->child_clear_tid = NULL;
111 em->child_set_tid = NULL;
112

--- 18 unchanged lines hidden (view full) ---

131 em->shared->refs++;
132 EMUL_SHARED_WUNLOCK(&emul_shared_lock);
133 } else {
134 /*
135 * handled earlier to avoid malloc(M_WAITOK) with
136 * rwlock held
137 */
138 }
173 /* lookup the old one */
174 em = em_find(td->td_proc, EMUL_DOLOCK);
175 KASSERT(em != NULL, ("proc_init: emuldata not found in exec case.\n"));
176 }
177
178 em->child_clear_tid = NULL;
179 em->child_set_tid = NULL;
180

--- 18 unchanged lines hidden (view full) ---

199 em->shared->refs++;
200 EMUL_SHARED_WUNLOCK(&emul_shared_lock);
201 } else {
202 /*
203 * handled earlier to avoid malloc(M_WAITOK) with
204 * rwlock held
205 */
206 }
139 }
140 if (child != 0) {
207
141 EMUL_SHARED_WLOCK(&emul_shared_lock);
142 LIST_INSERT_HEAD(&em->shared->threads, em, threads);
143 EMUL_SHARED_WUNLOCK(&emul_shared_lock);
144
145 p = pfind(child);
146 KASSERT(p != NULL, ("process not found in proc_init\n"));
147 p->p_emuldata = em;
148 PROC_UNLOCK(p);
149 } else
150 EMUL_UNLOCK(&emul_lock);
151
208 EMUL_SHARED_WLOCK(&emul_shared_lock);
209 LIST_INSERT_HEAD(&em->shared->threads, em, threads);
210 EMUL_SHARED_WUNLOCK(&emul_shared_lock);
211
212 p = pfind(child);
213 KASSERT(p != NULL, ("process not found in proc_init\n"));
214 p->p_emuldata = em;
215 PROC_UNLOCK(p);
216 } else
217 EMUL_UNLOCK(&emul_lock);
218
219 LIN_SDT_PROBE0(emul, proc_init, return);
152 return (0);
153}
154
155void
156linux_proc_exit(void *arg __unused, struct proc *p)
157{
158 struct linux_emuldata *em;
159 int error, shared_flags, shared_xstat;
160 struct thread *td = FIRST_THREAD_IN_PROC(p);
161 int *child_clear_tid;
162 struct proc *q, *nq;
163
164 if (__predict_true(p->p_sysent != &elf_linux_sysvec))
165 return;
166
220 return (0);
221}
222
223void
224linux_proc_exit(void *arg __unused, struct proc *p)
225{
226 struct linux_emuldata *em;
227 int error, shared_flags, shared_xstat;
228 struct thread *td = FIRST_THREAD_IN_PROC(p);
229 int *child_clear_tid;
230 struct proc *q, *nq;
231
232 if (__predict_true(p->p_sysent != &elf_linux_sysvec))
233 return;
234
235 LIN_SDT_PROBE1(emul, proc_exit, entry, p);
236
167 release_futexes(p);
168
169 /* find the emuldata */
170 em = em_find(p, EMUL_DOLOCK);
171
172 KASSERT(em != NULL, ("proc_exit: emuldata not found.\n"));
173
174 /* reparent all procs that are not a thread leader to initproc */
175 if (em->shared->group_pid != p->p_pid) {
237 release_futexes(p);
238
239 /* find the emuldata */
240 em = em_find(p, EMUL_DOLOCK);
241
242 KASSERT(em != NULL, ("proc_exit: emuldata not found.\n"));
243
244 /* reparent all procs that are not a thread leader to initproc */
245 if (em->shared->group_pid != p->p_pid) {
246 LIN_SDT_PROBE3(emul, proc_exit, reparent,
247 em->shared->group_pid, p->p_pid, p);
248
176 child_clear_tid = em->child_clear_tid;
177 EMUL_UNLOCK(&emul_lock);
178 sx_xlock(&proctree_lock);
179 wakeup(initproc);
180 PROC_LOCK(p);
181 proc_reparent(p, initproc);
182 p->p_sigparent = SIGCHLD;
183 PROC_UNLOCK(p);

--- 19 unchanged lines hidden (view full) ---

203 p->p_xstat = shared_xstat;
204
205 if (child_clear_tid != NULL) {
206 struct linux_sys_futex_args cup;
207 int null = 0;
208
209 error = copyout(&null, child_clear_tid, sizeof(null));
210 if (error) {
249 child_clear_tid = em->child_clear_tid;
250 EMUL_UNLOCK(&emul_lock);
251 sx_xlock(&proctree_lock);
252 wakeup(initproc);
253 PROC_LOCK(p);
254 proc_reparent(p, initproc);
255 p->p_sigparent = SIGCHLD;
256 PROC_UNLOCK(p);

--- 19 unchanged lines hidden (view full) ---

276 p->p_xstat = shared_xstat;
277
278 if (child_clear_tid != NULL) {
279 struct linux_sys_futex_args cup;
280 int null = 0;
281
282 error = copyout(&null, child_clear_tid, sizeof(null));
283 if (error) {
284 LIN_SDT_PROBE1(emul, proc_exit,
285 child_clear_tid_error, error);
286
211 free(em, M_LINUX);
287 free(em, M_LINUX);
288
289 LIN_SDT_PROBE0(emul, proc_exit, return);
212 return;
213 }
214
215 /* futexes stuff */
216 cup.uaddr = child_clear_tid;
217 cup.op = LINUX_FUTEX_WAKE;
218 cup.val = 0x7fffffff; /* Awake everyone */
219 cup.timeout = NULL;
220 cup.uaddr2 = NULL;
221 cup.val3 = 0;
222 error = linux_sys_futex(FIRST_THREAD_IN_PROC(p), &cup);
223 /*
224 * this cannot happen at the moment and if this happens it
225 * probably means there is a user space bug
226 */
290 return;
291 }
292
293 /* futexes stuff */
294 cup.uaddr = child_clear_tid;
295 cup.op = LINUX_FUTEX_WAKE;
296 cup.val = 0x7fffffff; /* Awake everyone */
297 cup.timeout = NULL;
298 cup.uaddr2 = NULL;
299 cup.val3 = 0;
300 error = linux_sys_futex(FIRST_THREAD_IN_PROC(p), &cup);
301 /*
302 * this cannot happen at the moment and if this happens it
303 * probably means there is a user space bug
304 */
227 if (error)
305 if (error) {
306 LIN_SDT_PROBE0(emul, proc_exit, futex_failed);
228 printf(LMSG("futex stuff in proc_exit failed.\n"));
307 printf(LMSG("futex stuff in proc_exit failed.\n"));
308 }
229 }
230
231 /* clean the stuff up */
232 free(em, M_LINUX);
233
234 /* this is a little weird but rewritten from exit1() */
235 sx_xlock(&proctree_lock);
236 q = LIST_FIRST(&p->p_children);

--- 8 unchanged lines hidden (view full) ---

245 PROC_LOCK(q);
246 if ((q->p_flag & P_WEXIT) == 0 && em->pdeath_signal != 0) {
247 kern_psignal(q, em->pdeath_signal);
248 }
249 PROC_UNLOCK(q);
250 EMUL_UNLOCK(&emul_lock);
251 }
252 sx_xunlock(&proctree_lock);
309 }
310
311 /* clean the stuff up */
312 free(em, M_LINUX);
313
314 /* this is a little weird but rewritten from exit1() */
315 sx_xlock(&proctree_lock);
316 q = LIST_FIRST(&p->p_children);

--- 8 unchanged lines hidden (view full) ---

325 PROC_LOCK(q);
326 if ((q->p_flag & P_WEXIT) == 0 && em->pdeath_signal != 0) {
327 kern_psignal(q, em->pdeath_signal);
328 }
329 PROC_UNLOCK(q);
330 EMUL_UNLOCK(&emul_lock);
331 }
332 sx_xunlock(&proctree_lock);
333
334 LIN_SDT_PROBE0(emul, proc_exit, return);
253}
254
255/*
256 * This is used in a case of transition from FreeBSD binary execing to linux binary
257 * in this case we create linux emuldata proc entry with the pid of the currently running
258 * process.
259 */
260void
261linux_proc_exec(void *arg __unused, struct proc *p, struct image_params *imgp)
262{
335}
336
337/*
338 * This is used in a case of transition from FreeBSD binary execing to linux binary
339 * in this case we create linux emuldata proc entry with the pid of the currently running
340 * process.
341 */
342void
343linux_proc_exec(void *arg __unused, struct proc *p, struct image_params *imgp)
344{
345 if (__predict_false(imgp->sysent == &elf_linux_sysvec)) {
346 LIN_SDT_PROBE2(emul, proc_exec, entry, p, imgp);
347 }
263 if (__predict_false(imgp->sysent == &elf_linux_sysvec
264 && p->p_sysent != &elf_linux_sysvec))
265 linux_proc_init(FIRST_THREAD_IN_PROC(p), p->p_pid, 0);
266 if (__predict_false((p->p_sysent->sv_flags & SV_ABI_MASK) ==
267 SV_ABI_LINUX))
268 /* Kill threads regardless of imgp->sysent value */
269 linux_kill_threads(FIRST_THREAD_IN_PROC(p), SIGKILL);
270 if (__predict_false(imgp->sysent != &elf_linux_sysvec

--- 21 unchanged lines hidden (view full) ---

292 if (em->shared->refs == 0) {
293 EMUL_SHARED_WUNLOCK(&emul_shared_lock);
294 free(em->shared, M_LINUX);
295 } else
296 EMUL_SHARED_WUNLOCK(&emul_shared_lock);
297
298 free(em, M_LINUX);
299 }
348 if (__predict_false(imgp->sysent == &elf_linux_sysvec
349 && p->p_sysent != &elf_linux_sysvec))
350 linux_proc_init(FIRST_THREAD_IN_PROC(p), p->p_pid, 0);
351 if (__predict_false((p->p_sysent->sv_flags & SV_ABI_MASK) ==
352 SV_ABI_LINUX))
353 /* Kill threads regardless of imgp->sysent value */
354 linux_kill_threads(FIRST_THREAD_IN_PROC(p), SIGKILL);
355 if (__predict_false(imgp->sysent != &elf_linux_sysvec

--- 21 unchanged lines hidden (view full) ---

377 if (em->shared->refs == 0) {
378 EMUL_SHARED_WUNLOCK(&emul_shared_lock);
379 free(em->shared, M_LINUX);
380 } else
381 EMUL_SHARED_WUNLOCK(&emul_shared_lock);
382
383 free(em, M_LINUX);
384 }
385
386 if (__predict_false(imgp->sysent == &elf_linux_sysvec)) {
387 LIN_SDT_PROBE0(emul, proc_exec, return);
388 }
300}
301
302void
303linux_schedtail(struct thread *td)
304{
305 struct linux_emuldata *em;
306 struct proc *p;
307 int error = 0;
308 int *child_set_tid;
309
310 p = td->td_proc;
311
389}
390
391void
392linux_schedtail(struct thread *td)
393{
394 struct linux_emuldata *em;
395 struct proc *p;
396 int error = 0;
397 int *child_set_tid;
398
399 p = td->td_proc;
400
401 LIN_SDT_PROBE1(emul, linux_schedtail, entry, p);
402
312 /* find the emuldata */
313 em = em_find(p, EMUL_DOLOCK);
314
315 KASSERT(em != NULL, ("linux_schedtail: emuldata not found.\n"));
316 child_set_tid = em->child_set_tid;
317 EMUL_UNLOCK(&emul_lock);
318
403 /* find the emuldata */
404 em = em_find(p, EMUL_DOLOCK);
405
406 KASSERT(em != NULL, ("linux_schedtail: emuldata not found.\n"));
407 child_set_tid = em->child_set_tid;
408 EMUL_UNLOCK(&emul_lock);
409
319 if (child_set_tid != NULL)
410 if (child_set_tid != NULL) {
320 error = copyout(&p->p_pid, (int *)child_set_tid,
321 sizeof(p->p_pid));
322
411 error = copyout(&p->p_pid, (int *)child_set_tid,
412 sizeof(p->p_pid));
413
414 if (error != 0) {
415 LIN_SDT_PROBE1(emul, linux_schedtail, copyout_error,
416 error);
417 }
418 }
419
420 LIN_SDT_PROBE0(emul, linux_schedtail, return);
421
323 return;
324}
325
326int
327linux_set_tid_address(struct thread *td, struct linux_set_tid_address_args *args)
328{
329 struct linux_emuldata *em;
330
422 return;
423}
424
425int
426linux_set_tid_address(struct thread *td, struct linux_set_tid_address_args *args)
427{
428 struct linux_emuldata *em;
429
331#ifdef DEBUG
332 if (ldebug(set_tid_address))
333 printf(ARGS(set_tid_address, "%p"), args->tidptr);
334#endif
430 LIN_SDT_PROBE1(emul, linux_set_tid_address, entry, args->tidptr);
335
336 /* find the emuldata */
337 em = em_find(td->td_proc, EMUL_DOLOCK);
338
339 KASSERT(em != NULL, ("set_tid_address: emuldata not found.\n"));
340
341 em->child_clear_tid = args->tidptr;
342 td->td_retval[0] = td->td_proc->p_pid;
343
344 EMUL_UNLOCK(&emul_lock);
431
432 /* find the emuldata */
433 em = em_find(td->td_proc, EMUL_DOLOCK);
434
435 KASSERT(em != NULL, ("set_tid_address: emuldata not found.\n"));
436
437 em->child_clear_tid = args->tidptr;
438 td->td_retval[0] = td->td_proc->p_pid;
439
440 EMUL_UNLOCK(&emul_lock);
441
442 LIN_SDT_PROBE0(emul, linux_set_tid_address, return);
345 return 0;
346}
347
348void
349linux_kill_threads(struct thread *td, int sig)
350{
351 struct linux_emuldata *em, *td_em, *tmp_em;
352 struct proc *sp;
353
443 return 0;
444}
445
446void
447linux_kill_threads(struct thread *td, int sig)
448{
449 struct linux_emuldata *em, *td_em, *tmp_em;
450 struct proc *sp;
451
452 LIN_SDT_PROBE2(emul, linux_kill_threads, entry, td, sig);
453
354 td_em = em_find(td->td_proc, EMUL_DONTLOCK);
355
356 KASSERT(td_em != NULL, ("linux_kill_threads: emuldata not found.\n"));
357
358 EMUL_SHARED_RLOCK(&emul_shared_lock);
359 LIST_FOREACH_SAFE(em, &td_em->shared->threads, threads, tmp_em) {
360 if (em->pid == td_em->pid)
361 continue;
362
363 sp = pfind(em->pid);
364 if ((sp->p_flag & P_WEXIT) == 0)
365 kern_psignal(sp, sig);
366 PROC_UNLOCK(sp);
454 td_em = em_find(td->td_proc, EMUL_DONTLOCK);
455
456 KASSERT(td_em != NULL, ("linux_kill_threads: emuldata not found.\n"));
457
458 EMUL_SHARED_RLOCK(&emul_shared_lock);
459 LIST_FOREACH_SAFE(em, &td_em->shared->threads, threads, tmp_em) {
460 if (em->pid == td_em->pid)
461 continue;
462
463 sp = pfind(em->pid);
464 if ((sp->p_flag & P_WEXIT) == 0)
465 kern_psignal(sp, sig);
466 PROC_UNLOCK(sp);
367#ifdef DEBUG
368 printf(LMSG("linux_kill_threads: kill PID %d\n"), em->pid);
369#endif
467
468 LIN_SDT_PROBE1(emul, linux_kill_threads, kill, em->pid);
370 }
371 EMUL_SHARED_RUNLOCK(&emul_shared_lock);
469 }
470 EMUL_SHARED_RUNLOCK(&emul_shared_lock);
471
472 LIN_SDT_PROBE0(emul, linux_kill_threads, return);
372}
473}