freebsd.git
2 years agogenet: pullup minimum header amount for IPv4
Mike Karels [Sun, 20 Jun 2021 17:50:31 +0000 (12:50 -0500)]
genet: pullup minimum header amount for IPv4

The genet driver (RPi4 Ethernet) had code to pull headers into the
first mbuf if there was only an Ethernet header there.  This was
originally needed for ICMPv6 replies, then for forwarded IPv6/TCP.
Now a situation has been found where it is needed for IPv4, when
using NAT with IPFW.  Generalize to do this for all protocols.
Rather than using an IPv6-related definition for the length, move
the length to a variable that can be set with sysctl
(hw.genet.tx_hdr_min).  Move an old tunable to a new RDTUN variable
with a better name.

PR: 25607
MFC after: 3 days
Reviewers: emaste
Differential Revision: https://reviews.freebsd.org/D30831

2 years agoarm64: fix a potential KVA leak in pmap_demote_l1()
Alan Cox [Sat, 26 Jun 2021 03:29:38 +0000 (22:29 -0500)]
arm64: fix a potential KVA leak in pmap_demote_l1()

In the unlikely event that the 1 GB page mapping being demoted is used
to access the L1 page table page containing the 1 GB page mapping and
the vm_page_alloc() to allocate a new L2 page table page fails, we
would leak a page of kernel virtual address space.  Fix this leak.

MFC after: 1 week

2 years agofusefs: correctly set lock owner during FUSE_SETLK
Alan Somers [Thu, 20 May 2021 01:10:15 +0000 (19:10 -0600)]
fusefs: correctly set lock owner during FUSE_SETLK

During FUSE_SETLK, the owner field should uniquely identify the calling
process.  The fusefs module now sets it to the process's pid.
Previously, it expected the calling process to set it directly, which
was wrong.

libfuse also apparently expects the owner field to be set during
FUSE_GETLK, though I'm not sure why.

PR: 256005
Reported by: Agata <chogata@moosefs.pro>
MFC after: 2 weeks
Reviewed by: pfg
Differential Revision: https://reviews.freebsd.org/D30622

2 years agoAdd support for link status, media and VLAN MTU (if supported) to if_cdce...
John-Mark Gurney [Sat, 26 Jun 2021 00:47:02 +0000 (17:47 -0700)]
Add support for link status, media and VLAN MTU (if supported) to if_cdce...

This makes it more usable in that dhclient will autolaunch from devd
now when cdce devices are plugged in..  It also sets the baudrate, but
this isn't exported via tools, and CDCE doesn't have a good way to
specify the media type, so there isn't a good way to tell userland
what the speed is currently...

Reviewed by: hps
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D30625

2 years agozfs: merge openzfs/zfs@5e2c8338b (master) into main
Martin Matuska [Sat, 26 Jun 2021 00:21:11 +0000 (02:21 +0200)]
zfs: merge openzfs/zfs@5e2c8338b (master) into main

Notable upstream pull request merges:
  #12183 Optimize small random numbers generation
  #12227 Revert Consolidate arc_buf allocation checks
  #12266 Fix flag copying in resume case
  #12273 zfs_metaslab_mem_limit should be 25 instead of 75
  #12276 Update cache file when setting compatibility property
  #12280 Help compiller optimize out abd_verify()
  #12282 FreeBSD: fix compilation of FreeBSD world after 29274c9f6

Obtained from: OpenZFS
OpenZFS commit: 5e2c8338bf17d31b44eb1dbbb3c9b6a0f64e96ee

2 years agoHelp compiller optimize out abd_verify()
Alexander Motin [Fri, 25 Jun 2021 23:38:31 +0000 (19:38 -0400)]
Help compiller optimize out abd_verify()

While abd_verify() does nothing when built without debug, compiler
can't optimize it out by itself due to calls to external list_*()
and abd_verify_scatter().  This commit makes it explicit.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Adam Moss <c@yotes.com>
Reviewed-by: George Melikov <mail@gmelikov.ru>
Signed-off-by: Alexander Motin <mav@FreeBSD.org>
Sponsored-By: iXsystems, Inc.
Closes #12280

2 years agocxgbe(4): Do not configure traffic classes automatically on attach.
Navdeep Parhar [Thu, 24 Jun 2021 20:05:57 +0000 (13:05 -0700)]
cxgbe(4): Do not configure traffic classes automatically on attach.

The driver used to configure all available classes with some default
parameters on attach and the rest of t4_sched.c was written with the
assumption that all traffic classes are always valid in the hardware.
But this resulted in a lot of informational messages being logged in the
firmware's circular log, crowding out other more useful messages.

This change leaves the tx scheduler alone during attach to reduce the
spam in the devlog.  The state of every class is now tracked separately
from its flags and there is support for an 'uninitialized' state.

MFC after: 2 weeks
Sponsored by: Chelsio Communications

2 years agocxgbe(4): Get the number of usable traffic classes from the firmware.
Navdeep Parhar [Tue, 22 Jun 2021 05:07:56 +0000 (22:07 -0700)]
cxgbe(4): Get the number of usable traffic classes from the firmware.

Recent firmwares are able to utilize the traffic classes of tx channels
that were previously unused.  This effectively doubles the number of
traffic classes available per port for 2 port cards.  Stop using the raw
per-channel value in the driver and ask the firmware for the number of
usable traffic classes instead.

MFC after: 2 weeks
Sponsored by: Chelsio Communications

2 years agoUpdate to bmake-20210621
Simon J. Gerraty [Fri, 25 Jun 2021 21:26:16 +0000 (14:26 -0700)]
Update to bmake-20210621

MFC after: 1 week

2 years agoMerge commit 'ee914ef902ae018bd4f67192832120f9bf05651f' into new_merge
Simon J. Gerraty [Fri, 25 Jun 2021 21:31:14 +0000 (14:31 -0700)]
Merge commit 'ee914ef902ae018bd4f67192832120f9bf05651f' into new_merge

2 years agomd5: Fix cross-build after c2870e576bd2
Jessica Clarke [Fri, 25 Jun 2021 21:00:11 +0000 (22:00 +0100)]
md5: Fix cross-build after c2870e576bd2

On macOS and Linux the current set of headers do not end up pulling in
sys/param.h, causing MAXPATHLEN to not be defined and the build to fail.

2 years agoWork around bogus old gcc "initializer element is not constant" error
Dimitry Andric [Fri, 25 Jun 2021 18:42:38 +0000 (20:42 +0200)]
Work around bogus old gcc "initializer element is not constant" error

After df3b437c1e073eb83e9a93af1c417f3ee8d0de3b, older gcc's such as
4.2.1 (still used on earlier branches for e.g. mips and powerpc) and
6.3.0 (still used for some cross-builds) started throwing bogus errors
like:

