]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
2 years agoHide acpi_timer_test behind a tunable
Colin Percival [Tue, 7 Sep 2021 23:58:18 +0000 (16:58 -0700)]
Hide acpi_timer_test behind a tunable

When hw.acpi.timer_test_enabled is set to 0, this makes acpi_timer_test
return 1 without actually testing the ACPI timer; this results in the
ACPI-fast timecounter always being used rather than potentially using
ACPI-safe.

The ACPI timer testing was introduced in 2002 as a workaround for
errata in Pentium II and Pentium III chipsets, and is unlikely to be
needed in 2021.

While I'm here, add TSENTER/TSEXIT to make it easier to see the time
spent on the test (if it is enabled).

Reviewed by: allanjude, imp
MFC After: 1 week

2 years agoopenssh: update to OpenSSH v8.7p1
Ed Maste [Wed, 8 Sep 2021 01:05:51 +0000 (21:05 -0400)]
openssh: update to OpenSSH v8.7p1

Some notable changes, from upstream's release notes:

- sshd(8): Remove support for obsolete "host/port" syntax.
- ssh(1): When prompting whether to record a new host key, accept the key
  fingerprint as a synonym for "yes".
- ssh-keygen(1): when acting as a CA and signing certificates with an RSA
  key, default to using the rsa-sha2-512 signature algorithm.
- ssh(1), sshd(8), ssh-keygen(1): this release removes the "ssh-rsa"
  (RSA/SHA1) algorithm from those accepted for certificate signatures.
- ssh-sk-helper(8): this is a new binary. It is used by the FIDO/U2F
  support to provide address-space isolation for token middleware
  libraries (including the internal one).
- ssh(1): this release enables UpdateHostkeys by default subject to some
  conservative preconditions.
- scp(1): this release changes the behaviour of remote to remote copies
  (e.g. "scp host-a:/path host-b:") to transfer through the local host
  by default.
- scp(1): experimental support for transfers using the SFTP protocol as
  a replacement for the venerable SCP/RCP protocol that it has
  traditionally used.

Additional integration work is needed to support FIDO/U2F in the base
system.

Deprecation Notice
------------------

OpenSSH will disable the ssh-rsa signature scheme by default in the
next release.

Reviewed by: imp
MFC after: 1 month
Relnotes: Yes
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D29985

2 years agoVOP_COPY_FILE_RANGE: Add a COPY_FILE_RANGE_TIMEO1SEC flag
Rick Macklem [Wed, 8 Sep 2021 00:35:26 +0000 (17:35 -0700)]
VOP_COPY_FILE_RANGE: Add a COPY_FILE_RANGE_TIMEO1SEC flag

Although it is not specified in the RFCs, the concept that
the NFSv4 server should reply to an RPC request within a
reasonable time is accepted practice within the NFSv4 community.

Without this patch, the NFSv4.2 server attempts to reply to
a Copy operation within 1second by limiting the copy to
vfs.nfs.maxcopyrange bytes (default 10Mbytes). This is crude at
best, given the large variation in I/O subsystem performance.

This patch adds a kernel only flag COPY_FILE_RANGE_TIMEO1SEC
that the NFSv4.2 can specify, which tells VOP_COPY_FILE_RANGE()
to return after approximately 1 second with a partial result and
implements this in vn_generic_copy_file_range(), used by
vop_stdcopyfilerange().

Modifying the NFSv4.2 server to set this flag will be done in
a separate patch.  Also under consideration is exposing the
COPY_FILE_RANGE_TIMEO1SEC to userland for use on the FreeBSD
copy_file_range(2) syscall.

MFC after: 2 weeks
Reviewed by: khng
Differential Revision: https://reviews.freebsd.org/D31829

2 years agocxgbe(4): Fix the decode and display of the DBVFIFO region in meminfo.
Navdeep Parhar [Tue, 7 Sep 2021 23:28:11 +0000 (16:28 -0700)]
cxgbe(4): Fix the decode and display of the DBVFIFO region in meminfo.

MFC after: 1 week
Sponsored by: Chelsio Communications

2 years agocxgbe(4): Display HMA information in meminfo.
Navdeep Parhar [Tue, 7 Sep 2021 20:39:44 +0000 (13:39 -0700)]
cxgbe(4): Display HMA information in meminfo.

This should have been added with initial T6 support many years ago.

MFC after: 1 week
Sponsored by: Chelsio Communications

2 years agorouting: fix source address selection rules for IPv4 over IPv6.
Alexander V. Chernikov [Mon, 6 Sep 2021 22:08:15 +0000 (22:08 +0000)]
routing: fix source address selection rules for IPv4 over IPv6.

Current logic always selects an IFA of the same family from the
 outgoing interfaces. In IPv4 over IPv6 setup there can be just
 single non-127.0.0.1 ifa, attached to the loopback interface.

Create a separate rt_getifa_family() to handle entire ifa selection
 for the IPv4 over IPv6.

Differential Revision: https://reviews.freebsd.org/D31868
MFC after: 1 week

2 years agoBump __FreeBSD_version for the recent socket KPI changes
Mark Johnston [Tue, 7 Sep 2021 21:14:36 +0000 (17:14 -0400)]
Bump __FreeBSD_version for the recent socket KPI changes

Sponsored by: The FreeBSD Foundation

2 years agosocket: Avoid clearing SS_ISCONNECTING if soconnect() fails
Mark Johnston [Tue, 7 Sep 2021 18:51:54 +0000 (14:51 -0400)]
socket: Avoid clearing SS_ISCONNECTING if soconnect() fails

This behaviour appears to date from the 4.4 BSD import.  It has two
problems:

1. The update to so_state is not protected by the socket lock, so
   concurrent updates to so_state may be lost.
2. Suppose two threads race to call connect(2) on a socket, and one
   succeeds while the other fails.  Then the failing thread may
   incorrectly clear SS_ISCONNECTING, confusing the state machine.

Simply remove the update.  It does not appear to be necessary:
pru_connect implementations which call soisconnecting() only do so after
all failure modes have been handled.  For instance, tcp_connect() and
tcp6_connect() will never return an error after calling soisconnected().
However, we cannot correctly assert that SS_ISCONNECTED is not set after
an error from soconnect() since the socket lock is not held across the
pru_connect call, so a concurrent connect(2) may have set the flag.

MFC after: 1 month
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D31699

2 years agosctp: Remove special handling for a listen(2) backlog of 0
Mark Johnston [Tue, 7 Sep 2021 18:51:19 +0000 (14:51 -0400)]
sctp: Remove special handling for a listen(2) backlog of 0

... when applied to one-to-one-style sockets.  sctp_listen() cannot be
used to toggle the listening state of such a socket.  See RFC 6458's
description of expected listen(2) semantics for one-to-one- and
one-to-many-style sockets.

Reviewed by: tuexen
MFC after: 1 month
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D31774

2 years agosocket: Remove unneeded SOLISTENING checks
Mark Johnston [Tue, 7 Sep 2021 18:50:02 +0000 (14:50 -0400)]
socket: Remove unneeded SOLISTENING checks

Now that SOCK_IO_*_LOCK() checks for listening sockets, we can eliminate
some racy SOLISTENING() checks.  No functional change intended.

Reviewed by: tuexen
MFC after: 1 month
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D31660

2 years agosocket: Properly interlock when transitioning to a listening socket
Mark Johnston [Tue, 7 Sep 2021 18:49:53 +0000 (14:49 -0400)]
socket: Properly interlock when transitioning to a listening socket

