]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
3 years agoMFC r350079:
Philip Paeps [Fri, 28 Aug 2020 08:13:49 +0000 (08:13 +0000)]
MFC r350079:

tzsetup: upgrade to zone1970.tab

zone.tab is deprecated.  Install zone1970.tab alongside it, and use it
for tzsetup(8).  This is also useful for other applications that need
the modern better maintained file.

PR: 243394
Submitted by: tmunro

3 years agoRename stable/12 to 12.2-PRERELEASE, marking the start of the
Glen Barber [Fri, 28 Aug 2020 00:00:37 +0000 (00:00 +0000)]
Rename stable/12 to 12.2-PRERELEASE, marking the start of the
12.2 release cycle.

Approved by: re (implicit)
Sponsored by: Rubicon Communications, LLC (netgate.com)

3 years agoMFC r362943:
Edward Tomasz Napierala [Thu, 27 Aug 2020 19:44:08 +0000 (19:44 +0000)]
MFC r362943:

Make linux(4) man page also mention /compat/linux/dev.

Sponsored by: The FreeBSD Foundation

3 years agoMFC r362935:
Edward Tomasz Napierala [Thu, 27 Aug 2020 19:42:52 +0000 (19:42 +0000)]
MFC r362935:

Make the linux rc script use linrdlnk by default.

This fixes Linux gettyname(3), with caveats (see PR).

PR: kern/240767
Sponsored by: The FreeBSD Foundation

3 years agoMFC r354690:
Edward Tomasz Napierala [Thu, 27 Aug 2020 19:41:31 +0000 (19:41 +0000)]
MFC r354690:

Add 'linux_mounts_enable' rc.conf(5) variable, to make it possible
to disable mounting Linux-specific filesystems under /compat/linux
when 'linux_enable' is set to YES.

Relnotes: yes
Sponsored by: The FreeBSD Foundation

3 years agoMFC r354458:
Edward Tomasz Napierala [Thu, 27 Aug 2020 19:40:33 +0000 (19:40 +0000)]
MFC r354458:

Extend the linux rc script to mount the neccessary file systems,
set ELF fallback brand, and load pty(4).

Sponsored by: The FreeBSD Foundation

3 years agoMFC r352999:
Edward Tomasz Napierala [Thu, 27 Aug 2020 19:37:28 +0000 (19:37 +0000)]
MFC r352999:

Rename etc/rc.d/abi to etc/rc.d/linux; after moving out the SysV IPC stuff
it's entirely linux-specific.

MFC r353054:

Add rcvar back to the linux rc script.  Without it it was enabled
unconditionally.

Sponsored by: The FreeBSD Foundation

3 years agoMFC r352836:
Edward Tomasz Napierala [Thu, 27 Aug 2020 19:35:02 +0000 (19:35 +0000)]
MFC r352836:

Move the SysV IPC stuff out of the 'abi' rc script, into a new one:
'sysvipc' - it has nothing to do with ABIs, and I'd like to later
rename 'abi' to 'linux', which better describes its purpose and also
matches the rcvar name.

Sponsored by: The FreeBSD Foundation

3 years agoMFC r363995
Vincenzo Maffione [Thu, 27 Aug 2020 19:12:39 +0000 (19:12 +0000)]
MFC r363995

em(4): honor vlanhwtag offload

The FreeBSD em driver fails to properly reset the VME flag
in the e1000 CTRL register oneg the following ifconfig command

    ifconfig em1 -vlanhwtag

Tested on the e1000 device emulated by QEMU, and on a real
NIC (chip=0x10d38086).

PR:     236584
Submitted by:    murat@sunnyvalley.io
Reported by:     murat@sunnyvalley.io
Differential Revision:  https://reviews.freebsd.org/D25286

3 years agoMFC r364410:
Mark Johnston [Thu, 27 Aug 2020 14:51:44 +0000 (14:51 +0000)]
MFC r364410:
Remove an unused parameter from map_table().

3 years agoMFC r364437:
Mark Johnston [Thu, 27 Aug 2020 14:50:48 +0000 (14:50 +0000)]
MFC r364437:
Remove non-FreeBSD ifdefs from dt_link.c.

3 years agoMFC r354621-r354623 by imp: scsi_da state machine improvements
Andriy Gapon [Thu, 27 Aug 2020 13:38:20 +0000 (13:38 +0000)]
MFC r354621-r354623 by imp: scsi_da state machine improvements

r354621
Require and enforce that dareprobe() has to be called with the periph lock held.

r354622
Update the softc state of the da driver before releasing the CCB.

r354623
Add asserts for some state transitions

3 years agoMFC r364423:
Konstantin Belousov [Thu, 27 Aug 2020 00:32:11 +0000 (00:32 +0000)]
MFC r364423:
dl_iterate_phdr(3): provide exclusive locking for callback when statically linked.

3 years agoMFC r364426: ipfw: style(9) fixes
Ed Maste [Thu, 27 Aug 2020 00:28:41 +0000 (00:28 +0000)]
MFC r364426: ipfw: style(9) fixes

Submitted by: Neel Chauhan <neel AT neelc DOT org>

3 years agoMFC r358924:
Navdeep Parhar [Wed, 26 Aug 2020 23:41:46 +0000 (23:41 +0000)]
MFC r358924:

cxgbe(4): Do not display error messages related to the CLIP table if
it's not in use by TOE or KTLS.

