aboutsummaryrefslogtreecommitdiff
path: root/sys/compat
Commit message (Collapse)AuthorAgeFilesLines
* linuxkpi: Add irq_work.hEmmanuel Vadot2020-05-191-0/+52
| | | | | | | | | | | | | | Since handlers are call in a thread context we can simply use a workqueue to emulate those functions. The DRM code was patched to do that already, having it in linuxkpi allows us to not patch the upstream code. Sponsored-by: The FreeBSD Foundation Reviewed by: hselasky Differential Revision: https://reviews.freebsd.org/D24859 Notes: svn path=/head/; revision=361247
* linuxkpi: add pci_dev_presentEmmanuel Vadot2020-05-191-0/+12
| | | | | | | | | | | | pci_dev_present shows if a set of pci ids are present in the system. It just wraps pci_find_device. Needed by DRMv5.2 Submitted by: Austing Shafer (ashafer@badland.io) Differential Revision: https://reviews.freebsd.org/D24796 Notes: svn path=/head/; revision=361246
* linuxkpi: Add __init_waitqueue_headEmmanuel Vadot2020-05-191-0/+2
| | | | | | | | | | | | The only difference with init_waitqueue_head is that the name and the lock class key are provided but we don't use those so use init_waitqueue_head directly. Sponsored-by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D24861 Notes: svn path=/head/; revision=361245
* linuxkpi: Add offsetofend macroEmmanuel Vadot2020-05-171-0/+3
| | | | | | | | | | | This calculate the offset of the end of the member in the given struct. Needed by DRM in Linux v5.3 Sponsored-by: The FreeBSD Foudation Differential Revision: https://reviews.freebsd.org/D24849 Notes: svn path=/head/; revision=361140
* linuxkpi: Add __mutex_initEmmanuel Vadot2020-05-171-0/+3
| | | | | | | | | | | | Same as mutex_init, the lock_class_key argument seems to be only used for debug in Linux, simply ignore it for now. Needed by DRM in Linux v5.3 Sponsored-by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D24848 Notes: svn path=/head/; revision=361139
* linuxkpi: Add atomic_dec_and_mutex_lockEmmanuel Vadot2020-05-171-0/+11
| | | | | | | | | | | | This function decrement the counter and if the result is 0 it acquires the mutex and returns 1, if not it simply returns 0. Needed by DRM from Linux v5.3 Sponsored-by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D24847 Notes: svn path=/head/; revision=361138
* Implement synchronize_srcu_expedited() in the LinuxKPI.Hans Petter Selasky2020-05-161-0/+4
| | | | | | | | | Differential Revision: https://reviews.freebsd.org/D24798 MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=361110
* linuxkpi: Add EBADRQC to errno.hEmmanuel Vadot2020-05-131-0/+2
| | | | | | | | | | This is used in the amdgpu driver from Linux 5.2 Sponsored-by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D24807 Notes: svn path=/head/; revision=361007
* linuxkpi: print stack trace in WARN_ON macrosAndriy Gapon2020-05-131-0/+2
| | | | | | | | | Reviewed by: hselasky, kib MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D24779 Notes: svn path=/head/; revision=361006
* linuxkpi: Really add bitmap_alloc and bitmap_zallocEmmanuel Vadot2020-05-101-0/+13
| | | | | | | | | This was missing in r360870 Sponsored-by: The FreeBSD Foundation Notes: svn path=/head/; revision=360871
* linuxkpi: Add bitmap_alloc and bitmap_freeEmmanuel Vadot2020-05-101-0/+7
| | | | | | | | | | | | This is a simple call to kmallock_array/kfree, therefore include linux/slab.h as this is where the kmalloc_array/kfree definition is. Sponsored-by: The FreeBSD Foundation Reviewed by: hselsasky Differential Revision: https://reviews.freebsd.org/D24794 Notes: svn path=/head/; revision=360870
* linuxkpi: Add bitmap_copy and bitmap_andnotEmmanuel Vadot2020-05-091-0/+22
| | | | | | | | | | | | bitmap_copy simply copy the bitmaps, no idea why it exists. bitmap_andnot is similar to bitmap_and but uses !src2. Sponsored-by: The FreeBSD Foundation Reviewed by: hselasky Differential Revision: https://reviews.freebsd.org/D24782 Notes: svn path=/head/; revision=360851
* linuxkpi: Add pci_iomap and pci_iounmapEmmanuel Vadot2020-05-072-0/+45
| | | | | | | | | | | | | | Those function are use to map/unmap io region of a pci device. Different resource can be mapped depending on the bar so use a tailq to store them all. Sponsored-by: The FreeBSD Foundation Reviewed by: emaste, hselasky Differential Revision: https://reviews.freebsd.org/D24696 Notes: svn path=/head/; revision=360787
* Optimise use of sg_page_count() in __sg_page_iter_next() in the LinuxKPI.Hans Petter Selasky2020-05-041-2/+7
| | | | | | | | | | | | No need to compute value twice. No functional change intended. MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=360623
* Implement more scatter and gather functions in the LinuxKPI.Hans Petter Selasky2020-05-041-5/+24
| | | | | | | | | | Differential Revision: https://reviews.freebsd.org/D24611 Submitted by: ashafer_badland.io (Austin Shafer) MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=360622
* Fix warning about sleeping with non-sleepable lock when allocatingHans Petter Selasky2020-05-041-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | "current" from linux_cdev_pager_populate() in the LinuxKPI: Backtrace: witness_debugger() witness_warn() uma_zalloc_arg() malloc() linux_alloc_current() linux_cdev_pager_populate() vm_fault() vm_fault_trap() trap_pfault() trap() calltrap() Suggested by: avg@ MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=360621
* Implement more PCI-express bandwidth functions in the LinuxKPI.Hans Petter Selasky2020-05-011-0/+41
| | | | | | | | | Submitted by: ashafer_badland.io (Austin Shafer) MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=360532
* Implement mutex_lock_killable() in the LinuxKPI.Hans Petter Selasky2020-05-011-0/+12
| | | | | | | | | Submitted by: ashafer_badland.io (Austin Shafer) MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=360531
* Implement DIV64_U64_ROUND_UP() in the LinuxKPI.Hans Petter Selasky2020-05-011-0/+9
| | | | | | | | | Submitted by: ashafer_badland.io (Austin Shafer) MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=360530
* Implement more lockdep macros in the LinuxKPI.Hans Petter Selasky2020-05-011-0/+6
| | | | | | | | | Submitted by: ashafer_badland.io (Austin Shafer) MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=360529
* Implement kstrtou64() in the LinuxKPI.Hans Petter Selasky2020-05-011-0/+15
| | | | | | | | | Submitted by: ashafer_badland.io (Austin Shafer) MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=360528
* sysent: re-roll after 360236 (AUE_CLOSERANGE used)Kyle Evans2020-04-241-1/+1
| | | | Notes: svn path=/head/; revision=360237
* close_range(2): use newly assigned AUE_CLOSERANGEKyle Evans2020-04-241-1/+1
| | | | Notes: svn path=/head/; revision=360236
* Factor code in LinuxKPI to allow attach and detach using any BSD device.Hans Petter Selasky2020-04-222-14/+50
| | | | | | | | | | | | | | | This allows non-LinuxKPI based infiniband device drivers to attach correctly to ibcore. No functional change intended. Reviewed by: np @ Differential Revision: https://reviews.freebsd.org/D24514 MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=360196
* Implement the atomic fetch add unless functions for the LinuxKPI.Hans Petter Selasky2020-04-203-0/+42
| | | | | | | | MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=360127
* Implement aligned LinuxKPI types for u16, u32 and u64.Hans Petter Selasky2020-04-201-0/+4
| | | | | | | | | | Makes a difference for 32-bit platforms mostly. MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=360119
* Allow test_bit() in the LinuxKPI to accept a const pointer.Hans Petter Selasky2020-04-201-1/+1
| | | | | | | | MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=360118
* Allow the ERR_CAST() function in the LinuxKPI to take a const void pointer.Hans Petter Selasky2020-04-201-2/+4
| | | | | | | | | | No functional change. MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=360115
* Remove a vestigal reference to kmem_object.Mark Johnston2020-04-171-1/+1
| | | | | | | | | kmem_object has been an alias of kernel_object for a while. MFC after: 1 week Notes: svn path=/head/; revision=360052
* Convert canary, execpathp, and pagesizes to pointers.Brooks Davis2020-04-161-6/+6
| | | | | | | | | | | | | Use AUXARGS_ENTRY_PTR to export these pointers. This is a followup to r359987 and r359988. Reviewed by: jhb Obtained from: CheriBSD Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D24446 Notes: svn path=/head/; revision=360024
* Export argc, argv, envc, envv, and ps_strings in auxargs.Brooks Davis2020-04-151-0/+2
| | | | | | | | | | | | | | | | | This simplifies discovery of these values, potentially with reducing the number of syscalls we need to make at runtime. Longer term, we wish to convert the startup process to pass an auxargs pointer to _start() and use that rather than walking off the end of envv. This is cleaner, more C-friendly, and for systems with strong bounds (e.g. CHERI) necessary. Reviewed by: kib Obtained from: CheriBSD Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D24407 Notes: svn path=/head/; revision=359988
* Make ps_strings in struct image_params into a pointer.Brooks Davis2020-04-151-0/+1
| | | | | | | | | | | This is a prepratory commit for D24407. Reviewed by: kib Obtained from: CheriBSD Sponsored by: DARPA Notes: svn path=/head/; revision=359987
* Remove bogus use of useracc() in (clock_)nanosleep.Brooks Davis2020-04-141-7/+2
| | | | | | | | | | | | | | | There's no point in pre-checking that we can access the user's rmtp pointer before we do it in copyout(). While here, improve style(9) compliance. Reviewed by: imp MFC after: 1 week Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D24409 Notes: svn path=/head/; revision=359938
* Centralize compatability translation macros.Brooks Davis2020-04-143-41/+6
| | | | | | | | | | | | | | | | Copy the CP, PTRIN, etc macros from freebsd32.h into a sys/abi_compat.h and replace existing definitation with includes where required. This eliminates duplicate code and allows Linux and FreeBSD compatability headers to be included in the same files. Input from: cem, jhb Obtained from: CheriBSD MFC after: 2 weeks Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D24275 Notes: svn path=/head/; revision=359937
* sysent: re-roll after r359930Kyle Evans2020-04-144-25/+3
| | | | Notes: svn path=/head/; revision=359931
* Mark closefrom(2) COMPAT12, reimplement in libc to wrap close_rangeKyle Evans2020-04-141-1/+1
| | | | | | | | | | | Include a temporarily compatibility shim as well for kernels predating close_range, since closefrom is used in some critical areas. Reviewed by: markj (previous version), kib Differential Revision: https://reviews.freebsd.org/D24399 Notes: svn path=/head/; revision=359930
* sysent: re-roll after introduction of close_range in r359836Kyle Evans2020-04-124-1/+34
| | | | Notes: svn path=/head/; revision=359837
* Implement a close_range(2) syscallKyle Evans2020-04-121-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | close_range(min, max, flags) allows for a range of descriptors to be closed. The Python folk have indicated that they would much prefer this interface to closefrom(2), as the case may be that they/someone have special fds dup'd to higher in the range and they can't necessarily closefrom(min) because they don't want to hit the upper range, but relocating them to lower isn't necessarily feasible. sys_closefrom has been rewritten to use kern_close_range() using ~0U to indicate closing to the end of the range. This was chosen rather than requiring callers of kern_close_range() to hold FILEDESC_SLOCK across the call to kern_close_range for simplicity. The flags argument of close_range(2) is currently unused, so any flags set is currently EINVAL. It was added to the interface in Linux so that future flags could be added for, e.g., "halt on first error" and things of this nature. This patch is based on a syscall of the same design that is expected to be merged into Linux. Reviewed by: kib, markj, vangyzen (all slightly earlier revisions) Differential Revision: https://reviews.freebsd.org/D21627 Notes: svn path=/head/; revision=359836
* Clone the RCU interface into a sleepable and a non-sleepable partHans Petter Selasky2020-04-082-49/+73
| | | | | | | | | | | | | | | | in the LinuxKPI. This allows synchronize RCU to be used inside a SRCU read section. No functional change intended. Bump the __FreeBSD_version to force recompilation of external kernel modules. PR: 242272 MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=359727
* Some fixes for SRCU in the LinuxKPI.Hans Petter Selasky2020-04-081-3/+6
| | | | | | | | | | | - Make sure to use READ_ONCE() when deferring variables. - Remove superfluous zero initializer. MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=359726
* Retire procfs-based process debugging.John Baldwin2020-04-011-1/+0
| | | | | | | | | | | | | | | | | | Modern debuggers and process tracers use ptrace() rather than procfs for debugging. ptrace() has a supserset of functionality available via procfs and new debugging features are only added to ptrace(). While the two debugging services share some fields in struct proc, they each use dedicated fields and separate code. This results in extra complexity to support a feature that hasn't been enabled in the default install for several years. PR: 244939 (exp-run) Reviewed by: kib, mjg (earlier version) Relnotes: yes Differential Revision: https://reviews.freebsd.org/D23837 Notes: svn path=/head/; revision=359530
* compat/linux/linux.h depends on queue.h since r353725.Mark Johnston2020-03-261-0/+2
| | | | | | | Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=359332
* Implement a workaround for kms-drm modulesWarner Losh2020-03-202-1/+6
| | | | | | | | | | | | pci_iov_if.h was added to pci.h, but none of the kms-drm branches have that. Rather than play whack a mole with the branches, move its inclusion to linux_pci.c which is the only part of the code that needs it now. Longer term, other solutions will be needed, but this gives us time to get those deployed on all the supported versions. Notes: svn path=/head/; revision=359165
* linuxkpi: Add infrastructure to pass FreeBSD IOV method calls intoKonstantin Belousov2020-03-182-0/+54
| | | | | | | | | | | pci_driver methods. Reviewed by: hselasky Sponsored by: Mellanox Technologies MFC after: 2 weeks Notes: svn path=/head/; revision=359096
* Add support for the device statistics IOCTL, needed by the comingHans Petter Selasky2020-03-102-1/+5
| | | | | | | | | | linux_libusb upgrade. MFC after: 3 days Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=358838
* Move compat.linux.map_sched_prio sysctl definition to linux_mib.c so it isTijl Coosemans2020-03-053-10/+11
| | | | | | | | | | only defined by linux_common kernel module and not both linux and linux64 modules. Reported by: Yuri Pankov <ypankov@fastmail.com> Notes: svn path=/head/; revision=358673
* Introduce kern_mmap_req().Brooks Davis2020-03-041-5/+14
| | | | | | | | | | | | | | | | | | | | | | | This presents an extensible interface to the generic mmap(2) implementation via a struct pointer intended to use a designated initializer or compount literal. We take advantage of the mandatory zeroing of fields not listed in the initializer. Remove kern_mmap_fpcheck() and use kern_mmap_req(). The motivation for this change is a desire to keep the core implementation from growing an ever-increasing number of arguments that must be specified in the correct order for the lowest-level implementations. In CheriBSD we have already added two more arguments. Reviewed by: kib Discussed with: kevans Obtained from: CheriBSD Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D23164 Notes: svn path=/head/; revision=358650
* When closing a LinuxKPI file always use the real release function to avoidHans Petter Selasky2020-03-031-2/+8
| | | | | | | | | | | | | resource leakage when destroying a LinuxKPI character device. Submitted by: Andrew Boyer <aboyer@pensando.io> Reviewed by: kib@ PR: 244572 MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=358586
* fd: move vnodes out of filedesc into a dedicated structureMateusz Guzik2020-03-011-20/+8
| | | | | | | | | | | | | | | | The new structure is copy-on-write. With the assumption that path lookups are significantly more frequent than chdirs and chrooting this is a win. This provides stable root and jail root vnodes without the need to reference them on lookup, which in turn means less work on globally shared structures. Note this also happens to fix a bug where jail vnode was never referenced, meaning subsequent access on lookup could run into use-after-free. Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D23884 Notes: svn path=/head/; revision=358503
* linuxulator: Map scheduler priorities to Linux priorities.Tijl Coosemans2020-03-012-7/+130
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On Linux the valid range of priorities for the SCHED_FIFO and SCHED_RR scheduling policies is [1,99]. For SCHED_OTHER the single valid priority is 0. On FreeBSD it is [0,31] for all policies. Programs are supposed to query the valid range using sched_get_priority_(min|max), but of course some programs assume the Linux values are valid. This commit adds a tunable compat.linux.map_sched_prio. When enabled sched_get_priority_(min|max) return the Linux values and sched_setscheduler and sched_(get|set)param translate between FreeBSD and Linux values. Because there are more Linux levels than FreeBSD levels, multiple Linux levels map to a single FreeBSD level, which means pre-emption might not happen as it does on Linux, so the tunable allows to disable this behaviour. It is enabled by default because I think it is unlikely that anyone runs real-time software under Linux emulation on FreeBSD that critically relies on correct pre-emption. This fixes FMOD, a commercial sound library used by several games. PR: 240043 Tested by: Alex S <iwtcex@gmail.com> Reviewed by: dchagin MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D23790 Notes: svn path=/head/; revision=358483