Currently, most protocols implement pru_listen with something like the
following:

SOCK_LOCK(so);
error = solisten_proto_check(so);
if (error) {
SOCK_UNLOCK(so);
return (error);
}
solisten_proto(so);
SOCK_UNLOCK(so);

solisten_proto_check() fails if the socket is connected or connecting.
However, the socket lock is not used during I/O, so this pattern is
racy.

The change modifies solisten_proto_check() to additionally acquire
socket buffer locks, and the calling thread holds them until
solisten_proto() or solisten_proto_abort() is called.  Now that the
socket buffer locks are preserved across a listen(2), this change allows
socket I/O paths to properly interlock with listen(2).

This fixes a large number of syzbot reports, only one is listed below
and the rest will be dup'ed to it.

Reported by: syzbot+9fece8a63c0e27273821@syzkaller.appspotmail.com
Reviewed by: tuexen, gallatin
MFC after: 1 month
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D31659

2 years agosocket: Move sockbuf mutexes into the owning socket
Mark Johnston [Tue, 7 Sep 2021 18:49:40 +0000 (14:49 -0400)]
socket: Move sockbuf mutexes into the owning socket

This is necessary to provide proper interlocking with listen(2), which
destroys the socket buffers.  Otherwise, code must lock the socket
itself and check SOLISTENING(so), but most I/O paths do not otherwise
need to acquire the socket lock, so the extra overhead needed to check a
rare error case is undesirable.

listen(2) calls are relatively rare.  Thus, the strategy is to have it
acquire all socket buffer locks when transitioning to a listening
socket.  To do this safely, these locks must be stable, and not
destroyed during listen(2) as they are today.  So, move them out of the
sockbuf and into the owning socket.  For the sockbuf mutexes, keep a
pointer to the mutex in the sockbuf itself, for now.  This can be
removed by replacing SOCKBUF_LOCK() etc. with macros which operate on
the socket itself, as was done for the sockbuf I/O locks.

Reviewed by: tuexen, gallatin
MFC after: 1 month
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D31658

2 years agosocket: Rename sb(un)lock() and interlock with listen(2)
Mark Johnston [Tue, 7 Sep 2021 18:49:31 +0000 (14:49 -0400)]
socket: Rename sb(un)lock() and interlock with listen(2)

In preparation for moving sockbuf locks into the containing socket,
provide alternative macros for the sockbuf I/O locks:
SOCK_IO_SEND_(UN)LOCK() and SOCK_IO_RECV_(UN)LOCK().  These operate on a
socket rather than a socket buffer.  Note that these locks are used only
to prevent concurrent readers and writters from interleaving I/O.

When locking for I/O, return an error if the socket is a listening
socket.  Currently the check is racy since the sockbuf sx locks are
destroyed during the transition to a listening socket, but that will no
longer be true after some follow-up changes.

Modify a few places to check for errors from
sblock()/SOCK_IO_(SEND|RECV)_LOCK() where they were not before.  In
particular, add checks to sendfile() and sorflush().

Reviewed by: tuexen, gallatin
MFC after: 1 month
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D31657

2 years agosocket: Reorder socket and sockbuf fields to eliminate some padding
Mark Johnston [Tue, 7 Sep 2021 18:45:22 +0000 (14:45 -0400)]
socket: Reorder socket and sockbuf fields to eliminate some padding

This is in preparation for moving sockbuf locks into the owning socket,
in order to provide proper interlocking for listen(2).  In particular,
listening sockets do not use the socket buffers and repurpose that space
in struct socket for their own purposes.  Moving the locks out of the
socket buffers and into the socket proper makes it possible to safely
lock socket buffers and test for a listening socket before deciding how
to proceed.

Reordering these fields saves some space and helps ensure that UMA will
provide the same space efficiency for sockets as before.  No functional
change intended.

Reviewed by: tuexen, gallatin
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D31656

2 years agoswap_pager: Handle large swap_pager_reserve() requests
Mark Johnston [Tue, 7 Sep 2021 18:03:52 +0000 (14:03 -0400)]
swap_pager: Handle large swap_pager_reserve() requests

This interface is used solely by md(4) when the MD_RESERVE flag is
specified, as in `mdconfig -a -t swap -s 1G -o reserve`.  It
pre-allocates swap blocks for the entire object.

The number of blocks to be reserved is specified as a vm_size_t, but
swp_pager_getswapspace() can allocate at most INT_MAX blocks.  vm_size_t
also seems like the incorrect type to use here it refers only to the
size of the VM object, not the size of a mapping.  So:
- change the type of "size" in swap_pager_reserve() to vm_pindex_t, and
- clamp the requested number of blocks for a single
  swp_pager_getswapspace() call to INT_MAX.

Reported by: syzkaller
Reviewed by: dougm, alc, kib
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D31875

2 years agodtrace.1: Document a couple of preprocessor-related options
Mark Johnston [Tue, 7 Sep 2021 18:03:23 +0000 (14:03 -0400)]
dtrace.1: Document a couple of preprocessor-related options

Suggested by: swills
MFC after: 1 week
Sponsored by: The FreeBSD Foundation

2 years agomprotect.2: Improve the description of prot
Brooks Davis [Tue, 7 Sep 2021 16:28:50 +0000 (17:28 +0100)]
mprotect.2: Improve the description of prot

The new wording for standard flags is losely based on the POSIX
description.

Make it clearer that PROT_MAX() is a local extension.

Reviewed by: alc, mckusick, imp, kib, markj
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D31777

2 years agogenoffset.sh: Use 10 X's instead of 5 for pick mkdtemp implementations
Warner Losh [Tue, 7 Sep 2021 16:08:51 +0000 (10:08 -0600)]
genoffset.sh: Use 10 X's instead of 5 for pick mkdtemp implementations

Linux fails to build now because the mkdtemp in the bootstrapped
environment wants 6 or more X's. Use 10 out of an abundance of caution.

Sponsored by: Netflix
Reviewed by: arichards
Differential Revision: https://reviews.freebsd.org/D31863

2 years agocdefs.h: Remove redundant #ifdefs
Warner Losh [Tue, 7 Sep 2021 15:34:02 +0000 (09:34 -0600)]
cdefs.h: Remove redundant #ifdefs

Remove redunant #ifdef __GNUC__ inside an #if defined(__GNUC__)
block. They are nops.

Sponsored by: Netflix

2 years agodtrace.1: Document -x ldpath
Mark Johnston [Tue, 7 Sep 2021 15:18:28 +0000 (11:18 -0400)]
dtrace.1: Document -x ldpath

MFC after: 1 week
Sponsored by: The FreeBSD Foundation

2 years agokqueue.2: Document the fact that EVFILT_READ can be used on kqueues
Mark Johnston [Tue, 7 Sep 2021 15:17:33 +0000 (11:17 -0400)]
kqueue.2: Document the fact that EVFILT_READ can be used on kqueues

Reviewed by: bcr, kib
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D31864

2 years agoip6mrouter: Make the expiration callout MPSAFE
Mark Johnston [Tue, 7 Sep 2021 15:15:49 +0000 (11:15 -0400)]
ip6mrouter: Make the expiration callout MPSAFE

- Protect the `expire_upcalls` callout with the MFC6 mutex.  The callout
  handler needs this mutex anyway.