In file included from /workspace/src/lib/msun/src/s_llround.c:11:0:
/workspace/src/lib/msun/src/s_lround.c:54:31: error: initializer element is not constant
 static const type dtype_min = type_min - 0.5;
                               ^~~~~~~~
/workspace/src/lib/msun/src/s_lround.c:55:31: error: initializer element is not constant
 static const type dtype_max = type_max + 0.5;
                               ^~~~~~~~

Since 'type_min' and 'type_max' are constants declared just above these
lines this error is nonsensical, but older gcc's are not smart enough.

Work around the error by reusing the (type)DTYPE_MIN and (type)DTYPE_MAX
macros, so I can MFC this right away, unbreaking a few stable builds.

MFC after: immediately

2 years agoImport bmake-20210621
Simon J. Gerraty [Fri, 25 Jun 2021 18:16:24 +0000 (11:16 -0700)]
Import bmake-20210621

Lots more unit tests and code cleanup

Relevant changes from ChangeLog

o job.c: Print -de error information when running multiple jobs
o var.c: only report error for unmatched regex subexpression
when linting (-dL) since we cannot tell when an unmatched
subexpression is an expected result.
reduce memory allocations in the modifiers ':D' and ':U'
reduce memory allocation and strlen calls in modifier ':from=to'
in the ':Q' modifier, only allocate memory if necessary
improve performance for LazyBuf
reduce debug logging and memory allocation for ${:U...}
reduce verbosity of the -dv debug logging for standard cases
fix double varname expansion in the variable modifier '::='
o var.c: avoid evaluating many modifiers in parse only mode
in strict mode (-dL) many variable references are parsed twice,
the first time just to report parse errors early, so we want to
avoid side effects and wasted effort to the extent possible.

2 years agoAllow sleepq_signal() to drop the lock.
Alexander Motin [Fri, 25 Jun 2021 17:52:58 +0000 (13:52 -0400)]
Allow sleepq_signal() to drop the lock.

Introduce SLEEPQ_DROP sleepq_signal() flag, allowing one to drop the
sleep queue chain lock before returning.  Reduced lock scope allows
significantly reduce lock contention inside taskqueue_enqueue() for
ZFS worker threads doing ~350K disk reads/s on 40-thread system.

MFC after: 2 weeks
Sponsored by: iXsystems, Inc.

2 years agobsd-family-tree: Add 2.8BSD relationship to Research 7th edition
Warner Losh [Fri, 25 Jun 2021 17:03:17 +0000 (11:03 -0600)]
bsd-family-tree: Add 2.8BSD relationship to Research 7th edition

In the 2BSD line, the 2.8BSD tapes were the first ones to include a
kernel, both source and a bootable tape. This was an AT&T V7 kernel,
with a number of bug fixes; new features in use at Berkeley; performance
enhancements that were circulating to V7 in the licensee community; and
build system changes. Based on the TUHS archives, it contains none of
the V32 changes, however.

In addition to the source code analysis, Mike Karels relates the story
of how his group lost a customizes to V6 on a PDP-11/40 due to a disk
crash. Since V7 just came out and Bill Jolitz had just brought that up
elsewhere, they replaced their customized V6 with a V7 system, and that
base would eventually become 2.8BSD. (Quarter Century of Unix)

Given both lines of evidence, add a direct line from V7 Unix to 2.8BSD.

Also confirmed that the V6 line to 1BSD and 2BSD was appropriate. 1BSD
and 2BSD included ashell(1) and ex(1). ashell(1) was derived from v6
hell. ex(1) was an enhanced v6 ed.  2.8BSD included process control and
user-land utilities from 4.1BSD

Discussed with: Clem Cole, Diomidis Spinellis (dds)
Differential Revision: https://reviews.freebsd.org/D30883

2 years agoFreeBSD: fix compilation of FreeBSD world after 29274c9f6
Martin Matuška [Fri, 25 Jun 2021 17:28:51 +0000 (19:28 +0200)]
FreeBSD: fix compilation of FreeBSD world after 29274c9f6

prng32_bounded() is available to kernel only on FreeBSD 13+.

Call inline random_get_pseudo_bytes() with correct pointer type.
To be consistent, apply to Linux as well.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Signed-off-by: Martin Matuska <mm@FreeBSD.org>
Closes #12282

2 years agoice_ddp: Revert mode back to 0644
Eric Joyner [Fri, 25 Jun 2021 17:28:28 +0000 (10:28 -0700)]
ice_ddp: Revert mode back to 0644

The last commit (538ef055b7ea11326ba22197537e617587a0d677) accidentally
set the executable bits for this file. This is not intended to be
executed at all. (Would that even work?)

Sponsored by: Intel Corporation

2 years agoice_ddp: Update to 1.3.24.0
Eric Joyner [Fri, 25 Jun 2021 17:20:24 +0000 (10:20 -0700)]
ice_ddp: Update to 1.3.24.0

This version is intended to be used with the 0.29.4 version of the
ice(4) driver, which will be be committed afterwards.

Signed-off-by: Eric Joyner <erj@FreeBSD.org>
Reviewed by: stallamr_netapp.com
Sponsored by: Intel Corporation
Differential Revision: https://reviews.freebsd.org/D30887

2 years agoshm_open(2): Cross-reference posixshmcontrol(1)
Michael Gmelin [Fri, 25 Jun 2021 14:04:37 +0000 (16:04 +0200)]
shm_open(2): Cross-reference posixshmcontrol(1)

When debugging POSIX shared memory issues, it's really
useful to learn that there is a command line tool now
to manipulate shared memory segments.

Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D30896

2 years agolinux(4): Make vDSO defines private.
Dmitry Chagin [Fri, 25 Jun 2021 15:41:04 +0000 (18:41 +0300)]
linux(4): Make vDSO defines private.

Hide the vDSO defines to the linux32_sysvec as they are not intended to
be used outside of it. Fix LINUX32_PS_STRINGS, use the size of
struct linux32_ps_strings instead of a numeric constant.

MFC after: 2 weeks

2 years agobhyve: fix NVMe MDTS comment
Chuck Tuffli [Thu, 24 Jun 2021 16:54:05 +0000 (09:54 -0700)]
bhyve: fix NVMe MDTS comment

Removes an obsolete comment and adds parenthesis around the macro while
in the area. No functional change.

2 years agoEnable OPENMP on riscv64* by default.
Piotr Kubaj [Fri, 25 Jun 2021 14:22:50 +0000 (16:22 +0200)]
Enable OPENMP on riscv64* by default.

Differential revision: https://reviews.freebsd.org/D30862
Approved by: mhorne

2 years agotcp: Preparation for allowing hardware TLS to be able to kick a tcp connection that...
Randall Stewart [Fri, 25 Jun 2021 13:30:54 +0000 (09:30 -0400)]
tcp: Preparation for allowing hardware TLS to be able to kick a tcp connection that is retransmitting too much out of hardware and back to software.

