]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
3 years agofusefs: fix two bugs regarding fcntl file locks
Alan Somers [Thu, 18 Mar 2021 20:27:27 +0000 (14:27 -0600)]
fusefs: fix two bugs regarding fcntl file locks

1) F_SETLKW (blocking) operations would be sent to the FUSE server as
   F_SETLK (non-blocking).

2) Release operations, F_SETLK with lk_type = F_UNLCK, would simply
   return EINVAL.

PR: 253500
Reported by: John Millikin <jmillikin@gmail.com>
MFC after: 2 weeks

3 years agoUnbreak MSG_CMSG_CLOEXEC
Alex Richardson [Thu, 18 Mar 2021 20:52:20 +0000 (20:52 +0000)]
Unbreak MSG_CMSG_CLOEXEC

MSG_CMSG_CLOEXEC has not been working since 2015 (SVN r284380) because
_finstall expects O_CLOEXEC and not UF_EXCLOSE as the flags argument.
This was probably not noticed because we don't have a test for this flag
so this commit adds one. I found this problem because one of the
libwayland tests was failing.

Fixes: ea31808c3b07 ("fd: move out actual fp installation to _finstall")
MFC after: 3 days
Reviewed By: mjg, kib
Differential Revision: https://reviews.freebsd.org/D29328

3 years agoAdd Chacha20+Poly1035 to the list of AEAD algorithms.
John Baldwin [Thu, 18 Mar 2021 20:31:39 +0000 (13:31 -0700)]
Add Chacha20+Poly1035 to the list of AEAD algorithms.

Sponsored by: Netflix

3 years agovtnet: fix TSO for TCP/IPv6
Michael Tuexen [Thu, 18 Mar 2021 20:25:47 +0000 (21:25 +0100)]
vtnet: fix TSO for TCP/IPv6

The decision whether a TCP packet is sent over IPv4 or IPv6 was
based on ethertype, which works correctly. In D27926 the criteria
was changed to checking if the CSUM_IP_TSO flag is set in the
csum-flags and then considering it to be TCP/IPv4.
However, the TCP stack sets the flag to CSUM_TSO for IPv4 and IPv6,
where CSUM_TSO is defined as CSUM_IP_TSO|CSUM_IP6_TSO.
Therefore TCP/IPv6 packets gets mis-classified as TCP/IPv4,
which breaks TSO for TCP/IPv6.
This patch bases the check again on the ethertype.
This fix will be MFC instantly as discussed with re(gjb).

MFC after: instantly
PR: 254366
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D29331

3 years agoFix the 'linux' rc script on aarch64.
Edward Tomasz Napierala [Tue, 16 Mar 2021 16:48:13 +0000 (16:48 +0000)]
Fix the 'linux' rc script on aarch64.

Previously it would try to load linux.ko instead of linux64.ko
and fail.  While here, don't try to match 'linuxaout'; even if
implemented, it's the same module as `linuxelf`.

Reviewed By: emaste
Sponsored By: EPSRC
Differential Revision: https://reviews.freebsd.org/D29288

3 years agonfsv4 pnfs client: fix updating of the layout stateid.seqid
Rick Macklem [Thu, 18 Mar 2021 19:20:25 +0000 (12:20 -0700)]
nfsv4 pnfs client: fix updating of the layout stateid.seqid

During a recent NFSv4 testing event a test server was replying
NFSERR_OLDSTATEID for layout stateids presented to the server
for LayoutReturn operations.  Upon rereading RFC5661, it was
apparent that the FreeBSD NFSv4.1/4.2 pNFS client did not
maintain the seqid field of the layout stateid correctly.

This patch is believed to correct the problem.  Tested against
a FreeBSD pNFS server with diagnostics added to check the stateid's
seqid did not indicate problems.  Unfortunately, testing aginst
this server will not happen in the near future, so the fix may
not be correct yet.

MFC after: 2 weeks

3 years agoRename linux_set_upcall_kse() to linux_set_upcall().
John Baldwin [Thu, 18 Mar 2021 19:14:34 +0000 (12:14 -0700)]
Rename linux_set_upcall_kse() to linux_set_upcall().

This matches the rename of cpu_set_upcall_kse() in
5c2cf818454375536fda522ba83cf67c50929e6b.

Reviewed by: kib, emaste
MFC after: 1 week
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D29295

3 years agox86: Reduce code duplication in cpu_fork() and cpu_copy_thread().
John Baldwin [Thu, 18 Mar 2021 19:13:17 +0000 (12:13 -0700)]
x86: Reduce code duplication in cpu_fork() and cpu_copy_thread().

Add copy_thread() to hold shared code.

Reviewed by: kib
MFC after: 1 week
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D29228

3 years agorc.conf(5): Document the 'workstation' firewall_type
Tobias Rehbein [Thu, 18 Mar 2021 17:01:09 +0000 (18:01 +0100)]
rc.conf(5): Document the 'workstation' firewall_type

Document the workstation ACL ruleset, which uses stateful rules.

While here, add a note about where some of the undocumented variables
can be found. This is not a perfect solution for bug 127359, but it at
at least gives a place to go look, and can be used as a reference for
when bug 127359 gets fixed properly.

PR: 254358, 127359

3 years agoRevert "bootstrap: add tic to the bootstrap tools"
Baptiste Daroussin [Thu, 18 Mar 2021 15:01:11 +0000 (16:01 +0100)]
Revert "bootstrap: add tic to the bootstrap tools"
Since we don't build and install the terminfo db anymore this is not
needed

This reverts commit b6a51d39e3a2e2f75d5b42a8c17a531063258a15.
This reverts commit e5e4845959ac60110677df302a68c220dff75abe.
This reverts commit 0af562d7e1850bbef230d30805c101b26588a3ed.

3 years agovfs: fix vnlru marker handling for filtered/unfiltered cases
Mateusz Guzik [Wed, 17 Mar 2021 21:33:47 +0000 (22:33 +0100)]
vfs: fix vnlru marker handling for filtered/unfiltered cases

The global list has a marker with an invariant that free vnodes are
placed somewhere past that. A caller which performs filtering (like ZFS)
can move said marker all the way to the end, across free vnodes which
don't match. Then a caller which does not perform filtering will fail to
find them. This makes vn_alloc_hard sleep for 1 second instead of
reclaiming, resulting in significant stalls.

Fix the problem by requiring an explicit marker by callers which do
filtering.

As a temporary measure extend vnlru_free to restart if it fails to
reclaim anything.

Big thanks go to the reporter for testing several iterations of the
patch.

Reported by: Yamagi <lists yamagi.org>
Tested by: Yamagi <lists yamagi.org>
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D29324

