aboutsummaryrefslogtreecommitdiff
path: root/sys/compat/linux
Commit message (Collapse)AuthorAgeFilesLines
* 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
* Make MAXPHYS tunable. Bump MAXPHYS to 1M.Konstantin Belousov2020-11-281-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-59/+42
| | | | | | | | | Reviewed by: markj Sponsored by: The FreeBSD Foundation Differential revision: https://reviews.freebsd.org/D27309 Notes: svn path=/head/; revision=367960
* 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
* 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
* 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
* 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
* - add more linux socket options (sorted by value)Alexander Leidinger2020-11-085-29/+446
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - 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
* 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-66/+31
| | | | | | | | | | 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
* 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
* linux: add missing conversions for compat.linux.use_emul_path handlingMateusz Guzik2020-10-262-44/+114
| | | | Notes: svn path=/head/; revision=367065
* Tweak linux(4) socket(2) debug messages.Edward Tomasz Napierala2020-10-242-0/+18
| | | | | | | | | MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D26900 Notes: svn path=/head/; revision=367001
* Further improve prctl(2) debug.Edward Tomasz Napierala2020-10-242-0/+15
| | | | | | | | | MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D26916 Notes: svn path=/head/; revision=367000
* Improve prctl(2) debug.Edward Tomasz Napierala2020-10-232-0/+10
| | | | | | | | | MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D26899 Notes: svn path=/head/; revision=366967
* Make linux(4) warn about unsupported socket(2) types.Edward Tomasz Napierala2020-10-211-1/+4
| | | | | | | | | MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D25680 Notes: svn path=/head/; revision=366915
* Fix potential race condition in linux stat(2).Edward Tomasz Napierala2020-10-203-7/+22
| | | | | | | | | | Reviewed by: kib MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D25618 Notes: svn path=/head/; revision=366899
* Add compat.linux.dummy_rlimits, and disable by default.Edward Tomasz Napierala2020-10-183-0/+9
| | | | | | | | | | | | Turns out the dummy rlimits fix prlimit(1), but break su(8) (login-1:4.5-1ubuntu2) - although not sudo(8), for some reason. MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D26814 Notes: svn path=/head/; revision=366809
* Set default stack size for Linux apps to 8MB. This matches Linux'Edward Tomasz Napierala2020-10-163-0/+30
| | | | | | | | | | | | | | | | | | | | defaults, makes core files smaller, and fixes applications which use pthread_join(3) in a wrong way, namely Steam. This is based on a patch submitted by Jason Yang, which I've reworked to set the limit instead of only changing the value reported (which is enough to fix the bug for Linux pthreads, but could be confusing). PR: 248225 Submitted by: Jason_YH_Yang at wistron.com (earlier version) Analyzed by: Alex S <iwtcex@gmail.com> Reviewed by: emaste MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D26778 Notes: svn path=/head/; revision=366756
* Make linux getrlimit(2) and prlimit(2) return something reasonableEdward Tomasz Napierala2020-10-162-6/+48
| | | | | | | | | | | | for linux-specific limits. Fixes prlimit (util-linux-2.31.1-0.4ubuntu3.7). Reviewed by: emaste MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D26777 Notes: svn path=/head/; revision=366749
* Do not leak oldvmspace if image activation failedKonstantin Belousov2020-09-231-1/+1
| | | | | | | | | | | | | | | | and current address space is already destroyed, so kern_execve() terminates the process. While there, clean up some internals of post_execve() inlined in init_main. Reported by: Peter <pmc@citylink.dinoex.sub.org> Reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D26525 Notes: svn path=/head/; revision=366085
* Reduce code duplication by introducing linux_copyout_sockaddr()Edward Tomasz Napierala2020-09-171-40/+26
| | | | | | | | | | | | helper function. No functional changes. Reviewed by: emaste MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D25804 Notes: svn path=/head/; revision=365834
* Add support for SOUND_MIXER_WRITE_MONITOR ioctl. Fixes alsamixer(1)Edward Tomasz Napierala2020-09-172-0/+5
| | | | | | | | | | | | on my x220. Reviewed by: emaste MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D25806 Notes: svn path=/head/; revision=365833
* Get rid of sv_errtbl and SV_ABI_ERRNO().Edward Tomasz Napierala2020-09-173-1/+18
| | | | | | | | | Reviewed by: kib Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D26388 Notes: svn path=/head/; revision=365832
* Add emulation support for the Linux kcov(4) ioctl API.Mark Johnston2020-09-042-0/+48
| | | | | | | | | | This makes it possible to run an unmodified Linux syzkaller executor against the Linuxulator, and have it gather code coverage information. Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=365319
* compat: clean up empty lines in .c and .h filesMateusz Guzik2020-09-0116-29/+0
| | | | Notes: svn path=/head/; revision=365080
* cache: drop the always curthread argument from reverse lookup routinesMateusz Guzik2020-08-241-1/+1
| | | | | | | | | Note VOP_VPTOCNP keeps getting it as temporary compatibility for zfs. Tested by: pho Notes: svn path=/head/; revision=364633
* vfs: drop the error parameter from vn_isdisk, introduce vn_isdisk_errorMateusz Guzik2020-08-191-2/+2
| | | | | | | Most consumers pass NULL. Notes: svn path=/head/; revision=364372
* linux: add sysctl compat.linux.use_emul_pathMateusz Guzik2020-08-186-137/+275
| | | | | | | | | | | | | | | | This is a step towards facilitating jails with only Linux binaries. Supporting emul_path adds path lookups which are completely spurious if the binary at hand runs in a Linux-based root directory. It defaults to on (== current behavior). make -C /root/linux-5.3-rc8 -s -j 1 bzImage: use_emul_path=1: 101.65s user 68.68s system 100% cpu 2:49.62 total use_emul_path=0: 101.41s user 64.32s system 100% cpu 2:45.02 total Notes: svn path=/head/; revision=364366
* Fix handling of ancillary data on non-AF_UNIX Linux sockets.Mark Johnston2020-08-181-1/+2
| | | | | | | | | | | | | | | | After r340674, the "continue" would restart the loop without having updated clen, resulting in an infinite loop. Restore the old behaviour of simply ignoring all control messages on such sockets, since we currently only implement handling for AF_UNIX-specific messages. Reported by: syzkaller Reviewed by: tijl MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D26093 Notes: svn path=/head/; revision=364346
* Remove "emulation" of clone(CLONE_PARENT | CLONE_THREAD).Mark Johnston2020-08-171-5/+3
| | | | | | | | | | | On Linux this is supposed to result in EINVAL. Reported by: syzkaller MFC after: 1 week Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=364329
* Fix a lock leak when emulating futex(FUTEX_WAIT_BITSET).Mark Johnston2020-08-171-0/+1
| | | | | | | | | Reported by: syzkaller MFC after: 1 week Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=364328
* Skip Linux madvise(MADV_DONTNEED) on unmanaged objects.Mark Johnston2020-08-171-0/+2
| | | | | | | | | | | | | | | | vm_object_madvise() is a no-op for unmanaged objects, but we should also limit the scope of mappings on which pmap_remove() is called. In particular, with the WIP largepage shm objects patch the kernel must remove mappings of such objects along superpage boundaries, and without this check Linux madvise(MADV_DONTNEED) could violate that requirement. Reviewed by: alc, kib MFC with: r362631 Sponsored by: Juniper Networks, Klara Inc. Differential Revision: https://reviews.freebsd.org/D26084 Notes: svn path=/head/; revision=364317