Commit Graph

6993 Commits

Author SHA1 Message Date
dchagin
735299091c MFC r283484:
Implement epoll_pwait() system call.
2016-01-09 17:45:02 +00:00
dchagin
e412c865a0 Regen for r293582. 2016-01-09 17:42:25 +00:00
dchagin
1e80f16f0f MFC r283480:
Add utimensat() system call.
2016-01-09 17:41:00 +00:00
dchagin
48b0af056f MFC r283479:
The kernel sends signals to the processes via ABI specific sv_sendsig method.
Native ABI do not need signal conversion, only emulators may want this. Usually
emulators implements its own sv_sendsig method. For now only ibcs2 emulator does
not have own sv_sendsig implementation and depends on native sendsig() method.
So, remove any extra attempts to convert signal numbers from native sendsig()
methods except from i386 where ibsc2 is living.
2016-01-09 17:39:41 +00:00
dchagin
05243c7228 MFC r283474:
Rework signal code to allow using it by other modules, like linprocfs:

1. Linux sigset always 64 bit on all platforms. In order to move Linux
sigset code to the linux_common module define it as 64 bit int. Move
Linux sigset manipulation routines to the MI path.

2. Move Linux signal number definitions to the MI path. In general, they
are the same on all platforms except for a few signals.

3. Map Linux RT signals to the FreeBSD RT signals and hide signal conversion
tables to avoid conversion errors.

4. Emulate Linux SIGPWR signal via FreeBSD SIGRTMIN signal which is outside
of allowed on Linux signal numbers.

PR:             197216
2016-01-09 17:29:08 +00:00
dchagin
858c17f9b3 MFC r283471:
According to Linux man sigaltstack(3) shall return EINVAL if the ss
argument is not a null pointer, and the ss_flags member pointed to by ss
contains flags other than SS_DISABLE. However, in fact, Linux also
allows SS_ONSTACK flag which is simply ignored.

For buggy apps (at least mono) ignore other than SS_DISABLE
flags as a Linux do.

While here move MI part of sigaltstack code to the appropriate place.
2016-01-09 17:22:51 +00:00
dchagin
1aaf87d264 Regen for r293569. 2016-01-09 17:20:19 +00:00
dchagin
8ab518aec9 MFC r283467:
Call nosys in case when the incorrect syscall number is specified.

Its my fault, fixed by mjg@ at r289055.
2016-01-09 17:18:03 +00:00
dchagin
c4895a81f6 Regen for r293567. 2016-01-09 17:15:03 +00:00
dchagin
5b01285f9b MFC r283465:
Add preliminary fallocate system call implementation
to emulate posix_fallocate() function.
2016-01-09 17:13:43 +00:00
dchagin
09f25351da Regen for r293555. 2016-01-09 17:00:15 +00:00
dchagin
682bdd605d MFC r283451:
Implement ppoll() system call.
2016-01-09 16:58:57 +00:00
dchagin
9d7b3777ea MFC r283446:
Include opt_compat.h, so that COMPAT_LINUX32 is defined, and we can
access to the semop structs and functions.
2016-01-09 16:52:25 +00:00
dchagin
b7022d5321 Regen for r293549. 2016-01-09 16:50:09 +00:00
dchagin
1eeab3feb9 MFC r283444:
Implement eventfd system call.
2016-01-09 16:48:50 +00:00
dchagin
623ca98188 MFC r283443:
Put the correct value for the abi_nfdbits parameter of kern_select() for
all supported Linuxulators.
2016-01-09 16:47:36 +00:00
dchagin
2ce85f55b6 Regen for r293546. 2016-01-09 16:45:54 +00:00
dchagin
ea9daca708 MFC r283441:
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@.
2016-01-09 16:44:17 +00:00
dchagin
2205518265 MFC r283437:
To avoid code duplication move open/fcntl definitions to the MI
header file.
2016-01-09 16:31:10 +00:00
dchagin
f31e70952f MFC r283436:
Use the BSD_TO_LINUX_SIGNAL() wherever there is no need
to check the ABI as it is known.
2016-01-09 16:29:51 +00:00
dchagin
a1e3b366c7 MFC r283432:
Being exported through vdso the note.Linux section used by glibc
to determine the kernel version (this saves one uname call).
Temporarily disable the export of a note.Linux section until I figured
out how to change the kernel version in the note.Linux on the fly.
2016-01-09 16:25:30 +00:00
dchagin
68ddeae1b4 MFC r283431:
Add AT_RANDOM and AT_EXECFN auxiliary vector entries which are used by
glibc. At list since glibc version 2.16 using AT_RANDOM is mandatory.
2016-01-09 16:24:30 +00:00
dchagin
6a70519414 Regen for r293533. 2016-01-09 16:23:11 +00:00
dchagin
f186d260e2 MFC r283428:
Change linux faccessat syscall definition to match actual linux one.