3 years agoMFC r340023 (by jhb@), r362905, r362938, and r363167.
Navdeep Parhar [Wed, 26 Aug 2020 23:21:26 +0000 (23:21 +0000)]
MFC r340023 (by jhb@), r362905, r362938, and r363167.

r340023:
Check cannot_use_txpkts() rather than needs_tso() in add_to_txpkts().

Currently this is a no-op, but will matter in the future when
cannot_use_txpkts() starts checking other conditions than just
needs_tso().

r362905:
cxgbe(4): changes in the Tx path to help increase tx coalescing.

- Ask the firmware for the number of frames that can be stuffed in one
  work request.

- Modify mp_ring to increase the likelihood of tx coalescing when there
  are just one or two threads that are doing most of the tx.  Add teeth
  to the abdication mechanism by pushing the consumer lock into mp_ring.
  This reduces the likelihood that a consumer will get stuck with all
  the work even though it is above its budget.

- Add support for coalesced tx WR to the VF driver.  This, with the
  changes above, results in a 7x improvement in the tx pps of the VF
  driver for some common cases.  The firmware vets the L2 headers
  submitted by the VF driver and it's a big win if the checks are
  performed for a batch of packets and not each one individually.

r362938:
cxgbe(4): Fix a bug (introduced in r362905) where some tx traffic wasn't
being reported to BPF.

r363167:
cxgbev(4): Compare at most 16 bytes of the Ethernet header when trying
to coalesce tx work requests.

Note that Coverity will still treat this as an out-of-bounds access.  We
do want to compare 16B starting from ethmacdst but cmp_l2hdr was was
going beyond that by 2B.

cmp_l2hdr was introduced in r362905.

Sponsored by: Chelsio Communications

3 years agoMFC 361767: Document SO_NO_OFFLOADS and SO_NO_DDP.
John Baldwin [Wed, 26 Aug 2020 22:52:07 +0000 (22:52 +0000)]
MFC 361767: Document SO_NO_OFFLOADS and SO_NO_DDP.

3 years agoMFC 361776: Explicitly zero AES key schedules on the stack.
John Baldwin [Wed, 26 Aug 2020 22:11:22 +0000 (22:11 +0000)]
MFC 361776: Explicitly zero AES key schedules on the stack.

3 years agoMFC 361220: Correct the order of arguments to copyin() for Q_SETQUOTA.
John Baldwin [Wed, 26 Aug 2020 21:41:14 +0000 (21:41 +0000)]
MFC 361220: Correct the order of arguments to copyin() for Q_SETQUOTA.

3 years agoMFC 361393: Correct the minimum key length for Camellia to 16 bytes (128 bits).
John Baldwin [Wed, 26 Aug 2020 21:35:28 +0000 (21:35 +0000)]
MFC 361393: Correct the minimum key length for Camellia to 16 bytes (128 bits).

3 years agoMFC 359050: Add missing DTrace files for WITHOUT_CDDL=yes.
John Baldwin [Wed, 26 Aug 2020 21:29:59 +0000 (21:29 +0000)]
MFC 359050: Add missing DTrace files for WITHOUT_CDDL=yes.

3 years agoMFC 361093: Don't remove ubsec(4) manual page for WITHOUT_USB=yes.
John Baldwin [Wed, 26 Aug 2020 21:19:05 +0000 (21:19 +0000)]
MFC 361093: Don't remove ubsec(4) manual page for WITHOUT_USB=yes.

In head this manpage has been removed entirely, but ubsec(4) is a PCI
device and not a USB device.

3 years agoMFC r364396: Unbreak `freebsd-update updatesready'.
Michael Gmelin [Wed, 26 Aug 2020 17:15:17 +0000 (17:15 +0000)]
MFC r364396: Unbreak `freebsd-update updatesready'.

The command would only work if PWD happened to be WORKDIR.
Also, exit 1 in case WORKDIR exists, but isn't accessible
by the current user.

PR: 242709
Reported by: Max Fiedler

3 years agoMFC r364600: caroot: switch to using echo+shell glob to enumerate certs
Kyle Evans [Wed, 26 Aug 2020 00:50:27 +0000 (00:50 +0000)]
MFC r364600: caroot: switch to using echo+shell glob to enumerate certs

This solves an issue on stable/12 that causes certs to not get installed.
ls is apparently not in PATH during installworld, so TRUSTED_CERTS ends up
blank and nothing gets installed. We don't really require anything
ls-specific, though, so let's just simplify it.

3 years agoMFC r364399: Remove some noisy ACPI tables messages from verbose dmesg.
Alexander Motin [Wed, 26 Aug 2020 00:28:28 +0000 (00:28 +0000)]
MFC r364399: Remove some noisy ACPI tables messages from verbose dmesg.

Those messages were printed hundreds of times during boot, often multiple
times for each table.  We already print information about the tables in
more organized form once to not duplicate it when random ACPI drivers are
attaching.

3 years agoMFC r363498:
Navdeep Parhar [Tue, 25 Aug 2020 18:21:13 +0000 (18:21 +0000)]
MFC r363498:
cxgbe(4): Some updates to the common code.

3 years agoMFC r364444:
Navdeep Parhar [Tue, 25 Aug 2020 18:11:45 +0000 (18:11 +0000)]
MFC r364444:
cxgbei: destroy the worker threads' CV and mutex in stop_worker_threads.

3 years agoMFC r364341
Vincenzo Maffione [Tue, 25 Aug 2020 11:10:37 +0000 (11:10 +0000)]
MFC r364341

