linux_emul.c (ad2056f2c46cd6f28b2f7a4bd0e1a72198b19eee) linux_emul.c (0eef2f8a4e5f42f98983e352732b9d883d96c53a)
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

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

105 /* lookup the old one */
106 em = em_find(td->td_proc, EMUL_UNLOCKED);
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
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

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

105 /* lookup the old one */
106 em = em_find(td->td_proc, EMUL_UNLOCKED);
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
113 /* allocate the shared struct only in clone()/fork cases
113 /*
114 * allocate the shared struct only in clone()/fork cases
114 * in the case of clone() td = calling proc and child = pid of
115 * the newly created proc
116 */
117 if (child != 0) {
118 if (flags & CLONE_VM) {
119 /* lookup the parent */
120 p_em = em_find(td->td_proc, EMUL_LOCKED);
121 KASSERT(p_em != NULL, ("proc_init: parent emuldata not found for CLONE_VM\n"));

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

185 /* futexes stuff */
186 cup.uaddr = child_clear_tid;
187 cup.op = LINUX_FUTEX_WAKE;
188 cup.val = 0x7fffffff; /* Awake everyone */
189 cup.timeout = NULL;
190 cup.uaddr2 = NULL;
191 cup.val3 = 0;
192 error = linux_sys_futex(FIRST_THREAD_IN_PROC(p), &cup);
115 * in the case of clone() td = calling proc and child = pid of
116 * the newly created proc
117 */
118 if (child != 0) {
119 if (flags & CLONE_VM) {
120 /* lookup the parent */
121 p_em = em_find(td->td_proc, EMUL_LOCKED);
122 KASSERT(p_em != NULL, ("proc_init: parent emuldata not found for CLONE_VM\n"));

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

186 /* futexes stuff */
187 cup.uaddr = child_clear_tid;
188 cup.op = LINUX_FUTEX_WAKE;
189 cup.val = 0x7fffffff; /* Awake everyone */
190 cup.timeout = NULL;
191 cup.uaddr2 = NULL;
192 cup.val3 = 0;
193 error = linux_sys_futex(FIRST_THREAD_IN_PROC(p), &cup);
193 /* this cannot happen at the moment and if this happens
194 /*
195 * this cannot happen at the moment and if this happens
194 * it probably mean there is a userspace bug
196 * it probably mean there is a userspace bug
195 */
197 */
196 if (error)
197 printf(LMSG("futex stuff in proc_exit failed.\n"));
198 }
199
200 /* clean the stuff up */
201 FREE(em, M_LINUX);
202}
203
198 if (error)
199 printf(LMSG("futex stuff in proc_exit failed.\n"));
200 }
201
202 /* clean the stuff up */
203 FREE(em, M_LINUX);
204}
205
204/* This is used in a case of transition from FreeBSD binary execing to linux binary
206/*
207 * This is used in a case of transition from FreeBSD binary execing to linux binary
205 * in this case we create linux emuldata proc entry with the pid of the currently running
206 * process.
207 */
208void linux_proc_exec(void *arg __unused, struct proc *p, struct image_params *imgp)
209{
210 if (__predict_false(imgp->sysent == &elf_linux_sysvec
211 && p->p_sysent != &elf_linux_sysvec))
212 linux_proc_init(FIRST_THREAD_IN_PROC(p), p->p_pid, 0);

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

251 if (p->p_sysent != &elf_linux_sysvec)
252 return;
253
254retry:
255 /* find the emuldata */
256 em = em_find(p, EMUL_UNLOCKED);
257
258 if (em == NULL) {
208 * in this case we create linux emuldata proc entry with the pid of the currently running
209 * process.
210 */
211void linux_proc_exec(void *arg __unused, struct proc *p, struct image_params *imgp)
212{
213 if (__predict_false(imgp->sysent == &elf_linux_sysvec
214 && p->p_sysent != &elf_linux_sysvec))
215 linux_proc_init(FIRST_THREAD_IN_PROC(p), p->p_pid, 0);

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

254 if (p->p_sysent != &elf_linux_sysvec)
255 return;
256
257retry:
258 /* find the emuldata */
259 em = em_find(p, EMUL_UNLOCKED);
260
261 if (em == NULL) {
259 /* We might have been called before proc_init for this process so
262 /*
263 * We might have been called before proc_init for this process so
260 * tsleep and be woken up by it. We use p->p_emuldata for this
261 */
262
263 error = tsleep(&p->p_emuldata, PLOCK, "linux_schedtail", hz);
264 if (error == 0)
265 goto retry;
266 panic("no emuldata found for userreting process.\n");
267 }

--- 30 unchanged lines hidden ---
264 * tsleep and be woken up by it. We use p->p_emuldata for this
265 */
266
267 error = tsleep(&p->p_emuldata, PLOCK, "linux_schedtail", hz);
268 if (error == 0)
269 goto retry;
270 panic("no emuldata found for userreting process.\n");
271 }

--- 30 unchanged lines hidden ---