diff options
author | dchagin <dchagin@FreeBSD.org> | 2016-01-09 15:16:13 +0000 |
---|---|---|
committer | dchagin <dchagin@FreeBSD.org> | 2016-01-09 15:16:13 +0000 |
commit | cb3b38d1640b6a07cdc16de9cc37c2da8cfff4c1 (patch) | |
tree | a6590a108af61dda64e892cb9d59ab130e0f805b /sys/i386/linux/linux_machdep.c | |
parent | ccb67dae7f74133acb97e4894ad207af1d13a6c4 (diff) | |
download | FreeBSD-src-cb3b38d1640b6a07cdc16de9cc37c2da8cfff4c1.zip FreeBSD-src-cb3b38d1640b6a07cdc16de9cc37c2da8cfff4c1.tar.gz |
MFC r283383:
Switch linuxulator to use the native 1:1 threads.
The reasons:
1. Get rid of the stubs/quirks with process dethreading,
process reparent when the process group leader exits and close
to this problems on wait(), waitpid(), etc.
2. Reuse our kernel code instead of writing excessive thread
managment routines in Linuxulator.
Implementation details:
1. The thread is created via kern_thr_new() in the clone() call with
the CLONE_THREAD parameter. Thus, everything else is a process.
2. The test that the process has a threads is done via P_HADTHREADS
bit p_flag of struct proc.
3. Per thread emulator state data structure is now located in the
struct thread and freed in the thread_dtor() hook.
Mandatory holdig of the p_mtx required when referencing emuldata
from the other threads.
4. PID mangling has changed. Now Linux pid is the native tid
and Linux tgid is the native pid, with the exception of the first
thread in the process where tid and pid are one and the same.
Ugliness:
In case when the Linux thread is the initial thread in the thread
group thread id is equal to the process id. Glibc depends on this
magic (assert in pthread_getattr_np.c). So for system calls that
take thread id as a parameter we should use the special method
to reference struct thread.
Diffstat (limited to 'sys/i386/linux/linux_machdep.c')
-rw-r--r-- | sys/i386/linux/linux_machdep.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/sys/i386/linux/linux_machdep.c b/sys/i386/linux/linux_machdep.c index effc32a..d3013e1 100644 --- a/sys/i386/linux/linux_machdep.c +++ b/sys/i386/linux/linux_machdep.c @@ -148,15 +148,8 @@ linux_execve(struct thread *td, struct linux_execve_args *args) free(newpath, M_TEMP); if (error == 0) error = kern_execve(td, &eargs, NULL); - if (error == 0) { - /* linux process can exec fbsd one, dont attempt - * to create emuldata for such process using - * linux_proc_init, this leads to a panic on KASSERT - * because such process has p->p_emuldata == NULL - */ - if (SV_PROC_ABI(td->td_proc) == SV_ABI_LINUX) - error = linux_proc_init(td, 0, 0); - } + if (error == 0) + error = linux_common_execve(td, &eargs); post_execve(td, error, oldvmspace); return (error); } @@ -368,8 +361,14 @@ int linux_set_upcall_kse(struct thread *td, register_t stack) { - td->td_frame->tf_esp = stack; + if (stack) + td->td_frame->tf_esp = stack; + /* + * The newly created Linux thread returns + * to the user space by the same path that a parent do. + */ + td->td_frame->tf_eax = 0; return (0); } |