netmap: fix parsing of legacy nmr->nr_ringid

Code was checking for NETMAP_{SW,HW}_RING in req->nr_ringid which
had already been masked by NETMAP_RING_MASK. Therefore, the comparisons
always failed and set NR_REG_ALL_NIC. Check against the original nmr
structure.

Submitted by:   bpoole@packetforensics.com
Reported by:    bpoole@packetforensics.com
Reviewed by:    giuseppe.lettieri@unipi.it
Approved by:    vmaffione

3 years agoMFC r362616:
Navdeep Parhar [Tue, 25 Aug 2020 02:54:48 +0000 (02:54 +0000)]
MFC r362616:

cxgbe(4): Add a pointer to the adapter softc in vi_info.

There were quite a few places where port_info was being accessed only to
get to the adapter.

Sponsored by: Chelsio Communications

3 years agoMFC r362532:
Navdeep Parhar [Tue, 25 Aug 2020 02:42:07 +0000 (02:42 +0000)]
MFC r362532:

cxgbe(4): Add a tx_len16_to_desc helper.

No functional change.

Sponsored by: Chelsio Communications

3 years agoMFC r351444, r357475, r357479, r357481-r357482, r358859, and r364497.
Navdeep Parhar [Tue, 25 Aug 2020 02:14:36 +0000 (02:14 +0000)]
MFC r351444, r357475, r357479, r357481-r357482, r358859, and r364497.

All these are rx improvements in the cxgbe(4) driver.

r351444:
cxgbe(4): Use the same buffer size for TOE rx queues as the NIC rx queues.

This is a minor simplification.

r357475:
cxgbe(4): Initialize the rx buffer's metadata on first-use and not on
allocation.

refill_fl doesn't touch any part of a freshly allocated cluster after
this change.

r357479:
cxgbe(4): Avoid ext_arg2 in rxb_free.

ext_arg2 is the only item in the third cacheline in an mbuf and could be
cold by the time rxb_free runs.  Put the information needed by rxb_free
in the same line as the refcount, which is very likely to be hot given
that rxb_free runs when the refcount is decremented and reaches 0.

r357481:
cxgbe(4): Retire the allow_mbufs_in_cluster optimization.

This simplifies the driver's rx fast path as well as the bookkeeping
code that tracks various rx buffer sizes and layouts.

r357482:
cxgbe(4): Treat NIC rx as special and run its handler directly and not
via the t4_cpl_handler dispatch table.

r358859:
cxgbe(4): Do not try to use 0 as an rx buffer address when the driver is
already allocating from the safe zone and the allocation fails.

This bug was introduced in r357481.

r364497:
cxgbe(4): Use large clusters for TOE rx queues when TOE+TLS is enabled.

Rx is more efficient within the chip when the receive buffer size
matches the TLS PDU size.

Sponsored by: Chelsio Communications

3 years agoMFC r364346:
Mark Johnston [Tue, 25 Aug 2020 00:49:57 +0000 (00:49 +0000)]
MFC r364346:
Fix handling of ancillary data on non-AF_UNIX Linux sockets.

3 years agoMFC r362631, r364317:
Mark Johnston [Mon, 24 Aug 2020 20:02:36 +0000 (20:02 +0000)]
MFC r362631, r364317:
Implement an approximation of Linux MADV_DONTNEED semantics.

PR: 230160

3 years agoMFC r363087:
Edward Tomasz Napierala [Mon, 24 Aug 2020 17:31:17 +0000 (17:31 +0000)]
MFC r363087:

Don't emit warnings on MADV_HUGEPAGE; Firefox uses it a lot.

Sponsored by: The FreeBSD Foundation

3 years agoMFC r362441:
Edward Tomasz Napierala [Mon, 24 Aug 2020 17:29:37 +0000 (17:29 +0000)]
MFC r362441:

Regen after r362440.

Sponsored by: The FreeBSD Foundation

3 years agoMFC r362440:
Edward Tomasz Napierala [Mon, 24 Aug 2020 17:25:26 +0000 (17:25 +0000)]
MFC r362440:

Add linux_madvise(2) instead of having Linux apps call the native
FreeBSD madvise(2) directly.  While some of the flag values match,
most don't.

PR: kern/230160
Sponsored by: The FreeBSD Foundation

3 years agoMFC r347538 by dchagin:
Edward Tomasz Napierala [Mon, 24 Aug 2020 17:06:34 +0000 (17:06 +0000)]
MFC r347538 by dchagin:

Linuxulator depends on a fundamental kernel settings such as SMP. Many
of them listed in opt_global.h which is not generated while building
modules outside of a kernel and such modules never match real cofigured
kernel.

So, we should prevent our users from building obviously defective modules.

Therefore, remove the root cause of the building of modules outside of a
kernel - the possibility of building modules with DEBUG or KTR flags.
And remove all of DEBUG printfs as it is incomplete and in threaded
programms not informative, also a half of system call does not have DEBUG
printf. For debuging Linux programms we have dtrace, ktr and ktrace ability.

PR: 222861

3 years agoMFC r362101:
Edward Tomasz Napierala [Mon, 24 Aug 2020 16:44:17 +0000 (16:44 +0000)]
MFC r362101:

Minor code cleanup; no functional changes.

Sponsored by: The FreeBSD Foundation

3 years agoMFC r356729:
Edward Tomasz Napierala [Mon, 24 Aug 2020 16:41:10 +0000 (16:41 +0000)]
MFC r356729:

