aboutsummaryrefslogtreecommitdiff
path: root/sys/compat
Commit message (Collapse)AuthorAgeFilesLines
* Streamline the LinuxKPI spinlock wrappers.Hans Petter Selasky2017-02-211-19/+109
| | | | | | | | | | | | | | | | 1) Add better spinlock debug names when WITNESS_ALL is defined. 2) Make sure that the calling thread gets bound to the current CPU while a spinlock is locked. Some Linux kernel code depends on that the CPU ID doesn't change while a spinlock is locked. 3) Add support for using LinuxKPI spinlocks during a panic(). MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=314044
* Add support for LinuxKPI tasklets.Hans Petter Selasky2017-02-213-0/+238
| | | | | | | | | | | | | | Tasklets are implemented using a taskqueue and a small statemachine on top. The additional statemachine is required to ensure all LinuxKPI tasklets get serialized. FreeBSD taskqueues do not guarantee serialisation of its tasks, except when there is only one worker thread configured. MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=314043
* Make the LinuxKPI task struct persistent accross system calls.Hans Petter Selasky2017-02-2118-177/+304
| | | | | | | | | | | | | | | | | | | | | | | | | A set of helper functions have been added to manage the life of the LinuxKPI task struct. When an external system call or task is invoked, a check is made to create the task struct by demand. A thread destructor callback is registered to free the task struct when a thread exits to avoid memory leaks. This change lays the ground for emulating the Linux kernel more closely which is a dependency by the code using the LinuxKPI APIs. Add new dedicated td_lkpi_task field has been added to struct thread instead of abusing td_retval[1]. Fix some header file inclusions to make LINT kernel build properly after this change. Bump the __FreeBSD_version to force a rebuild of all kernel modules. MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=314040
* Add /proc/self/mounts to linprocfs; some linux binaries need it.Edward Tomasz Napierala2017-02-201-0/+2
| | | | | | | | MFC after: 2 weeks Sponsored by: DARPA, AFRL Notes: svn path=/head/; revision=313995
* There are some Linux binaries that expect the system to obey the "addr"Edward Tomasz Napierala2017-02-191-1/+16
| | | | | | | | | | | | | | parameter to mmap(2), even if MAP_FIXED is not explicitly specified. Android ART is one example. Implement bug compatibility for this case in linuxulator. Reviewed by: dchagin@ MFC after: 2 weeks Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D9373 Notes: svn path=/head/; revision=313947
* Implement rt_tgsigqueueinfo system call used by glibc for pthread_sigqueue(3).Dmitry Chagin2017-02-191-0/+29
| | | | | | | MFC after: 2 week Notes: svn path=/head/; revision=313940
* Style(9), some XXX comments fix. No functional changes.Dmitry Chagin2017-02-181-19/+17
| | | | | | | MFC after: 1 week Notes: svn path=/head/; revision=313914
* Initialize cap_rights before use.Dmitry Chagin2017-02-181-1/+2
| | | | | | | MFC after: 1 week Notes: svn path=/head/; revision=313913
* Finich r313684.Dmitry Chagin2017-02-182-11/+11
| | | | | | | | | | | | Convert linux_recv(), linux_send() and linux_accept() system call arguments to the register_t type too. PR: 217161 MFC after: 3 days xMFC with: r313284,r313285,r313684 Notes: svn path=/head/; revision=313912
* Implement GFP_DMA32 flag in the LinuxKPI.Hans Petter Selasky2017-02-172-3/+6
| | | | | | | | | | | Define all FreeBSD native GFP bits as GFP_NATIVE_MASK. Obtained from: kmacy @ MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=313872
* Allow container_of() to be used with constant data pointers.Hans Petter Selasky2017-02-161-2/+2
| | | | | | | | | Obtained from: kmacy @ MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=313810
* Implement more LinuxKPI atomic functions and macros.Hans Petter Selasky2017-02-163-0/+32
| | | | | | | | | Obtained from: kmacy @ MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=313808
* Allow passing a constant atomic_t to atomic_read().Hans Petter Selasky2017-02-161-2/+2
| | | | | | | | | Obtained from: kmacy @ MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=313807
* Whitespace fix.Hans Petter Selasky2017-02-161-1/+1
| | | | | | | | | Obtained from: kmacy @ MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=313806
* Improve debugging output.Edward Tomasz Napierala2017-02-161-1/+1
| | | | | | | | MFC after: 2 weeks Sponsored by: DARPA, AFRL Notes: svn path=/head/; revision=313804
* Replace Linuxulator implementation of readdir(), getdents() andDmitry Chagin2017-02-141-203/+204
| | | | | | | | | | | | | | | | | | | | | | | | getdents64() with wrapper over kern_getdirentries(). The patch was originally written by emaste@ and then adapted by trasz@ and me. Note: 1. I divided linux_getdents() and linux_readdir() as in case when the getdents() called with count = 1 (readdir() case) it can overwrite user stack (by writing to user buffer pointer more than 1 byte). 2. Linux returns EINVAL in case when user supplied buffer is not enough to contain fetched dirent. 3. Linux returns ENOTDIR in case when fd points to not a directory. Reviewed by: trasz@ MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D2210 Notes: svn path=/head/; revision=313740
* Rework r313352.Konstantin Belousov2017-02-134-30/+30
| | | | | | | | | | | | | | | Rename kern_vm_* functions to kern_*. Move the prototypes to syscallsubr.h. Also change Mach VM types to uintptr_t/size_t as needed, to avoid headers pollution. Requested by: alc, jhb Reviewed by: alc Sponsored by: The FreeBSD Foundation MFC after: 2 weeks Differential revision: https://reviews.freebsd.org/D9535 Notes: svn path=/head/; revision=313696
* Style: wrap long line.Konstantin Belousov2017-02-131-1/+2
| | | | | | | | Sponsored by: The FreeBSD Foundation MFC after: 3 days Notes: svn path=/head/; revision=313692
* Fix r313284.Dmitry Chagin2017-02-121-20/+26
| | | | | | | | | | | | Members of the syscall argument structures are padded to a word size. So, for COMPAT_LINUX32 we should convert user supplied system call arguments which is 32-bit in that case to the array of register_t. Reported by: Oleg V. Nauman MFC after: 1 week Notes: svn path=/head/; revision=313684
* Regenerate all the system call tables to drop "created from" lines.John Baldwin2017-02-1016-16/+0
| | | | | | | | One of the ibcs2 files contains some actual changes (new headers) as it hasn't been regenerated after older changes to makesyscalls.sh. Notes: svn path=/head/; revision=313566
* Add kern_vm_mmap2(), kern_vm_mprotect(), kern_vm_msync(), kern_vm_munlock(),Edward Tomasz Napierala2017-02-064-131/+70
| | | | | | | | | | | | | kern_vm_munmap(), and kern_vm_madvise(), and use them in various compats instead of their sys_*() counterparts. Reviewed by: ed, dchagin, kib MFC after: 2 weeks Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D9378 Notes: svn path=/head/; revision=313352
* Update syscall.master to 4.10-rc6. Also fix comments, a typo,Dmitry Chagin2017-02-051-115/+2
| | | | | | | | | | | | | | | | | and wrong numbering for a few unimplemented syscalls. For 32-bit Linuxulator, socketcall() syscall was historically the entry point for the sockets API. Starting in Linux 4.3, direct syscalls are provided for the sockets API. Enable it. The initial version of patch was provided by trasz@ and extended by me. Submitted by: trasz MFC after: 2 week Differential Revision: https://reviews.freebsd.org/D9381 Notes: svn path=/head/; revision=313284
* Fix linux_pipe() and linux_pipe2() to close file descriptors on copyoutEdward Tomasz Napierala2017-02-051-6/+16
| | | | | | | | | | | | error. Reviewed by: dchagin MFC after: 2 weeks Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D9425 Notes: svn path=/head/; revision=313283
* Add kern_cpuset_getaffinity() and kern_cpuset_getaffinity(),Edward Tomasz Napierala2017-02-052-30/+9
| | | | | | | | | | | | and use it in compats instead of their sys_*() counterparts. Reviewed by: kib, jhb, dchagin MFC after: 2 weeks Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D9383 Notes: svn path=/head/; revision=313281
* Add kern_pread() and kern_pwrite(), and use it in compats insteadEdward Tomasz Napierala2017-01-312-42/+12
| | | | | | | | | | | | of their sys_*() counterparts. The svr4 is left unchanged. Reviewed by: kib@ MFC after: 2 weeks Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D9379 Notes: svn path=/head/; revision=313018
* Fix linux_getppid() to debug the actual parent, even it was reparentedEdward Tomasz Napierala2017-01-311-3/+1
| | | | | | | | | | | | by debugger. Reviewed by: dchagin@ MFC after: 2 weeks Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D9361 Notes: svn path=/head/; revision=313017
* Replace calls to sys_truncate() with kern_truncate().Edward Tomasz Napierala2017-01-311-8/+4
| | | | | | | | | | Reviewed by: kib@ MFC after: 2 weeks Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D9371 Notes: svn path=/head/; revision=313016
* Add kern_cpuset_getid() and kern_cpuset_setid(), and use themEdward Tomasz Napierala2017-01-311-13/+4
| | | | | | | | | | | | in compat32 instead of their sub_*() counterparts. Reviewed by: jhb@, kib@ MFC after: 2 weeks Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D9382 Notes: svn path=/head/; revision=313015
* Add kern_listen(), kern_shutdown(), and kern_socket(), and use themEdward Tomasz Napierala2017-01-303-53/+22
| | | | | | | | | | | | | instead of their sys_*() counterparts in various compats. The svr4 is left untouched, because there's no point. Reviewed by: ed@, kib@ MFC after: 2 weeks Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D9367 Notes: svn path=/head/; revision=312988
* Add kern_lseek() and use it instead of sys_lseek() in various compats.Edward Tomasz Napierala2017-01-303-42/+15
| | | | | | | | | | | | I didn't touch svr4/, there's no point. Reviewed by: ed@, kib@ MFC after: 2 weeks Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D9366 Notes: svn path=/head/; revision=312987
* Replace sys_ftruncate() with kern_ftruncate() in various compats.Edward Tomasz Napierala2017-01-302-16/+3
| | | | | | | | | | Reviewed by: kib@ MFC after: 2 weeks Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D9368 Notes: svn path=/head/; revision=312986
* Revert crap accidentally committedBaptiste Daroussin2017-01-283-10/+0
| | | | Notes: svn path=/head/; revision=312927
* Revert r312923 a better approach will be taken laterBaptiste Daroussin2017-01-283-0/+10
| | | | Notes: svn path=/head/; revision=312926
* Introduce __read_mostly and __exclusive_cache_line macros.Mateusz Guzik2017-01-271-1/+0
| | | | | | | | | | | | | | | | The intended use is to annotate frequently used globals which either rarely change (and thus can be grouped in the same cacheline) or are an atomic counter (which means it may benefit from being the only variable in the cacheline). Linker script support is provided only for amd64. Architectures without it risk having other variables put in, i.e. as if they were not annotated. This is harmless from correctness point of view. Reviewed by: bde (previous version) MFC after: 1 month Notes: svn path=/head/; revision=312888
* Catch up with changes to structure member names.Ed Schouten2017-01-1713-73/+73
| | | | | | | Pointer/length pairs are now always named ${name} and ${name}_len. Notes: svn path=/head/; revision=312355
* Regenerate sources based on the system call tables.Ed Schouten2017-01-1710-188/+188
| | | | Notes: svn path=/head/; revision=312354
* Use getsock_cap() instead of fgetsock().Gleb Smirnoff2017-01-061-16/+16
| | | | | | | Reviewed by: dchagin Notes: svn path=/head/; revision=311474
* Do not allocate struct statfs on kernel stack.Konstantin Belousov2017-01-053-56/+85
| | | | | | | | | | | | | | | | Right now size of the structure is 472 bytes on amd64, which is already large and stack allocations are indesirable. With the ino64 work, MNAMELEN is increased to 1024, which will make it impossible to have struct statfs on the stack. Extracted from: ino64 work by gleb Discussed with: mckusick Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Notes: svn path=/head/; revision=311452
* Some style fixes for getfstat(2)-related code.Konstantin Belousov2017-01-051-1/+2
| | | | | | | | Sponsored by: The FreeBSD Foundation MFC after: 1 week Notes: svn path=/head/; revision=311447
* Regen after r310638.John Baldwin2016-12-275-6/+6
| | | | | | | Differential Revision: https://reviews.freebsd.org/D8854 Notes: svn path=/head/; revision=310639
* Rename the 'flags' argument to getfsstat() to 'mode' and validate it.John Baldwin2016-12-272-3/+3
| | | | | | | | | | | | | | This argument is not a bitmask of flags, but only accepts a single value. Fail with EINVAL if an invalid value is passed to 'flag'. Rename the 'flags' argument to getmntinfo(3) to 'mode' as well to match. This is a followup to r308088. Reviewed by: kib MFC after: 1 month Notes: svn path=/head/; revision=310638
* Implement more list header file functions.Hans Petter Selasky2016-12-261-2/+29
| | | | | | | | | | | Add definition guard for the list_head structure. Obtained from: kmacy @ MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=310589
* Fix LINT build.Hans Petter Selasky2016-12-261-1/+1
| | | | | | | | | Found by: mmel @ MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=310583
* Implement register and unregister chrdev in the LinuxKPI.Hans Petter Selasky2016-12-263-4/+115
| | | | | | | | | Obtained from: kmacy @ MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=310559
* Use correct integer type when computing the maximum physical addressHans Petter Selasky2016-12-251-2/+2
| | | | | | | | | | | for kmem_alloc_contig(). Obtained from: kmacy @ MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=310557
* Improve LinuxKPI device support. Only delete own BSD devices and notHans Petter Selasky2016-12-251-12/+38
| | | | | | | | | | | | the ones obtained through devclass_get_device(). Some minor code cleanups while at it. Obtained from: kmacy @ MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=310553
* linuxkpi: Fix not-found case of linux_pci_find_irq_devConrad Meyer2016-12-131-6/+7
| | | | | | | | | | | | | | | Linux list_for_each_entry() does not neccessarily end with the iterator NULL (it may be an offset from NULL if the list member is not the first element of the member struct). Reported by: Coverity CID: 1366940 Reviewed by: hselasky@ Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D8780 Notes: svn path=/head/; revision=310031
* Remove the only user of sysctl_add_oid().Ed Schouten2016-12-131-2/+2
| | | | | | | | | | My plan is to change this function's prototype at some point in the future to add a new label argument, which can be used to export all of sysctl as metrics that can be scraped by Prometheus. Switch over this caller to use the macro wrapper counterpart. Notes: svn path=/head/; revision=310014
* Add more LinuxKPI PCI definitions.Hans Petter Selasky2016-12-091-5/+65
| | | | | | | | | Obtained from: kmacy @ Sponsored by: Mellanox Technologies MFC after: 1 week Notes: svn path=/head/; revision=309737
* Prefer function macros over regular macros in the LinuxKPI.Hans Petter Selasky2016-12-091-3/+3
| | | | | | | | MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=309736