- Convert the MROUTER6 mutex to a sleepable sx lock.  It is only used
  when configuring the global v6 multicast routing socket, so is only
  used in system call paths where sleeping is safe.  This lets us drain
  the callout without having to drop the lock.
- For all locking macros in the file, convert to using a _LOCKPTR macro.

Reported by: mav
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D31836

2 years agoefirt: Mark buffers filled out by EFI firmware as initialized
Mark Johnston [Tue, 7 Sep 2021 14:07:04 +0000 (10:07 -0400)]
efirt: Mark buffers filled out by EFI firmware as initialized

Otherwise KMSAN may report false positives.

Sponsored by: The FreeBSD Foundation

2 years agond6: Make the DAD callout MPSAFE
Mark Johnston [Tue, 7 Sep 2021 13:49:47 +0000 (09:49 -0400)]
nd6: Make the DAD callout MPSAFE

Interface addresses with pending duplicate address detection (DAD) live
in a global queue.  In this case, a callout is associated with each
entry.  The callout transmits neighbour solicitations until the system
decides the address is no longer tentative, or until a duplicate address
is discovered.  At this point the entry is dequeued and freed.  DAD may
be manually stopped as well.

The callout currently runs (and potentially transmits packets) with
Giant held.  Reorganize DAD queue locking to interlock properly with the
callout:

- Configure the callout to acquire the DAD queue lock before running.
  The lock is dropped before transmitting any packets.  Stop protecting
  the callout with Giant.
- When looking up DAD queue entries for an incoming NS or NA, don't
  bother fiddling with the DAD queue entry reference count.
- Split nd6_dad_starttimer() so that the caller is responsible to
  transmitting a NS if it so desires.
- Remove the DAD entry from the queue before stopping the timer.  Use a
  temporary reference to make sure that the entry doesn't get freed by
  the callout while we're draining.

Reported by: mav
Reviewed by: bz, hrs
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D31826

2 years agog_label: Handle small sector sizes when tasting
Mark Johnston [Tue, 7 Sep 2021 13:46:58 +0000 (09:46 -0400)]
g_label: Handle small sector sizes when tasting

Make sure that the provider sector size is large enough to contain a
valid label before trying to read it.  We performed this check already
for most label types, but not for several filesystem labels.

Reported by: syzbot+f52918174cdf193ae29c@syzkaller.appspotmail.com
MFC after: 1 week
Sponsored by: The FreeBSD Foundation

2 years agosctp: Fix iterator synchronization in sctp_sendall()
Mark Johnston [Tue, 7 Sep 2021 13:44:57 +0000 (09:44 -0400)]
sctp: Fix iterator synchronization in sctp_sendall()

- The SCTP_PCB_FLAGS_SND_ITERATOR_UP check was racy, since two threads
  could observe that the flag is not set and then both set it.  I'm not
  sure if this is actually a problem in practice, i.e., maybe there's no
  problem having multiple sends for a single PCB in the iterator list?
- sctp_sendall() was modifying sctp_flags without the inp lock held.

The change simply acquires the PCB write lock before toggling the flag,
fixing both problems.

Reviewed by: tuexen
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D31813

2 years agosctp: Remove an unused sctp_inpcb field
Mark Johnston [Tue, 7 Sep 2021 13:44:48 +0000 (09:44 -0400)]
sctp: Remove an unused sctp_inpcb field

This appears to be unused in usrsctp as well.  No functional change
intended.

Reviewed by: tuexen
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D31812

2 years agosctp: Fix races around sctp_inpcb_free()
Mark Johnston [Tue, 7 Sep 2021 13:44:12 +0000 (09:44 -0400)]
sctp: Fix races around sctp_inpcb_free()

sctp_close() and sctp_abort() disassociate the PCB from its socket.
As a part of this, they attempt to free the PCB, which may end up
lingering.  Fix some bugs in this area:

- For some reason, sctp_close() and sctp_abort() set
  SCTP_PCB_FLAGS_SOCKET_GONE using an atomic compare-and-set without the
  PCB lock held.  This is racy since sctp_flags is normally updated
  without atomics, using the PCB lock to synchronize.  So, the update
  can be lost, which can cause all sort of races with other SCTP
  components which look for the _GONE flag.  Fix the problem simply by
  acquiring the PCB lock in order to set the flag.  Note that we have to
  drop and re-acquire the lock again in sctp_inpcb_free(), but I don't
  see a good way around that for now.  If it's a real problem, the _GONE
  flag could be split out of sctp_flags and into a dedicated sctp_inpcb
  field.
- In sctp_inpcb_free(), load sctp_socket after acquiring the PCB lock,
  to avoid possible races with parallel sctp_inpcb_free() calls.
- Add an assertion sctp_inpcb_free() to verify that _ALLGONE is not set.

Reviewed by: tuexen
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D31811

2 years agopf: remove unused function prototype
Kristof Provost [Tue, 7 Sep 2021 12:33:59 +0000 (14:33 +0200)]
pf: remove unused function prototype

MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")

2 years agowpa: Address CTRL-EVENT-SCAN-FAILED
Cy Schubert [Tue, 7 Sep 2021 01:48:39 +0000 (18:48 -0700)]
wpa: Address CTRL-EVENT-SCAN-FAILED

Some installations may experience CTRL-EVENT-SCAN-FAILED when
associating to an AP. Installations that specify
ifconfig_wlan0="WPA ... up" in rc.conf do not experience
the problem whereas those which specify ifconfig_wlan0="WPA" without
the "up" will experience CTRL-EVENT-SCAN_FAILED.

However those that specify "up" in ifconfig_wlan0 will be able to
reproduce this problem by service netif stop wlan0;
service netif start wlan0. Interestingly The service netif stop/start
problem is reproducible on the older wpa 2.9 as well.

Reported by: dhw
Reported by: "Oleg V. Nauman" <oleg _ theweb_org_ua>
Reported by: Filipe da Silva Santos <contact _ shiori_com_br>
Reported by: Jakob Alvermark <jakob _ alvermark_net>
MFC after: 3 days

2 years agoFix cross-builds after 4e5d32a445f90d37966cd6de571978551654e3f3
Jose Luis Duran [Mon, 30 Aug 2021 19:29:17 +0000 (16:29 -0300)]
Fix cross-builds after 4e5d32a445f90d37966cd6de571978551654e3f3

Add alignment macros to cross-build's sys/cdefs.h

Pull Request: https://github.com/freebsd/freebsd-src/pull/531
MFC after: immediately (build fix)

2 years agopkgbase: Create a FreeBSD-ftp package
Emmanuel Vadot [Thu, 2 Sep 2021 15:14:20 +0000 (17:14 +0200)]
pkgbase: Create a FreeBSD-ftp package

ftp tools aren't that useful nowadays but some might want them.
Create a FreeBSD-ftp package so users have a choice to have
them or not.

Differential Revision: https://reviews.freebsd.org/D31794

2 years agopkgbase: Create a FreeBSD-hyperv package
Emmanuel Vadot [Thu, 2 Sep 2021 15:13:45 +0000 (17:13 +0200)]
pkgbase: Create a FreeBSD-hyperv package

Put all hyperv utilities in it.

Differential Revision:  https://reviews.freebsd.org/D31805

2 years agopkgbase: Remove libefivar package and add a efi-tools one
Emmanuel Vadot [Thu, 2 Sep 2021 15:12:51 +0000 (17:12 +0200)]
pkgbase: Remove libefivar package and add a efi-tools one