Make linux(4) use kern_setsockopt(9) instead of going through
sys_setsockopt.  Just a cleanup; no functional changes.

Sponsored by: The FreeBSD Foundation

3 years agoMFC r356728:
Edward Tomasz Napierala [Mon, 24 Aug 2020 16:36:35 +0000 (16:36 +0000)]
MFC r356728:

Make linux(4) use kern_getsockopt(9) instead of going through
sys_getsockopt().  It's a cleanup; no functional changes.

Sponsored by: The FreeBSD Foundation

3 years agoMFC r362941:
Edward Tomasz Napierala [Mon, 24 Aug 2020 16:27:51 +0000 (16:27 +0000)]
MFC r362941:

Fix Linux recvmsg(2) when msg_namelen returned is 0.  Previously
it would fail with EINVAL, breaking some of the Python regression
tests.

While here, cap the user-controlled message length.

Note that the code doesn't seem to be copying out the new length
in either (success or failure) case. This will be addressed separately.

Sponsored by: The FreeBSD Foundation

3 years agoMFC r362833:
Edward Tomasz Napierala [Mon, 24 Aug 2020 16:25:27 +0000 (16:25 +0000)]
MFC r362833:

Rework linux accept(2).  This makes the code flow easier to follow,
and fixes a bug where calling accept(2) could result in closing fd 0.

Note that the code still contains a number of problems: it makes
assumptions about l_sockaddr_in being the same as sockaddr_in,
the EFAULT-related code looks like it doesn't work at all, and the
socket type check is racy.  Those will be addressed later on;
I'm trying to work in small steps to avoid breaking one thing while
fixing another.

It fixes Redis, among other things.

Sponsored by: The FreeBSD Foundation

3 years agoMFC r362735:
Edward Tomasz Napierala [Mon, 24 Aug 2020 16:23:27 +0000 (16:23 +0000)]
MFC r362735:

Make linux(4) support SO_PROTOCOL.  Running Python test suite
with python3.8 from Focal triggers those.

Sponsored by: The FreeBSD Foundation

3 years agoMFC r362176:
Edward Tomasz Napierala [Mon, 24 Aug 2020 16:21:03 +0000 (16:21 +0000)]
MFC r362176:

Make linux(4) warn about unsupported CMSG level/type.

Sponsored by: The FreeBSD Foundation

3 years agoMFC r362059:
Edward Tomasz Napierala [Mon, 24 Aug 2020 16:15:12 +0000 (16:15 +0000)]
MFC r362059:

Don't use newlines with linux_msg().  No functional changes.

Sponsored by: The FreeBSD Foundation

3 years agoMFC r354413:
Edward Tomasz Napierala [Mon, 24 Aug 2020 16:06:17 +0000 (16:06 +0000)]
MFC r354413:

Make linux(4) create /dev/shm.  Linux applications often expect
a tmpfs to be mounted there, and because they like to verify it's
actually a mountpoint, a symlink won't do.

Sponsored by: The FreeBSD Foundation

3 years agoMFC r362103:
Edward Tomasz Napierala [Mon, 24 Aug 2020 16:00:58 +0000 (16:00 +0000)]
MFC r362103:

Fix naming clash.

Sponsored by: The FreeBSD Foundation

3 years agoMFC r348418 by dchagin:
Edward Tomasz Napierala [Mon, 24 Aug 2020 15:56:31 +0000 (15:56 +0000)]
MFC r348418 by dchagin:

Linux does not support MSG_OOB for unix(4) or non-stream oriented socket,
return EOPNOTSUPP as a Linux does.

3 years agoMFC r348058 by dchagin:
Edward Tomasz Napierala [Mon, 24 Aug 2020 15:54:58 +0000 (15:54 +0000)]
MFC r348058 by dchagin:

Do not leak sa in linux_recvmsg() call if kern_recvit() fails.

3 years agoMFC r348057 by dchagin:
Edward Tomasz Napierala [Mon, 24 Aug 2020 15:53:52 +0000 (15:53 +0000)]
MFC r348057 by dchagin:

Do not use uninitialised sa.

3 years agoMFC r348056 by dchagin:
Edward Tomasz Napierala [Mon, 24 Aug 2020 15:52:45 +0000 (15:52 +0000)]
MFC r348056 by dchagin:

Do not leak sa in linux_recvfrom() call if kern_recvit() fails.

3 years agoMFC r347969 by dchagin:
Edward Tomasz Napierala [Mon, 24 Aug 2020 15:50:57 +0000 (15:50 +0000)]
MFC r347969 by dchagin:

Linux send() call returns EAGAIN instead of ENOTCONN in case when the
socket is non-blocking and connect() is not finished yet.

Initial patch developed by Steven Hartland in 2008 and adopted by me.

PR: 129169

3 years agoMFC r347537 by dchagin:
Edward Tomasz Napierala [Mon, 24 Aug 2020 15:49:37 +0000 (15:49 +0000)]
MFC r347537 by dchagin:

Linuxulator getpeername() returns EINVAL in case then namelen less then 0.

3 years agoMFC r347533 by dchagin:
Edward Tomasz Napierala [Mon, 24 Aug 2020 15:45:42 +0000 (15:45 +0000)]
MFC r347533 by dchagin:

Our bsd_to_linux_sockaddr() and linux_to_bsd_sockaddr() functions
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