The AT_EACCESS and AT_SYMLINK_NOFOLLOW flags are actually implemented
within the glibc wrapper function for faccessat().  If either of these
flags are specified, then the wrapper function employs fstatat() to
determine access permissions.
2016-01-09 16:21:39 +00:00
dchagin
199f40b151 Regen for r293530. 2016-01-09 16:16:16 +00:00
dchagin
aaac17a4f9 MFC r283424:
Add preliminary support for x86-64 Linux binaries.
2016-01-09 16:14:24 +00:00
dchagin
6c12e20ac1 MFC r283422:
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.
2016-01-09 16:11:09 +00:00
dchagin
d30e84112a MFC r283421:
Introduce a new module linux_common.ko which is intended for the
following primary purposes:

1. Remove the dependency of linsysfs and linprocfs modules from linux.ko,
which will be architecture specific on amd64.

2. Incorporate into linux_common.ko general code for platforms on which
we'll support two Linuxulator modules (for both instruction set - 32 & 64 bit).

3. Move malloc(9) declaration to linux_common.ko, to enable getting memory
usage statistics properly.

Currently linux_common.ko incorporates a code from linux_mib.c and linux_util.c
and linprocfs, linsysfs and linux kernel modules depend on linux_common.ko.

Temporarily remove dtrace garbage from linux_mib.c and linux_util.c
2016-01-09 16:08:22 +00:00
dchagin
793bb9c3f7 MFC r283416:
x86_64 Linux do not use multiplexing on ipc system calls.
Move struct ipc_perm definition to the MD path as it differs for 64 and
32 bit platform.
2016-01-09 15:56:01 +00:00
dchagin
f536abaf31 MFC r283411:
Remove stale comment about a signal trampoline which
is moved to the shared page at r219609.
2016-01-09 15:49:42 +00:00
dchagin
a034df74fd MFC r283410:
Put linux_platform into the vdso to avoid copying it onto the stack at
every exec.
2016-01-09 15:48:11 +00:00
dchagin
5c3e282c6e MFC r283408:
Eliminate a now unused global declaration of elf_linux_sysvec.
2016-01-09 15:46:05 +00:00
dchagin
18c1672334 MFC r283407:
Implement vdso - virtual dynamic shared object. Through vdso Linux
exposes functions from kernel with proper DWARF CFI information so that
it becomes easier to unwind through them.
Using vdso is a mandatory for a thread cancelation && cleanup
on a modern glibc.
2016-01-09 15:44:38 +00:00
dchagin
2e9cc3f70d Regen for r293511. 2016-01-09 15:40:44 +00:00
dchagin
4ed27590e5 MFC r283403:
Implement pselect6() system call.
2016-01-09 15:39:41 +00:00
dchagin
4992ef5f9d Regen for r293510. 2016-01-09 15:38:16 +00:00
dchagin
027f6631c0 MFC r283401:
Implement prlimit64() system call.
2016-01-09 15:37:10 +00:00
dchagin
a82405c150 Regen for r293508. 2016-01-09 15:35:57 +00:00
dchagin
b4d7be064f MFC r283399:
Implement dup3() system call.
2016-01-09 15:34:54 +00:00
dchagin
e327d1c9cc Regen for r293505. 2016-01-09 15:32:33 +00:00
dchagin
df59792813 MFC r283396:
Implement rt_sigqueueinfo() system call.
2016-01-09 15:31:15 +00:00
dchagin
4e3ae75e5e Regen for r293503. 2016-01-09 15:29:10 +00:00
dchagin
3c97a00938 MFC r283394:
Implement waitid() system call.
2016-01-09 15:28:05 +00:00
dchagin
a14064e328 MFC r283391:
To reduce code duplication introduce linux_copyout_rusage() method.
Use it in linux_wait4() system call and move linux_wait4() to the MI path.
While here add a prototype for the static bsd_to_linux_rusage().
2016-01-09 15:23:54 +00:00
dchagin
2646cf70a0 MFC r283385:
Some style(9) && whitespaces fixes. No functional changes.
2016-01-09 15:18:36 +00:00
dchagin
cb3b38d164 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.
2016-01-09 15:16:13 +00:00
dchagin
2b83b41438 MFC r283382:
In preparation for switching linuxulator to the use the native 1:1
threads add a hook for cleaning thread resources before the thread die.
2016-01-09 14:53:08 +00:00
dchagin
c12aa632f3 Regen fro r293487. 2016-01-09 14:48:23 +00:00
dchagin
31e61f6749 MFC r283379:
Implement a Linux version of sched_getparam() && sched_setparam().
Temporarily use the first thread in proc.
2016-01-09 14:47:08 +00:00
dchagin
65d490113d MFC r283378:
Remove a now unused include.
2016-01-09 14:45:41 +00:00