summaryrefslogtreecommitdiff
path: root/sys/compat
Commit message (Collapse)AuthorAgeFilesLines
* Add ELF flag to disable ASLR stack gap.Konstantin Belousov2020-12-181-2/+1
| | | | | | | | | | | | Also centralize and unify checks to enable ASLR stack gap in a new helper exec_stackgap(). PR: 239873 Sponsored by: The FreeBSD Foundation MFC after: 1 week Notes: svn path=/head/; revision=368772
* Cleanups to *ERR* compat shims.John Baldwin2020-12-171-7/+7
| | | | | | | | | | | | | | - Use [u]intptr_t casts to convert pointers to integers. - Change IS_ERR* to return bool instead of long. Reviewed by: manu Obtained from: CheriBSD Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D27577 Notes: svn path=/head/; revision=368738
* Use the 't' modifier to print a ptrdiff_t.John Baldwin2020-12-161-1/+1
| | | | | | | | | | Reviewed by: imp Obtained from: CheriBSD Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D27576 Notes: svn path=/head/; revision=368685
* Improve handling of alternate settings in the USB stack.Hans Petter Selasky2020-12-151-5/+0
| | | | | | | | | | | | | | | | | Allow setting the alternate interface number to fail when there is only one alternate setting present, to comply with the USB specification. Refactor how iface->num_altsetting is computed. Bump the __FreeBSD_version due to change of core USB structure. PR: 251856 MFC after: 1 week Submitted by: Ma, Horse <Shichun.Ma@dell.com> Sponsored by: Mellanox Technologies // NVIDIA Networking Notes: svn path=/head/; revision=368659
* linux_dma: Ensure proper flags pass to allocators.Bryan Drewery2020-12-101-3/+3
| | | | | | | | | | | | | Possibly fixes the wrong flags being passed to the kernel allocators in linux_dma_alloc_coherent() and linux_dma_pool_alloc(). Reviewed by: hps MFC after: 2 weeks Sponsored by: Dell EMC Differential Revision: https://reviews.freebsd.org/D27508 Notes: svn path=/head/; revision=368524
* Prefer using the MIN() function macro over the min() inline functionHans Petter Selasky2020-12-072-2/+2
| | | | | | | | | | | | in the LinuxKPI. Linux defines min() to be a macro, while in FreeBSD min() is a static inline function clamping its arguments to "unsigned int". MFC after: 1 week Sponsored by: Mellanox Technologies // NVIDIA Networking Notes: svn path=/head/; revision=368406
* Move V4L feature declarations and DTrace provider definitions fromTijl Coosemans2020-12-062-19/+18
| | | | | | | | | | | | | | | | | linux_common.c to linux_util.c so they become available on i386. linux_common.c defines the linux_common kernel module but this module does not exist on i386 and linux_common.c is not included in the linux module. linux_util.c is included in the linux_common module on amd64 and the linux module on i386. Remove linux_common.c from files.i386 again. It was added recently in r367433 when the DTrace provider definitions were moved. The V4L feature declarations were moved to linux_common in r283423. Notes: svn path=/head/; revision=368384
* RegenKonstantin Belousov2020-12-045-9/+14
| | | | Notes: svn path=/head/; revision=368344
* Fix compat32 for ntp_adjtime(2).Konstantin Belousov2020-12-043-1/+88
| | | | | | | | | | | | | struct timex is not 32-bit safe, it uses longs for members. Provide translation. Reviewed by: brooks, cy Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D27471 Notes: svn path=/head/; revision=368343
* Allow the rbtree header file in the LinuxKPI to be used in standalone code.Hans Petter Selasky2020-12-041-0/+3
| | | | | | | | MFC after: 1 week Sponsored by: Mellanox Technologies // NVIDIA Networking Notes: svn path=/head/; revision=368336
* Allow the list header file in the LinuxKPI to be used in standalone code.Hans Petter Selasky2020-12-041-1/+4
| | | | | | | | | | Some style and spelling nits while at it. MFC after: 1 week Sponsored by: Mellanox Technologies // NVIDIA Networking Notes: svn path=/head/; revision=368335
* Use function macro for sema_init() in the LinuxKPI to limit macro expansion ↵Hans Petter Selasky2020-11-301-1/+1
| | | | | | | | | | scope. MFC after: 1 week Sponsored by: Mellanox Technologies // NVIDIA Networking Notes: svn path=/head/; revision=368182
* Make MAXPHYS tunable. Bump MAXPHYS to 1M.Konstantin Belousov2020-11-282-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Replace MAXPHYS by runtime variable maxphys. It is initialized from MAXPHYS by default, but can be also adjusted with the tunable kern.maxphys. Make b_pages[] array in struct buf flexible. Size b_pages[] for buffer cache buffers exactly to atop(maxbcachebuf) (currently it is sized to atop(MAXPHYS)), and b_pages[] for pbufs is sized to atop(maxphys) + 1. The +1 for pbufs allow several pbuf consumers, among them vmapbuf(), to use unaligned buffers still sized to maxphys, esp. when such buffers come from userspace (*). Overall, we save significant amount of otherwise wasted memory in b_pages[] for buffer cache buffers, while bumping MAXPHYS to desired high value. Eliminate all direct uses of the MAXPHYS constant in kernel and driver sources, except a place which initialize maxphys. Some random (and arguably weird) uses of MAXPHYS, e.g. in linuxolator, are converted straight. Some drivers, which use MAXPHYS to size embeded structures, get private MAXPHYS-like constant; their convertion is out of scope for this work. Changes to cam/, dev/ahci, dev/ata, dev/mpr, dev/mpt, dev/mvs, dev/siis, where either submitted by, or based on changes by mav. Suggested by: mav (*) Reviewed by: imp, mav, imp, mckusick, scottl (intermediate versions) Tested by: pho Sponsored by: The FreeBSD Foundation Differential revision: https://reviews.freebsd.org/D27225 Notes: svn path=/head/; revision=368124
* Linuxolator: Replace use of eventhandlers by sysent hooks.Konstantin Belousov2020-11-233-60/+43
| | | | | | | | | Reviewed by: markj Sponsored by: The FreeBSD Foundation Differential revision: https://reviews.freebsd.org/D27309 Notes: svn path=/head/; revision=367960
* freebsd32: take the _umtx_op struct definitions backKyle Evans2020-11-231-0/+21
| | | | | | | | | Providing these in freebsd32.h facilitates local testing/measuring of the structs rather than forcing one to locally recreate them. Sanity checking offsets/sizes remains in kern_umtx.c where these are typically used. Notes: svn path=/head/; revision=367943
* _umtx_op: move compat32 definitions back inKyle Evans2020-11-222-29/+0
| | | | | | | | These are reasonably compact, and a future commit will blur the compat32 lines by supporting 32-bit operations with the native _umtx_op. Notes: svn path=/head/; revision=367928
* Allow LinuxKPI types to be used in bootloaders, by checking for theHans Petter Selasky2020-11-182-3/+5
| | | | | | | | | | | | _STANDALONE definition. No functional change intended. MFC after: 1 week Sponsored by: Mellanox Technologies // NVIDIA Networking Notes: svn path=/head/; revision=367789
* linux(4) clone(2): Correctly handle CLONE_FS and CLONE_FILESConrad Meyer2020-11-171-8/+10
| | | | | | | | | | | | | | | | | | | | | | | | The two flags are distinct and it is impossible to correctly handle clone(2) without the assistance of fork1(). This change depends on the pwddesc split introduced in r367777. I've added a fork_req flag, FR2_SHARE_PATHS, which indicates that p_pd should be treated the opposite way p_fd is (based on RFFDG flag). This is a little ugly, but the benefit is that existing RFFDG API is preserved. Holding FR2_SHARE_PATHS disabled, RFFDG indicates both p_fd and p_pd are copied, while !RFFDG indicates both should be cloned. In Chrome, clone(2) is used with CLONE_FS, without CLONE_FILES, and expects independent fd tables. The previous conflation of CLONE_FS and CLONE_FILES was introduced in r163371 (2006). Discussed with: markj, trasz (earlier version) Differential Revision: https://reviews.freebsd.org/D27016 Notes: svn path=/head/; revision=367778
* Split out cwd/root/jail, cmask state from filedesc tableConrad Meyer2020-11-171-1/+1
| | | | | | | | | | | | | | | | No functional change intended. Tracking these structures separately for each proc enables future work to correctly emulate clone(2) in linux(4). __FreeBSD_version is bumped (to 1300130) for consumption by, e.g., lsof. Reviewed by: kib Discussed with: markj, mjg Differential Revision: https://reviews.freebsd.org/D27037 Notes: svn path=/head/; revision=367777
* unix(4): Enhance LOCAL_CREDS_PERSISTENT ABIConrad Meyer2020-11-171-0/+13
| | | | | | | | | | | | | | As this ABI is still fresh (r367287), let's correct some mistakes now: - Version the structure to allow for future changes - Include sender's pid in control message structure - Use a distinct control message type from the cmsgcred / sockcred mess Discussed with: kib, markj, trasz Differential Revision: https://reviews.freebsd.org/D27084 Notes: svn path=/head/; revision=367776
* linprocfs(5): Add rudimentary /proc/<pid>/mountinfoConrad Meyer2020-11-171-43/+163
| | | | | | | | | | This is used by some Linux programs using filehandles (r367773) to locate the mountpoint for a given fsid. Differential Revision: https://reviews.freebsd.org/D27136 Notes: svn path=/head/; revision=367775
* linux(4): Implement name_to_handle_at(), open_by_handle_at()Conrad Meyer2020-11-173-8/+117
| | | | | | | | | They are similar to our getfhat(2) and fhopen(2) syscalls. Differential Revision: https://reviews.freebsd.org/D27111 Notes: svn path=/head/; revision=367773
* umtx_op: reduce redundancy required for compat32Kyle Evans2020-11-172-0/+30
| | | | | | | | | | | | | | | | | | All of the compat32 variants are substantially the same, save for copyin/copyout (mostly). Apply the same kind of technique used with kevent here by having the syscall routines supply a umtx_copyops describing the operations needed. umtx_copyops carries the bare minimum needed- size of timespec and _umtx_time are used for determining if copyout is needed in the sem2_wait case. Reviewed by: kib MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D27222 Notes: svn path=/head/; revision=367744
* LinuxKPI: Exclude linux/acpi.h content on non-ACPI archs.Vladimir Kondratyev2020-11-141-0/+4
| | | | | | | | | | | | | LinuxKPI ACPI support is based on FreeBSD import of ACPICA which can be compiled only on aarch64, amd64 and i386. Ifdef-out broken parts on our side to avoid patching of vendor code. This fixes drm-devel-kmod build on powerpc64(le). Reported by: pkubaj Notes: svn path=/head/; revision=367673
* LinuxKPI: Implement ACPI bits required by drm-kmod in base systemEmmanuel Vadot2020-11-095-0/+475
| | | | | | | | | | | | | | | It includes: ACPI_HANDLE() implementation. AC and VIDEO ACPI events notification support. Replacement of hand-rolled GPLed _DSM method evaluation helpers with in-base ones. Submitted by: wulf Differential Revision: https://reviews.freebsd.org/D26603 Notes: svn path=/head/; revision=367521
* Make it possible to mount a fuse filesystem, such as squashfuse,Edward Tomasz Napierala2020-11-091-8/+36
| | | | | | | | | | | | from a Linux binary. Should come handy for AppImages. Reviewed by: asomers MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D26959 Notes: svn path=/head/; revision=367517
* kqueue: save space by using only one func pointer for assertionsMateusz Guzik2020-11-091-14/+6
| | | | Notes: svn path=/head/; revision=367498
* - add more linux socket options (sorted by value)Alexander Leidinger2020-11-085-30/+447
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - map those IPv4 / IPv6 socket options which exist in FreeBSD + most of them visually verified to have the same type/layout of arguments + not tested with linux programs to behave as intended - be more human readable for known options which are not handled - be more verbose for unhandled socket message flags we know about - print the jail ID in linux_msg if run in a jail - add possibility to print debug message about known missing parts only once - add multiple levels of sysctl linux.debug: 1: print debug messages, tell about unimplemented stuff (only once) 2: like 1, but also print messages about implemented but not tested stuff (only once) 3+: like 2, but no rate limiting of messages - increase default linux debug level from 1 to 3 We are a lot more verbose in as we need to be (e.g. some of the IP socket options which are the same, and share the same memory layout, and are believed to work). The reason is that we have no good testsuite to test those linux-bits. The LTP or other test suites like the python one, are not fully up to the task we need. As such the excessive messages about emulated but not tested socket options. IMO any MFC (possible, but most probably not by me) should set the default debug level to 1. Discussed with: trasz Notes: svn path=/head/; revision=367481
* linux(4): Fix loadable modules after r367395Conrad Meyer2020-11-063-20/+20
| | | | | | | | | | | | | | | | Move dtrace SDT definitions into linux_common module code. Also, build linux_dummy.c into the linux_common kld -- we don't need separate versions of these stubs for 32- and 64-bit emulation. Reported by: several PR: 250897 Discussed with: emaste, trasz Tested by: John Kennedy, Yasuhiro KIMURA, Oleg Sidorkin X-MFC-With: r367395 Differential Revision: https://reviews.freebsd.org/D27124 Notes: svn path=/head/; revision=367433
* linux(4): Deduplicate unimpl/dummy syscall handlersConrad Meyer2020-11-051-0/+159
| | | | | | | | | | No functional change. Reviewed by: emaste, trasz Differential Revision: https://reviews.freebsd.org/D27099 Notes: svn path=/head/; revision=367395
* Add sbuf streaming mode to pseudofs(9), use in linprocfs(5)Conrad Meyer2020-11-051-5/+1
| | | | | | | | | | | | | | | | | Add a pseudofs node flag 'PFS_AUTODRAIN', which automatically emits sbuf contents to the caller when the sbuf buffer fills. This is only permissible if the corresponding PFS node fill function can sleep whenever it appends to the sbuf. linprocfs' /proc/self/maps node happens to meet this requirement. Streaming out the file as it is composed avoids truncating the output and also avoids preallocating a very large buffer. Reviewed by: markj; earlier version: emaste, kib, trasz Differential Revision: https://reviews.freebsd.org/D27047 Notes: svn path=/head/; revision=367362
* Unbreak buildworld after r367339.Edward Tomasz Napierala2020-11-041-2/+0
| | | | | | | | MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=367348
* Add linux_to_bsd_errtbl[], mapping Linux errnos to their BSD counterparts.Edward Tomasz Napierala2020-11-043-0/+177
| | | | | | | | | | | | This will be used by fuse(4). Reviewed by: asomers MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D26974 Notes: svn path=/head/; revision=367339
* linux(4): Improve netlink diagnosticsConrad Meyer2020-11-032-17/+41
| | | | | | | | | | | | | | | | Add some missing netlink_family definitions and produce vaguely human-readable error messages for those definitions, like we used to do for just ROUTE and KOBJECT_UEVENTS. Additionally, if we know it's a netfilter socket but didn't find it in the table, fall back to printing that instead of the generic handler ("socket domain 16, ..."). No change to the emulator correctness, just mildly improved diagnostics for gaps. Notes: svn path=/head/; revision=367303
* Make linux_errtbl[] static.Edward Tomasz Napierala2020-11-032-3/+1
| | | | | | | | | MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D27004 Notes: svn path=/head/; revision=367301
* Fix rookie mistake - it's nitems(), not sizeof().Edward Tomasz Napierala2020-11-031-1/+1
| | | | | | | | | Reported by: xtouqh_icloud.com MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=367298
* linux(4) prctl(2): Implement PR_[GS]ET_DUMPABLEConrad Meyer2020-11-032-4/+46
| | | | | | | | | | | | | | | Proxy the flag to the roughly analogous FreeBSD procctl 'TRACE'. TRACE-disabled processes are not coredumped, and Linux !DUMPABLE processes can not be ptraced. There are some additional semantics around ownership of files in the /proc/[pid] pseudo-filesystem, which we do not attempt to emulate correctly at this time. Reviewed by: markj (earlier version) Differential Revision: https://reviews.freebsd.org/D27015 Notes: svn path=/head/; revision=367290
* linux(4): Emulate Linux SOL_SOCKET:SO_PASSCREDConrad Meyer2020-11-031-0/+8
| | | | | | | | | | | | This is required by some major linux applications, such as Chrome and Firefox. (As well as Electron-using applications, which are essentially a bundled version of Chrome.) Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D27012 Notes: svn path=/head/; revision=367288
* linux(4): style: Eliminate dead 'break' after 'return'Conrad Meyer2020-11-031-1/+0
| | | | | | | No functional change. Notes: svn path=/head/; revision=367286
* linux(4): Quiesce unrecognized ioctl warning for F2FS queryConrad Meyer2020-11-022-0/+6
| | | | | | | | | | | | | | | | On Linux, sqlite probes for underlying F2FS filesystems that support certain kinds of atomic update with this ioctl. The expected result on non-F2FS filesystem (i.e., all FreeBSD filesystems) is any error value. Minimally implement the ioctl and avoid the warning message. (This shows up in Linux Chrome, which embeds sqlite.) Reviewed by: emaste, trasz Differential Revision: https://reviews.freebsd.org/D27050 Notes: svn path=/head/; revision=367279
* linux(4): Deduplicate ioctl range construction with a helper macroConrad Meyer2020-11-022-68/+33
| | | | | | | | | | No functional change. Reviewed by: emaste, trasz Differential Revision: https://reviews.freebsd.org/D27049 Notes: svn path=/head/; revision=367278
* linux(4): Disambiguate identical ioctl errors in distinct pathsConrad Meyer2020-11-021-4/+4
| | | | | | | | | | And stop truncating the full ioctl number in the error message. Reviewed by: emaste Differential Revision: https://reviews.freebsd.org/D27048 Notes: svn path=/head/; revision=367267
* linux(4): Add missing clone(2) flagsConrad Meyer2020-10-311-0/+12
| | | | Notes: svn path=/head/; revision=367190
* linux(4): Quiesce warning about madvise(..., -1)Conrad Meyer2020-10-301-0/+10
| | | | | | | | | | | | | | | This API misuse is intended to produce an error value to detect certain bogus stub implementations of MADV_WIPEONFORK. We don't need to log a warning about it. Example: https://boringssl.googlesource.com/boringssl/+/ad5582985cc6b89d0e7caf0d9cc7e301de61cf66%5E%21/ Reviewed by: emaste, trasz Differential Revision: https://reviews.freebsd.org/D27017 Notes: svn path=/head/; revision=367182
* Make linprocfs(4) print a warning when there's not enough room to fillEdward Tomasz Napierala2020-10-291-0/+4
| | | | | | | | | | | | | /proc/self/maps. Submitted by: dchagin (earlier version) Reviewed by: emaste (earlier version) MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D20576 Notes: svn path=/head/; revision=367139
* Fix typo.Edward Tomasz Napierala2020-10-291-1/+1
| | | | | | | | MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=367135
* Add defines for Linux errno values and use them to make linux_errtbl[]Edward Tomasz Napierala2020-10-295-97/+301
| | | | | | | | | | | | | more readable. While here, add linux_check_errtbl() function to make sure we don't leave holes. No objections: emaste (earlier version) MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D26972 Notes: svn path=/head/; revision=367132
* Make linux_errtbl a bit more readable by using named initializers.Edward Tomasz Napierala2020-10-281-98/+108
| | | | | | | | | MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D26970 Notes: svn path=/head/; revision=367106
* Fix misnomer - linux_to_bsd_errno() does the exact opposite.Edward Tomasz Napierala2020-10-273-3/+3
| | | | | | | | | | Reported by: arichardson MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D26965 Notes: svn path=/head/; revision=367079
* linux: silence renameat2 flags warningMateusz Guzik2020-10-261-0/+8
| | | | | | | Hogs the console while building the Linux kernel in a Ubuntu Focal jail. Notes: svn path=/head/; revision=367066