3 years agoMFC r363307:
Edward Tomasz Napierala [Mon, 24 Aug 2020 14:58:58 +0000 (14:58 +0000)]
MFC r363307:

Make linux fallocate(2) return EOPNOTSUPP, not ENOSYS, on unsupported mode,
as documented in the man page.

Sponsored by: The FreeBSD Foundation

3 years agoMFC r363125 by netchild:
Edward Tomasz Napierala [Mon, 24 Aug 2020 14:53:29 +0000 (14:53 +0000)]
MFC r363125 by netchild:

Implement CLOCK_MONOTONIC_RAW (linux >= 2.6.28).

It is documented as a raw hardware-based clock not subject to NTP or
incremental adjustments. With this "not as precise as CLOCK_MONOTONIC"
description in mind, map it to our CLOCK_MONOTNIC_FAST (the same
mapping as for the linux CLOCK_MONOTONIC_COARSE).

This is needed for the webcomponent of steam (chromium) and some
other steam component or game.

The linux-steam-utils port contains a LD_PRELOAD based fix for this.
There this is mapped to CLOCK_MONOTONIC.
As an untrained ear/eye (= the majority of people) is normaly not
noticing a difference of jitter in the 10-20 ms range, specially
if you don't pay attention like for example in a browser session
while watching a video stream, the mapping to CLOCK_MONOTONIC_FAST
seems more appropriate than to CLOCK_MONOTONIC.

MFC r363130 by netchild:

Fix r363125 (Implement CLOCK_MONOTONIC_RAW (linux >= 2.6.28)),
by realy using the MONOTONIC version and not the REALTIME version.

3 years agoMFC r362416:
Edward Tomasz Napierala [Mon, 24 Aug 2020 14:50:52 +0000 (14:50 +0000)]
MFC r362416:

Add warnings for unsupported Linux clockids.

Sponsored by: The FreeBSD Foundation

3 years agoMFC r357493 by dchagin:
Edward Tomasz Napierala [Mon, 24 Aug 2020 14:48:54 +0000 (14:48 +0000)]
MFC r357493 by dchagin:

Fix clock_gettime() and clock_getres() for cpu clocks:
- handle the CLOCK_{PROCESS,THREAD}_CPUTIME_ID specified directly;
- fix thread id calculation as in the Linuxulator we should
  convert the user supplied thread id to struct thread * by linux_tdfind();
- fix CPUCLOCK_SCHED case by using kern_{process,thread}_cputime()
  directly as native get_cputime() used by kern_clock_gettime() uses
  native tdfind()/pfind() to find proccess/thread.

PR: 240990

3 years agoMFC r357492 by dchagin:
Edward Tomasz Napierala [Mon, 24 Aug 2020 14:26:48 +0000 (14:26 +0000)]
MFC r357492 by dchagin:

For code reuse in Linuxulator rename get_proccess_cputime()
and get_thread_cputime() and add prototypes for it to <sys/syscallsubr.h>.

As both functions become a public interface add process lock assert
to ensure that the process is not exiting under it.

Fix whitespace nit while here.

3 years agoMFC r357491 by dchagin:
Edward Tomasz Napierala [Mon, 24 Aug 2020 14:17:25 +0000 (14:17 +0000)]
MFC r357491 by dchagin:

linux_to_native_clockid() properly initializes nwhich variable (or return error),
so don't initialize nwhich in declaration and remove stale comment from r161304.

3 years agoMFC r356727:
Edward Tomasz Napierala [Mon, 24 Aug 2020 14:13:20 +0000 (14:13 +0000)]
MFC r356727:

Make linux getcpu(2) report the domain.

Submitted by: markj
Sponsored by: The FreeBSD Foundation

3 years agoMFC r354805:
Edward Tomasz Napierala [Mon, 24 Aug 2020 14:05:45 +0000 (14:05 +0000)]
MFC r354805:

Make linux(4) open(2)/openat(2) return ELOOP instead of EMLINK,
when being passed O_NOFOLLOW.  This fixes LTP testcase openat02:5.

Sponsored by: The FreeBSD Foundation

3 years agoMFC r362055:
Edward Tomasz Napierala [Mon, 24 Aug 2020 14:01:52 +0000 (14:01 +0000)]
MFC r362055:

Replace LINUX_FASYNC with LINUX_O_ASYNC; no functional changes.

Sponsored by: The FreeBSD Foundation

3 years agoMFC r364329:
Mark Johnston [Mon, 24 Aug 2020 13:55:24 +0000 (13:55 +0000)]
MFC r364329:
Remove "emulation" of clone(CLONE_PARENT | CLONE_THREAD).

3 years agoMFC r364328:
Mark Johnston [Mon, 24 Aug 2020 13:54:58 +0000 (13:54 +0000)]
MFC r364328:
Fix a lock leak when emulating futex(FUTEX_WAIT_BITSET).

3 years agoMFC r364304:
Mark Johnston [Mon, 24 Aug 2020 13:54:41 +0000 (13:54 +0000)]
MFC r364304:
cpuset(1): Update the usage message.

3 years agoMFC r354732:
Edward Tomasz Napierala [Mon, 24 Aug 2020 13:52:47 +0000 (13:52 +0000)]
MFC r354732:

Support O_CLOEXEC in linux(4) open(2) and openat(2).

Sponsored by: The FreeBSD Foundation

