Commit Graph

6977 Commits

Author SHA1 Message Date
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
dchagin
fd9d33be2a MFC r283374:
In preparation for switching linuxulator to the use the native 1:1
threads refactor kern_sched_rr_get_interval() and sys_sched_rr_get_interval().
Add a kern_sched_rr_get_interval() counterpart which takes a targettd
parameter to allow specify target thread directly by callee (new Linuxulator).

Linuxulator temporarily uses first thread in proc.

Move linux_sched_rr_get_interval() to the MI part.
2016-01-09 14:40:38 +00:00
dchagin
994d3d5889 Regen for r293478. 2016-01-09 14:34:29 +00:00
dchagin
e060fa6fed MFC r283370:
In preparation for switching linuxulator to the use the native 1:1
threads introduce linux_exit() stub instead of sys_exit() call
(which terminates process).
In the new linuxulator exit() system call terminates the calling
thread (not a whole process).
2016-01-09 14:33:10 +00:00
dchagin
358125d39c MFC r283369:
In preparation for switching linuxulator to the use the native 1:1
threads print the thread id in addition to the pid in debug messages.
2016-01-09 14:31:03 +00:00
dim
7295d680ea MFC r277735 (by royger):
amd64: allow base memory segment to start at address different than 0

Current code requires that the first physical memory segment starts at 0,
but this is not really needed. We only need to make sure the bootstrap code
and page tables for APs are allocated below 4GB.

This patch removes this requirement and allows booting a Dell R710 from
UEFI, where the first physical memory segment starts at 0x10000.

Sponsored by: Citrix Systems R&D
Reviewed by: jhb
Differential Revision: https://reviews.freebsd.org/D1417
2015-12-21 17:15:03 +00:00
kib
9167bbc1e5 MFC r291948:
Use ANSI C definition.
2015-12-14 07:54:45 +00:00
jhb
f91ade9d24 MFC 284325:
Report the values of x86 segment registers to remote debuggers.

While here, also report %eflags from the i386 trapframe.
2015-11-13 00:50:34 +00:00
jhb
d10f133720 MFC 285783:
Various changes to the registers displayed in DDB for x86.
- Fix segment registers to only display the low 16 bits.
- Remove unused handlers and entries for the debug registers.
- Display xcr0 (if valid) in 'show sysregs'.
- Add '0x' prefix to MSR values to match other values in 'show sysregs'.
- MFamd64: Display various MSRs in 'show sysregs'.
- Add a 'show dbregs' to display the value of debug registers.
- Dynamically size the column width for register values to properly
  align columns on 64-bit platforms.
- Display %gs for i386 in 'show registers'.
2015-11-12 23:49:47 +00:00
jhb
2285630285 MFC 285773,285775,285776:
Various fixes for stack unwinding in DDB on x86.

285773:
Remove some dead code from DDB's amd64 stack unwinder.

The amd64 port copied some code from i386 to fetch function arguments and
display them in backtraces. However, it was commented out and can't easily
be implemented since the function arguments are passed in
registers rather than on the stack in amd64. Remove it in preparation for
some bug fixes in this area.

285775:
Improve stack unwinding on i386 and amd64 after an IP fault.

If we can't find a symbol corresponding to the faulting instruction, assume
that the previously-executed function is a call and attempt to find the
calling function using the return address on the stack. Otherwise we end
up associating the last stack frame with the current call, which is
incorrect and causes the unwinder to skip printing of the calling function,
resulting in a confusing backtrace.

285776:
Let the unwinder handle faults during function prologues or epilogues.

The i386 and amd64 DDB stack unwinders contain code to detect and handle
the case where the first frame is not completely set up or torn down. This
code was accidentally unused however, since db_backtrace() was never called
with a non-NULL trap frame. This change fixes that.

Also remove get_rsp() from the amd64 code. It appears to have come from
i386, which needs to take into account whether the exception triggered a
CPL switch, since SS:ESP is only pushed onto the stack if so. On amd64,
SS:RSP is pushed regardless, so get_rsp() was doing the wrong thing for
kernel-mode exceptions. As a result, we can also remove custom print
functions for these registers.
2015-11-12 22:45:51 +00:00
kib
70c328a1bb MFC r289824:
Add CLFLUSHOPT instruction wrappers.

MFC r290188:
Fix prefix on i386.
2015-10-30 10:02:57 +00:00
avg
bef317767a MFC r261891: provide fast versions of ffsl and flsl for i386; ffsll and
flsll for amd64
2015-10-23 10:05:43 +00:00
kib
b44e8c1443 MFC r288000:
Add support for weak symbols to the kernel linkers.
2015-09-27 01:33:43 +00:00
rstone
26a0cf375a MFC r280957
Fix integer truncation bug in malloc(9)

  A couple of internal functions used by malloc(9) and uma truncated
  a size_t down to an int.  This could cause any number of issues
  (e.g. indefinite sleeps, memory corruption) if any kernel
  subsystem tried to allocate 2GB or more through malloc.  zfs would
  attempt such an allocation when run on a system with 2TB or more
  of RAM.
2015-09-17 23:31:44 +00:00
marcel
966727ca3b MFC r286808, r286809, r286867, r286868
-   Improve support for Macs that have a stride not equal to the
    horizonal resolution (width).
-   Support frame buffers that are larger than the default screen
    size.
-   Support large frame buffers: add 24 more page table pages we
    allocate on boot-up.

PR:		193745
2015-08-25 15:14:50 +00:00
marcel
87b09c366d MFC r286667 & r286723
Better support memory mapped console devices, such as VGA and EFI
frame buffers and memory mapped UARTs.

PR:		191564, 194952, 202276
2015-08-25 14:39:40 +00:00
kib
70c41a2cb1 MFC r286228:
Clear the IA32_MISC_ENABLE MSR bit on APs.
2015-08-17 18:33:16 +00:00