3 years agoinetd.conf: Wordsmith recommendation
Daniel Ebdrup Jensen [Thu, 18 Mar 2021 14:17:32 +0000 (15:17 +0100)]
inetd.conf: Wordsmith recommendation

Rather than recommend specific VTIs, it's better to give a general
recommendation for where current and future suitable VTIs can be found.

3 years agolib80211: Start adding 11ac ETSI bits to regdomain.xml
Bjoern A. Zeeb [Thu, 18 Mar 2021 11:08:47 +0000 (11:08 +0000)]
lib80211: Start adding 11ac ETSI bits to regdomain.xml

Summary:
This change currently (partially) duplicates AC1 freqbands as AC2
as they are not fully overlapping.
It then adds the 11ac netband to the "etsi" domain including
"indoor" and "dfs" flags, which we can deal with, as well as
appropriate (round down) maxpower values.
Comments are left for the actual frequency bands as we do use the
centerfreq for the first/last (chansep sized) channel in the
freqband and their "id" name, which can be confusing.

Sponsored-by: Rubicon Communications, LLC ("Netgate")
Reviewed-by: philip, adrian
MFC-after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D25999

3 years agonet80211: split up ieee80211_probereq()
Bjoern A. Zeeb [Sat, 6 Mar 2021 21:05:43 +0000 (21:05 +0000)]
net80211: split up ieee80211_probereq()

Factor out ieee80211_probereq_ie() and ieee80211_probereq_ie_len()
and make the length dynamic rather than static max.  The latter is
needed as our current fixed length was longer than some "hw scan",
e.g. that of ath10k, will take.  This way we can pass what we have.
Should this not be sufficient in the future we might have to deal
with filtering and much more error handling.

This also removes a duplicate calculation for ieee80211_ie_wpa [1].

Repoprted-by: Martin Husemann <martin NetBSD.org> [1]
Sponsored-by: Rubicon Communications, LLC ("Netgate")
Sponsored-by: The FreeBSD Foundation (update for alloc)
Reviewed-by: adrian, martin NetBSD.org (earlier version)
Reviewed-by: philip
MFC-after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D26545

3 years agoLinuxKPI: add support for crc32_le()
Bjoern A. Zeeb [Wed, 10 Mar 2021 15:01:10 +0000 (15:01 +0000)]
LinuxKPI: add support for crc32_le()

Add support for crc32_le() as a wrapper around crc32_raw().

Sponsored-by: The FreeBSD Foundation
Obtained-from: bz_iwlwifi
MFC-after: 2 weeks
Reviewed-by: hselasky
Differential Revision: https://reviews.freebsd.org/D29187

3 years agotermios: add more speeds
Bjoern A. Zeeb [Wed, 10 Mar 2021 22:17:07 +0000 (22:17 +0000)]
termios: add more speeds

A lot of small arm64 gadgets are using 1500000 as console speed.
While cu can perfectly deal with this some 3rd party software, e.g.,
comms/conserver-con add speeds based on B<n> being defined.
Having it defined here simplifies enhancing other software.

Obtained-from: NetBSD sys/sys/termios.h 1.36
MFC-after: 2 weeks
Reviewed-by: philip (,okayed by imp)
Differential Revision: https://reviews.freebsd.org/D29209

3 years agoterminfo db: add entries for the terminfo database removal
Baptiste Daroussin [Thu, 18 Mar 2021 10:04:32 +0000 (11:04 +0100)]
terminfo db: add entries for the terminfo database removal

3 years agoRevert "terminfo: add terminfo database"
Baptiste Daroussin [Thu, 18 Mar 2021 09:57:23 +0000 (10:57 +0100)]
Revert "terminfo: add terminfo database"

This reverts commit 2a50a9de8340f08bd876e9e5993332ae14376f80.

3 years agoterminfo: add more path to lookup for the database
Baptiste Daroussin [Thu, 18 Mar 2021 08:46:15 +0000 (09:46 +0100)]
terminfo: add more path to lookup for the database

In preparation for the move of the database out of base, add one more
path to lookup
Now the default lookup path is

1. base
2. localbase
3. localbase special site for custom terminfo (for ports adding custom
terminfo and avoid potential collision with the general db)
4. termcap

The plan is to allow the terminfo-db to be installed by end users via
a package for people willing to have the support for features from
this database provides. And keep the fallback on termcap for people who
don't want to hear about the terminfo db or how to configure the terminal
if it uses by default the features proposed in the definitions
of the terminfo db.

the first look up path is a window open for a proposal made by glebius@
consisting on creating a tool where the user at install time will select
the feature it want for a given terminal and generate its configurations
based on that. I won't work on it, but it is now posssible and there is
a path where to store those definitions

3 years agoClarify that the new STABLE branch is branched off CURRENT, not renamed
Li-Wen Hsu [Thu, 18 Mar 2021 09:16:16 +0000 (17:16 +0800)]
Clarify that the new STABLE branch is branched off CURRENT, not renamed

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

3 years agogenet: Fix problem with forwarding some TCP/IPv6 packets
Mike Karels [Thu, 18 Mar 2021 00:19:24 +0000 (19:19 -0500)]
genet: Fix problem with forwarding some TCP/IPv6 packets

TCP/IPv6 packets to be forwarded can be laid out with only the Ethernet
header in the first mbuf, and these packets are lost.  There was a
previous hack to pullup ICMPv6 packets with such a layout for the
same reason.  Generalize, and pullup any IPv6 packets with only the
Ethernet header in the first mbuf.  Possibly this should also include
IPv4, but that situation has not been observed to fail.

PR: 254060
Reported by: denis at h3q.com
MFC after: 3 days

3 years agoRemove unused obj variable missed in r354870.
Bryan Drewery [Wed, 17 Mar 2021 22:01:19 +0000 (15:01 -0700)]
Remove unused obj variable missed in r354870.

Sponsored by: Dell EMC

3 years agoarm64: implement COMPAT_FREEBSD32 fill/set dbregs/fpregs
Ed Maste [Wed, 17 Mar 2021 14:10:41 +0000 (10:10 -0400)]
arm64: implement COMPAT_FREEBSD32 fill/set dbregs/fpregs

On FreeBSD/arm fill_fpregs, fill_dbregs are stubs that zero the reg
struct and return success. set_fpregs and set_dbregs do nothing and
return success.

Provide the same implementation for arm64 COMPAT_FREEBSD32.

Reviewed by: andrew
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D29314

3 years agoaarch64: Clear TLS registers during exec().
John Baldwin [Wed, 17 Mar 2021 20:19:04 +0000 (13:19 -0700)]
aarch64: Clear TLS registers during exec().