3 years agoMFC r364300:
Mark Johnston [Mon, 24 Aug 2020 13:50:55 +0000 (13:50 +0000)]
MFC r364300:
asmc(4): Add support for MacBook7,1.

PR: 248693

3 years agoMFC r363564-r363567, r363575, r363835-r363837, r363842-r363843, r364232
Emmanuel Vadot [Mon, 24 Aug 2020 13:19:16 +0000 (13:19 +0000)]
MFC r363564-r363567, r363575, r363835-r363837, r363842-r363843, r364232

r363564:
linuxkpi: Include linux/sizes.h in dma-mapping.h

Linux does the same, this avoids ifdef or extra includes in ported drivers.

Reviewed by: emaste, hselasky
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D25701

r363565:
linuxkpi: Include hardirq.h in preempt.h and lockdep.h in hardirq.h

Linux does the same, this avoids ifdef or extra includes in ported drivers.

Reviewed by: emaste, hselasky
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D25702

r363566:
linuxkpi: Add taint* defines

This isn't used for us but allow us to port drivers more easily.

Reviewed by: hselasky
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D25703

r363567:
Revert r363564

linux/sizes.h doesn't exists in base ... sorry.

r363575:
Fix r363565

lockdep.h needs sys/lock.h for LOCK_CLASS

r363835:
linuxkpi: Add linux/sizes.h

This file contain some defines for common sizes.

Sponsored-by: The FreeBSD Foundation
Reviewed by: hselasky, emaste
Differential Revision: https://reviews.freebsd.org/D25941

r363836:
linuxkpi: Add kref_put_lock

Same as kref_put but in addition to calling the rel function it will
acquire the lock first.

Sponsored by: The FreeBSD Foundation
Reviewed by: hselasky, emaste
Differential Revision: https://reviews.freebsd.org/D25942

r363837:
linuxkpi: Add nested variant of mutex_lock_interruptible

We don't do anything with the _nesteds variant so just call mutex_lock_interruptible

Sponsoredby: The FreeBSD Foundation
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D25944

r363842:
linuxkpi: Add clear_bit_unlock

This calls clear_bit and adds a memory barrier.

Sponsored by: The FreeBSD Foundation

Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D25943

r363843:
linuxkpi: Add time_after32 and time_before32

This compare two 32 bits times

Sponsored by: The FreeBSD Foundation
Reviewed by: kib, hselasky
Differential Revision: https://reviews.freebsd.org/D25700

r364232:
linuxkpi: Add a few wait_bit functions

The linux function does a lot more than that as multiple waitqueue could be fetch
from a static table based on the hash of the argument but since in DRM it's only used
in one place just add a single variable.
We will probably need to change that in the futur but it's ok with DRM even with current
linux.

Reviewed by: hselasky
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D26054

3 years agoMFC r361450, r361452, r361550-r361551
Emmanuel Vadot [Mon, 24 Aug 2020 13:14:38 +0000 (13:14 +0000)]
MFC r361450, r361452, r361550-r361551

r361450:
linuxkpi: Add refcount.h

Implement some refcount functions needed by drm.
Just use the atomic_t struct and functions from linuxkpi for simplicity.

Sponsored-by: The FreeBSD Foundation
Reviewed by: hselsasky
Differential Revision: https://reviews.freebsd.org/D24985

r361452:
linuxkpi: Fix mod_timer and del_timer_sync

mod_timer is supposed to return 1 if the modified timer was pending, which
is exactly what callout_reset does so return the value after checking
that it's a correct one in case the api change.
del_timer_sync returns int so add a function and handle that.

Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D24983

r361550:
linuxkpi: Add rcu_swap_protected

This macros swap an rcu pointer with a normal pointer.
The condition only seems to be used for debug/warning under linux, ignore
for now.

Sponsored-by: The FreeBSD Foundation
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D24954

r361551:
linuxkpi: Add kstrtou16

This function convert a char * to a u16.
Simply use strtoul and cast to compare for ERANGE

Sponsored-by: The FreeBSD Foundation
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D24996

3 years agoMFC r361247, r361343, r361418-r361419, r361422, r361449
Emmanuel Vadot [Mon, 24 Aug 2020 12:59:55 +0000 (12:59 +0000)]
MFC r361247, r361343, r361418-r361419, r361422, r361449

r361247:
linuxkpi: Add irq_work.h

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

r361343:
linuxkpi: Add rcu_work functions

The rcu_work function helps to queue some work after waiting for a grace
period.
This is needed by DRM drivers.

Sponsored-by: The FreeBSD Foundation
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D24942

r361418:
libkern: Add arc4random_uniform

This variant get a random number up to the limit passed as the argument.
This is simply a copy of the libc version.

Sponsored-by: The FreeBSD Foundation
Reviewed by: cem, hselasky (previous version)
Differential Revision: https://reviews.freebsd.org/D24962

r361419:
linuxkpi: Add prandom_u32_max

This is just a wrapper around arc4random_uniform
Needed by DRM v5.3

Sponsored-by: The FreeBSD Foundation
Reviewed by: cem, hselasky
Differential Revision: https://reviews.freebsd.org/D24961

r361422:
bbr: Use arc4random_uniform from libkern.

This unbreak LINT build

Reported by: jenkins, melifaro

r361449:
linuxkpi: Add __same_type and __must_be_array macros

The same_type macro simply wraps around builtin_types_compatible_p which
exist for both GCC and CLANG, which returns 1 if both types are the same.
The __must_be_array macros returns 1 if the argument is an array.