Put all the efi related tools into FreeBSD-efi-tools.

Differential Revision: https://reviews.freebsd.org/D31803

2 years agopkgbase: Remove FreeBSD-libregex package
Emmanuel Vadot [Thu, 2 Sep 2021 06:14:56 +0000 (08:14 +0200)]
pkgbase: Remove FreeBSD-libregex package

The only user of libregex is grep (and its variation), no need for a
dedicated package.
This moves libregex to the default package (FreeBSD-utilities).

Differential Revision: https://reviews.freebsd.org/D31802

2 years agopkgbase: Create a FreeBSD-kerberos package
Emmanuel Vadot [Thu, 2 Sep 2021 04:09:15 +0000 (06:09 +0200)]
pkgbase: Create a FreeBSD-kerberos package

This allows users to install or not kerberos related utilities
and libs.

Differential Revision: https://reviews.freebsd.org/D31801

2 years agopkgbase: Put libbsdxml in FreeBSD-runtime
Emmanuel Vadot [Wed, 1 Sep 2021 18:25:50 +0000 (20:25 +0200)]
pkgbase: Put libbsdxml in FreeBSD-runtime

libbsdxml is used by a lot of programs so just put it in FreeBSD-runtime.

Differential Revision: https://reviews.freebsd.org/D31800
Reviewed by: emaste

2 years agopkgbase: Create a FreeBSD-rdma package
Emmanuel Vadot [Wed, 1 Sep 2021 18:23:56 +0000 (20:23 +0200)]
pkgbase: Create a FreeBSD-rdma package

Put all the rdma related tools into this package.

Differential Revision:  https://reviews.freebsd.org/D31799

2 years agopkgbase: Create a syscons-data package
Emmanuel Vadot [Wed, 1 Sep 2021 17:58:27 +0000 (19:58 +0200)]
pkgbase: Create a syscons-data package

syscons is mostly deprecated and all it's files aren't needed for most
users so create a separate package for them.

Differential Revision:    https://reviews.freebsd.org/D31798
Reviewed by: emaste

2 years agopkgbase: Create a vt-data package
Emmanuel Vadot [Wed, 1 Sep 2021 17:56:55 +0000 (19:56 +0200)]
pkgbase: Create a vt-data package

vt files for either keyboards and fonts are totally optional
so create a separate package for them.

Differential Revision:      https://reviews.freebsd.org/D31797

2 years agopkgbase: Create a FreeBSD-dwatch package
Emmanuel Vadot [Wed, 1 Sep 2021 17:38:40 +0000 (19:38 +0200)]
pkgbase: Create a FreeBSD-dwatch package

While dwatch is useful some users might not want it by default.
Create a package for it.

Differential Revision: https://reviews.freebsd.org/D31796

2 years agopkgbase: Create a mlx-tools package
Emmanuel Vadot [Wed, 1 Sep 2021 17:12:09 +0000 (19:12 +0200)]
pkgbase: Create a mlx-tools package

mlx* are only useful for users who have a Mellanox card.
Create a package for it so users that don't have this card can
avoid having this program.

Differential Revision: https://reviews.freebsd.org/D31795

2 years agopkgbase: Create a cxgbe-tools package
Emmanuel Vadot [Wed, 1 Sep 2021 17:08:49 +0000 (19:08 +0200)]
pkgbase: Create a cxgbe-tools package

cxgbetool is only useful for users who have a Chelsio card.
Create a package for it so users that don't have this card can
avoid having this program.

Differential Revision: https://reviews.freebsd.org/D31793

2 years agopkgbase: Move spppcontrol to FreeBSD-ppp
Emmanuel Vadot [Wed, 1 Sep 2021 17:03:38 +0000 (19:03 +0200)]
pkgbase: Move spppcontrol to FreeBSD-ppp

This program belong with the other ppp-related programs.

Differential Revision:  https://reviews.freebsd.org/D31792
Reviewed by: emaste

2 years agopkgbase: Create a FreeBSD-telnet package
Emmanuel Vadot [Wed, 1 Sep 2021 17:02:00 +0000 (19:02 +0200)]
pkgbase: Create a FreeBSD-telnet package

both telnet and telnetd aren't that useful nowadays but some
might want them.
Create a FreeBSD-telnet package so users have a choice to have
them or not.

Differential Revision: https://reviews.freebsd.org/D31791
Reviewed by: emaste

2 years agopkgbase: Create a FreeBSD-ggate package
Emmanuel Vadot [Wed, 1 Sep 2021 15:16:07 +0000 (17:16 +0200)]
pkgbase: Create a FreeBSD-ggate package

Move ggate* to it.

Differential Revision: https://reviews.freebsd.org/D31790

2 years agoixgbe: increase the timeout
Qiming Yang [Wed, 10 Jan 2018 16:04:33 +0000 (00:04 +0800)]
ixgbe: increase the timeout

Increase SECRX_RDY polling frequency and semaphore timeout which
fixes the FWSW.PT check in ixgbe_mng_present().

Signed-off-by: Qiming Yang <qiming.yang@intel.com>
Acked-by: Wenzhuo Lu <wenzhuo.lu@intel.com>
Approved by: imp
Obtained from: DPDK (6175260d12cc22852cecf2fb7ecd95cdb07611b5)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31621

2 years agoixgbe: cleanup spelling mistakes in comments
Guinan Sun [Thu, 9 Jul 2020 08:00:33 +0000 (08:00 +0000)]
ixgbe: cleanup spelling mistakes in comments

Several functions in the driver code have a weird function comment
formatting which uses two spaces instead of only one space for the main
function body.

This formatting will be mechanically fixed by sed in a future patch, but
doing so leads to some spelling warnings on that patch. Cleanup the
spelling mistakes that will be detected first. This way, it is easier to
verify the mechanical transformation done by sed in the following patch.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Signed-off-by: Guinan Sun <guinanx.sun@intel.com>
Reviewed-by: Wei Zhao <wei.zhao1@intel.com>
Approved by: imp
Obtained from: DPDK (fc75eee32037c1379e77e57031c1c353badd2272)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31621

2 years agoixgbe: remove unnecessary return value check
Guinan Sun [Thu, 9 Jul 2020 08:00:38 +0000 (08:00 +0000)]
ixgbe: remove unnecessary return value check

Remove unnecessary return value check.

Signed-off-by: Jakub Chylkowski <jakubx.chylkowski@intel.com>
Signed-off-by: Guinan Sun <guinanx.sun@intel.com>
Reviewed-by: Wei Zhao <wei.zhao1@intel.com>
Approved by: imp
Obtained from: DPDK (4b0ee6529b7897c2a08dd56669f07ac1f46a8474)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31621

2 years agoixgbe: create function to restart autoneg
Guinan Sun [Thu, 9 Jul 2020 08:00:36 +0000 (08:00 +0000)]
ixgbe: create function to restart autoneg

This patch is for restarting auto negotiation on PHY.

Signed-off-by: Jakub Chylkowski <jakubx.chylkowski@intel.com>
Signed-off-by: Guinan Sun <guinanx.sun@intel.com>
Reviewed-by: Wei Zhao <wei.zhao1@intel.com>
Approved by: imp
Obtained from: DPDK (664ea2614eafbec8eda5c86764ff047475a1e5c6)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31621

2 years agoixgbe: add register definitions for NVM update
Guinan Sun [Thu, 9 Jul 2020 08:00:32 +0000 (08:00 +0000)]
ixgbe: add register definitions for NVM update