Hardware TLS is now supported in some interface cards and it works well. Except that
when we have connections that retransmit a lot we get into trouble with all the retransmits.
This prep step makes way for change that Drew will be making so that we can "kick out" a
session from hardware TLS.

Reviewed by: mtuexen, gallatin
Sponsored by: Netflix Inc
Differential Revision: https://reviews.freebsd.org/D30895

2 years agosbin/md5: re-enable tests
Stefan Eßer [Fri, 25 Jun 2021 10:41:14 +0000 (12:41 +0200)]
sbin/md5: re-enable tests

The directory for the tests was missing in BSD.tests.dist, causing
build failures in "make distribute".

Li-Wen Hsu fixed this issue in commit cb194afef50dc, allowing me to
re-enable installation of the tests.

MFC after: 3 days

2 years agosbin/md5: Create /usr/tests/sbin/md5 directory for placing tests
Li-Wen Hsu [Fri, 25 Jun 2021 10:29:46 +0000 (18:29 +0800)]
sbin/md5: Create /usr/tests/sbin/md5 directory for placing tests

Sponsored by: The FreeBSD Foundation

2 years agosbin/md5: disable tests due to build failures
Stefan Eßer [Fri, 25 Jun 2021 10:14:25 +0000 (12:14 +0200)]
sbin/md5: disable tests due to build failures

Testing with buildworld/installworld had succeeded, but it appears
that a path is not correctly set for the distribute target in the
tests directory.

Commenting out HAS_TESTS should make the build succeed again and give
time to resolve the "make distribute" issue.

The tests have been locally run to verify that the recent changes to
add a coreutils compatible -c option does not lead to any regressions.

2 years agosbin/md5: fix test case to not write outside temp directory
Stefan Eßer [Fri, 25 Jun 2021 08:37:51 +0000 (10:37 +0200)]
sbin/md5: fix test case to not write outside temp directory

The bsd-p-test did create files 1.out .. 8.out in the test directory.
This has been fixed and the temporary output files are now written
to the temporary directory.

MFC after: 3 days

2 years agosbin/md5: improve compatibility with coreutils -c option
Stefan Eßer [Fri, 25 Jun 2021 06:54:36 +0000 (08:54 +0200)]
sbin/md5: improve compatibility with coreutils -c option

The -c option expects a digest file in either BSD or coreutils format.

The output for matched and mismatched files is identical to that
of the coreutils version.

The review of these changes included test cases that have already
been committed for the functionality that existed before.
Another test script is added to cover the coreutils compatible
extension implemented by this patch.

This commit contains a tests/Makefile that has been cleaned up
compared to the review version, using an implicit rule to apply the
TESTBASE path at build time (and the scripts have been renamed to
have an extension of .SH instead of .sh to trigger this rule).

Reviewed by:    imp
Differential Revision:  https://reviews.freebsd.org/D30812

2 years agosbin/md5: add tests
Stefan Eßer [Fri, 25 Jun 2021 06:51:40 +0000 (08:51 +0200)]
sbin/md5: add tests

While the correctness of the supported hash algorithms can be tested
with the built-in self-test feature, these test cases are meant to
detect changes in the output format.

A follow-up commit will improve the compatibility with the coreutils
versions of the hash programs, and these tests should detect any
unintended side-effects of such a change on existing functionality.

2 years agonfscl: Add entries to UPDATING and RELNOTES for commit a145cf3f73c7
Rick Macklem [Fri, 25 Jun 2021 02:10:36 +0000 (19:10 -0700)]
nfscl: Add entries to UPDATING and RELNOTES for commit a145cf3f73c7

2 years agonfscl: Change the default minor version for NFSv4 mounts
Rick Macklem [Fri, 25 Jun 2021 01:52:23 +0000 (18:52 -0700)]
nfscl: Change the default minor version for NFSv4 mounts

When NFSv4.1 support was added to the client, the implementation was
still experimental and, as such, the default minor version was set to 0.
Since the NFSv4.1 client implementation is now believed to be solid
and the NFSv4.1/4.2 protocol is significantly better than NFSv4.0,
I beieve that NFSv4.1/4.2 should be used where possible.

This patch changes the default minor version for NFSv4 to be the highest
minor version supported by the NFSv4 server. If a specific minor version
is desired, the "minorversion" mount option can be used to override
this default.  This is compatible with the Linux NFSv4 client behaviour.

This was discussed on freebsd-current@ in mid-May 2021 under
the subject "changing the default NFSv4 minor version" and
the consensus seemed to be support for this change.
It also appeared that changing this for FreeBSD 13.1 was
not considered a POLA violation, so long as UPDATING
and RELNOTES entries were made for it.

MFC after: 2 weeks

2 years agoarm64: make it possible to define PV_STATS
Alan Cox [Thu, 24 Jun 2021 23:09:23 +0000 (18:09 -0500)]
arm64: make it possible to define PV_STATS

Remove an #if 0 that results in a compilation error if PV_STATS is
defined.  Aside from this #if 0, there is nothing wrong with the
PV_STATS code.

MFC after: 1 week

2 years agoUpdate cache file when setting compatibility property
Brian Behlendorf [Thu, 24 Jun 2021 21:30:02 +0000 (14:30 -0700)]
Update cache file when setting compatibility property

Unlike most other properties the 'compatibility' property is stored
in the pool config object and not the DMU_OT_POOL_PROPS object.

This had the advantage that the compatibility information is available
without needing to fully import the pool (it can be read with zdb).
However, this means we need to make sure to update both the copy of
the config in the MOS and the cache file.  This wasn't being done.

This commit adds a call to spa_async_request() to ensure the copy of
the config in the cache file gets updated as well as the one stored
in the pool.  This same change is made for the 'comment' property
which suffers from the same inconsistency.

Reviewed-by: Sean Eric Fagan <sef@ixsystems.com>
Reviewed-by: Colm Buckley <colm@tuatha.org>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #12261
Closes #12276

2 years agoFix flag copying in resume case
Paul Dagnelie [Thu, 24 Jun 2021 19:42:01 +0000 (12:42 -0700)]
Fix flag copying in resume case

A couple flags weren't being copied in the case where we're doing size
estimation on a resume.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Matthew Ahrens <mahrens@delphix.com>
Signed-off-by: Paul Dagnelie <pcd@delphix.com>
Closes: #12266

2 years agotcp: Rack not being very friendly with V6:4 socket and having a connection from V4
Randall Stewart [Thu, 24 Jun 2021 18:42:21 +0000 (14:42 -0400)]
tcp: Rack not being very friendly with V6:4 socket and having a connection from V4

There were two bugs that prevented V4 sockets from connecting to
a rack server running a V4/V6 socket. As well as a bug that stops the
mapped v4 in V6 address from working.