This is needed for DRM v5.3

Sponsored-by: The FreeBSD Foundation
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D24953

3 years agoMFC r349750:
Edward Tomasz Napierala [Mon, 24 Aug 2020 12:59:15 +0000 (12:59 +0000)]
MFC r349750:

Return ENOTSUP for Linux FS_IOC_FIEMAP ioctl.

Linux man(1) calls it for no good reason; this avoids the console spam
(eg '(man): ioctl fd=4, cmd=0x660b ('f',11) is not implemented').

Sponsored by: The FreeBSD Foundation

3 years agoMFC r349746:
Edward Tomasz Napierala [Mon, 24 Aug 2020 12:57:03 +0000 (12:57 +0000)]
MFC r349746:

Fix linuxulator prlimit64(2) with pid == 0.  This makes 'ulimit -a'
return something reasonable, and helps linux binaries which attempt
to close all the files, eg apt(8).

Sponsored by: The FreeBSD Foundation

3 years agoMFC r362205:
Edward Tomasz Napierala [Mon, 24 Aug 2020 12:54:19 +0000 (12:54 +0000)]
MFC r362205:

Make Linux uname(2) return x86_64 to 32-bit apps.  This helps Steam.

PR: kern/240432
Analyzed by: Alex S <iwtcex@gmail.com>
Sponsored by: The FreeBSD Foundation

3 years agoMFC r362104:
Edward Tomasz Napierala [Mon, 24 Aug 2020 12:51:20 +0000 (12:51 +0000)]
MFC r362104:

Add compat.linux.debug sysctl, to make it possible to silence down
the debug messages. While here, clean up some variable naming.

Sponsored by: The FreeBSD Foundation

3 years agoMFC r362015:
Edward Tomasz Napierala [Mon, 24 Aug 2020 12:49:51 +0000 (12:49 +0000)]
MFC r362015:

Make linux(4) set the openfiles soft resource limit to 1024 for Linux
applications, which often depend on this being the case.  There's a new
sysctl, compat.linux.default_openfiles, to control this behaviour.

Sponsored by: The FreeBSD Foundation

3 years agoMFC r358673 by tijl:
Edward Tomasz Napierala [Mon, 24 Aug 2020 12:47:20 +0000 (12:47 +0000)]
MFC r358673 by tijl:

Move compat.linux.map_sched_prio sysctl definition to linux_mib.c so it is
only defined by linux_common kernel module and not both linux and linux64
modules.

Reported by: Yuri Pankov <ypankov@fastmail.com>

3 years agoMFC r358483 by tijl:
Edward Tomasz Napierala [Mon, 24 Aug 2020 12:43:54 +0000 (12:43 +0000)]
MFC r358483 by tijl:

linuxulator: Map scheduler priorities to Linux priorities.

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>

3 years agoMFC r357202:
Edward Tomasz Napierala [Mon, 24 Aug 2020 12:35:02 +0000 (12:35 +0000)]
MFC r357202:

