summaryrefslogtreecommitdiffstats
path: root/sys/compat/linux/linux_emul.c
Commit message (Collapse)AuthorAgeFilesLines
* MFC r284051:dchagin2016-01-091-0/+12
| | | | | Finish r283544. In exec case properly detach threads from user space before suicide.
* MFC r283544:dchagin2016-01-091-13/+5
| | | | | | When I merged the lemul branch I missied kib@'s r282708 commit. This is not the final fix as I need properly cleanup thread resources before other threads suicide.
* MFC r283456:dchagin2016-01-091-3/+6
| | | | Improve ktr(9) records in thread managment code.
* MFC r283455:dchagin2016-01-091-8/+11
| | | | Use local struct proc * varable instead of dereferencing td->td_proc.
* MFC r283454:dchagin2016-01-091-4/+5
| | | | | | Avoid unnecessary em zeroing in non-exec path as it already zeroed by malloc with M_ZERO flag and move zeroing to the proper place in exec path.
* MFC r283453:dchagin2016-01-091-1/+1
| | | | Remove the unnecessary cast.
* MFC r283441:dchagin2016-01-091-2/+33
| | | | | | | | | | | Implement epoll family system calls. This is a tiny wrapper around kqueue() to implement epoll subset of functionality. The kqueue user data are 32bit on i386 which is not enough for epoll user data, so we keep user data in the proc emuldata. Initial patch developed by rdivacky@ in 2007, then extended by Yuri Victorovich @ r255672 and finished by me in collaboration with mjg@ and jillies@.
* MFC r283427:dchagin2016-01-091-3/+3
| | | | | Where possible we will use M_LINUX malloc(9) type. Move M_FUTEX defines to the linux_common.ko.
* MFC r283422:dchagin2016-01-091-159/+44
| | | | | | | | | Refund the proc emuldata struct for future use. For now move flags from thread emuldata to proc emuldata as it was originally intended. As we can have both 64 & 32 bit Linuxulator running any eventhandler can be called twice for us. To prevent this move eventhandlers code from linux_emul.c to the linux_common.ko module.
* MFC r283384:dchagin2016-01-091-1/+1
| | | | | | pthread_join() caller do futex_wait on child_clear_tid. As a results of multiple simultaneous calls to pthread_join() specifying the same target thread are undefined wake up the one thread.
* MFC r283383:dchagin2016-01-091-261/+145
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Reduce duplication between i386/linux/linux.h and amd64/linux32/linux.hjhb2013-01-291-0/+1
| | | | | | | by moving bits that are MI out into headers in compat/linux. Reviewed by: Chagin Dmitry dmitry | gmail MFC after: 2 weeks
* - >500 static DTrace probes for the linuxulatornetchild2012-05-051-12/+113
| | | | | | | | | | | | | | | | | | - DTrace scripts to check for errors, performance, ... they serve mostly as examples of what you can do with the static probe;s with moderate load the scripts may be overwhelmed, excessive lock-tracing may influence program behavior (see the last design decission) Design decissions: - use "linuxulator" as the provider for the native bitsize; add the bitsize for the non-native emulation (e.g. "linuxuator32" on amd64) - Add probes only for locks which are acquired in one function and released in another function. Locks which are aquired and released in the same function should be easy to pair in the code, inter-function locking is more easy to verify in DTrace. - Probes for locks should be fired after locking and before releasing to prevent races (to provide data/function stability in DTrace, see the man-page of "dtrace -v ..." and the corresponding DTrace docs).
* In order to maximize the re-usability of kernel code in user space thiskmacy2011-09-161-2/+2
| | | | | | | | | | | | | patch modifies makesyscalls.sh to prefix all of the non-compatibility calls (e.g. not linux_, freebsd32_) with sys_ and updates the kernel entry points and all places in the code that use them. It also fixes an additional name space collision between the kernel function psignal and the libc function of the same name by renaming the kernel psignal kern_psignal(). By introducing this change now we will ease future MFCs that change syscalls. Reviewed by: rwatson Approved by: re (bz)
* Indeed, remove bogus since r219405 check of the Linux ABI.dchagin2011-03-091-3/+0
| | | | | | Pointed out: jhb MFC after: 2 Week
* Extend struct sysvec with new method sv_schedtail, which is used for andchagin2011-03-081-2/+5
| | | | | | | | | | | | | | | explicit process at fork trampoline path instead of eventhadler(schedtail) invocation for each child process. Remove eventhandler(schedtail) code and change linux ABI to use newly added sysvec method. While here replace explicit comparing of module sysentvec structure with the newly created process sysentvec to detect the linux ABI. Discussed with: kib MFC after: 2 Week
* Rename used_requeue and use it as bitwise field to store more flags.dchagin2011-02-121-1/+1
| | | | Reimplement used_requeue logic with LINUX_XDEPR_REQUEUEOP flag.
* Fix linux kernel module breakage introduced in r215675, by includingdim2010-11-221-0/+1
| | | | | | | <sys/sysent.h>. Noticed by: many Pointy hat to: netchild
* Do not take the process lock. The assignment to u_short inside thenetchild2010-11-221-5/+3
| | | | | | | | | | | properly aligned structure is atomic on all supported architectures, and the thread that should see side-effect of assignment is the same thread that does assignment. Use a more appropriate conditional to detect the linux ABI. Suggested by: kib X-MFC: together with r215664
* By using the 32-bit Linux version of Sun's Java Development Kit 1.6netchild2010-11-221-1/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | on FreeBSD (amd64), invocations of "javac" (or "java") eventually end with the output of "Killed" and exit code 137. This is caused by: 1. After calling exec() in multithreaded linux program threads are not destroyed and continue running. They get killed after program being executed finishes. 2. linux_exit_group doesn't return correct exit code when called not from group leader. Which happens regularly using sun jvm. The submitters fix this in a similar way to how NetBSD handles this. I took the PRs away from dchagin, who seems to be out of touch of this since a while (no response from him). The patches committed here are from [2], with some little modifications from me to the style. PR: 141439 [1], 144194 [2] Submitted by: Stefan Schmidt <stefan.schmidt@stadtbuch.de>, gk Reviewed by: rdivacky (in april 2010) MFC after: 5 days
* Remove support for FUTEX_REQUEUE operation.dchagin2009-04-191-0/+1
| | | | | | | | | | | | | | | | Glibc does not use this operation since 2.3.3 version (Jun 2004), as it is racy and replaced by FUTEX_CMP_REQUEUE operation. Glibc versions prior to 2.3.3 fall back to FUTEX_WAKE when FUTEX_REQUEUE returned EINVAL. Any application directly using FUTEX_REQUEUE without return value checking are definitely broken. Limit quantity of messages per process about unsupported operation. Approved by: kib (mentor) MFC after: 1 month
* The code in linux_proc_exit() contains a race when multiple linux basedkib2008-10-311-3/+3
| | | | | | | | | | | | | processes exits at the same time. The linux_emuldata structure is freed but p->p_emuldata is left as a dangling pointer to the just freed memory. The check for W_EXIT in the loop scanning the child processes isn't safe since the state of the child process can change right afterwards. Lock the process and check the W_EXIT before delivering signal. Submitted by: tegge Reviewed by: davidxu MFC after: 1 week
* Implement robust futexes. Most of the code is modelled afterrdivacky2008-05-131-3/+6
| | | | | | | | | | | what Linux does. This is because robust futexes are mostly userspace thing which we cannot alter. Two syscalls maintain pointer to userspace list and when process exits a routine walks this list waking up processes sleeping on futexes from that list. Reviewed by: kib (mentor) MFC after: 1 month
* MFP4: Turn emul_lock into a mutex.jkim2007-04-021-2/+2
| | | | Submitted by: rdivacky
* MFP4: 115220, 115222jkim2007-03-021-2/+2
| | | | | - Fix style(9) and reduce diff between amd64 and i386. - Prefix Linuxulator macros with LINUX_ to prevent future collision.
* Partial MFp4 of 114977:netchild2007-02-241-1/+1
| | | | | | Whitespace commit: Fix grammar, spelling and punctuation. Submitted by: "Scot Hetzel" <swhetzel@gmail.com>
* MFp4 (114193 (i386 part), 114194, 114195, 114200):netchild2007-02-231-4/+8
| | | | | | | | | | | | | - Dont "return" in linux_clone() after we forked the new process in a case of problems. - Move the copyout of p2->p_pid outside the emul_lock coverage in linux_clone(). - Cache the em->pdeath_signal in a local variable and move the copyout out of the emul_lock coverage. - Move the free() out of the emul_shared_lock coverage in a preparation to switch emul_lock to non-sleepable lock (mutex). Submitted by: rdivacky
* MFp4 (part of 114132):netchild2007-02-231-7/+8
| | | | | | - Fix a LOR caused by holding emul_lock and proctree_lock at once. Submitted by: rdivacky
* Remove extern int hz; use proper include file instead.kib2007-02-021-2/+1
|
* No need to synchronize linux_schedtail with linux_proc_init.kib2007-02-011-26/+28
| | | | | | | | | | | | | | | | | | | | | | p->p_emuldata is properly initialized in the time when the child can run. Do not set p->p_emuldata to NULL when the process is exiting. It does not make any sense and only costs 2 mutex operations. Do not lock emul_data to unlock it on the very next line. Comment on possible race while there. Reparent all procs that are part of a threading group but not its leaders to init and SIGCHLD init to finish the zombies off. This fixes zombies left after opera's exit. [1] There is no need to lock p_em in the linux_proc_init CLONE_THREAD case because the process cannot change the address of the p_em->shared because its currently running this code path. Move assigning of em->shared outside emul_shared_lock. Noticed by: Scott Robbins <scottro@nyc.rr.com> [1] Submitted by: rdivacky
* MFp4 (113077, 113083, 113103, 113124, 113097):netchild2007-01-201-8/+5
| | | | | | | | | | | | | | | | | | | | | | | | | Dont expose em->shared to the outside world before its properly initialized. Might not affect anything but its at least a better coding style. Dont expose em via p->p_emuldata until its properly initialized. This also enables us to get rid of some locking and simplify the code because we are workin on a local copy. In linux_fork and linux_vfork create the process in stopped state to be sure that the new process runs with fully initialized emuldata structure [1]. Also fix the vfork (both in linux_clone and linux_vfork) race that could result in never woken up process [2]. Reported by: Scot Hetzel [1] Suggested by: jhb [2] Reviewed by: jhb (at least some important parts) Submitted by: rdivacky Tested by: Scot Hetzel (on amd64) Change 2 comments (in the new code) to comply to style(9). Suggested by: jhb
* MFp4 (112499):netchild2007-01-071-0/+2
| | | | | | Protect em->shared with the lock in case of CLONE_THREAD. Submitted by: rdivacky
* MFp4 (112498):netchild2007-01-071-9/+9
| | | | | | Rename the locking flags to EMUL_DOLOCK and EMUL_DONTLOCK to prevent confusion. Submitted by: rdivacky
* MFp4:netchild2006-12-311-60/+64
| | | | - semi-automatic style fixes
* Group pid and parent are shared in a case of CLONE_THREAD not CLONE_VM.kib2006-11-151-3/+3
| | | | | | | | This fix lets clone02 LTP test pass with 2.6 emulation. In reality 99% of the cases are that CLONE_VM and CLONE_THREAD are both set so it seemed to work. Submitted by: rdivacky
* MFP4:netchild2006-10-281-1/+23
| | | | | | | Implement prctl(). Submitted by: rdivacky Tested with: LTP
* - change if (cond) panic() to KASSERT.netchild2006-10-081-3/+4
| | | | | | | | - Dont forget to free em in a case of error. Suggested by: ssouhlal Submitted by: rdivacky Tested with: LTP
* - Extend the coverage of PROC_LOCK to cover wakeup(&p->p_emuldata);netchild2006-09-091-1/+3
| | | | | | | | - Lock the emuldata in a case when we just created it. Sponsored by: Google SoC 2006 Submitted by: rdivacky Suggested by: jhb
* FREE -> freessouhlal2006-08-281-2/+2
| | | | Submitted by: rdivacky
* MALLOC -> malloc and FREE -> freessouhlal2006-08-191-4/+4
| | | | | Submitted by: rdivacky Pointed out by: jhb
* Fix the DEBUG build:netchild2006-08-171-3/+0
| | | | | | | | | - linux_emul.c [1] - linux_futex.c [2] Sponsored by: Google SoC 2006 [1] Submitted by: rdivacky [1] netchild [2]
* Style fixes to comments.netchild2006-08-161-5/+9
| | | | | | Sponsored by: Google SoC 2006 Submitted by: rdivacky Noticed by: jhb, ssouhlal
* Add some new files needed for linux 2.6.x compatibility.netchild2006-08-151-0/+297
Please don't style(9) the NetBSD code, we want to stay in sync. Not imported on a vendor branch since we need local changes. Sponsored by: Google SoC 2006 Submitted by: rdivacky With help from: manu@NetBSD.org Obtained from: NetBSD (linux_{futex,time}.*)
OpenPOWER on IntegriCloud