aboutsummaryrefslogtreecommitdiff
path: root/sys/compat/linux/linux.h
Commit message (Collapse)AuthorAgeFilesLines
* linux.h: don't redefine lower_32_bits if already definedWarner Losh2024-10-151-0/+2
| | | | | | | | | | | systrace.c fails to build if we're using a common compiler.h for both openzfs and linuxkpi. The issue is easy enough to fix: don't redefined lower_32_bits if it's already defined in linux.h, since it's the least 'standardized'. This will allow systrace.c to build using an equivalent macro. MFC After: 3 days Sponsored by: Netflix
* linux(4): Update my copyrights, add SPDX tagDmitry Chagin2023-08-171-0/+2
|
* sys: Remove $FreeBSD$: two-line .h patternWarner Losh2023-08-161-2/+0
| | | | Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
* linux(4): Uniformly dev_t arguments translationDmitry Chagin2023-04-281-0/+68
| | | | | | | | | | | | | | | | | | The two main uses of dev_t are in struct stat and as a parameter of the mknod system calls. As of version 2.6.0 of the Linux kernel, dev_t is a 32-bit quantity with 12 bits set asaid for the major number and 20 for the minor number. The in-kernel dev_t encoded as MMMmmmmm, where M is a hex digit of the major number and m is a hex digit of the minor number. The user-space dev_t encoded as mmmM MMmm, where M and m is the major and minor numbers accordingly. This is downward compatible with legacy systems where dev_t is 16 bits wide, encoded as MMmm. In glibc dev_t is a 64-bit quantity, with 32-bit major and minor numbers, encoded as MMMM Mmmm mmmM MMmm. This is downward compatible with the Linux kernel and with legacy systems where dev_t is 16 bits wide. In the FreeBSD dev_t is a 64-bit quantity. The major and minor numbers are encoded as MMMmmmMm, therefore conversion of the device numbers between Linux user-space and FreeBSD kernel required.
* linux(4): Move dev_t type declaration under /compat/linuxDmitry Chagin2023-04-281-0/+5
| | | | | As of version 2.6.0 of the Linux kernel, dev_t is a 32-bit unsigned integer on all platforms. Move it into the MI linux.h under /compat/linux.
* linux(4): Migrate to IfAPIDmitry Chagin2023-03-041-2/+2
| | | | | | | | | Migrate linux and linprocfs to use the IfAPI interfaces instead of direct ifnet accesses. The code initially writed by jhibbits@, and adapted by me to 3ab3c9c2. Reviewed by: jhibbits Differential Revision: https://reviews.freebsd.org/D38735
* Revert "Port Linuxulator to IfAPI"Justin Hibbits2023-02-211-2/+2
| | | | | | | | Revert pending netlink fixes, and further fixes to this. This reverts commit 52d984831d82d97dc132d0d57fca6ee89572799b. Requested by: dchagin
* Port Linuxulator to IfAPIJustin Hibbits2023-02-141-2/+2
| | | | | | Reviewed by: dchagin Sponsored by: Juniper Networks, Inc. Differential Revision: https://reviews.freebsd.org/D38349
* linux(4): Move use_real_names knob to the linux.cDmitry Chagin2023-02-141-0/+10
| | | | | | | | | | | | MI linux.[c|h] are the module independent in terms of the Linux emulation layer (ie, intended for both ISA - 32 & 64 bit), analogue of MD linux.h. There must be a code here that cannot be placed into the corresponding by common sense MI source and header files, i.e., code is machine independent, but ISA dependent. For the use_real_names knob, the code must be placed into the linux_socket.[c|h], however linux_socket is ISA dependent. MFC after: 2 weeks
* linux(4): Cleanup sys/queue.h from linux.hDmitry Chagin2023-02-141-2/+0
| | | | | | Leftover after converting futexes to the umtx API. NFC after: 2 weeks
* linux(4): Convert mount exported flags for statfs system calls.Dmitry Chagin2023-01-281-0/+15
| | | | MFC after: 1 week
* linuxolator: add netlink supportAlexander V. Chernikov2022-10-011-0/+3
| | | | | | | | | | | | | | | | | Add the glue code to support netlink in Linuxolator. linux_common(4) now depends on netlink(4). All netlink protocol constants are consistent with the Linux version. However, certain OS-specific constants such as AF_INET6, interface flags or default routing table id, are different between FreeBSD and Linux. Thus, it may be needed to rewrite some message parts or even rewrite the whole message, adding or removing some TLVs. The core netlink implementation code provides efficient rewriting callbacks which Linuxolator now uses. Reviewed by: dchagin Differential Revision: https://reviews.freebsd.org/D36361 MFC after: 2 months
* linux(4): Trace Linux l_sigset_t.Dmitry Chagin2022-06-221-0/+5
| | | | MFC after: 2 weeks
* linux(4): Fix the type of a constant in the signal mask macroDmitry Chagin2022-05-301-2/+2
| | | | | | | | | | | Since l_sigset_t is 64-bit unsigned on all Linuxulators, fix the type of a constant in the signal mask manipulation macro. The suffix L indicates type long which is 32-bit on i386, therefore, bitwise operations between a 32-bit constant and 64-bit signal mask lead to the wrong result. Pointy hat to: dchagin MFC after: 2 weeks
* linux(4): Reduce duplication between MD parts of the LinuxulatorDmitry Chagin2022-05-301-0/+5
| | | | | | | Move sigprocmask actions defines under compat/linux, they are identical across all Linux architectures. MFC after: 2 weeks
* linux: add sysctl to pass untranslated interface namesAlexander V. Chernikov2022-01-171-6/+0
| | | | | | Reviewed by: kib MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D33792
* linux(4): Add struct clone_args for future clone3 system call.Dmitry Chagin2021-08-121-0/+2
| | | | | | | | | In preparation for clone3 system call add struct clone_args and use it in clone implementation. Move all of clone related bits to the newly created linux_fork.h header. Differential revision: https://reviews.freebsd.org/D31474 MFC after: 2 weeks
* linux(4): Reimplement futexes using umtx.Dmitry Chagin2021-07-291-3/+0
| | | | | Differential Revision: https://reviews.freebsd.org/D31236 MFC after: 2 weeks
* linux(4): Allow musl brand to use FUTEX_REQUEUE op.Dmitry Chagin2021-07-201-0/+5
| | | | | | | | | Initial patch from submitter was adapted by me to prevent unconditional FUTEX_REQUEUE use. PR: 255947 Submitted by: Philippe Michaud-Boudreault Differential Revision: https://reviews.freebsd.org/D30332
* Drop "All rights reserved" from my copyright statements.Dmitry Chagin2021-07-201-2/+1
| | | | | | | | Add email and fixup years while here. Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D30912 MFC after: 2 weeks
* linux(4): Rework Linux ppoll system call.Dmitry Chagin2021-06-221-0/+17
| | | | | | | | | | | | | | | | | | For now the Linux emulation layer uses in kernel ppoll(2) without conversion of user supplied fd 'events', and does not convert the kernel supplied fd 'revents'. At least POLLRDHUP is handled by FreeBSD differently than by Linux. Seems that Linux silencly ignores POLLRDHUP on non socket fd's unlike FreeBSD, which does more strictly check and fails. Rework the Linux ppoll, using kern_poll and converting 'events' and 'revents' values. While here, move poll events defines to the MI part of code as they mostly identical on all arches except arm. Differential Revision: https://reviews.freebsd.org/D30716 MFC after: 2 weeks
* linux: implement statx(2)Philippe Michaud-Boudreault2021-06-081-0/+42
| | | | | | PR: 252106 Reviewed By: dchagin Differential Revision: https://reviews.freebsd.org/D30466
* linux(4): Improve netlink diagnosticsConrad Meyer2020-11-031-2/+8
| | | | | | | | | | | | | | | | 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
* Add defines for Linux errno values and use them to make linux_errtbl[]Edward Tomasz Napierala2020-10-291-0/+1
| | | | | | | | | | | | | 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
* Fix misnomer - linux_to_bsd_errno() does the exact opposite.Edward Tomasz Napierala2020-10-271-1/+1
| | | | | | | | | | 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
* Tweak linux(4) socket(2) debug messages.Edward Tomasz Napierala2020-10-241-0/+4
| | | | | | | | | MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D26900 Notes: svn path=/head/; revision=367001
* Get rid of sv_errtbl and SV_ABI_ERRNO().Edward Tomasz Napierala2020-09-171-0/+2
| | | | | | | | | Reviewed by: kib Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D26388 Notes: svn path=/head/; revision=365832
* linux: reposition the comment for bsd_to_linux_bits/linux_to_bsd_bitsKyle Evans2020-06-291-3/+2
| | | | | | | | | | | rpokala notes that splitting the definitions like this is kind of silly, since the comment applies to both. Move the comment up (or the definition down, depending on your perspective on life) accordingly. Reported by: rpokala Notes: svn path=/head/; revision=362786
* linuxolator: implement memfd_create syscallKyle Evans2020-06-291-0/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This effectively mirrors our libc implementation, but with minor fudging -- name needs to be copied in from userspace, so we just copy it straight into stack-allocated memfd_name into the correct position rather than allocating memory that needs to be cleaned up. The sealing-related fcntl(2) commands, F_GET_SEALS and F_ADD_SEALS, have also been implemented now that we support them. Note that this implementation is still not quite at feature parity w.r.t. the actual Linux version; some caveats, from my foggy memory: - Need to implement SHM_GROW_ON_WRITE, default for memfd (in progress) - LTP wants the memfd name exposed to fdescfs - Linux allows open() of an fdescfs fd with O_TRUNC to truncate after dup. (?) Interested parties can install and run LTP from ports (devel/linux-ltp) to confirm any fixes. PR: 240874 Reviewed by: kib, trasz Differential Revision: https://reviews.freebsd.org/D21845 Notes: svn path=/head/; revision=362769
* 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
* Make linux(4) create /dev/shm. Linux applications often expectEdward Tomasz Napierala2019-11-061-0/+3
| | | | | | | | | | | | | a tmpfs to be mounted there, and because they like to verify it's actually a mountpoint, a symlink won't do. Reviewed by: dchagin (earlier version) MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D20333 Notes: svn path=/head/; revision=354413
* linux: futex_mtx should follow futex_listYuri Pankov2019-10-181-0/+1
| | | | | | | | | | | Move futex_mtx to linux_common.ko for amd64 and aarch64 along with respective list/mutex init/destroy. PR: 240989 Reported by: Alex S <iwtcex@gmail.com> Notes: svn path=/head/; revision=353725
* linux: provide just one instance of futex_listYuri Pankov2019-10-181-0/+2
| | | | | | | | | | | | | | Move futex_list definition to linux.c which is included once in linux.ko (i386) and in linux_common.ko (amd64 and aarch64) allowing 32/64 bit linux programs to access the same futexes in the latter case. PR: 240989 Reviewed by: dchagin Differential Revision: https://reviews.freebsd.org/D22073 Notes: svn path=/head/; revision=353724
* Our bsd_to_linux_sockaddr() and linux_to_bsd_sockaddr() functionsDmitry Chagin2019-05-131-0/+11
| | | | | | | | | | | | | | | | | | | | | | alter the userspace sockaddr to convert the format between linux and BSD versions. That's the minimum 3 of copyin/copyout operations for one syscall. Also some syscall uses linux_sa_put() and linux_getsockaddr() when load sockaddr to userspace or from userspace accordingly. To avoid this chaos, especially converting sockaddr in the userspace, rewrite these 4 functions to convert sockaddr only in kernel and leave only 2 of this functions. Also in order to reduce duplication between MD parts of the Linuxulator put struct sockaddr conversion functions that are MI out into linux_common module. PR: 232920 MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D20157 Notes: svn path=/head/; revision=347533
* Rewrite linux_ifflags() in more readable Linuxulator style.Dmitry Chagin2019-05-061-0/+20
| | | | | | | | | Reviewed by: emaste MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D20146 Notes: svn path=/head/; revision=347203
* In order to reduce duplication between MD parts of the LinuxulatorDmitry Chagin2019-05-031-0/+17
| | | | | | | | | | | | | | | | | | | move bits that are MI out into the headers in compat/linux. For that remove bogus _packed attribute from struct l_sockaddr and use MI types for struct members. And continue to move into the linux_common module a code that is intended for both Linuxulator modules (both instruction set - 32 & 64 bit) or for external modules like linsysfs or linprocfs. To avoid header pollution introduce new sys/compat/linux_common.h header. Reviewed by: emaste MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D20137 Notes: svn path=/head/; revision=347052
* Rework signal code to allow using it by other modules, like linprocfs:Dmitry Chagin2015-05-241-0/+95
1. Linux sigset always 64 bit on all platforms. In order to move Linux sigset code to the linux_common module define it as 64 bit int. Move Linux sigset manipulation routines to the MI path. 2. Move Linux signal number definitions to the MI path. In general, they are the same on all platforms except for a few signals. 3. Map Linux RT signals to the FreeBSD RT signals and hide signal conversion tables to avoid conversion errors. 4. Emulate Linux SIGPWR signal via FreeBSD SIGRTMIN signal which is outside of allowed on Linux signal numbers. PR: 197216 Notes: svn path=/head/; revision=283474