These are not stored in the trapframe so must be cleared explicitly.

This is similar to one of the MIPS changes in 822d2d6ac94f.

Reviewed by: andrew
Obtained from: CheriBSD
MFC after: 1 week
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D28711

3 years agopf tests: pfsync bulk update test
Kristof Provost [Mon, 15 Mar 2021 13:10:55 +0000 (14:10 +0100)]
pf tests: pfsync bulk update test

Test that pfsync works as expected with bulk updates. That is, create
some state before setting up the second firewall. Let that firewall
request a bulk update so it can catch up, and check that it got the
state which was created before it enable pfsync.

PR: 254236
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D29272

3 years agopfsync: Unconditionally push packets when requesting state updates
Thomas Kurschel [Mon, 15 Mar 2021 13:28:52 +0000 (14:28 +0100)]
pfsync: Unconditionally push packets when requesting state updates

When we request a bulk sync we need to ensure we actually send out that
request, not just buffer it until we have enough data to send a full
packet.

PR: 254236
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D29271

3 years agofix panic when rescue retransmission and FIN overlap
Richard Scheffenegger [Wed, 17 Mar 2021 15:44:29 +0000 (16:44 +0100)]
fix panic when rescue retransmission and FIN overlap

PR:           254244
PR:           254309
Reviewed By:  #transport, hselasky, tuexen
MFC after:    3 days
Sponsored By: NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D29315

3 years agorelease: sync 'git count' logic with newvers.sh
Glen Barber [Wed, 17 Mar 2021 14:57:32 +0000 (10:57 -0400)]
release: sync 'git count' logic with newvers.sh

Sync determining the git count with newvers.sh by adding the
--first-parent argument.  This ensures uname(1) reflects the
file name for snapshots.

Reported by: Mark Millard
MFC after: 3 days
Sponsored by: Rubicon Communications, LLC ("Netgate")

3 years agonvme: Replace potentially long DELAY() with pause().
Alexander Motin [Wed, 17 Mar 2021 14:30:40 +0000 (10:30 -0400)]
nvme: Replace potentially long DELAY() with pause().

In some cases like broken hardware nvme(4) may wait minutes for
controller response before timeout.  Doing so in a tight spin loop
made whole system unresponsive.

Reviewed by: imp
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D29309
Sponsored by: iXsystems, Inc.

3 years agobase: remove if_wg(4) and associated utilities, manpage
Kyle Evans [Tue, 16 Mar 2021 02:38:23 +0000 (21:38 -0500)]
base: remove if_wg(4) and associated utilities, manpage

After length decisions, we've decided that the if_wg(4) driver and
related work is not yet ready to live in the tree.  This driver has
larger security implications than many, and thus will be held to
more scrutiny than other drivers.

Please also see the related message sent to the freebsd-hackers@
and freebsd-arch@ lists by Kyle Evans <kevans@FreeBSD.org> on
2021/03/16, with the subject line "Removing WireGuard Support From Base"
for additional context.

3 years agoRemove tmpfs size and properly format generated fstab for arm
Daniel Engerg [Wed, 17 Mar 2021 14:00:57 +0000 (15:00 +0100)]
Remove tmpfs size and properly format generated fstab for arm

Remove tmpfs size limitation, this breaks make installworld and installation of some packages
Format generated fstab using tabs to make it consistent and readable

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

3 years agowpa: import fix for P2P provision discovery processing vulnerability
Cy Schubert [Wed, 17 Mar 2021 00:06:17 +0000 (17:06 -0700)]
wpa: import fix for P2P provision discovery processing vulnerability

Latest version available from: https://w1.fi/security/2021-1/

Vulnerability

A vulnerability was discovered in how wpa_supplicant processes P2P
(Wi-Fi Direct) provision discovery requests. Under a corner case
condition, an invalid Provision Discovery Request frame could end up
reaching a state where the oldest peer entry needs to be removed. With
a suitably constructed invalid frame, this could result in use
(read+write) of freed memory. This can result in an attacker within
radio range of the device running P2P discovery being able to cause
unexpected behavior, including termination of the wpa_supplicant process
and potentially code execution.

Vulnerable versions/configurations

wpa_supplicant v1.0-v2.9 with CONFIG_P2P build option enabled

An attacker (or a system controlled by the attacker) needs to be within
radio range of the vulnerable system to send a set of suitably
constructed management frames that trigger the corner case to be reached
in the management of the P2P peer table.

Note: FreeBSD base does not enable P2P.

3 years agoImplement pci_get_relaxed_ordering_enabled() helper function.
Hans Petter Selasky [Tue, 16 Mar 2021 15:06:42 +0000 (16:06 +0100)]
Implement pci_get_relaxed_ordering_enabled() helper function.

Discussed with: kib@
MFC after: 1 week
Sponsored by: Mellanox Technologies // NVIDIA Networking

3 years agoImplement sndstat nvlist-based enumeration ioctls.
Ka Ho Ng [Wed, 17 Mar 2021 10:51:58 +0000 (18:51 +0800)]
Implement sndstat nvlist-based enumeration ioctls.

These ioctl commands aim to provide easier ways for user space
applications to enumerate existing audio devices and the node they can
potentially use.

The exchange of device lists between user space and kernel is done on
nv(9). Some ioctl commands are added to /dev/sndstat node:
  - SNDSTAT_REFRESH_DEVS
  - SNDSTAT_GET_DEVS
  - SNDSTAT_ADD_USER_DEVS
  - SNDSTAT_FLUSH_USER_DEVS

Bump __FreeBSD_version to reflect the addition of the ioctls.

Sponsored by: The FreeBSD Foundation
Reviewed by: hselasky
Approved by: philip (mentor)
Differential Revision: https://reviews.freebsd.org/D26884

3 years agonlmrsa: Mark deprecated for 14.
John Baldwin [Tue, 16 Mar 2021 21:34:58 +0000 (14:34 -0700)]
nlmrsa: Mark deprecated for 14.

This is the only in-tree driver for the asymmetric crypto support in
OCF that is already marked deprecated for 14.

MFC after: 3 days
Sponsored by: Chelsio Communications

3 years agonfs: Cleanup dead files
Peter Jeremy [Tue, 16 Mar 2021 19:16:31 +0000 (06:16 +1100)]
nfs: Cleanup dead files

These files are no longer used by the FreeBSD base system. They were being used by the amd port but that has also been deleted.

Reviewed by: rmacklem
Sponsored by: Google
Differential Revision: https://reviews.freebsd.org/D29180