Reviewed by: mtuexen
Sponsored by: Netflix Inc
Differential Revision: https://reviews.freebsd.org/D30885

2 years agorc.subr: use _pidcmd to determine pid for protect
Mariusz Zaborski [Thu, 24 Jun 2021 18:14:31 +0000 (20:14 +0200)]
rc.subr: use _pidcmd to determine pid for protect

This is a more reliable method that accounts for existing pidfiles,
procname and interpreter settings.

Current method of obtaining the pid for oomprotect="YES"|"ALL" processes
in certain cases fails to find a unique pid.

One such case are rc.d scripts defining command as:
command="daemon"

which results in all processes started via daemon being selected and
passed to protect(1) which fails and prints usage:

$ /etc/rc.d/exampled restart
Stopping exampled.
Starting exampled.
usage: protect [-i] command
   protect [-cdi] -g pgrp | -p pid

Running the same with -x reveals what happens:

+ pid='3051 4268 4390 4421 4427 4470 4588 4733 4740 4870 4949 4954 4979
5835 5866 55487 55583 56525 57643 57789 57882 58072 58167 99419'
+ /usr/bin/protect -p 3051 4268 4390 4421 4427 4470 4588 4733 4740 4870
4949 4954 4979 5835 5866 55487 55583 56525 57643 57789 57882 58072 58167
99419
usage: protect [-i] command
   protect [-cdi] -g pgrp | -p pid

We have a more reliable way of obtaining pid already defined in rc.subr
and available when protect(1) needs it. We can simply `eval $_pidcmd`
which also invokes `check_process` but properly accounts for existing
pidfile, procname and interpreter settings.

With the change the pidfile is properly obtained.

Submitted by: Adam Wolk <a.wolk at fudosecurity.com>
Sponsored by: Fudo Security
Differential Revision: https://reviews.freebsd.org/D30367

2 years agozfs_metaslab_mem_limit should be 25 instead of 75
jumbi77 [Thu, 24 Jun 2021 17:02:54 +0000 (19:02 +0200)]
zfs_metaslab_mem_limit should be 25 instead of 75

According to current zfs man page zfs_metaslab_mem_limit should be
25 instead of 75.

Reviewed-by: Matthew Ahrens <mahrens@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Paul Dagnelie <pcd@delphix.com>
Reviewed-by: Mark Maybee <mark.maybee@delphix.com>
Signed-off-by: jumbi77@users.noreply.github.com
Closes #12273

2 years agobsd-family-tree: add DragonFly 6.0.0
Warner Losh [Thu, 24 Jun 2021 16:42:36 +0000 (10:42 -0600)]
bsd-family-tree: add DragonFly 6.0.0

Tagged on May 8, 2021.

Sponsored by: Netflix

2 years agoStop using "zstreamdump" in tests/
Rich Ercolani [Thu, 24 Jun 2021 16:38:33 +0000 (12:38 -0400)]
Stop using "zstreamdump" in tests/

zstreamdump was replaced with "zstream dump"; let's stop using the
old name, compat symlink or no.

Reviewed-by: George Melikov <mail@gmelikov.ru>
Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Rich Ercolani <rincebrain@gmail.com>
Closes #12277

2 years agoUpdate ENA version to v2.4.0
Marcin Wojtas [Thu, 24 Jun 2021 14:32:52 +0000 (16:32 +0200)]
Update ENA version to v2.4.0

Some of the changes in this release:
* Large LLQ headers,
* Bug/stability fixes,
* Change of the README/Documentation.

Submitted by: Michal Krawczyk <mk@semihalf.com>
Obtained from: Semihalf
MFC after: 2 weeks
Sponsored by: Amazon, Inc.

2 years agoUpdate ENA driver man page
Marcin Wojtas [Mon, 14 Jun 2021 09:00:30 +0000 (11:00 +0200)]
Update ENA driver man page

Bring the obsolete man page up to date:
* update diagnostic error messages
* add documentation of loader tunables
* document netmap support
* add a driver history section
* update the contact information

Submitted by: Artur Rojek <ar@semihalf.com>
Submitted by: Michal Krawczyk <mk@semihalf.com>
Obtained from: Semihalf
MFC after: 2 weeks
Sponsored by: Amazon, Inc.

2 years agoMerge tag 'vendor/ena-com/2.4.0'
Marcin Wojtas [Thu, 24 Jun 2021 14:07:33 +0000 (16:07 +0200)]
Merge tag 'vendor/ena-com/2.4.0'

Update the driver in order not to break its compilation
and make use of the new ENA logging system

Migrate platform code to the new logging system provided by ena_com
layer.

Make ENA_INFO the new default log level.

Remove all explicit use of `device_printf`, all new logs requiring one
of the log macros to be used.

2 years agoena: hide sysctl nodes for unused ENA queues
Marcin Wojtas [Mon, 14 Jun 2021 08:57:54 +0000 (10:57 +0200)]
ena: hide sysctl nodes for unused ENA queues

IO queue related attributes are registered statically at driver attach
with the rest of the ENA specific sysctl nodes. However, the number of
queues can be changed at runtime via the `ena_sysctl_io_queues_nb`
request, leading to a potential exposure of attributes for non-existing
queues.

Introduce a new `ena_sysctl_update_queue_node_nb` function, which
updates the sysctl nodes after the number of queues is altered.
This happens by either registering or unregistering node specific oids,
based on a delta between the previous and current queue count.

NOTE: All unregistered oids must be registered again before the driver
detach, e.g. by another call to this function.

Submitted by: Artur Rojek <ar@semihalf.com>
Obtained from: Semihalf
MFC after: 2 weeks
Sponsored by: Amazon, Inc.

2 years agoena: remove surplus NULL checks when freeing ENA resources
Marcin Wojtas [Mon, 14 Jun 2021 08:57:49 +0000 (10:57 +0200)]
ena: remove surplus NULL checks when freeing ENA resources

Calling free on a NULL pointer is valid, as appropriate check is already
done internally:

/* free(NULL, ...) does nothing */
if (addr == NULL)
    return;

Submitted by: Artur Rojek <ar@semihalf.com>
Obtained from: Semihalf
MFC after: 2 weeks
Sponsored by: Amazon, Inc.

2 years agoena: add support for the large LLQ headers in ENA
Marcin Wojtas [Mon, 14 Jun 2021 08:57:47 +0000 (10:57 +0200)]
ena: add support for the large LLQ headers in ENA

Default LLQ (Low-latency queue) maximum header size is 96 bytes and can
be too small for some types of packets - like IPv6 packets with multiple
extension. This can be fixed, by using large LLQ headers.

If the device supports larger LLQ headers, the user can activate this
feature by setting sysctl tunable 'hw.ena.force_large_llq_header' to '1'
in the /boot/loader.conf file.

In case the device isn't supporting this feature, the default value (96B)
will be used.