Add compat.linux.ignore_ip_recverr sysctl.  This is a workaround
for missing IP_RECVERR setsockopt(2) support. Without it, DNS
resolution is broken for glibc >= 2.30 (glibc BZ #24047).

From the user point of view this fixes "yum update" on recent
CentOS 8.

Sponsored by: The FreeBSD Foundation

3 years agoMFC r355820:
Edward Tomasz Napierala [Mon, 24 Aug 2020 12:33:42 +0000 (12:33 +0000)]
MFC r355820:

Add a hack to make ^T work for Linux binaries, enabled with
'compat.linux.preserve_vstatus=1' sysctl.

Sponsored by: The FreeBSD Foundation

3 years agoMFC r362051:
Edward Tomasz Napierala [Mon, 24 Aug 2020 12:30:43 +0000 (12:30 +0000)]
MFC r362051:

Make linux(4) handle SO_REUSEPORT.

Sponsored by: The FreeBSD Foundation

3 years agoMFC r357203:
Edward Tomasz Napierala [Mon, 24 Aug 2020 12:29:23 +0000 (12:29 +0000)]
MFC r357203:

Add TCP_CORK support to linux(4).  This fixes one of the things Nginx
trips over.

Sponsored by: The FreeBSD Foundation

3 years agoMFC r357076:
Edward Tomasz Napierala [Mon, 24 Aug 2020 12:26:49 +0000 (12:26 +0000)]
MFC r357076:

Make linux(4) handle MAP_32BIT.

This unbreaks Mono (mono-devel-4.6.2.7+dfsg-1ubuntu1 from Ubuntu Bionic);
previously would crash on "amd64_is_imm32" assert.

Sponsored by: The FreeBSD Foundation

3 years agoMFC r362014:
Edward Tomasz Napierala [Mon, 24 Aug 2020 12:23:55 +0000 (12:23 +0000)]
MFC r362014:

Support SO_SNDBUFFORCE/SO_RCVBUFFORCE by aliasing them to the
standard SO_SNDBUF/SO_RCVBUF.  Mostly cosmetics, to get rid
of the warning during 'apt upgrade'.

Sponsored by: The FreeBSD Foundation

3 years agoMFC r363322:
Edward Tomasz Napierala [Mon, 24 Aug 2020 12:20:55 +0000 (12:20 +0000)]
MFC r363322:

Make linux(4) support the BLKPBSZGET ioctl.  Oracle uses it.

Sponsored by: The FreeBSD Foundation

3 years agoMFC r361007, r361138-r361140, r361245-r361246
Emmanuel Vadot [Mon, 24 Aug 2020 10:46:09 +0000 (10:46 +0000)]
MFC r361007, r361138-r361140, r361245-r361246

r361007:
linuxkpi: Add EBADRQC to errno.h

This is used in the amdgpu driver from Linux 5.2

Sponsored-by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D24807

r361138:
linuxkpi: Add atomic_dec_and_mutex_lock

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

r361139:
linuxkpi: Add __mutex_init

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

r361140:
linuxkpi: Add offsetofend macro

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

r361245:
linuxkpi: Add __init_waitqueue_head

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

r361246:
linuxkpi: add pci_dev_present

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

3 years agoMFC r360787, r360851, r360870-r360872
Emmanuel Vadot [Mon, 24 Aug 2020 10:42:04 +0000 (10:42 +0000)]
MFC r360787, r360851, r360870-r360872

r360787:
linuxkpi: Add pci_iomap and pci_iounmap

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

r360851:
linuxkpi: Add bitmap_copy and bitmap_andnot

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

r360870:
linuxkpi: Add bitmap_alloc and bitmap_free

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

r360871:
linuxkpi: Really add bitmap_alloc and bitmap_zalloc

This was missing in r360870

Sponsored-by: The FreeBSD Foundation
r360872:
qnlx: Do not redifines types.

r360870 added linux/slab.h into liunx/bitmap.h and this include linux/types.h
The qlnx driver is redefining some of those types so remove them and add an
explicit linux/types.h include.

Pointy hat: manu
Reported by: Austin Shafer <ashafer@badland.io>

3 years agoMFC r358176-r358177
Emmanuel Vadot [Mon, 24 Aug 2020 10:28:15 +0000 (10:28 +0000)]
MFC r358176-r358177

r358176:
linuxkpi: Add list_is_first function

This function just test if the element is the first of the list.

Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D23766

r358177:
linuxkpi: Add str_has_prefix

This function test if the string str begins with the string pointed
at by prefix.

Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D23767

3 years agoMFC 364268:
Michael Tuexen [Mon, 24 Aug 2020 09:19:05 +0000 (09:19 +0000)]
MFC 364268:
Improve the handling of concurrent send() calls for SCTP sockets,
especially when having the explicit EOR mode enabled.

MFC r364270:
Remove a line which is needed and was added in
https://svnweb.freebsd.org/changeset/base/364268

3 years agoMFC r363456:
Michael Tuexen [Mon, 24 Aug 2020 09:15:52 +0000 (09:15 +0000)]
MFC r363456:
Clear the pointer to the socket when closing it also in case of
an ungraceful operation.
This fixes a use-after-free bug found and reported by Taylor
Brandstetter of Google by testing the userland stack.

3 years agoMFC r363440:
Michael Tuexen [Mon, 24 Aug 2020 09:14:32 +0000 (09:14 +0000)]
MFC r363440:
Detect and handle an invalid reassembly constellation, which results in
a memory leak.

Thanks to Felix Weinrank for finding this issue using fuzz testing the
userland stack.

3 years agoMFC r363323:
Michael Tuexen [Mon, 24 Aug 2020 09:13:06 +0000 (09:13 +0000)]
MFC r363323:
Add reference counts for inp/stcb/net when timers are running.
This avoids a use-after-free reported for the userland stack.
Thanks to Taylor Brandstetter for suggesting a patch for
the userland stack.

3 years agoMFC r363309:
Michael Tuexen [Mon, 24 Aug 2020 09:11:37 +0000 (09:11 +0000)]
MFC r363309:
Remove code which is not needed.

3 years agoMFC r363275:
Michael Tuexen [Mon, 24 Aug 2020 09:10:19 +0000 (09:10 +0000)]
MFC r363275:
Improve the locking of address lists by adding some asserts and
rearranging the addition of address such that the lock is not
given up during checking and adding.

3 years agoMFC r363194:
Michael Tuexen [Mon, 24 Aug 2020 09:06:46 +0000 (09:06 +0000)]
MFC r363194:
Improve the error handling in generating ASCONF chunks.
In case of errors, the cleanup was not consistent.
Thanks to Felix Weinrank for fuzzing the userland stack and making
me aware of the issue.

3 years agoMFC r363076:
Michael Tuexen [Mon, 24 Aug 2020 09:00:07 +0000 (09:00 +0000)]
MFC r363076:
Fix a use-after-free bug for the userland stack. The kernel
stack is not affected.
Thanks to Mark Wodrich from Google for finding and reporting the
bug.

3 years agoMFC r363046:
Michael Tuexen [Mon, 24 Aug 2020 08:58:45 +0000 (08:58 +0000)]
MFC r363046:
Optimize flushing of receive queues.
This addresses an issue found and reported for the userland stack in
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=21243

3 years agoMFC r363012:
Michael Tuexen [Mon, 24 Aug 2020 08:57:27 +0000 (08:57 +0000)]
MFC r363012:
Improve consistency.

3 years agoMFC r363011:
Michael Tuexen [Mon, 24 Aug 2020 08:41:22 +0000 (08:41 +0000)]
MFC r363011:
Fix error description.

3 years agoMFC r363010:
Michael Tuexen [Mon, 24 Aug 2020 08:40:10 +0000 (08:40 +0000)]
MFC r363010:
Don't accept FORWARD-TSN chunks when I-FORWARD-TSN was negotiated
and vice versa.