3 years agostand: Load INIT_ARRAY and FINI_ARRAY sections
Mark Johnston [Tue, 16 Mar 2021 19:01:41 +0000 (15:01 -0400)]
stand: Load INIT_ARRAY and FINI_ARRAY sections

This is required for preloading modules into a KASAN-configured kernel.

MFC after: 1 week
Sponsored by: The FreeBSD Foundation

3 years agolink_elf_obj: Add a case missing from 5e6989ba4f26
Mark Johnston [Tue, 16 Mar 2021 19:01:41 +0000 (15:01 -0400)]
link_elf_obj: Add a case missing from 5e6989ba4f26

Fixes: 5e6989ba4f26
MFC after: 3 days
Sponsored by: The FreeBSD Foundation

3 years agopkgbase: Fix building out-of-tree manual pages
Jung-uk Kim [Tue, 16 Mar 2021 18:16:10 +0000 (14:16 -0400)]
pkgbase: Fix building out-of-tree manual pages

c7e6cb9e08d6 introduced MK_MANSPLITPKG but it was not available for
building out-of-tree manual pages.  For example, x11/nvidia-driver fails
with the following error:

===> doc (all)
make[3]: "/usr/share/mk/bsd.man.mk" line 53: Malformed conditional (${MK_MANSPLITPKG} == "no")
make[3]: Fatal errors encountered -- cannot continue

Move the definition from src.opts.mk to bsd.opts.mk to make it visible.

3 years agocxgbe(4): catch up with the latest cryptocaps.
Navdeep Parhar [Mon, 15 Mar 2021 19:54:34 +0000 (12:54 -0700)]
cxgbe(4): catch up with the latest cryptocaps.

There are two crypto capabilities that the driver didn't know about.

MFC after: 1 week
Sponsored by: Chelsio Communications

3 years agorelease: do not set __MAKE_CONF and SRCCONF for the chroot build
Glen Barber [Tue, 16 Mar 2021 16:01:48 +0000 (12:01 -0400)]
release: do not set __MAKE_CONF and SRCCONF for the chroot build

PR: 254319
Submitted by: truckman
MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")

3 years agopkg: settle the uniq extension to .pkg instead of .bsd
Baptiste Daroussin [Tue, 16 Mar 2021 15:18:48 +0000 (16:18 +0100)]
pkg: settle the uniq extension to .pkg instead of .bsd

Requested by: many

3 years agobhyve: virtio shares definitions between sys/dev/virtio
Ka Ho Ng [Tue, 16 Mar 2021 11:27:38 +0000 (19:27 +0800)]
bhyve: virtio shares definitions between sys/dev/virtio

Definitions inside usr.sbin/bhyve/virtio.h are thrown away.
Definitions in sys/dev/virtio are used instead.

This reduces code duplication.

Sponsored by: The FreeBSD Foundation
Reviewed by: grehan
Approved by: philip (mentor)
Differential Revision: https://reviews.freebsd.org/D29084

3 years agopf: pool/kpool conversion code
Kristof Provost [Thu, 11 Mar 2021 10:37:05 +0000 (11:37 +0100)]
pf: pool/kpool conversion code

stuct pf_pool and struct pf_kpool are different. We should not simply
bcopy() them.

Happily it turns out that their differences were all pointers, and the
userspace provided pointers were overwritten by the kernel, so this did
actually work correctly, but we should fix it anyway.

Reviewed by: glebius
MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D29216

3 years agoRevert "include: Remove symlink installation"
Emmanuel Vadot [Tue, 16 Mar 2021 07:40:59 +0000 (08:40 +0100)]
Revert "include: Remove symlink installation"

This reverts commit 0006530aa14b9df56f88df7d819fae89b115d865.

3 years agoRevert "include: Tag directly the last headers"
Emmanuel Vadot [Tue, 16 Mar 2021 07:40:54 +0000 (08:40 +0100)]
Revert "include: Tag directly the last headers"

This reverts commit 839fc8cdf9b6bafe120e7da8a4b78950ad7295c4.

3 years agopkgbase: Add an src.conf option for splitting man pages
Emmanuel Vadot [Tue, 16 Mar 2021 06:11:56 +0000 (07:11 +0100)]
pkgbase: Add an src.conf option for splitting man pages

Man pages can be big in total, add an options to split man pages
in -man packages so we produce smaller packages.
This is useful for small jails or mfsroot produced of pkgbase.
The option is off by default.

Reviewed by: bapt, Mina Galić <me@igalic.co>
Differential Revision: https://reviews.freebsd.org/D29169
MFC after:      2 weeks

3 years agoConvert libs with pc files to use PCFILES
Emmanuel Vadot [Tue, 16 Mar 2021 06:13:07 +0000 (07:13 +0100)]
Convert libs with pc files to use PCFILES

Now the .pc ends up in the correct package (-dev)

Reviewed by: bapt, emaste
Differential Revision: https://reviews.freebsd.org/D29172
MFC after:      2 weeks

3 years agobsd.lib.mk: Add a install target for .pc files
Emmanuel Vadot [Tue, 16 Mar 2021 06:13:03 +0000 (07:13 +0100)]
bsd.lib.mk: Add a install target for .pc files

That way the files are correctly taggued for pkgbase

Reviewed by: bapt, emaste (both earlier version)
Differential Revision: https://reviews.freebsd.org/D29171
MFC after:      2 weeks

3 years agoinclude: Tag directly the last headers
Emmanuel Vadot [Tue, 16 Mar 2021 06:13:00 +0000 (07:13 +0100)]
include: Tag directly the last headers

We cannot easily used the TAG here and we don't yet have something to install
even .h from a diretory in bsd.prog.mk

Reviewed by: bapt
Differential Revision: https://reviews.freebsd.org/D29170
MFC after:      2 weeks

3 years agopkgbase: Remove case for runtime and jail package ucl generation
Emmanuel Vadot [Tue, 16 Mar 2021 06:12:56 +0000 (07:12 +0100)]
pkgbase: Remove case for runtime and jail package ucl generation

They aren't needed and produce wrong package comments :
We use to have "runtime-dev package" instead of
"FreeBSD Base System (Development Files)" for example

Reviewed by: bapt
Differential Revision: https://reviews.freebsd.org/D29168
MFC after:      2 weeks

3 years agoinclude: Remove symlink installation
Emmanuel Vadot [Tue, 16 Mar 2021 06:12:53 +0000 (07:12 +0100)]
include: Remove symlink installation

headers could be installed as symlink to the source tree instead of copies.
Remove the possibility to do that.
This make the makefile easier to read and to maintain and also don't duplicate
code.

While here remove some directories from LSBUDIRS as we already install them using
the INCS stuff.

Reviewed by: bapt
Differential Revision: https://reviews.freebsd.org/D29167
MFC after:      2 weeks