Submitted by: Michal Krawczyk <mk@semihalf.com>
Obtained from: Semihalf
MFC after: 2 weeks
Sponsored by: Amazon, Inc.

2 years agoena: change ENA C++-style comment into C-style
Marcin Wojtas [Mon, 14 Jun 2021 08:57:45 +0000 (10:57 +0200)]
ena: change ENA C++-style comment into C-style

According to man style(9), only C-style comments should be used.

Submitted by: Michal Krawczyk <mk@semihalf.com>
Obtained from: Semihalf
MFC after: 2 weeks
Sponsored by: Amazon, Inc.

2 years agoena-com: restructure the ENA logging system
Marcin Wojtas [Thu, 24 Jun 2021 13:48:26 +0000 (15:48 +0200)]
ena-com: restructure the ENA logging system

Introduce a new logging system, which replaces the old logging method.

All logs are now displayed in `device_printf` format, requiring
`adapter->pdev` to be passed down to `ena_log`. Whenever that's
impossible, a `printf` wrapped `ena_log_raw` is provided.

For netmap logs, `ena_log_nm` is available, prepending "[nm] " to
an `ena_log` formatted message.

Tx/Rx data path logs are now printed via `ena_log_io`. This allows them
to be conditionally compiled out, depending on the presence of
ENA_LOG_IO_ENABLE compilation flag. By default this flag is disabled.

All `ena_trc_*` ena_com level messages are now also wrapped around
`ena_log` and require `ena_dev->dmadev` to be present.

There are four log levels:
* 0 - ENA_ERR  - enable driver error messages and ena_com error logs,
* 1 - ENA_WARN - enable logs for non-critical errors,
* 2 - ENA_INFO - make the driver more verbose about its actions,
* 3 - ENA_DBG  - enable debug logs

Please see `ena_fbsd_log.h` for implementation details.

Submitted by: Artur Rojek <ar@semihalf.com>
Obtained from: Semihalf
MFC after: 2 weeks
Sponsored by: Amazon, Inc.

2 years agoena-com: update sources to the latest version
Marcin Wojtas [Thu, 24 Jun 2021 13:45:32 +0000 (15:45 +0200)]
ena-com: update sources to the latest version

This patch mainly introduces fixes from the static code analysis.

Submitted by: Michal Krawczyk <mk@semihalf.com>
Obtained from: Semihalf
MFC after: 2 weeks
Sponsored by: Amazon, Inc.

2 years agoIntroduce LS1028A PCI MDIO driver.
Marcin Wojtas [Wed, 19 May 2021 14:35:19 +0000 (16:35 +0200)]
Introduce LS1028A PCI MDIO driver.

Implement support for the NXP LS1028A SoC MDIO controller.
It is attached to the internal PCI root complex.
The controller is used to communicate with PHYs of ports connected
to the internal switch.

Submitted by: Lukasz Hajec <lha@semihalf.com>
Reviewed by: manu
Obtained from: Semihalf
Sponsored by: Alstom Group
Differential Revision: https://reviews.freebsd.org/D30731

2 years agoIntroduce new driver for NXP Ethernet controller
Marcin Wojtas [Wed, 7 Apr 2021 14:39:58 +0000 (16:39 +0200)]
Introduce new driver for NXP Ethernet controller

ENETC it a gigabit Ethernet controller found on the LS1028A board.
It supports basic VLAN offloads - tag extraction, injection and hardware
filtering. Inband MDIO connectivity is used for link status
monitoring through the miibus interface. Fixed-link mode is also
supported, which allows for operation of internal cpu to switch port.
Since no admin interrupts are present in hardware, link status polling
has to be used.
Due to a hardware bug software reset of the NIC results in a external
abort. Because of that most of the hardware initialization is done
during attach. This also means that in the case of an fatal error full
board reset is required.
The enetc_hw.h header was imporoted from Linux. It is dual licensed.

Submitted by: Kornel Duleba <mindal@semihalf.com>
Obtained from: Semihalf
Sponsored by: Alstom Group
Differential Revision: https://reviews.freebsd.org/D30729

2 years agoIntroduce MDIO read/write functions for LS1028A.
Marcin Wojtas [Wed, 19 May 2021 14:31:35 +0000 (16:31 +0200)]
Introduce MDIO read/write functions for LS1028A.

Provide common MDIO code for two LS1028 ENETC controllers -
an external one found on the PCI bus and internal one found in ENETC.

Submitted by: Lukasz Hajec <lha@semihalf.com>
Reviewed by: manu
Obtained from: Semihalf
Sponsored by: Alstom Group
Differential Revision: https://reviews.freebsd.org/D30730

2 years agoiflib: Add a new quirk
Marcin Wojtas [Wed, 19 May 2021 09:09:16 +0000 (11:09 +0200)]
iflib: Add a new quirk

ENETC NIC found in LS1028A has a bug where clearing TX pidx/cidx
causes the ring to hang after being re-enabled.
Add a new flag, if set iflib will preserve the indices during restart.

Submitted by: Kornel Duleba <mindal@semihalf.com>
Reviewed by: gallatin, erj
Obtained from: Semihalf
Sponsored by: Alstom Group
Differential Revision: https://reviews.freebsd.org/D30728

2 years agoFix error value returned by ofw_bus_gen_get_node().
Michal Meloun [Thu, 24 Jun 2021 09:56:20 +0000 (11:56 +0200)]
Fix error value returned by ofw_bus_gen_get_node().

By definition ofw_bus_get_node() should  consistently return -1 when there
is no associated OF node.

MFC after: 4 weeks
Discussed with: nwhitehorn
Analyzed in:  https://reviews.freebsd.org/D30761

2 years agolibsa: Add tslog support for arm64
Colin Percival [Thu, 24 Jun 2021 05:21:23 +0000 (22:21 -0700)]
libsa: Add tslog support for arm64

The original code only supported x86 and used rdtsc(); we now also
support arm64 and use the CNTVCT_EL0 special register.

2 years agoarm64: Instrument initarm with TSLOG
Colin Percival [Thu, 24 Jun 2021 05:17:55 +0000 (22:17 -0700)]
arm64: Instrument initarm with TSLOG