Added additional register for X550 and above device family.

Signed-off-by: Piotr Skajewski <piotrx.skajewski@intel.com>
Signed-off-by: Guinan Sun <guinanx.sun@intel.com>
Reviewed-by: Wei Zhao <wei.zhao1@intel.com>
Approved by: imp
Obtained from: DPDK (4a6847d78814b1c3df896efe31562643d419317d)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31621

2 years agoixgbe: move increments after evaluations
Guinan Sun [Thu, 9 Jul 2020 08:00:35 +0000 (08:00 +0000)]
ixgbe: move increments after evaluations

The retry variable was being incremented before it was evaluated by the
subsequent conditional against the maximum retries to figure out which
message to print.  So we'll move the increment op to the end.

Signed-off-by: Jeb Cramer <jeb.j.cramer@intel.com>
Signed-off-by: Guinan Sun <guinanx.sun@intel.com>
Reviewed-by: Wei Zhao <wei.zhao1@intel.com>
Approved by: imp
Obtained from: DPDK (390445ec30b4c52a3d2887c3d2a202d9cf37ea8e)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31621

2 years agoixgbe: remove whitespace in function comments
Kevin Bowling [Tue, 7 Sep 2021 03:26:44 +0000 (20:26 -0700)]
ixgbe: remove whitespace in function comments

Remove unnecessary extra whitespace on all function comments, replacing
' *  ' with ' * '.

This was done automatically via sed using the following transformation:

  sed 's/^ \*  / * /'

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Signed-off-by: Guinan Sun <guinanx.sun@intel.com>
Reviewed-by: Wei Zhao <wei.zhao1@intel.com>
Approved by: imp
Obtained from: DPDK (40023f73c76579e58a859dab87b4c30278eb2e48)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31621

2 years agoixgbe: support DCB registers dump
Xiaoyun Li [Mon, 17 Sep 2018 09:28:13 +0000 (17:28 +0800)]
ixgbe: support DCB registers dump

Add support for DCB registers dump.

Signed-off-by: Xiaoyun Li <xiaoyun.li@intel.com>
Acked-by: Qi Zhang <qi.z.zhang@intel.com>
Approved by: imp
Obtained from: DPDK (36a036bc6fdd0da74576a39ab74e50954598ba82)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31621

2 years agoixgbe: update X550 SFP identification
Xiaoyun Li [Mon, 17 Sep 2018 09:28:12 +0000 (17:28 +0800)]
ixgbe: update X550 SFP identification

Use ixgbe_identify_sfp_module_X550em to update SFP identification
flow. ixgbe_identify_sfp_module_X550em includes specific checks for
X550 about supported SFP modules.

Signed-off-by: Xiaoyun Li <xiaoyun.li@intel.com>
Acked-by: Qi Zhang <qi.z.zhang@intel.com>
Approved by: imp
Obtained from: DPDK (175bedb0cc8f801be3050fa35b8d8d0971cea7cc)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31621

2 years agoixgbe: Update copyright to 2020
Kevin Bowling [Tue, 7 Sep 2021 03:11:44 +0000 (20:11 -0700)]
ixgbe: Update copyright to 2020

Synced to the ixgbe shared code with DPDK shared code which has local
fixes on top of "not-released-cid-ixgbe.2020.06.09.tar.gz"

Approved by: imp
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31621

2 years agoixgbe: remove dead code
Ferruh Yigit [Tue, 30 Jun 2020 14:45:54 +0000 (15:45 +0100)]
ixgbe: remove dead code

The question around getting rid of the assignments seems lived
long enough, if they are not needed until now, we can drop them.

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Qi Zhang <qi.z.zhang@intel.com>
Approved by: imp
Obtained from: DPDK (a6395d471e14e5a7432875dad8fb3533238c5167)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31621

2 years agoixgbe: replace an operation in X550 setup
Xiaoyun Li [Mon, 17 Sep 2018 09:28:11 +0000 (17:28 +0800)]
ixgbe: replace an operation in X550 setup

Replace "=" operation with "|=" operation to only set the intended
register bits.

Signed-off-by: Xiaoyun Li <xiaoyun.li@intel.com>
Acked-by: Qi Zhang <qi.z.zhang@intel.com>
Approved by: imp
Obtained from: DPDK (1b665ccd9cd73499e934b807bec2fd77193912ef)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31621

2 years agoixgbe: Use C99 bool types
Kevin Bowling [Tue, 7 Sep 2021 02:54:22 +0000 (19:54 -0700)]
ixgbe: Use C99 bool types

Approved by: imp
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31621

2 years agoixgbe: add FW recovery mode check
Xiaoyun Li [Mon, 17 Sep 2018 09:28:10 +0000 (17:28 +0800)]
ixgbe: add FW recovery mode check

Add FM NVM recovery mode check. Allow the software to detect this.

Signed-off-by: Xiaoyun Li <xiaoyun.li@intel.com>
Acked-by: Qi Zhang <qi.z.zhang@intel.com>
Approved by: imp
Obtained from: DPDK (5fb0a9acbb844b21691568c0014866e0e887bd19)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31621

2 years agoixgbe: add typecast for type mismatch
Guinan Sun [Thu, 9 Jul 2020 08:00:37 +0000 (08:00 +0000)]
ixgbe: add typecast for type mismatch

Add typecast for type mismatch.

Signed-off-by: Jakub Chylkowski <jakubx.chylkowski@intel.com>
Signed-off-by: Guinan Sun <guinanx.sun@intel.com>
Reviewed-by: Wei Zhao <wei.zhao1@intel.com>
Approved by: imp
Obtained from: DPDK (d8e52b2cf771c31b523b46852fd86225b5a2c721)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31621

2 years agoixgbe: wait for link after copper MAC setup
Ashijeet Acharya [Fri, 24 May 2019 09:30:15 +0000 (11:30 +0200)]
ixgbe: wait for link after copper MAC setup

After setting up the link on x552/X557-AT 10GBASE-T NICs, sometimes the
link does not get set up properly and as a result all the subsequent
calls to ixgbe_check_link() from ixgbe_dev_link_update_share() fail.

Introduce a delay time of 1s in ixgbe_setup_mac_link_t_X550em() before
beginning to set up the external PHY link speed to ensure that the
controller can acquire the link.

Signed-off-by: Ashijeet Acharya <ashijeet.acharya@6wind.com>
Acked-by: Qi Zhang <qi.z.zhang@intel.com>
Approved by: imp
Obtained from: DPDK (d31b95860d8e9dd7c6e242bd08baaac00a9714f0)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31621

2 years agoixgbe: check host interface return status
Guinan Sun [Thu, 9 Jul 2020 08:00:44 +0000 (08:00 +0000)]
ixgbe: check host interface return status

Writing to read-only fields returns a non-OK Return Status
for shadow RAM write command for X550.
This information was previously discarded.

Signed-off-by: Stanislaw Grzeszczak <stanislaw.a.grzeszczak@intel.com>
Signed-off-by: Guinan Sun <guinanx.sun@intel.com>
Reviewed-by: Wei Zhao <wei.zhao1@intel.com>
Approved by: imp
Obtained from: DPDK (db18e37090a3b9af47d6a6886248520f6b220bf9)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31621

2 years agoixgbe: initialize data field in struct buffer
Guinan Sun [Thu, 9 Jul 2020 08:00:40 +0000 (08:00 +0000)]
ixgbe: initialize data field in struct buffer