3 years agopkgbase: Install all cam includes with INCS
Emmanuel Vadot [Tue, 16 Mar 2021 06:12:49 +0000 (07:12 +0100)]
pkgbase: Install all cam includes with INCS

Now they are correctly taggued and put into the -dev package

Reviewed by: bapt
Differential Revision: https://reviews.freebsd.org/D29166
MFC after:      2 weeks

3 years agopkgbase: Install all BSM includes with INCS
Emmanuel Vadot [Tue, 16 Mar 2021 06:12:46 +0000 (07:12 +0100)]
pkgbase: Install all BSM includes with INCS

Now they are correctly taggued and put them into the libbsm package

Reviewed by: bapt
Differential Revision: https://reviews.freebsd.org/D29165
MFC after:      2 weeks

3 years agopkgbase: Move libicp in utilities
Emmanuel Vadot [Tue, 16 Mar 2021 06:12:40 +0000 (07:12 +0100)]
pkgbase: Move libicp in utilities

libicp is used by zdb zhack zinject zstream ztest libzpool.so.2 which
are all in FreeBSD-utilities.

Reviewed by: bapt, emaste
Differential Revision: https://reviews.freebsd.org/D29164
MFC after: 2 weeks

3 years agofactor out PT page allocation/freeing
Jason A. Harmening [Mon, 1 Mar 2021 16:42:05 +0000 (08:42 -0800)]
factor out PT page allocation/freeing

As follow-on work to e4b8deb222278b2a, move page table page
allocation and freeing into their own functions.  Use these
functions to provide separate kernel vs. user page table page
accounting, and to wrap common tasks such as management of
zero-filled page state.

Requested by: markj, kib
Reviewed by: kib
Differential Revision:  https://reviews.freebsd.org/D29151

3 years agoStop installing kernel-only crypto headers to /usr/include/crypto.
John Baldwin [Tue, 16 Mar 2021 00:00:21 +0000 (17:00 -0700)]
Stop installing kernel-only crypto headers to /usr/include/crypto.

The only user-facing header from OCF is <crypto/cryptodev.h>.

PR: 254167 (exp-run)
MFC after: 1 week
Sponsored by: Chelsio Communications

3 years agoFix fib algo rebuild delay calculation.
Alexander V. Chernikov [Mon, 15 Mar 2021 21:09:07 +0000 (21:09 +0000)]
Fix fib algo rebuild delay calculation.

Submitted by: Marco Zec <zec at fer.hr>
MFC after: 3 days

3 years agoInclude ccompile.h after opt_global.h.
Alexander Motin [Mon, 15 Mar 2021 17:48:50 +0000 (13:48 -0400)]
Include ccompile.h after opt_global.h.

This restores INVARIANTS enabling ZFS_DEBUG when built as module.

Discussed with: freqlabs
MFC after: 1 week

3 years agonetmap: fix memory leak in NETMAP_REQ_PORT_INFO_GET
Vincenzo Maffione [Mon, 15 Mar 2021 17:39:18 +0000 (17:39 +0000)]
netmap: fix memory leak in NETMAP_REQ_PORT_INFO_GET

The netmap_ioctl() function has a reference counting bug in case of
NETMAP_REQ_PORT_INFO_GET command. When `hdr->nr_name[0] == '\0'`,
the function does not decrease the refcount of "nmd", which is
increased by netmap_mem_find(), causing a refcount leak.

Reported by: Xiyu Yang <sherllyyang00@gmail.com>
Submitted by: Carl Smith <carl.smith@alliedtelesis.co.nz>
MFC after: 3 days
PR: 254311

3 years agopkg(7): when bootstrapping first search for pkg.bsd file then pkg.txz
Baptiste Daroussin [Fri, 12 Mar 2021 17:36:30 +0000 (18:36 +0100)]
pkg(7): when bootstrapping first search for pkg.bsd file then pkg.txz

The package extension is going to be changed to .bsd to be among other
things resilient to the change of compression format used and reduce
the impact of all third party tool of that change.

Ensure the bootstrap knows about it

Reviewed by: manu
Differential revision: https://reviews.freebsd.org/D29232

3 years agoxen: move x86-specific xen_vector_callback_enabled to sys/x86
Julien Grall [Mon, 15 Mar 2021 11:27:36 +0000 (12:27 +0100)]
xen: move x86-specific xen_vector_callback_enabled to sys/x86

This is x86-only and so should not be in the common area.

Submitted by: Elliott Mitchell <ehem+freebsd@m5p.com>
Reviewed by: royger
Differential revision: https://reviews.freebsd.org/D29040

3 years agoxen/xenusb: always include xen/xen-os.h rather than machine/xen/xen-os.h
Julien Grall [Mon, 15 Mar 2021 11:15:47 +0000 (12:15 +0100)]
xen/xenusb: always include xen/xen-os.h rather than machine/xen/xen-os.h

Fix compilation since machine/xen/xen-os.h is requiring definition
existing in xen/xen-os.h.

In general machine/xen/xen-os.h should never be included

Submitted by: Elliott Mitchell <ehem+freebsd@m5p.com>
Reviewed by: royger
Differential revision: https://reviews.freebsd.org/D29043

3 years agoif_wg: fix build with DIAGNOSTICS
Kyle Evans [Mon, 15 Mar 2021 12:31:09 +0000 (07:31 -0500)]
if_wg: fix build with DIAGNOSTICS

This file got resynced with OpenBSD to pick up fixes that had taken
place after the version initially ported to FreeBSD.  KASSERT there is
more like MPASS here.

Reported by: David Wolfskill <david@catwhisker.org>

3 years agostress2: Update expetced errno
Peter Holm [Mon, 15 Mar 2021 11:16:52 +0000 (12:16 +0100)]
stress2:  Update expetced errno

3 years agostress2: Fix usage of unitializer data
Peter Holm [Mon, 15 Mar 2021 11:00:01 +0000 (12:00 +0100)]
stress2:  Fix usage of unitializer data

3 years agoHyper-V: hn: Initialize the internal field of per packet info on tx path
Wei Hu [Mon, 15 Mar 2021 10:20:52 +0000 (10:20 +0000)]
Hyper-V: hn: Initialize the internal field of per packet info on tx path

The RSC support feature introduced a bit field "rm_internal" in
struct rndis_pktinfo with total size unchanged.

The guest does not use this field in the tx path. However we need to
initialize it to zero in case older hosts which are not aware of this
field.

Fixes: a491581f ("Hyper-V: hn: Enable vSwitch RSC support")
MFC after: 2 weeks
Sponsored by: Microsoft