The "function entry" needs to be recorded with TSRAW() rather than
TSENTER() since curthread is not yet defined.  (The same approach
is taken in amd64's hammer_time.)

2 years agoarm64: Disable early printf if TSLOG
Colin Percival [Thu, 24 Jun 2021 05:10:26 +0000 (22:10 -0700)]
arm64: Disable early printf if TSLOG

The warning message "ERROR loading DTB" (for systems without a device
tree blob) is printed extremely early in the boot process -- among
other things, before curthread or other pcpu data has been set up.
Unfortunately, printf is instrumented with TSLOG, which cannot run
quite this early.

Wrap the printf in #ifndef TSLOG; the situations where the printf
will be useful are not ones where TSLOG would be in use.

2 years agoarm64: replace pa_to_pvh() with page_to_pvh() in pmap_remove_l2()
Alan Cox [Wed, 23 Jun 2021 19:14:31 +0000 (14:14 -0500)]
arm64: replace pa_to_pvh() with page_to_pvh() in pmap_remove_l2()

Revise pmap_remove_l2() to use the constant-time function page_to_pvh()
instead of the linear-time function pa_to_pvh().

Reviewed by: kib, markj
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D30876

2 years agoUpdate libera webchat client URL
Jonathon [Thu, 24 Jun 2021 00:14:58 +0000 (00:14 +0000)]
Update libera webchat client URL

Libera have made a webchat client available. This change builds on #12127.

Reviewed-by: Matthew Ahrens <mahrens@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Jonathon Fernyhough <jonathon@m2x.dev>
Closes #12251

2 years agogcc 11 cleanup
Attila Fülöp [Wed, 23 Jun 2021 23:57:06 +0000 (01:57 +0200)]
gcc 11 cleanup

Compiling with gcc 11.1.0 produces three new warnings.
Change the code slightly to avoid them.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Matthew Ahrens <mahrens@delphix.com>
Signed-off-by: Attila Fülöp <attila@fueloep.org>
Closes #12130
Closes #12188
Closes #12237

2 years agoZTS: Add known exceptions
Brian Behlendorf [Wed, 23 Jun 2021 22:53:13 +0000 (15:53 -0700)]
ZTS: Add known exceptions

The receive-o-x_props_override test case reliably fails on the
FreeBSD main builders (but not on Linux), until the root cause is
understood add this test to the FreeBSD exception list.

On Linux the alloc_class_012_pos test case may occasionally fail.
This is a known false positive which has also been added to the
Linux exception list until the test can be made entirely reliable.

Reviewed-by: George Melikov <mail@gmelikov.ru>
Reviewed-by: John Kennedy <john.kennedy@delphix.com>
Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #12272

2 years agoamd64: do not touch BIOS reset flag halfword, unless we boot through BIOS
Konstantin Belousov [Sun, 20 Jun 2021 14:58:11 +0000 (17:58 +0300)]
amd64: do not touch BIOS reset flag halfword, unless we boot through BIOS

Reviewed by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D30872

2 years agovdso: lower precision of vdso implementation of CLOCK_MONOTONIC_FAST and CLOCK_UPTIME...
Konstantin Belousov [Tue, 22 Jun 2021 23:24:08 +0000 (02:24 +0300)]
vdso: lower precision of vdso implementation of CLOCK_MONOTONIC_FAST and CLOCK_UPTIME_FAST

so that libc vdso and kernel syscall give closer results.

Reported by: dchagin
Reviewed by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D30873

2 years agovdso gettimeofday: minor restructuring
Konstantin Belousov [Tue, 22 Jun 2021 23:58:32 +0000 (02:58 +0300)]
vdso gettimeofday: minor restructuring

Call binuptime inside switch statement, instead of pre-calculating
the abs argument.
Change the type of the abs argument to bool.

Reviewed by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D30873

2 years agobsdinstall: Avoid double-mounting /dev
Ryan Moeller [Wed, 23 Jun 2021 13:42:43 +0000 (13:42 +0000)]
bsdinstall: Avoid double-mounting /dev

After 34766aa8cb514472c571f8b0e90e833833acef51 we are mounting and
unmounting devfs elsewhere already.

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

2 years agoffs_softdep: force sync if journal is low in journal_check_space
Konstantin Belousov [Tue, 15 Jun 2021 10:27:37 +0000 (13:27 +0300)]
ffs_softdep: force sync if journal is low in journal_check_space

This effectively causes syncing of the mount point from softdep_prealloc(),
softdep_prerename(), and softdep_prelink().  Typically it avoids the need
for journal suspension at this point, at all.

Suggested and reviewed by: mckusick
Discussed with: markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D30041

2 years agoffs_softdep.c: add journal_check_space() helper
Konstantin Belousov [Tue, 15 Jun 2021 10:23:44 +0000 (13:23 +0300)]
ffs_softdep.c: add journal_check_space() helper

Reviewed by: mckusick
Discussed with: markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D30041

2 years agosoftdep_prelink(): only do sync if other thread changed the vnode metadata since...
Konstantin Belousov [Sat, 1 May 2021 21:53:21 +0000 (00:53 +0300)]
softdep_prelink(): only do sync if other thread changed the vnode metadata since previous prelink

We call into softdep_prerename() and softdep_prelink() when there is
low free space in the journal. Functions sync all vnodes participating
in the VOP, in the hope that this would reduce journal utilization. But
if the vnodes are already synced, doing sync would only spend writes,
journal is filled not due to the records from modifications of our
vnodes.

Remember original seqc numbers for vnodes, and only initiate syncs when
seqc changed.

Reviewed by: mckusick
Discussed with: markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D30041

2 years agoufs_rename(): only do softdep_prerename() when other thread changed a vnode
Konstantin Belousov [Thu, 29 Apr 2021 22:39:57 +0000 (01:39 +0300)]
ufs_rename(): only do softdep_prerename() when other thread changed a vnode

Reviewed by: mckusick
Discussed with: markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D30041

2 years agoffs: mark block (re-)allocations as seqc writes
Konstantin Belousov [Fri, 21 May 2021 14:12:08 +0000 (17:12 +0300)]
ffs: mark block (re-)allocations as seqc writes

Reviewed by: mckusick
Discussed with: markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D30041

2 years agoufs_rename(): softdep_prerename() does something only for SU+J
Konstantin Belousov [Thu, 29 Apr 2021 22:23:38 +0000 (01:23 +0300)]
ufs_rename(): softdep_prerename() does something only for SU+J

so call it only in SU+J case

Reviewed by: mckusick
Discussed with: markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D30041

2 years agoffs: reduce number of dvp relocks in softdep_prelink()
Konstantin Belousov [Thu, 29 Apr 2021 22:21:33 +0000 (01:21 +0300)]
ffs: reduce number of dvp relocks in softdep_prelink()

If vp == NULL, we unlocked and then immediately relocked dvp there.

Reviewed by: mckusick
Discussed with: markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D30041

2 years agoufs_vnops.c: style
Konstantin Belousov [Sat, 1 May 2021 21:40:50 +0000 (00:40 +0300)]
ufs_vnops.c: style

Wrap too long functions declarations.

Reviewed by: mckusick
Discussed with: markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D30041

2 years agounionfs: do not use bare struct componentname
Konstantin Belousov [Mon, 14 Jun 2021 18:45:23 +0000 (21:45 +0300)]
unionfs: do not use bare struct componentname

Allocate nameidata on stack and NDPREINIT() it, for compatibility with
assumptions from other filesystems' lookup code.

Reviewed by: mckusick
Discussed with: markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D30041

2 years agonamei: add NDPREINIT() macro
Konstantin Belousov [Mon, 14 Jun 2021 19:03:41 +0000 (22:03 +0300)]
namei: add NDPREINIT() macro

Its intent is to do the initialization of the future part of struct nameidata
which should be used across several namei() and VOPs.  Right now it is NOP.

Reviewed by: mckusick
Discussed with: markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D30041

2 years agoseqc: add symbolic name for in-modify bit
Konstantin Belousov [Thu, 29 Apr 2021 22:39:23 +0000 (01:39 +0300)]
seqc: add symbolic name for in-modify bit

Reviewed by: mckusick
Discussed with: markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D30041

2 years agoarm64: remove an unneeded test from pmap_clear_modify()
Alan Cox [Wed, 23 Jun 2021 05:10:20 +0000 (00:10 -0500)]
arm64: remove an unneeded test from pmap_clear_modify()

The page table entry for a 4KB page mapping must be valid if a PV entry
for the mapping exists, so there is no point in testing each page table
entry's validity when iterating over a PV list.

Reviewed by: kib, markj
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D30875

2 years agonet/bpf: Fix writing of buffer bigger than PAGESIZE
Florian Florensa [Fri, 16 Feb 2018 09:53:22 +0000 (10:53 +0100)]
net/bpf: Fix writing of buffer bigger than PAGESIZE

When allocating the mbuf we used m_get2 which fails
if len is superior to MJUMPAGESIZE, if its the case,
use m_getjcl instead.

Reviewed by: kp@
PR: 205164
Pull Request: https://github.com/freebsd/freebsd-src/pull/131

2 years agodevctl: add ADDR_ADD and ADDR_DEL devctl event for IFNET
Rozhuk Ivan [Wed, 23 Jun 2021 16:20:10 +0000 (10:20 -0600)]
devctl: add ADDR_ADD and ADDR_DEL devctl event for IFNET

Add devd event on network iface address add/remove.  Can be used to
automate actions on any address change.

Reviewed by: imp@ (and minor style tweaks)
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D30840

2 years agodevctl: add RENAME devctl event for IFNET
Rozhuk Ivan [Wed, 23 Jun 2021 16:15:11 +0000 (10:15 -0600)]
devctl: add RENAME devctl event for IFNET

Add devd event on network iface rename.

Reviewed by: imp@,asomers@
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D30839

2 years agomdconfig tests: Correct a copy-pasted test description
Mark Johnston [Wed, 23 Jun 2021 14:37:40 +0000 (10:37 -0400)]
mdconfig tests: Correct a copy-pasted test description

MFC after: 1 week
Sponsored by: The FreeBSD Foundation

2 years agorpc.lockd: Use libc strnlen() instead of reimplementing it
Mark Johnston [Wed, 23 Jun 2021 14:06:57 +0000 (10:06 -0400)]
rpc.lockd: Use libc strnlen() instead of reimplementing it

No functional change intended.

MFC after: 1 week
Sponsored by: The FreeBSD Foundation

2 years agoip_mroute: initialize vif ifnet properly
Wojciech Macek [Wed, 2 Jun 2021 06:46:29 +0000 (08:46 +0200)]
ip_mroute: initialize vif ifnet properly

Use if_alloc to ensure all fields of ifnet are allocated
properly

Reported by:   Damien Deville
Sponsored by:  Stormshield
Obtained from: Semihalf
Reviewed by:   mw
Differential revision: https://reviews.freebsd.org/D30608

2 years agolibalias: Fix compile time warning about unused functions
Lutz Donnerhacke [Mon, 21 Jun 2021 15:19:35 +0000 (17:19 +0200)]
libalias: Fix compile time warning about unused functions

Compiling libalias results in warnings about unused functions.
Those warnings are caused by clang's heuristic to consider an inline
function as in use, iff the declaration is in a *.c file.
Declarations in *.h files do not emit those warnings.

Hence the declarations must be moved to an extra *.h file.

MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D30844

2 years agoAnnotated dprintf as printf-like
Rich Ercolani [Wed, 23 Jun 2021 04:53:45 +0000 (00:53 -0400)]
Annotated dprintf as printf-like

ZFS loves using %llu for uint64_t, but that requires a cast to not
be noisy - which is even done in many, though not all, places.
Also a couple places used %u for uint64_t, which were promoted
to %llu.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Rich Ercolani <rincebrain@gmail.com>
Closes #12233

2 years agoRevert Consolidate arc_buf allocation checks
Antonio Russo [Wed, 23 Jun 2021 04:39:15 +0000 (22:39 -0600)]
Revert Consolidate arc_buf allocation checks

This reverts commit 13fac09868b4e4e08cc3ef7b937ac277c1c407b1.

Per the discussion in #11531, the reverted commit---which intended only
to be a cleanup commit---introduced a subtle, unintended change in
behavior.

Care was taken to partially revert and then reapply 10b3c7f5e4
which would otherwise have caused a conflict.  These changes were
squashed in to this commit.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Suggested-by: @chrisrd
Suggested-by: robn@despairlabs.com
Signed-off-by: Antonio Russo <aerusso@aerusso.net>
Closes #11531
Closes #12227

2 years agobus_child_pnpinfo: fix two stragglers
Warner Losh [Wed, 23 Jun 2021 04:10:31 +0000 (22:10 -0600)]
bus_child_pnpinfo: fix two stragglers

ddfc9c4c59e2 was missing changes to two files to complete the
bus_child_pnpinfo_str->bus_child_pnpinfo. This fixes the broken kernel
builds.

Sponsored by: Netflix

2 years agonewbus: Move from bus_child_{pnpinfo,location}_src to bus_child_{pnpinfo,location...
Warner Losh [Wed, 23 Jun 2021 02:27:57 +0000 (20:27 -0600)]
newbus: Move from bus_child_{pnpinfo,location}_src to bus_child_{pnpinfo,location} with sbuf

Now that the upper layers all go through a layer to tie into these
information functions that translates an sbuf into char * and len. The
current interface suffers issues of what to do in cases of truncation,
etc. Instead, migrate all these functions to using struct sbuf and these
issues go away. The caller is also in charge of any memory allocation
and/or expansion that's needed during this process.

Create a bus_generic_child_{pnpinfo,location} and make it default. It
just returns success. This is for those busses that have no information
for these items. Migrate the now-empty routines to using this as
appropriate.

Document these new interfaces with man pages, and oversight from before.

Reviewed by: jhb, bcr
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D29937

2 years agoOptimize small random numbers generation
Alexander Motin [Tue, 22 Jun 2021 23:35:23 +0000 (19:35 -0400)]
Optimize small random numbers generation

In all places except two spa_get_random() is used for small values,
and the consumers do not require well seeded high quality values.
Switch those two exceptions directly to random_get_pseudo_bytes()
and optimize spa_get_random(), renaming it to random_in_range(),
since it is not related to SPA or ZFS in general.

On FreeBSD directly map random_in_range() to new prng32_bounded() KPI
added in FreeBSD 13.  On Linux and in user-space just reduce the type
used to uint32_t to avoid more expensive 64bit division.

Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Alexander Motin <mav@FreeBSD.org>
Sponsored-By: iXsystems, Inc.
Closes #12183

2 years agotoe: Read-lock the inp in toe_4tuple_check().
John Baldwin [Tue, 22 Jun 2021 23:31:01 +0000 (16:31 -0700)]
toe: Read-lock the inp in toe_4tuple_check().

tcp_twcheck now expects a read lock on the inp for the SYN case
instead of a write lock.

Reviewed by: np
Fixes: 1db08fbe3ffa tcp_input: always request read-locking of PCB for any pure SYN segment.
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D30782

2 years agocxgbei: Better handle new tasks and transfers when disconnecting.
John Baldwin [Fri, 18 Jun 2021 23:15:50 +0000 (16:15 -0700)]
cxgbei: Better handle new tasks and transfers when disconnecting.

If the connection is in the process of disconnecting, ic_socket can be
NULL.  For icl_cxgbei_conn_transfer_setup(), lock the connection and
check ic_socket before using it.  For icl_cxgbei_conn_task_setup(),
the caller already holds the connection lock, so assert it and bail
early with ECONNRESET if the connection is disconnecting.

Reported by: Jithesh Arakkan @ Chelsio
Fixes:   f949967c8eb3 cxgbei: Fix a race between transfer setup and a peer reset.

2 years agoUnbreak TFO, that was broken with 8d5719aa74f. These two assignments
Gleb Smirnoff [Tue, 22 Jun 2021 23:03:44 +0000 (16:03 -0700)]
Unbreak TFO, that was broken with 8d5719aa74f.  These two assignments
are unneccessary and used to be there before TFO as an invariant.  With
TFO and after 8d5719aa74f the "so" value is still needed.

Reported & tested by: tuexen
Fixes: 8d5719aa74f1d1441ee5ee365d45d53f934e81d6

2 years agoDisable llvm generating 128-bit multiply libcalls on 32-bit ARM
Dimitry Andric [Tue, 22 Jun 2021 20:26:13 +0000 (22:26 +0200)]
Disable llvm generating 128-bit multiply libcalls on 32-bit ARM

Merge commit 789708617d20 from llvm git (Koutheir Attouchi):

  Do not generate calls to the 128-bit function __multi3() on 32-bit ARM

  Re-applying this patch after bots failures. Should be fine now.

  The function __multi3() is undefined on 32-bit ARM, so a call to it should
  never be emitted. Instead, plain instructions need to be generated to
  perform 128-bit multiplications.

  Differential Revision: https://reviews.llvm.org/D103906

Reported by: mmel
MFC after: 3 days

2 years agoFix failures in libm's lround_test after clang 12 import
Dimitry Andric [Tue, 22 Jun 2021 16:38:27 +0000 (18:38 +0200)]
Fix failures in libm's lround_test after clang 12 import

It turned out that the (type)DTYPE_MAX conversions at the top of
s_lround.c are now emitted as cvtsi2sd instructions, at least on SSE
capable CPUs. This caused the FE_INEXACT flag to always be set, at least
for the double and float variants. Under clang 11, the whole INRANGE()
comparisons were still optimized away, but this has "improved" in clang
12, due to stricter adherence to the -ffp-exception-behavior=maytrap
compiler flag.

To avoid run-time integer to float conversions, use static constants
instead, so they are computed at compile time, and the INRANGE()
statements are optimized away again, if applicable.

While here, use an integer instead of a floating type to store the test
results in lround_test.c, as this is more appropriate, and we can also
drop the volatile hack.

Reported by: arichardson
MFC after: 3 days

2 years agoUPDATING: Fix typo
Maigurs Stalidzans [Tue, 22 Jun 2021 14:45:35 +0000 (08:45 -0600)]
UPDATING: Fix typo

Revired by: imp@
Sponsored by: Netflix

2 years agortld-elf: Check the return value of obj_enforce_relro()
Alex Richardson [Tue, 22 Jun 2021 08:09:44 +0000 (09:09 +0100)]
rtld-elf: Check the return value of obj_enforce_relro()

The mprotect() call was failing on CheriBSD when changing rtld's relro
page permissions due to missing CHERI capability permissions on the
mprotect() argument but did not report an error since the return value
was being ignored. It should never fail on any supported FreeBSD
architecture, but checking the return value seems like a good
sanity check to me.

Reviewed By: kib, imp
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D30820

2 years agomkimg: Add fat32lba partition type
Jose Luis Duran [Fri, 18 Jun 2021 14:55:24 +0000 (11:55 -0300)]
mkimg: Add fat32lba partition type

Syntactic sugar for a `gpart add -t '!12' ...` equivalent.

Reviewed by: emaste
Pull Request: https://github.com/freebsd/freebsd-src/pull/484

2 years agoMerge tag 'vendor/NetBSD/vis/20210621' into vis
Warner Losh [Mon, 21 Jun 2021 23:56:21 +0000 (17:56 -0600)]
Merge tag 'vendor/NetBSD/vis/20210621' into vis

Bring in NetBSD's vis as of 2021-06-21

Man page fixes, -M, -N and -S support for shell meta characters (all or some)
and no locale.

Discussed with: emaste@
Differential Revision: https://reviews.freebsd.org/D25358

2 years agoImport vis(1) from NetBSD as of 20210621
Warner Losh [Mon, 21 Jun 2021 23:51:00 +0000 (17:51 -0600)]
Import vis(1) from NetBSD as of 20210621

2 years agoEC2: Tell gptboot to skip its 3 second wait
Colin Percival [Mon, 21 Jun 2021 22:35:16 +0000 (15:35 -0700)]
EC2: Tell gptboot to skip its 3 second wait

Nobody is going to hit a key to tell gptboot to select another disk,
so there's no point waiting.

2 years agoarm64: Use page_to_pvh() when the vm_page_t is known
Alan Cox [Mon, 21 Jun 2021 07:45:21 +0000 (02:45 -0500)]
arm64: Use page_to_pvh() when the vm_page_t is known

When support for a sparse pv_table was added, the implementation of
pa_to_pvh() changed from a simple constant-time calculation to iterating
over the array vm_phys_segs[].  To mitigate this issue, an alternative
function, page_to_pvh(), was introduced that still runs in constant time
but requires the vm_page_t to be known.  However, three cases where the
vm_page_t is known were not converted to page_to_pvh().  This change
converts those three cases.

Reviewed by: kib, markj
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D30832