While sending request using ixgbe_hic_unlocked() the data field in
buffer struct is not used. It is set when the struct is overwritten by
FW to deliver the response. To not pass random data to FW the whole
structure should be zeroed before use.

Signed-off-by: Krzysztof Galazka <krzysztof.galazka@intel.com>
Signed-off-by: Piotr Pietruszewski <piotr.pietruszewski@intel.com>
Signed-off-by: Guinan Sun <guinanx.sun@intel.com>
Reviewed-by: Wei Zhao <wei.zhao1@intel.com>
Approved by: imp
Obtained from: DPDK (40543be5376ca415b2a7e196315d0555725b8bdf)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31621

2 years agoixgbe: fix x550em 10G NIC link status
Guinan Sun [Thu, 9 Jul 2020 08:00:30 +0000 (08:00 +0000)]
ixgbe: fix x550em 10G NIC link status

With the NVM image for x550em XFI will not report
the auto-negotiation feature correctly. The auto-negotiation
should be "No" for supports and advertised items.
At the same time update speed makes it support 1G and 10G.

Signed-off-by: Piotr Skajewski <piotrx.skajewski@intel.com>
Signed-off-by: Guinan Sun <guinanx.sun@intel.com>
Reviewed-by: Wei Zhao <wei.zhao1@intel.com>
Approved by: imp
Obtained from: DPDK (fb03b51da940f1d56d701776fd85a0dfc1ace098)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31621

2 years agoixgbe: fix maximum wait time in comment
Xiaolong Ye [Thu, 15 Nov 2018 07:20:05 +0000 (15:20 +0800)]
ixgbe: fix maximum wait time in comment

As the code has changed the max wait time to 1000ms, the comment should
be changed accordingly.

Signed-off-by: Xiaolong Ye <xiaolong.ye@intel.com>
Acked-by: Qi Zhang <qi.z.zhang@intel.com>
Approved by: imp
Obtained from: DPDK (73247f1ced303c16987bb366d38a2d8a0fc40db4)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31621

2 years agoixgbe: wait longer for link after fiber MAC setup
Matthew Smith [Mon, 16 Jul 2018 16:36:04 +0000 (11:36 -0500)]
ixgbe: wait longer for link after fiber MAC setup

After setting up the link on a fiber port, the maximum wait time for
the link to come up is 500 ms in ixgbe_setup_mac_link_multispeed_fiber().
On an x550 SFP+ port, this is often not sufficiently long for the link
to come up. This can result in never being able to retrieve accurate
link status for the port using rte_eth_link_get_nowait().

Increase the maximum wait time in ixgbe_setup_mac_link_multispeed_fiber()
to 1 s.

Signed-off-by: Matthew Smith <mgsmith@netgate.com>
Acked-by: Qi Zhang <qi.z.zhang@intel.com>
Approved by: imp
Obtained from: DPDK (64f1c8539c8ce99214b9eb1fb728a2c6745f3300)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31621

2 years agoixgbe: fix host interface shadow RAM read
Guinan Sun [Thu, 9 Jul 2020 08:00:28 +0000 (08:00 +0000)]
ixgbe: fix host interface shadow RAM read

Host interface Shadow RAM Read (0x31) command response
buffer length should be stored in two bytes, instead of one byte.
This patch fixes it.

Signed-off-by: Mateusz Kowalski <mateusz.kowalski@intel.com>
Signed-off-by: Guinan Sun <guinanx.sun@intel.com>
Reviewed-by: Wei Zhao <wei.zhao1@intel.com>
Approved by: imp
Obtained from: DPDK (713fc4dd340e5eadd3bfa9a468446afaa5188624)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31621

2 years agoixgbe: fix response to apply-update command
Guinan Sun [Thu, 9 Jul 2020 08:00:29 +0000 (08:00 +0000)]
ixgbe: fix response to apply-update command

For the "Apply Update" command the firmware does not
given an response. For this command, success should
be return.

Signed-off-by: Mateusz Kowalski <mateusz.kowalski@intel.com>
Signed-off-by: Guinan Sun <guinanx.sun@intel.com>
Reviewed-by: Wei Zhao <wei.zhao1@intel.com>
Approved by: imp
Obtained from: DPDK (03b09c71c0c6c516ce05cad8e8aa75e8b9e14fba)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31621

2 years agoixgbe: improve log about autoneg being disabled
Guinan Sun [Thu, 9 Jul 2020 08:00:41 +0000 (08:00 +0000)]
ixgbe: improve log about autoneg being disabled

On ESXi OS, when user disables auto negotiation, the following log
appears: "(unsupported) Flow control autoneg is disabled".
It is true that auto negotiation is disabled but it is
not necessarily true that it is not supported.

Signed-off-by: Jakub Chylkowski <jakubx.chylkowski@intel.com>
Signed-off-by: Guinan Sun <guinanx.sun@intel.com>
Reviewed-by: Wei Zhao <wei.zhao1@intel.com>
Approved by: imp
Obtained from: DPDK (ab6ac48d483ef7f906b90f45182f2ddf3254d876)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31621

2 years agoixgbe: add IPv6 mask for flow director
Guinan Sun [Thu, 9 Jul 2020 08:00:42 +0000 (08:00 +0000)]
ixgbe: add IPv6 mask for flow director

Write FDIRIP6M register to allow flow director filter
to set ipv6 rules without setting ipv6 source/destination address.

Signed-off-by: Piotr Skajewski <piotrx.skajewski@intel.com>
Signed-off-by: Guinan Sun <guinanx.sun@intel.com>
Reviewed-by: Wei Zhao <wei.zhao1@intel.com>
Approved by: imp
Obtained from: DPDK (21feefa2fcd5899ee26a10be405c17c0a1109860)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31621

2 years agoixgbe: fix infinite recursion on PCIe link down
Guinan Sun [Thu, 9 Jul 2020 08:00:31 +0000 (08:00 +0000)]
ixgbe: fix infinite recursion on PCIe link down

In some corner cases the functions ixgbe_clear_rar_generic and
ixgbe_clear_vmdq_generic may call one another leading to infinite
recursion.

When ixgbe_clear_vmdq_generic is called with IXGBE_CLEAR_VMDQ_ALL
flag, it's going to clear MPSAR registers, and proceed to call
ixgbe_clear_rar_generic, which in turn will clear the RAR registers,
and recursively call back ixgbe_clear_vmdq_generic. Normally, the
latter would detect that MPSAR registers have already been cleared
and terminate the recursion.

However, when PCIe link is down, and before the driver has had the
opportunity to shut itself down, all register reads return 0xFFFFFFFF,
and all register writes fail silently. In such case, because
ixgbe_clear_vmdq_generic blindly assumes that clearing MPSAR registers
succeeded, it's going to always call ixgbe_clear_rar_generic, which
in turn will always call back ixgbe_clear_vmdq_generic, creating
infinite recursion.

This patch re-reads MPSAR register values after they had been cleared.
In case of PCIe link failure, the values read will be non-zero, which
will terminate the recursion. On the other hand, under normal
circumstances the value read from MPSAR registers is going to be equal
to the value previously written, so this patch is expected not to cause
any regressions.

Signed-off-by: Robert Konklewski <robertx.konklewski@intel.com>
Signed-off-by: Guinan Sun <guinanx.sun@intel.com>
Reviewed-by: Wei Zhao <wei.zhao1@intel.com>
Approved by: imp
Obtained from: DPDK (2d04b9e856125197ec8e967471426d56ab7efcf0)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31621