3 years agowlandebug.8: remove Xref for missing manpages
Fernando Apesteguía [Wed, 3 Mar 2021 06:48:11 +0000 (07:48 +0100)]
wlandebug.8: remove Xref for missing manpages

Remove references for: athdebug(8), athstats(8) and wlanstats(8)

Those are tools in the tools/ directory that are not built as part of the base
system. According to the toolds/README file:

"...these tools are not meant to be built as part of the standard system..."

Even more, the tools/tools/README is not udpated and wlanstats does not even
built on current:

error: cast from 'struct sockaddr *' to 'const struct sockaddr_dl *' increases
required alignment from 1 to 2 [-Werror,-Wcast-align]

PR:  227174
Reported by: freebsd.org@alexandrews.me.uk
Reviewed by: gbe@ adrian@
Approved by: gbe@ (mentor) adrian@
Differential Revision: https://reviews.freebsd.org/D29033

3 years agoif_wg: close the sockets if wg_socket_bind() failed
Kyle Evans [Mon, 15 Mar 2021 06:23:56 +0000 (01:23 -0500)]
if_wg: close the sockets if wg_socket_bind() failed

This fixes the remaining cred leak that prevented jails from fully dying
in some error cases.

3 years agoif_wg: stop holding creds in wg_socket_init()
Kyle Evans [Mon, 15 Mar 2021 06:21:25 +0000 (01:21 -0500)]
if_wg: stop holding creds in wg_socket_init()

We're now xlocked when we create sockets, so we're now guaranteed that
the creds won't be released out from underneath us over in
wg_prison_remove().

3 years agoif_wg: fix the !INET6 support
Kyle Evans [Mon, 15 Mar 2021 05:38:22 +0000 (00:38 -0500)]
if_wg: fix the !INET6 support

INET is still required, so formally don't build it in !INET
configurations.

3 years agotests: netinet: add missing up from local change
Kyle Evans [Mon, 15 Mar 2021 05:24:54 +0000 (00:24 -0500)]
tests: netinet: add missing up from local change

3 years agoif_wg: import latest fixup work from the wireguard-freebsd project
Kyle Evans [Mon, 15 Mar 2021 02:25:40 +0000 (21:25 -0500)]
if_wg: import latest fixup work from the wireguard-freebsd project

This is the culmination of about a week of work from three developers to
fix a number of functional and security issues.  This patch consists of
work done by the following folks:

- Jason A. Donenfeld <Jason@zx2c4.com>
- Matt Dunwoodie <ncon@noconroy.net>
- Kyle Evans <kevans@FreeBSD.org>

Notable changes include:
- Packets are now correctly staged for processing once the handshake has
  completed, resulting in less packet loss in the interim.
- Various race conditions have been resolved, particularly w.r.t. socket
  and packet lifetime (panics)
- Various tests have been added to assure correct functionality and
  tooling conformance
- Many security issues have been addressed
- if_wg now maintains jail-friendly semantics: sockets are created in
  the interface's home vnet so that it can act as the sole network
  connection for a jail
- if_wg no longer fails to remove peer allowed-ips of 0.0.0.0/0
- if_wg now exports via ioctl a format that is future proof and
  complete.  It is additionally supported by the upstream
  wireguard-tools (which we plan to merge in to base soon)
- if_wg now conforms to the WireGuard protocol and is more closely
  aligned with security auditing guidelines

Note that the driver has been rebased away from using iflib.  iflib
poses a number of challenges for a cloned device trying to operate in a
vnet that are non-trivial to solve and adds complexity to the
implementation for little gain.

The crypto implementation that was previously added to the tree was a
super complex integration of what previously appeared in an old out of
tree Linux module, which has been reduced to crypto.c containing simple
boring reference implementations.  This is part of a near-to-mid term
goal to work with FreeBSD kernel crypto folks and take advantage of or
improve accelerated crypto already offered elsewhere.

There's additional test suite effort underway out-of-tree taking
advantage of the aforementioned jail-friendly semantics to test a number
of real-world topologies, based on netns.sh.

Also note that this is still a work in progress; work going further will
be much smaller in nature.

MFC after: 1 month (maybe)

3 years agoddb: enable the use of ^C and ^S/^Q
Ryan Libby [Sun, 14 Mar 2021 23:04:27 +0000 (16:04 -0700)]
ddb: enable the use of ^C and ^S/^Q

This lets one interrupt DDB's output, which is useful if paging is
disabled and the output device is slow.

This follows a previous implementation in svn r311952 / git
5fddef79998678d256ba30316353393b4d8ebb32 which was reverted because it
broke DDB type-ahead.

Now, try this again, but with a 512-byte type-ahead buffer.  While there
is buffer space, control input is handled and non-control input is
buffered.  When the buffer is exhausted, the default is to print a
warning and drop further non-control input in order to continue handling
control input.  sysctl debug.ddb.prioritize_control_input can be set to
0 to instead preserve all input but lose immediate handling of control
input.  This could for example effect pasting of a large script into the
ddb console.

Suggested by: Anton Rang <rang@acm.org>
Reviewed by: markj
Discussed with: imp
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D28676

3 years agokobj: avoid gcc -Wcast-function-type
Ryan Libby [Sun, 14 Mar 2021 23:04:27 +0000 (16:04 -0700)]
kobj: avoid gcc -Wcast-function-type

The actual type of kobjop_t is arbitrary, it is only used as a generic
function pointer type.  Declare it as void (*)(void) in order to avoid
gcc's -Wcast-function-type, which is included in -Wextra.

Reviewed by: avg, jhb
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D28769

3 years agoMerge tcsh 6.22.03-ceccc7f
Dmitry Chagin [Sun, 14 Mar 2021 16:33:13 +0000 (19:33 +0300)]
Merge tcsh 6.22.03-ceccc7f

PR: 252663
MFC after: 1 week

3 years agoImport 6.22.03-ceccc7f
Dmitry Chagin [Sun, 14 Mar 2021 16:28:29 +0000 (19:28 +0300)]
Import 6.22.03-ceccc7f

3 years agozfs: merge OpenZFS master-9305ff2ed
Martin Matuska [Sun, 14 Mar 2021 01:23:51 +0000 (02:23 +0100)]
zfs: merge OpenZFS master-9305ff2ed

Notable upstream pull request merges:
  #11153 Scalable teardown lock for FreeBSD
  #11651 Don't bomb out when using keylocation=file://
  #11667 zvol: call zil_replaying() during replay
  #11683 abd_get_offset_struct() may allocate new abd
  #11693 Intentionally allow ZFS_READONLY in zfs_write
  #11716 zpool import cachefile improvements
  #11720 FreeBSD: Clean up zfsdev_close to match Linux
  #11730 FreeBSD: bring back possibility to rewind the
         checkpoint from bootloader

