aboutsummaryrefslogtreecommitdiff
path: root/sys/compat
Commit message (Collapse)AuthorAgeFilesLines
* Eliminate kmem_malloc()'s unused arena parameter. (The arena parameterAlan Cox2018-08-211-1/+1
| | | | | | | | | | | | became unused in FreeBSD 12.x as a side-effect of the NUMA-related changes.) Reviewed by: kib, markj Discussed with: jeff, re@ Differential Revision: https://reviews.freebsd.org/D16825 Notes: svn path=/head/; revision=338143
* Eliminate kmem_alloc_contig()'s unused arena parameter.Alan Cox2018-08-203-7/+6
| | | | | | | | | Reviewed by: hselasky, kib, markj Discussed with: jeff Differential Revision: https://reviews.freebsd.org/D16799 Notes: svn path=/head/; revision=338107
* Regen after r337998.Xin LI2018-08-181-1/+1
| | | | Notes: svn path=/head/; revision=337999
* getrandom(2) should not be restricted in capability mode.Xin LI2018-08-181-0/+1
| | | | Notes: svn path=/head/; revision=337998
* Revert r337922, except for some documention-only bits. This needs to waitJamie Gritton2018-08-167-14/+33
| | | | | | | | | until user is changed to stop using jail(2). Differential Revision: D14791 Notes: svn path=/head/; revision=337925
* Put jail(2) under COMPAT_FREEBSD11. It has been the "old" way of creatingJamie Gritton2018-08-167-33/+14
| | | | | | | | | | | | | | | | | jails since FreeBSD 7. Along with the system call, put the various security.jail.allow_foo and security.jail.foo_allowed sysctls partly under COMPAT_FREEBSD11 (or BURN_BRIDGES). These sysctls had two disparate uses: on the system side, they were global permissions for jails created via jail(2) which lacked fine-grained permission controls; inside a jail, they're read-only descriptions of what the current jail is allowed to do. The first use is obsolete along with jail(2), but keep them for the second-read-only use. Differential Revision: D14791 Notes: svn path=/head/; revision=337922
* Use atomic_fcmpset_XXX() instead of atomic_cmpset_XXX() when possibleHans Petter Selasky2018-08-094-33/+23
| | | | | | | | | | | in the LinuxKPI. Suggested by: mjg @ MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=337527
* Update the list of architectures having atomic_fcmpset_{8,16,64}(9) andMarius Strobl2018-08-072-9/+7
| | | | | | | atomic_swap_{64,int}(9) respectively as of r337433. Notes: svn path=/head/; revision=337434
* Improve handling of control message truncation.Mark Johnston2018-08-073-52/+60
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | If a recvmsg(2) or recvmmsg(2) caller doesn't provide sufficient space for all control messages, the kernel sets MSG_CTRUNC in the message flags to indicate truncation of the control messages. In the case of SCM_RIGHTS messages, however, we were failing to dispose of the rights that had already been externalized into the recipient's file descriptor table. Add a new function and mbuf type to handle this cleanup task, and use it any time we fail to copy control messages out to the recipient. To simplify cleanup, control message truncation is now only performed at control message boundaries. The change also fixes a few related bugs: - Rights could be leaked to the recipient process if an error occurred while copying out a message's contents. - We failed to set MSG_CTRUNC if the truncation occurred on a control message boundary, e.g., if the caller received two control messages and provided only the exact amount of buffer space needed for the first. PR: 131876 Reviewed by: ed (previous version) MFC after: 1 month Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D16561 Notes: svn path=/head/; revision=337423
* Implement current_work() function in the LinuxKPI.Hans Petter Selasky2018-08-063-1/+20
| | | | | | | | | Tested by: Johannes Lundberg <johalun0@gmail.com> MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=337376
* Implement atomic_long_cmpxchg() function in the LinuxKPI.Hans Petter Selasky2018-08-061-0/+15
| | | | | | | | | Submitted by: Johannes Lundberg <johalun0@gmail.com> MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=337374
* Define __poll_t type in the LinuxKPI.Hans Petter Selasky2018-08-061-0/+1
| | | | | | | | | Submitted by: Johannes Lundberg <johalun0@gmail.com> MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=337373
* Implement ktime_add_ms() and ktime_before() in the LinuxKPI.Hans Petter Selasky2018-08-031-0/+14
| | | | | | | | | Submitted by: Johannes Lundberg <johalun0@gmail.com> MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=337232
* Don't refer to non-existing atomic functions, even though not compiled,Hans Petter Selasky2018-08-011-5/+38
| | | | | | | | | | | in the LinuxKPI. Found by: rpolka @ MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=337056
* Add ioctl to conveniently mmap a PCI device BAR into userspace.Konstantin Belousov2018-08-012-1/+52
| | | | | | | | | | | | | | | | | | | | | | Add the ioctl PCIOCBARMMAP on /dev/pci to conveniently create userspace mapping of a PCI device BAR. This is enormously superior to read the BAR value with PCIOCREAD and then try to mmap /dev/mem, and should allow to automatically activate the mapped BARs when needed in future. Current implementation creates new sg pager for each user mmap request. If the pointer (and reference) to a managed device pager is stored in pci_map, we would be able to revoke all mappings on the BAR deactivation or relocation. This is related to the unimplemented BAR activation on mmap, and is postponed for the future. Discussed with: imp, jhb Sponsored by: The FreeBSD Foundation, Mellanox Technologies MFC after: 2 weeks Differential revision: https://reviews.freebsd.org/D15583 Notes: svn path=/head/; revision=337053
* Regenerate after r336980.Konstantin Belousov2018-07-315-9/+15
| | | | Notes: svn path=/head/; revision=336981
* Provide compat32 shims for sched_rr_get_interval(2).Konstantin Belousov2018-07-312-2/+20
| | | | | | | | | | | | | The interface uses struct timespec, which needs a translation. Reported and reviewed by: asomers PR: 230175 Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D16525 Notes: svn path=/head/; revision=336980
* Make timespecadd(3) and friends publicAlan Somers2018-07-305-17/+15
| | | | | | | | | | | | | | | | | | | | | | The timespecadd(3) family of macros were imported from NetBSD back in r35029. However, they were initially guarded by #ifdef _KERNEL. In the meantime, we have grown at least 28 syscalls that use timespecs in some way, leading many programs both inside and outside of the base system to redefine those macros. It's better just to make the definitions public. Our kernel currently defines two-argument versions of timespecadd and timespecsub. NetBSD, OpenBSD, and FreeDesktop.org's libbsd, however, define three-argument versions. Solaris also defines a three-argument version, but only in its kernel. This revision changes our definition to match the common three-argument version. Bump _FreeBSD_version due to the breaking KPI change. Discussed with: cem, jilles, ian, bde Differential Revision: https://reviews.freebsd.org/D14725 Notes: svn path=/head/; revision=336914
* freebsd32_getrusage(2): skip freebsd32_rusage_out on errorAlan Somers2018-07-291-2/+3
| | | | | | | | | | | PR: 230153 Reported by: kib MFC after: 2 weeks X-MFC-With: 336871 Differential Revision: https://reviews.freebsd.org/D16500 Notes: svn path=/head/; revision=336874
* getrusage(2): fix return value under 32-bit emulationAlan Somers2018-07-291-5/+2
| | | | | | | | | | | | | | | | According to the man page, getrusage(2) should return EFAULT if the rusage argument lies outside of the process's address space. But due to an oversight in r100384, that's never been the case during 32-bit emulation. Fix it. PR: 230153 Reported by: tests(7) Reviewed by: cem MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D16500 Notes: svn path=/head/; revision=336871
* Regen after r336171.Brooks Davis2018-07-104-66/+6
| | | | Notes: svn path=/head/; revision=336172
* Get rid of netbsd_lchown and netbsd_msync syscall entries.Brooks Davis2018-07-101-5/+2
| | | | | | | | | | | | | | | No valid FreeBSD binary very called them (they would call lchown and msync directly) and we haven't supported NetBSD binaries in ages. This is a respin of r335983 with a workaround for the ancient BFD linker in the libc stubs. Reviewed by: kib Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D16193 Notes: svn path=/head/; revision=336171
* Create PCI_MATCH and pci_match_deviceWarner Losh2018-07-071-0/+1
| | | | | | | | | | Create a covenience function to match PCI device IDs. It's about 15 years overdue. Differential Revision: https://reviews.freebsd.org/D15999 Notes: svn path=/head/; revision=336066
* Create a new macro for static DPCPU data.Andrew Turner2018-07-053-3/+3
| | | | | | | | | | | | | | | | | On arm64 (and possible other architectures) we are unable to use static DPCPU data in kernel modules. This is because the compiler will generate PC-relative accesses, however the runtime-linker expects to be able to relocate these. In preparation to fix this create two macros depending on if the data is global or static. Reviewed by: bz, emaste, markj Sponsored by: ABT Systems Ltd Differential Revision: https://reviews.freebsd.org/D16140 Notes: svn path=/head/; revision=336007
* Revert r335983.Brooks Davis2018-07-051-2/+5
| | | | | | | | The bfd linker in tree doesn't support multiple names for the same symbol (at least with current flags). Notes: svn path=/head/; revision=335990
* Get rid of netbsd_lchown and netbsd_msync syscall entries.Brooks Davis2018-07-051-5/+2
| | | | | | | | | | | | No valid FreeBSD binary ever called them (they would call lchown and msync directly) and we haven't supported NetBSD binaries in ages. Reviewed by: kib Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D15814 Notes: svn path=/head/; revision=335983
* Regen after 335900.Mariusz Zaborski2018-07-031-1/+1
| | | | | | | PR: 228671 Notes: svn path=/head/; revision=335901
* capsicum: add getdirentries to the freebsd32 compactMariusz Zaborski2018-07-031-0/+1
| | | | | | | | | | There is a getdirentries syscall in freebsd32 and it's capability ready so allow calling it in the capability mode. PR: 228671 Notes: svn path=/head/; revision=335900
* Split kern_break from sys_break and use it in linuxulatorEd Maste2018-06-271-10/+6
| | | | | | | | | | | | | | | | | Previously the linuxulator's linux_brk invoked the FreeBSD sys_break syscall implementation directly. Instead, move the bulk of the existing implementation to kern_break, and call that from both sys_break and linux_brk. This also addresses a minor bug in linux_brk in that we now return the actual (rounded up) break address, rather than the requested value. Reviewed by: brooks (earlier version) Sponsored by: Turing Robotic Industries Differential Revision: https://reviews.freebsd.org/D16019 Notes: svn path=/head/; revision=335702
* Quiet unused fn warning for linuxulator w/o legacy syscallsEd Maste2018-06-251-1/+1
| | | | | | | Sponsored by: Turing Robotic Industries Notes: svn path=/head/; revision=335644
* Fix output of linprocfs stat entryChuck Tuffli2018-06-221-5/+49
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The Linux /proc/stat entry has grown over time v2.5.41 < user, nice, system, idle v2.5.41 user, nice, system, idle, iowait, irq v2.6.11 user, nice, system, idle, iowait, irq, softirq, steal v2.6.24 user, nice, system, idle, iowait, irq, softirq, steal, guest v2.6.32 > user, nice, system, idle, iowait, irq, softirq, steal, guest, guest_nice Some applications (e.g. nodejs) depend on the correct number of entries and will abort otherwise. Fix is to print the correct number of entries based on the value of osrelease set either in sysctl or the jail settings. Change is similar to approach used by illumos. Reviewed by: emaste, imp (mentor) Approved by: imp (mentor) Differential Revision: https://reviews.freebsd.org/D15858 Notes: svn path=/head/; revision=335516
* Fix the Linux kernel version number calculationChuck Tuffli2018-06-221-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | The Linux compatibility code was converting the version number (e.g. 2.6.32) in two different ways and then comparing the results. The linux_map_osrel() function converted MAJOR.MINOR.PATCH similar to what FreeBSD does natively. I.e. where major=v0, minor=v1, and patch=v2 v = v0 * 1000000 + v1 * 1000 + v2; The LINUX_KERNVER() macro, on the other hand, converted the value with bit shifts. I.e. where major=a, minor=b, and patch=c v = (((a) << 16) + ((b) << 8) + (c)) The Linux kernel uses the later format via the KERNEL_VERSION() macro in include/generated/uapi/linux/version.h Fix is to use the LINUX_KERNVER() macro in linux_map_osrel() as well as in the .trans_osrel functions. PR: 229209 Reviewed by: emaste, cem, imp (mentor) Approved by: imp (mentor) Differential Revision: https://reviews.freebsd.org/D15952 Notes: svn path=/head/; revision=335515
* linux_clone_thread: mark new thread as TDB_BORN.Konstantin Belousov2018-06-211-0/+4
| | | | | | | | | | | | | So that the ptrace code will catch it and report it to attached debugger. Enables debugging of threaded Linux binaries with FreeBSD debugger. Submitted by: Yanko Yankulov <yanko.yankulov@gmail.com> MFC after: 1 week Differential revision: https://reviews.freebsd.org/D15880 Notes: svn path=/head/; revision=335505
* linuxulator: handle V3 capget/capsetEd Maste2018-06-191-28/+49
| | | | | | | | | | | | | Linux 2.6.26 introduced 64-bit capability sets. Extend our stub implementation to handle both 32- and 64-bit. (We still report no capabilities in capget, and disallow any in capset.) Reviewed by: chuck Sponsored by: Turing Robotic Industries Inc. Differential Revision: https://reviews.freebsd.org/D15887 Notes: svn path=/head/; revision=335387
* linuxulator: add debugging for invalid capget/capset versionEd Maste2018-06-181-0/+10
| | | | | | | Sponsored by: Turing Robotic Industries Inc. Notes: svn path=/head/; revision=335327
* linsysfs: depend on linux_common module on arm64, as on amd64Ed Maste2018-06-181-1/+1
| | | | | | | Sponsored by: Turing Robotic Industries Notes: svn path=/head/; revision=335315
* Fix build of ndis with base gcc on i386Dimitry Andric2018-06-171-1/+1
| | | | | | | | | | | | | | Casting from rman_res_t to a pointer results in "cast to pointer from integer of different size" warnings with base gcc on i386, so use an intermediate cast to uintptr_t to suppress it. In this case, the I/O port range is effectively limited to the range of 0..65535. Reviewed by: imp MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D15746 Notes: svn path=/head/; revision=335297
* Add linprocfs support for min_free_kbytesChuck Tuffli2018-06-151-2/+23
| | | | | | | | | | | | | This adds linprocfs support for proc/sys/vm/min_free_kbytes which the free program requires for correct operation. The approach mirrors the approach used in illumos. Reviewed by: imp (mentor), emaste Approved by: imp (mentor) Differential Revision: https://reviews.freebsd.org/D15563 Notes: svn path=/head/; revision=335205
* linuxulator: do not include legacy syscalls on arm64Ed Maste2018-06-156-1/+64
| | | | | | | | | | | | | | | | | Existing linuxulator platforms (i386, amd64) support legacy syscalls, such as non-*at ones like open, but arm64 and other new platforms do not. Wrap these in #ifdef LINUX_LEGACY_SYSCALLS, #defined in the MD linux.h files. We may need finer grained control in the future but this is sufficient for now. Reviewed by: andrew Sponsored by: Turing Robotic Industries Differential Revision: https://reviews.freebsd.org/D15237 Notes: svn path=/head/; revision=335201
* Correct debug control for linuxulator faccessatEd Maste2018-06-151-1/+1
| | | | | | | | | | | | The Linuxulator provides per-syscall debug control via the compat.linux.debug sysctl. There's generally a 1:1 mapping between sysctl setting and syscall, but faccessat was controlled by the access setting, perhaps due to copy-paste. Sponsored by: Turing Robotic Industries Notes: svn path=/head/; revision=335200
* linprocfs: add TracerPid to /proc/pid/status.Konstantin Belousov2018-06-151-2/+2
| | | | | | | | | | Also fix the value of parent pid if the process is traced. Submitted by: Yanko Yankulov <yanko.yankulov@gmail.com> MFC after: 1 week Notes: svn path=/head/; revision=335199
* Add stubbed arm64 linuxulator /proc/cpuinfo handlerEd Maste2018-06-151-1/+27
| | | | | | | Sponsored by: Turing Robotic Industries Notes: svn path=/head/; revision=335198
* Regen after 335177 (rename sys_obreak to sys_break).Brooks Davis2018-06-142-5/+5
| | | | Notes: svn path=/head/; revision=335178
* Name the implementation of brk and sbrk sys_break().Brooks Davis2018-06-142-4/+3
| | | | | | | | | | | | | | | The break() system call was renamed (several times) starting in v3 AT&T UNIX when C was invented and break was a language keyword. The last vestage of a need for it to be called something else (eg obreak) was removed in r225617 which consistantly prefixed all syscall implementations. Reviewed by: emaste, kib (older version) Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D15638 Notes: svn path=/head/; revision=335177
* Oops, r335053 had an old version of the comment about 16-bit linux dev_tBruce Evans2018-06-131-11/+13
| | | | | | | translation. Notes: svn path=/head/; revision=335057
* Fix the encoding of major and minor numbers in 64-bit dev_t by restoringBruce Evans2018-06-132-5/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | the old encodings for the lower 16 and 32 bits and only using the higher 32 bits for unusually large major and minor numbers. This change breaks compatibility with the previous encoding (which was only used in -current). Fix truncation to (essentially) 16-bit dev_t in newnfs v3. Any encoding of device numbers gives an ABI, so it can't be changed without translations for compatibility. Extra bits give the much larger complication that the translations need to compress into fewer bits. Fortunately, more than 32 bits are rarely needed, so compression is rarely needed except for 16-bit linux dev_t where it was always needed but never done. The previous encoding moved the major number into the top 32 bits. Almost no translation code handled this, so the major number was blindly truncated away in most 32-bit encodings. E.g., for ffs, mknod(8) with major = 1 and minor = 2 gave dev_t = 0x10000002; ffs cannot represent this and blindly truncated it to 2. But if this mknod was run on any released version of FreeBSD, it gives dev_t = 0x102. ffs can represent this, but in the previous encoding it was not decoded, giving major = 0, minor = 0x102. The presence of bugs was most obvious for exporting dev_t's from an old system to -current, since bugs in newnfs augment them. I fixed oldnfs to support 32-bit dev_t in 1996 (r16634), but this regressed to 16-bit dev_t in newnfs, first to the old 16-bit encoding and then further in -current. E.g., old ad0 with major = 234, minor = 0x10002 had the correct (major, minor) number on the wire, but newnfs truncated this to (234, 2) and then the previous encoding shifted the major number into oblivion as seen by ffs or old applications. I first tried to fix this by translating on every ABI/API boundary, but there are too many boundaries and too many sloppy translations by blind truncation. So use the old encoding for the low 32 bits so that sloppy translations work no worse than before provided the high 32 bits are not set. Add some error checking for when bits are lost. Keep not doing any error checking for translations for almost everything in compat/linux. compat/freebsd32/freebsd32_misc.c: Optionally check for losing bits after possibly-truncating assignments as before. compat/linux/linux_stats.c: Depend on the representation being compatible with Linux's (or just with itself for local use) and spell some of the translations as assignments in a macro that hides the details. fs/nfsclient/nfs_clcomsubs.c: Essentially the same fix as in 1996, except there is now no possible truncation in makedev() itself. Also fix nearby style bugs. kern/vfs_syscalls.c: As for freebsd32. Also update the sysctl description to include file numbers, and change it to describe device ids as device numbers. sys/types.h: Use inline functions (wrapped by macros) since the expressions are now a bit too complicated for plain macros. Describe the encoding and some of the reasons for it. 16-bit compatibility didn't leave many reasonable choices for the 32-bit encoding, and 32-bit compatibility doesn't leave many reasonable choices for the 64-bit encoding. My choice is to put the 8 new minor bits in the low 8 bits of the top 32 bits. This minimizes discontiguities. Reviewed by: kib (except for rewrite of the comment in linux_stats.c) Notes: svn path=/head/; revision=335053
* Fix some bugs found while fixing the representation and translationBruce Evans2018-06-132-5/+3
| | | | | | | | | | | | | | | | | of 64-bit dev_t's (but not ones involving dev_t's). st_size was supposed to be clamped in cvtstat() and linux's copy_stat(), but the clamping code wasn't aware that st_size is signed, and also had an obfuscated off-by-1 value for the unsigned limit, so its effect was to produce a bizarre negative size instead of clamping. Change freebsd32's copy_ostat() to be no worse than cvtstat(). It was missing clamping and bzero()ing of padding. Reviewed by: kib (except a final fix of the clamp to the signed maximum) Notes: svn path=/head/; revision=335035
* Implement the ip_eth_mc_map() function in the LinuxKPI.Hans Petter Selasky2018-06-121-0/+14
| | | | | | | | MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=334993
* Implement the kstrtobool() and kstrtobool_from_user() functionsHans Petter Selasky2018-06-111-0/+42
| | | | | | | | | | | | in the LinuxKPI. Submitted by: Johannes Lundberg <johalun0@gmail.com> MFC after: 1 week Sponsored by: Mellanox Technologies Sponsored by: Limelight Networks Notes: svn path=/head/; revision=334958
* Implement the user_access_begin(), user_access_end(), usafe_get_user() andHans Petter Selasky2018-06-111-0/+13
| | | | | | | | | | | | unsafe_put_user() function macros in the LinuxKPI. Submitted by: Johannes Lundberg <johalun0@gmail.com> MFC after: 1 week Sponsored by: Mellanox Technologies Sponsored by: Limelight Networks Notes: svn path=/head/; revision=334953