2 years agoixgbe: clear all queues on VF reset
Simon Ellmann [Thu, 17 Dec 2020 17:14:52 +0000 (18:14 +0100)]
ixgbe: clear all queues on VF reset

ixgbe devices support up to 8 Rx and Tx queues per virtual function.
Currently, the registers of only seven queues are set to default when
resetting a VF.

Signed-off-by: Simon Ellmann <simon.ellmann@tum.de>
Acked-by: Haiyue Wang <haiyue.wang@intel.com>
Approved by: imp
Obtained from: DPDK (d2565b347915def3a0f3c68bde6824acf096a0e6)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31621

2 years agokqueue: drain kqueue taskqueue if syscall tickled it
Konstantin Belousov [Mon, 6 Sep 2021 11:43:06 +0000 (14:43 +0300)]
kqueue: drain kqueue taskqueue if syscall tickled it

Otherwise return from the syscall and next syscall, which could be
kevent(2) on the kqueue that should be notified, races with the kqueue
taskqueue thread, and potentially misses the wakeup.  This is reliably
visible when kevent(2) only peeks into events using zeroed timeout.

PR: 258310
Reported by: arichardson, Jan Kokemüller <jan.kokemueller@gmail.com>
Reviewed by: arichardson, markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D31858

2 years agolltable: do not require prefix lookup when checking lle allocation rules.
Alexander V. Chernikov [Fri, 3 Sep 2021 11:48:36 +0000 (11:48 +0000)]
lltable: do not require prefix lookup when checking lle allocation rules.

With the new FIB_ALGO infrastructure, nearly all subsystems use
 fib[46]_lookup() functions, which provides lockless lookups.
A number of places remains that uses old-style lookup functions, that
 still requires RIB read lock to return the result. One of such places
 is arp processing code.
FIB_ALGO implementation makes some tradeoffs, resulting in (relatively)
 prolonged periods of holding RIB_WLOCK. If the lock is held and datapath
 competes for it, the RX ring may get blocked, ending in traffic delays and losses.
As currently arp processing is performed directly in the interrupt handler,
 handling ARP replies triggers the problem descibed above when the amount of
 ARP replies is high.

To be more specific, prior to creating new ARP entry, routing lookup for the entry
 address in interface fib is executed. The following conditions are the verified:

1. If lookup returns an empty result, or the resulting prefix is non-directly-reachable,
 failure is returned. The only exception are host routes w/ gateway==address.
2. If the routing lookup returns different interface and non-host route,
 we want to support the use case of having multiple interfaces with the same prefix.
 In fact, the current code just checks if the returned prefix covers target address
 (always true) and effectively allow allocating ARP entries for any directly-reachable prefix,
 regardless of its interface.

Change the code to perform the following:

1) use fib4_lookup() to get the nexthop, instead of requesting exact prefix.
2) Rewrite first condition check using nexthop flags (1:1 match)
3) Rewrite second condition to check for interface addresses matching target address on
 the input interface.

Differential Revision: https://reviews.freebsd.org/D31824
Reviewed by: ae
MFC after: 1 week
PR: 257965

2 years agocompiler-rt: add aarch64 init function for LSE atomics
Dimitry Andric [Mon, 6 Sep 2021 19:23:10 +0000 (21:23 +0200)]
compiler-rt: add aarch64 init function for LSE atomics

As reported by Ronald, adding the out-of-line LSE atomics helpers for
aarch64 to compiler-rt was not sufficient to link programs using these,
as they also require a __aarch64_have_lse_atomics global. This is
initialized in compiler-rt's lib/builtins/cpu_model.c, roughly similar
to the x86 CPU model and feature detection in that file.

Since upstream does not yet have a FreeBSD specific implementation for
getting the required information, add a simple one that should work for
now, while I try to get it sorted with the LLVM people.

Reported by: Ronald Klop <ronald-lists@klop.ws>
Fixes: cc55ee8009a5
PR: 257392
MFC after: 2 weeks

2 years agoFix powf().
Mark Murray [Mon, 6 Sep 2021 17:26:39 +0000 (18:26 +0100)]
Fix powf().

Summary:
From Steve Kargl:

Paul Zimmermann has identified a bug in Openlibm's powf(),
which is identical to FreeBSD's libm.  Both derived from
fdlibm. https://github.com/JuliaMath/openlibm/issues/212.

Consider

% cat h.c
int
main(void)
{
  float x, y, z;
  x =  0x1.ffffecp-1F;
  y = -0x1.000002p+27F;
  z =  0x1.557a86p115F;
  printf("%e %e %e <-- should be %e\n", x, y, powf(x,y), z);
  return 0;
}

% cc -o h -fno-builtin h.c -lm && ./h
9.999994e-01 -1.342177e+08 inf <-- should be 5.540807e+34

Reviewers: manu

Subscribers: imp, andrew, emaste

Differential Revision: https://reviews.freebsd.org/D31865

2 years agogit-arc: allow word splitting in build_commit_list()
Robert Wing [Mon, 6 Sep 2021 15:42:46 +0000 (07:42 -0800)]
git-arc: allow word splitting in build_commit_list()

git-rev-list expects commits to be listed separately, allow word
splitting and disable shellcheck SC2086 when using git-rev-list
to build the commit list.

Fixes: 4fd0c6ab1a9e ("Fix most shellcheck warnings in git-arc.sh")
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D31838

2 years agoiconv: Fix "make make-ref"
Edward Tomasz Napierala [Mon, 6 Sep 2021 14:47:30 +0000 (15:47 +0100)]
iconv: Fix "make make-ref"

The purpose of this command is to "refresh" the source reference
files generated with GNU libiconv, located in tools/test/iconv/ref/.
Previously it would generate copies somewhere in OBJDIR, which
we don't use.

Reviewed By: allanjude
Sponsored by:   Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D31820

2 years agoiconv: Fix tablegen iconv test utility on arm64
Edward Tomasz Napierala [Mon, 6 Sep 2021 14:44:59 +0000 (15:44 +0100)]
iconv: Fix tablegen iconv test utility on arm64

Previously it would loop indefinitely on getopt_long(3)
due to 'char' being unsigned.

Reviewed By: allanjude
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D31817

2 years agoiconv: Fix path names used by iconv(3) tests.
Edward Tomasz Napierala [Mon, 6 Sep 2021 14:43:24 +0000 (15:43 +0100)]
iconv: Fix path names used by iconv(3) tests.

Reviewed By: allanjude
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D31815

2 years agoiconv: Make it possible to build iconv(3) test suite.
Edward Tomasz Napierala [Mon, 6 Sep 2021 14:41:06 +0000 (15:41 +0100)]
iconv: Make it possible to build iconv(3) test suite.

It was broken after 1243a98e38a5.

Reviewed By: allanjude
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D31816

2 years agostress2: Added a syzkaller reproducer
Peter Holm [Mon, 6 Sep 2021 13:32:23 +0000 (13:32 +0000)]
stress2: Added a syzkaller reproducer

2 years agoEnable MK_LLVM_BINUTILS if MK_ASAN is requested
Alex Richardson [Mon, 6 Sep 2021 09:24:33 +0000 (10:24 +0100)]
Enable MK_LLVM_BINUTILS if MK_ASAN is requested