Obtained from: OpenZFS
MFC after: 2 weeks

3 years agols(1): Refine the HISTORY within the manual page.
Gordon Bergling [Sat, 13 Mar 2021 18:28:26 +0000 (19:28 +0100)]
ls(1): Refine the HISTORY within the manual page.

A simple find command appeared in Version 1 AT&T UNIX and was removed in
Version 3 AT&T UNIX. It was rewritten for Version 5 AT&T UNIX and later
be enhanced for the Programmer's Workbench (PWB). These changes were
later incorporated in AT&T UNIX v7.

Reviewed by: imp
MFC after: 1 week

3 years agoUpdate vendor/openzfs to master-9305ff2ed
Martin Matuska [Sat, 13 Mar 2021 17:30:04 +0000 (18:30 +0100)]
Update vendor/openzfs to master-9305ff2ed

Notable upstream pull request merges:
  #11153 Scalable teardown lock for FreeBSD
  #11651 Don't bomb out when using keylocation=file://
  #11667 zvol: call zil_replaying() during replay
  #11683 abd_get_offset_struct() may allocate new abd
  #11693 Intentionally allow ZFS_READONLY in zfs_write
  #11716 zpool import cachefile improvements
  #11720 FreeBSD: Clean up zfsdev_close to match Linux
  #11730 FreeBSD: bring back possibility to rewind the
         checkpoint from bootloader

3 years agoFix some common typos in comments
Gordon Bergling [Sat, 13 Mar 2021 17:26:15 +0000 (18:26 +0100)]
Fix some common typos in comments

- occured -> occurred
- normaly -> normally
- controling -> controlling
- fileds -> fields
- insterted -> inserted
- outputing -> outputting

MFC after: 1 week

3 years agoFix a few typos in comments
Gordon Bergling [Sat, 13 Mar 2021 15:37:28 +0000 (16:37 +0100)]
Fix a few typos in comments

- trough -> through

MFC after: 1 week

3 years agoi386: Fix a few typos
Gordon Bergling [Sat, 13 Mar 2021 15:10:01 +0000 (16:10 +0100)]
i386: Fix a few typos

- wheter -> whether
- while here, fix some whitespace issues

MFC after: 1 week

3 years agonet80211: Fix a typo in a comment
Gordon Bergling [Sat, 13 Mar 2021 14:51:30 +0000 (15:51 +0100)]
net80211: Fix a typo in a comment

- destionation -> destination
- while here, fix some whitespace issues

MFC after: 1 week

3 years agoPartially revert libcxxrt changes to avoid _Unwind_Exception change
Dimitry Andric [Sat, 13 Mar 2021 13:54:24 +0000 (14:54 +0100)]
Partially revert libcxxrt changes to avoid _Unwind_Exception change

(Note I am also applying this to main and stable/13, to restore the old
libcxxrt ABI and to avoid having to maintain a compat library.)

After the recent cherry-picking of libcxxrt commits 0ee0dbfb0d26 and
d2b3fadf2db5, users reported that editors/libreoffice packages from the
official package builders did not start anymore. It turns out that the
combination of these commits subtly changes the ABI, requiring all
applications that depend on internal details of struct _Unwind_Exception
(available via unwind-arm.h and unwind-itanium.h) to be recompiled.

However, the FreeBSD package builders always use -RELEASE jails, so
these still use the old declaration of struct _Unwind_Exception, which
is not entirely compatible. In particular, LibreOffice uses this struct
in its internal "uno bridge" component, where it attempts to setup its
own exception handling mechanism.

To fix this incompatibility, go back to the old declarations of struct
_Unwind_Exception, and restore the __LP64__ specific workaround we had
in place before (which was to cope with yet another, older ABI bug).

Effectively, this reverts upstream libcxxrt commits 88bdf6b290da
("Specify double-word alignment for ARM unwind") and b96169641f79
("Updated Itanium unwind"), and reapplies our commit 3c4fd2463bb2
("libcxxrt: add padding in __cxa_allocate_* to fix alignment").

PR: 253840

3 years agozfs: bring back possibility to rewind the checkpoint from
Mariusz Zaborski [Sat, 13 Mar 2021 11:56:17 +0000 (12:56 +0100)]
zfs: bring back possibility to rewind the checkpoint from

Add parsing of the rewind options.

When I was upstreaming the change [1], I omitted the part where we
detect that the pool should be rewind. When the FreeBSD repo has
synced with the OpenZFS, this part of the code was removed.

[1] FreeBSD repo: 277f38abffc6a8160b5044128b5b2c620fbb970c
[2] OpenZFS repo: f2c027bd6a003ec5793f8716e6189c389c60f47a

Originally reviewed by: tsoome, allanjude
Originally reviewed by: kevans (ok from high-level overview)

Signed-off-by: Mariusz Zaborski <oshogbo@vexillium.org>
PR: 254152
Reported by: Zhenlei Huang <zlei.huang at gmail.com>
Obtained from: https://github.com/openzfs/zfs/pull/11730

3 years agozfs: make seqc asserts conditional on replay
Mateusz Guzik [Sat, 13 Mar 2021 09:10:16 +0000 (10:10 +0100)]
zfs: make seqc asserts conditional on replay

Avoids tripping on asserts when doing pool recovery.

3 years ago[ath] do a cold reset if TSFOOR triggers
Adrian Chadd [Sat, 13 Mar 2021 07:30:25 +0000 (23:30 -0800)]
[ath] do a cold reset if TSFOOR triggers

TSFOOR happens if a beacon with a given TSF isn't received within the
programmed/expected TSF value, plus/minus a fudge range. (OOR == out of range.)

If this happens then it could be because the baseband/mac is stuck, or
the baseband is deaf.  So, do a cold reset and resync the beacon to
try and unstick the hardware.

It also happens when a bad AP decides to err, slew its TSF because they
themselves are resetting and they don't preserve the TSF "well."

This has fixed a bunch of weird corner cases on my 2GHz AP radio upstairs
here where it occasionally goes deaf due to how much 2GHz noise is up
here (and ANI gets a little sideways) and this unsticks the station
VAP.

For AP modes a hung baseband/mac usually ends up as a stuck beacon
and those have been addressed for a long time by just resetting the
hardware.  But similar hangs in station mode didn't have a similar
recovery mechanism.

Tested:

* AR9380, STA mode, 2GHz/5GHz
* AR9580, STA mode, 5GHz
* QCA9344 SoC w/ on-board wifi (TL-WDR4300/3600 devices); 2GHz
  STA mode