ASan will not be able to provide backtraces with symbol names with
elftoolchain's addr2line. To fix this turn MK_LLVM_BINUTILS on by
default when ASan instrumentation is requested.

Reviewed By: emaste, markj
Differential Revision: https://reviews.freebsd.org/D31061

2 years agoAdd WITH_LLVM_BINUTILS to install LLVM binutils instead of Elftoolchain
Alex Richardson [Mon, 6 Sep 2021 08:49:49 +0000 (09:49 +0100)]
Add WITH_LLVM_BINUTILS to install LLVM binutils instead of Elftoolchain

When WITH_LLVM_BINUTILS is set, we will install the LLVM binutils as
ar/ranlib/nm/objcopy/etc. instead of the elftoolchain ones.
Having the LLVM binutils instead of the elftoolchain ones allows us to use
features such as LTO that depend on binutils that understand LLVM IR.
Another benefit will be an improved user-experience when compiling with
AddressSanitizer, since ASAN does not symbolize backtraces correctly if
addr2line is elftoolchain addr2line instead of llvm-symbolizer.
See https://lists.freebsd.org/archives/freebsd-toolchain/2021-July/000062.html
for more details.

This is currently off by default but will be turned on by default at some
point in the near future.

Reviewed By: emaste

Differential Revision: https://reviews.freebsd.org/D31060

2 years agoDon't build and install {llvm,clang,lldb}-tblgen for the target
Alex Richardson [Mon, 6 Sep 2021 08:31:58 +0000 (09:31 +0100)]
Don't build and install {llvm,clang,lldb}-tblgen for the target

The tablegen binaries are only needed to build software that uses
LLVM's infrastructure for command line options,
disassembler tables, etc. They are not user-facing binaries and
should therefore not be installed by default.

Reviewed By: emaste
Differential Revision: https://reviews.freebsd.org/D31058

2 years agoDon't default MK_LLVM_TARGET_ALL to yes unless MK_CLANG is requested
Alex Richardson [Mon, 6 Sep 2021 08:31:24 +0000 (09:31 +0100)]
Don't default MK_LLVM_TARGET_ALL to yes unless MK_CLANG is requested

When building -DWITH_LLVM_BINUTILS -DWITHOUT_CLANG, this avoids
building a few hundred C++ source files that should not be needed
by default.

Reviewed By: emaste
Differential Revision: https://reviews.freebsd.org/D31059

2 years agoAdd _sleep to TSLOG
Colin Percival [Sun, 5 Sep 2021 19:50:15 +0000 (12:50 -0700)]
Add _sleep to TSLOG

Most of the nvme initialization time in my tests is being spent here
(via pause_sbt).

2 years agoAdd some nvme initialization routines to TSLOG
Colin Percival [Sun, 5 Sep 2021 19:48:43 +0000 (12:48 -0700)]
Add some nvme initialization routines to TSLOG

About 335 ms of EC2 instance boot time is being spent here.

2 years agoAdd run_interrupt_driven_config_hooks to TSLOG
Colin Percival [Sun, 5 Sep 2021 19:45:29 +0000 (12:45 -0700)]
Add run_interrupt_driven_config_hooks to TSLOG

The 'intr_config_hooks' SYSINIT is now taking a nontrivial amount of
time in my profiling; run_interrupt_driven_config_hooks is responsible
for most of it, so this adds useful information to the resulting
flamecharts.

2 years agohpen(4): removed leftover hpen_final_digi_cb declaration
Mateusz Guzik [Sun, 5 Sep 2021 17:30:51 +0000 (17:30 +0000)]
hpen(4): removed leftover hpen_final_digi_cb declaration

2 years agostress2: Added missing ktrace() cleanup
Peter Holm [Sun, 5 Sep 2021 07:01:20 +0000 (09:01 +0200)]
stress2: Added missing ktrace() cleanup

2 years agosound(4): Remove pointless Giant from bus_dma_tag_create().
Alexander Motin [Sat, 4 Sep 2021 22:22:53 +0000 (18:22 -0400)]
sound(4): Remove pointless Giant from bus_dma_tag_create().

None of the drivers really implement asynchronous buffer loading, so
they don't need lock there.  The only question is which of them have
BUS_DMA_NOWAIT flag there already, and to which it should be added.

2 years agoffs: remove unused thread argument from ffs_reload()
Robert Wing [Sat, 4 Sep 2021 20:25:10 +0000 (12:25 -0800)]
ffs: remove unused thread argument from ffs_reload()

MFC After:      1 week
Reviewed by: imp, kib
Differential Revision: https://reviews.freebsd.org/D31127

2 years agoRemove impossible checks.
Alexander Motin [Sat, 4 Sep 2021 20:10:50 +0000 (16:10 -0400)]
Remove impossible checks.

2 years agoioat(4): Remove Giant from ioat_test enable/disable.
Alexander Motin [Sat, 4 Sep 2021 19:53:28 +0000 (15:53 -0400)]
ioat(4): Remove Giant from ioat_test enable/disable.

MFC after: 1 month

2 years agoaltq: mark callouts as mpsafe
Kristof Provost [Sat, 4 Sep 2021 12:18:45 +0000 (14:18 +0200)]
altq: mark callouts as mpsafe

There's no reason to acquire the Giant lock while executing the ALTQ
callouts.

While here also remove a few backwards compatibility defines for long
obsolete FreeBSD versions.

Reviewed by: mav
Suggested by: mav
Differential Revision: https://reviews.freebsd.org/D31835

2 years agoSupport bootstrapping from Linux/ppc*
Justin Hibbits [Sat, 4 Sep 2021 16:45:56 +0000 (11:45 -0500)]
Support bootstrapping from Linux/ppc*

2 years agopowerpc: Fix typo in thread register copy
Justin Hibbits [Sat, 4 Sep 2021 16:43:17 +0000 (11:43 -0500)]
powerpc: Fix typo in thread register copy

Should be saving off td0's register's, not td's.

2 years ago[PowerPC] Fix outdated FP regs on fork(2) and friends
Brandon Bergren [Mon, 3 May 2021 02:12:18 +0000 (21:12 -0500)]
[PowerPC] Fix outdated FP regs on fork(2) and friends

Summary:
Failure to update the FP / vector state was causing daemon(3) to violate C ABI by failing to preserve nonvolatile registers.

This was causing a weird issue where moused was not working on PowerBook G4s when daemonizing, but was working fine when running it foreground.

Force saving off the same state that cpu_switch() does in cases where we are about to copy a thread.

MFC after: 1 week
Sponsored by: Tag1 Consulting, Inc.

Test Plan:
```
/*
 * Test for ABI violation due to side effects of daemon(3).
 *
 * NOTE: Compile with -O2 to see the effect.
 */
/* Allow compiling for Linux too. */

static double test = 1234.56f;

/*
 * This contrivance coerces clang to not bounce the double
 * off of memory again in main.
 */
void __attribute__((noinline))
print_double(int j1, int j2, double d)
{
printf("%f\n", d);
}

int
main(int argc, char *argv[])
{
print_double(0, 0, test);

if (daemon(0, 1)) {
}
/* Compiler assumes nonvolatile regs are intact... */
print_double(0, 0, test);
return(0);
}
```

Working output:
```
1234.560059
1234.560059
```

Output in broken case:
```
1234.560059
0.0
```

Reviewers: #powerpc

Subscribers: jhibbits, luporl, alfredo

Tags: #powerpc

Differential Revision: https://reviews.freebsd.org/D29851