3 years ago[ath] validate ts_antenna before updating tx statistics
Adrian Chadd [Sat, 13 Mar 2021 01:29:09 +0000 (17:29 -0800)]
[ath] validate ts_antenna before updating tx statistics

Right now ts_antenna is either 0 or 1 in each supported HAL so
this is purely a sanity check.

Later on if I ever get magical free time I may add some extensions
for the NICs that can have slightly more complicated antenna switches
for transmit and I'd like this to not bust memory.

3 years agoarm64: Add support for the RK805/RK808 RTC
Peter Jeremy [Fri, 12 Mar 2021 22:06:04 +0000 (09:06 +1100)]
arm64: Add support for the RK805/RK808 RTC

Implement a driver for the RTC embedded in the RK805/RK808 power
management system used for RK3328 and RK3399 SoCs.

Based on experiments on my RK808, setting the time doesn't alter the
internal/inaccessible sub-second counter, therefore there's no point
in calling clock_schedule().

Based on an earlier revision by andrew.

Reviewed by: manu
Differential Revision: https://reviews.freebsd.org/D22692
Sponsored by: Google
MFC after: 1 week

3 years agocam: Run all XPT_ASYNC ccbs in a dedicated thread
Warner Losh [Fri, 12 Mar 2021 20:20:52 +0000 (13:20 -0700)]
cam: Run all XPT_ASYNC ccbs in a dedicated thread

Queue all XPT_ASYNC ccb's and run those in a new cam async thread. This thread
is allowed to sleep for things like memory. This should allow us to make all the
registration routines for cam periph drivers simpler since they can assume they
can always allocate memory. This is a separate thread so that any I/O that's
completed in xpt_done_td isn't held up.

This should fix the panics for WAITOK alloations that are elsewhere in the
storage stack that aren't so easy to convert to NOWAIT. Additional future work
will convert other allocations in the registration path to WAITOK should
detailed analysis show it to be safe.

Reviewed by: chs@, rpokala@
Differential Revision: https://reviews.freebsd.org/D29210

3 years agoccr: Disable requests on port 1 when needed to workaround a firmware bug.
John Baldwin [Fri, 12 Mar 2021 18:35:56 +0000 (10:35 -0800)]
ccr: Disable requests on port 1 when needed to workaround a firmware bug.

Completions for crypto requests on port 1 can sometimes return a stale
cookie value due to a firmware bug.  Disable requests on port 1 by
default on affected firmware.

Reviewed by: np
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D26581

3 years agoccr: Add per-port stats of queued and completed requests.
John Baldwin [Fri, 12 Mar 2021 18:35:32 +0000 (10:35 -0800)]
ccr: Add per-port stats of queued and completed requests.

Reviewed by: np
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D29176

3 years agoccr: Set the RX channel ID correctly in work requests.
John Baldwin [Fri, 12 Mar 2021 18:35:05 +0000 (10:35 -0800)]
ccr: Set the RX channel ID correctly in work requests.

These fixes are only relevant for requests on the second port.  In
some cases, the crypto completion data, completion message, and
receive descriptor could be written in the wrong order.

- Add a separate rx_channel_id that is a copy of the port's rx_c_chan
  and use it when an RX channel ID is required in crypto requests
  instead of using the tx_channel_id.

- Set the correct rx_channel_id in the CPL_RX_PHYS_ADDR used to write
  the crypto result.

- Set the FID to the first rx queue ID on the adapter rather than the
  queue ID of the first rx queue for the port.

- While here, use tx_chan to set the tx_channel_id though this is
  identical to the previous value.

Reviewed by: np
Reported by: Chelsio QA
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D29175

3 years agolib/msun: Fix x86 GCC6 build after 221622ec0c8e184
Alex Richardson [Fri, 12 Mar 2021 18:44:42 +0000 (18:44 +0000)]
lib/msun: Fix x86 GCC6 build after 221622ec0c8e184

Apparently GCC only supports arithmetic expressions that use static
const variables in initializers starting with GCC8. To keep older
versions happy use a macro instead.

Fixes: 221622ec0c ("lib/msun: Avoid FE_INEXACT for x86 log2l/log10l")
Reported by: Jenkins
Reviewed By: imp
Differential Revision: https://reviews.freebsd.org/D29233

3 years agoFetch the sigfastblock value in syscalls that wait for signals
Jonathan T. Looney [Fri, 12 Mar 2021 18:14:17 +0000 (18:14 +0000)]
Fetch the sigfastblock value in syscalls that wait for signals

We have seen several cases of processes which have become "stuck" in
kern_sigsuspend(). When this occurs, the kernel's td_sigblock_val
is set to 0x10 (one block outstanding) and the userspace copy of the
word is set to 0 (unblocked). Because the kernel's cached value
shows that signals are blocked, kern_sigsuspend() blocks almost all
signals, which means the process hangs indefinitely in sigsuspend().

It is not entirely clear what is causing this condition to occur.
However, it seems to make sense to add some protection against this
case by fetching the latest sigfastblock value from userspace for
syscalls which will sleep waiting for signals. Here, the change is
applied to kern_sigsuspend() and kern_sigtimedwait().

Reviewed by: kib
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D29225

3 years agox86: Update some stale comments in cpu_fork() and cpu_copy_thread().
John Baldwin [Fri, 12 Mar 2021 17:48:49 +0000 (09:48 -0800)]
x86: Update some stale comments in cpu_fork() and cpu_copy_thread().

Neither of these routines allocate stacks.

Reviewed by: kib
MFC after: 1 week
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D29227

3 years agox86: Always use clean FPU and segment base state for new kthreads.
John Baldwin [Fri, 12 Mar 2021 17:48:36 +0000 (09:48 -0800)]
x86: Always use clean FPU and segment base state for new kthreads.

Reviewed by: kib
MFC after: 1 week
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D29208

3 years agoSet TDP_KTHREAD before calling cpu_fork() and cpu_copy_thread().
John Baldwin [Fri, 12 Mar 2021 17:48:20 +0000 (09:48 -0800)]
Set TDP_KTHREAD before calling cpu_fork() and cpu_copy_thread().

This permits these routines to use special logic for initializing MD
kthread state.

For the kproc case, this required moving the logic to set these flags
from kproc_create() into do_fork().

Reviewed by: kib
MFC after: 1 week
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D29207

3 years agoDon't pass RFPROC to kproc_create(), it is redundant.
John Baldwin [Fri, 12 Mar 2021 17:48:10 +0000 (09:48 -0800)]
Don't pass RFPROC to kproc_create(), it is redundant.

Reviewed by: tuexen, kib
MFC after: 1 week
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D29206