]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
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.

(cherry picked from commit 5dd84e315a9f777772017f9f628aa67f08a6493a)

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.

(cherry picked from commit c94249decd16de71a00d837ee132954d9f259e49)

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

(cherry picked from commit 0c188c06c627b5de30eeeeb7cde00d071a80ecfa)

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

(cherry picked from commit 62ea198e95f139e6b8041ec44f75d65aa26970d0)

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

(cherry picked from commit 6f6a166eaf5e59dedb761ea6152417433a841e3b)

2 years agoExplicitly link zfsd with libspl to avoid undefined references
Dimitry Andric [Sat, 28 Aug 2021 18:23:15 +0000 (20:23 +0200)]
Explicitly link zfsd with libspl to avoid undefined references

Because lld 13.0.0 is more strict about undefined references when
linking to shared libraries, it produces the following errors for zfsd:

ld: error: /home/dim/obj/home/dim/src/llvm-13-update/amd64.amd64/tmp/usr/lib/libzfs_core.so: undefined reference to libspl_assertf [--no-allow-shlib-undefined]
ld: error: /home/dim/obj/home/dim/src/llvm-13-update/amd64.amd64/tmp/usr/lib/libnvpair.so: undefined reference to libspl_assertf [--no-allow-shlib-undefined]
ld: error: /home/dim/obj/home/dim/src/llvm-13-update/amd64.amd64/tmp/usr/lib/libavl.so: undefined reference to libspl_assertf [--no-allow-shlib-undefined]
*** [zfsd.full] Error code 1

Fix this by adding libspl (where libspl_assertf lives) to zfsd's LIBADD.

(cherry picked from commit 9fae476669574792d75706a5401bbdc927ab2b9a)

2 years agoSilence more gtest warnings, now in fusefs tests
Dimitry Andric [Fri, 27 Aug 2021 21:39:23 +0000 (23:39 +0200)]
Silence more gtest warnings, now in fusefs tests

Follow-up d396c67f26b0 by also silencing warnings about deprecated
implicit copy constructors in the fusefs tests, which use googletest.

Fixes: d396c67f26b0

(cherry picked from commit 5a3a8cb01ab8ef4aa16a1950b1ef804070ce1ac6)

2 years agoFix null pointer subtraction in mergesort()
Dimitry Andric [Fri, 27 Aug 2021 17:45:43 +0000 (19:45 +0200)]
Fix null pointer subtraction in mergesort()

Clang 13 produces the following warning for this function:

lib/libc/stdlib/merge.c:137:41: error: performing pointer subtraction with a null pointer has undefined behavior [-Werror,-Wnull-pointer-subtraction]
        if (!(size % ISIZE) && !(((char *)base - (char *)0) % ISIZE))
                                               ^ ~~~~~~~~~

This is meant to check whether the size and base parameters are aligned
to the size of an int, so use our __is_aligned() macro instead.

Also remove the comment that indicated this "stupid subtraction" was
done to pacify some ancient and unknown Cray compiler, and which has
been there since the BSD 4.4 Lite Lib Sources were imported.

(cherry picked from commit 4e5d32a445f90d37966cd6de571978551654e3f3)

2 years agopfctl: build fix
Kristof Provost [Tue, 24 Aug 2021 11:21:05 +0000 (13:21 +0200)]
pfctl: build fix

Fix the build issue introduced in e59eff9ad328 (pfctl: fix killing states by ID)

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

(cherry picked from commit 9ce320820e6d760df11a88de11fbae024c18d23c)

2 years agopf tests: test killing states by ID
Kristof Provost [Tue, 24 Aug 2021 10:36:57 +0000 (12:36 +0200)]
pf tests: test killing states by ID

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

(cherry picked from commit bbf832f34479d19bff0fa8dc43b48ab5553cc85e)

2 years agopfctl: fix killing states by ID
Kristof Provost [Tue, 24 Aug 2021 10:24:28 +0000 (12:24 +0200)]
pfctl: fix killing states by ID

Since the conversion to the new DIOCKILLSTATESNV the kernel no longer
exists the id and creatorid to be big-endian.
As a result killing states by id (i.e. `pfctl -k id -k 12345`) no longer
worked.

Reported by: Özkan KIRIK
MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit e59eff9ad3285838730acf48f6d066cec0e53114)

2 years agopmap_extract.9: Fix pmap_extract_and_hold()'s function type
Ka Ho Ng [Fri, 27 Aug 2021 13:42:49 +0000 (21:42 +0800)]
pmap_extract.9: Fix pmap_extract_and_hold()'s function type

pmap_extract_and_hold() returns a vm_page_t instead of a physical page
address.

Sponsored by: The FreeBSD Foundation
Reviewed by: alc
Differential Revision: https://reviews.freebsd.org/D31691

(cherry picked from commit 6e1df1d14c6dfcc209c1416ec0832e4d08191c72)

2 years agoFix some common typos in source code comments
Gordon Bergling [Sat, 28 Aug 2021 16:57:23 +0000 (18:57 +0200)]
Fix some common typos in source code comments

- s/priviledged/privileged/
- s/funtion/function/
- s/doens't/doesn't/
- s/sychronization/synchronization/

(cherry picked from commit 5bdf58e196096993758b3e50291db17104025b65)

2 years agosound(4): Fix some common typos in comments
Gordon Bergling [Thu, 26 Aug 2021 15:15:55 +0000 (17:15 +0200)]
sound(4): Fix some common typos in comments

- s/doens't/doesn't/
- s/apropriate/appropriate/
- s/intepretation/interpretation/

(cherry picked from commit 58d868c88d21b46d3d6d40a2920e7ba8996723b8)

2 years agoinet(3): Fix a few common typos in source code comments
Gordon Bergling [Sat, 28 Aug 2021 16:53:02 +0000 (18:53 +0200)]
inet(3): Fix a few common typos in source code comments

- s/funtion/function/

(cherry picked from commit 586c9dc37470a2b862b50c041d70229026dd530a)

2 years agoinet6(4): Fix a few common typos in source code comments
Gordon Bergling [Sat, 28 Aug 2021 16:53:59 +0000 (18:53 +0200)]
inet6(4): Fix a few common typos in source code comments

- s/reshedule/reschedule/

(cherry picked from commit 10e0082fff4ec9392db2763ce3b095bc010526df)

2 years agoktls: Fix accounting for TLS 1.0 empty fragments.
John Baldwin [Mon, 16 Aug 2021 17:42:46 +0000 (10:42 -0700)]
ktls: Fix accounting for TLS 1.0 empty fragments.

TLS 1.0 empty fragment mbufs have no payload and thus m_epg_npgs is
zero.  However, these mbufs need to occupy a "unit" of space for the
purposes of M_NOTREADY tracking similar to regular mbufs.  Previously
this was done for the page count returned from ktls_frame() and passed
to ktls_enqueue() as well as the page count passed to pru_ready().

However, sbready() and mb_free_notready() only use m_epg_nrdy to
determine the number of "units" of space in an M_EXT mbuf, so when a
TLS 1.0 fragment was marked ready it would mark one unit of the next
mbuf in the socket buffer as ready as well.  To fix, set m_epg_nrdy to
1 for empty fragments.  This actually simplifies the code as now only
ktls_frame() has to handle TLS 1.0 fragments explicitly and the rest
of the KTLS functions can just use m_epg_nrdy.

Reviewed by: gallatin
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D31536

(cherry picked from commit d16cb228c1a62a9641ffb2f0bfcacc3bffec5db1)

2 years agoktls: Init reset tag task for cloned sessions
Andrew Gallatin [Wed, 11 Aug 2021 18:06:43 +0000 (14:06 -0400)]
ktls: Init reset tag task for cloned sessions

When cloning a ktls session (which is needed when we need to
switch output NICs for a NIC TLS session), we need to also
init the reset task, like we do when creating a new tls session.

Reviewed by: jhb
Sponsored by: Netflix

(cherry picked from commit 95c51fafa40d56d0a32aff857261097acc65ec92)

2 years agoktls: Don't mark existing received mbufs notready for TOE TLS.
John Baldwin [Tue, 15 Jun 2021 17:36:57 +0000 (10:36 -0700)]
ktls: Don't mark existing received mbufs notready for TOE TLS.

The TOE driver might receive decrypted TLS records that are enqueued
to the socket buffer after ktls_try_toe() returns and before
ktls_enable_rx() locks the receive buffer to call sb_mark_notready().
In that case, sb_mark_notready() would incorrectly treat the decrypted
TLS record as an encrypted record and schedule it for decryption.
This always resulted in the connection being dropped as the data in
the control message did not look like a valid TLS header.

To fix, don't try to handle software decryption of existing buffers in
the socket buffer for TOE TLS in ktls_enable_rx().  If a TOE TLS
driver needs to decrypt existing data in the socket buffer, the driver
will need to manage that in its tod_alloc_tls_session method.

Sponsored by: Chelsio Communications

(cherry picked from commit faf0224ff27b93b743d50b3830bf5ce345b67e94)

2 years agokdb: Handle process enumeration before procinit()
Mitchell Horne [Wed, 11 Aug 2021 17:40:01 +0000 (14:40 -0300)]
kdb: Handle process enumeration before procinit()

Make kdb_thr_first() and kdb_thr_next() return sane values if the
allproc list and pidhashtbl haven't been initialized yet. This can
happen if the debugger is entered very early on, for example with the
'-d' boot flag.

This allows remote gdb to attach at such a time, and fixes some ddb
commands like 'show threads'.

Be explicit about the static initialization of these variables. This
part has no functional change.

Reviewed by: markj, imp (previous version)
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D31495

(cherry picked from commit 4ccaa87f695c8b9eb31f2ba9ce4913a045755fe0)

2 years agopmc(3): remove Pentium-related man pages and references
Mitchell Horne [Tue, 10 Aug 2021 20:19:58 +0000 (17:19 -0300)]
pmc(3): remove Pentium-related man pages and references

Support for Pentium events was removed completely in e92a1350b50e.

Don't bump .Dd where we are just removing xrefs.

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

(cherry picked from commit d78896e46f1d7744155919476c012400321d0dab)

2 years agoarm: enable stack-smashing protection
Mitchell Horne [Wed, 4 Aug 2021 18:18:18 +0000 (15:18 -0300)]
arm: enable stack-smashing protection

With current generation clang/llvm it can pass all of our tests in
libc/ssp.

While here, remove the extra MACHINE_CPUARCH check for mips. SSP is
included in BROKEN_OPTIONS for this architecture in src.opts.mk, which
is enough to ensure normal builds won't set SSP_CFLAGS.

Reviewed by: kevans, imp, emaste
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D31400

(cherry picked from commit 1b8db4b4e3614ef6334ce776dcdd46fe7f2c5a78)

2 years agollvm/powerpc64*: fix broken binaries generated by clang12
Alfredo Dal'Ava Junior [Fri, 27 Aug 2021 14:47:11 +0000 (11:47 -0300)]
llvm/powerpc64*: fix broken binaries generated by clang12

Amends LLVM commit 2518433f861fcb877d0a7bdd9aec1aec1f77505a that
was pointed as the source of regression on LLVM12.

This affects powerpc64*, making binaries crash with segmentation fault
due to bad code generation around "__stack_chk_guard"

Root cause and/or proper fix is under investigation by:
    https://bugs.llvm.org/show_bug.cgi?id=51590

Reviewed by:    dim
MFC after:      2 days
Sponsored by:   Instituto de Pesquisas Eldorado (eldorado.org.br)
Differential Revision:  https://reviews.freebsd.org/D31698

(cherry picked from commit 9a4d48a645a7a3ebee05fae25afd154a132b638a)

2 years agovirtio-modern: fix PCI common read/write functions on big endian targets
Alfredo Dal'Ava Junior [Fri, 7 May 2021 05:40:35 +0000 (02:40 -0300)]
virtio-modern: fix PCI common read/write functions on big endian targets

Virtio modern has the common data organized in little endian, but
on powerpc64 BE it was reading and writing in the wrong endian.

Submitted by: Leonardo Bianconi <leonardo.bianconi@eldorado.org.br>
Reviewed by: bryanv, alfredo
Sponsored by: Eldorado Research Institute (eldorado.org.br)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D28947

(cherry picked from commit fb53b42e36a9745d0a33821175a962c7a15eeeaa)

2 years agoAdd more arm64 external abort sources
Andrew Turner [Tue, 3 Aug 2021 13:20:54 +0000 (13:20 +0000)]
Add more arm64 external abort sources

These will be used when we support the Arm Reliability, Availability,
and Serviceability extension.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit dcfd60587102b6854cda04a7c59c8de51ecf89b3)

2 years agoOnly store the arm64 ID registers in the cpu_desc
Andrew Turner [Thu, 29 Jul 2021 08:55:01 +0000 (08:55 +0000)]
Only store the arm64 ID registers in the cpu_desc

There is no need to store a pointer to the CPU implementer and part
strings. Switch to load them directly into the sbuf used to print them
on boot.

While here print the machine ID register when we fail to determine the
implementer or part we are booting on.

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

(cherry picked from commit 8b3bd5a2b571e2681c96dbe5b4a04529ef0d7f53)

2 years agoMove setting arm64 HWCAP values to the ID tables
Andrew Turner [Fri, 16 Jul 2021 13:49:33 +0000 (13:49 +0000)]
Move setting arm64 HWCAP values to the ID tables

The HWCAPS values are based on the ID registers. Move setting these
to the existing ID register parsing code.

Previously we would need to handle all possible ID field values where
a HWCAP is set, however as most ID fields follow a scheme where when
the field increments it will only add new features meaning we only
need to check if the field is greater than when the HWCAP feature
was added.

While here stop setting HWCAP value that need kernel support, but this
support is missing.

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

(cherry picked from commit 1a78f44cd205b6f9ca11ef5cdb6e1f32c0134193)

2 years agoAdd missing arm64 ID registers
Andrew Turner [Wed, 28 Jul 2021 19:00:36 +0000 (19:00 +0000)]
Add missing arm64 ID registers

These may contain values we export to userpsace.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 2d6d5f88d16fc43b6e7ce2b71136ec6b04d10e6e)

2 years agoSort the arm64 ID_AA64* user registers
Andrew Turner [Wed, 28 Jul 2021 18:30:09 +0000 (18:30 +0000)]
Sort the arm64 ID_AA64* user registers

Sponsored by: The FreeBSD Foundation

(cherry picked from commit c3f2fcf5b90991c0155ed64bbf3d9468c3033ebc)

2 years agoAdd macros for arm64 special reg op and CR values
Andrew Turner [Wed, 28 Jul 2021 13:01:14 +0000 (15:01 +0200)]
Add macros for arm64 special reg op and CR values

Use these to simplify the definition of the user_regs array.

Reviewed by: imp, markj
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D31333

(cherry picked from commit 10f6680faae0177cb5ab18754fb27dbb8a0cf226)

2 years agoTeach the arm64 kernel to identify the Arm AEM
Andrew Turner [Tue, 27 Jul 2021 19:28:33 +0000 (19:28 +0000)]
Teach the arm64 kernel to identify the Arm AEM

The Arm Architecture Envelope Model is a simulator that models the
architecture rather than any specific implementation. Add its part ID
macro and add it to the list of Arm CPUs we can decode.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 2531f067ea0e9c77b081445800de8e9584d7d4ab)

2 years agoSwitch to an ifunc in the kernel for crc32c
Andrew Turner [Thu, 22 Jul 2021 10:24:33 +0000 (10:24 +0000)]
Switch to an ifunc in the kernel for crc32c

There is no need to read the same variable to check if the CPU supports
crc32c instructions.

Reviewed by: arichardson, kib, markj
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D31274

(cherry picked from commit a93941b439fce7047dffad6bc380cc9454b967cd)

2 years agoStart to clean up arm64 address space selection
Andrew Turner [Wed, 14 Jul 2021 15:19:06 +0000 (15:19 +0000)]
Start to clean up arm64 address space selection

On arm64 we should use bit 55 of the address to decide if aan address
is a user or kernel address. Add a new macro with this check and a
second to ensure the address is in teh canonical form, i.e.
the top bits are all zero or all one.

This will help with supporting future cpu features, including Top
Byte Ignore, Pointer Authentication, and Memory Tagging.

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

(cherry picked from commit b7a78d573a566c77117af5fe0b259620934a5c7f)

2 years agoSplit out the arm64 ID field comparison function
Andrew Turner [Fri, 16 Jul 2021 12:46:59 +0000 (12:46 +0000)]
Split out the arm64 ID field comparison function

This will be useful in an update for finding which HWCAPS to set.

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

(cherry picked from commit 04f6015706f73c90ba78699953d0d4d0b0237298)

2 years agoaltq: Fix panics on rmc_restart()
Kristof Provost [Sat, 21 Aug 2021 11:42:27 +0000 (13:42 +0200)]
altq: Fix panics on rmc_restart()

rmc_restart() is called from a timer, but can trigger traffic. This
means the curvnet context will not be set.
Use the vnet associated with the interface we're currently processing to
set it. We also have to enter net_epoch here, for the same reason.

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

(cherry picked from commit 159258afb50ad57f7ed27fe86ded83a7b3a26f90)

2 years agonfsstat(1): Fix a typo in an error message
Gordon Bergling [Mon, 23 Aug 2021 07:21:28 +0000 (09:21 +0200)]
nfsstat(1): Fix a typo in an error message

- s/priviledged/privileged/

(cherry picked from commit 72a92f91f466fdb73071ec28982b9f4d4cf9b672)

2 years agokern: mountroot: avoid fd leak in .md parsing
Kyle Evans [Tue, 20 Jul 2021 10:23:11 +0000 (05:23 -0500)]
kern: mountroot: avoid fd leak in .md parsing

parse_dir_md() opens /dev/mdctl but only closes the resulting fd on
success, not upon failure of the ioctl or when we exceed the md unit
max.

Sponsored by: NetApp, Inc.
Sponsored by: Klara, Inc.
X-NetApp-PR: #62

(cherry picked from commit 23ecfa9d5bc4f04eb58e26018c2d15f032d5d742)

2 years agofreebsd-update: create a ZFS boot environment on install
Dave Fullard [Fri, 16 Jul 2021 04:02:48 +0000 (23:02 -0500)]
freebsd-update: create a ZFS boot environment on install

Updated freebsd-update to allow it to create boot environments using
bectl should the system support it. The bectl utility was updated in
r352211 (490e13c1403f) to support a 'check' to determine if the system
supports boot environments.  If UFS is used, the bectl check will fail
then no attempt will be made to create the boot environment.

If freebsd-update is run inside a jail, no attempt will be made to
create a boot environment.

The boot environment function will create a new environment using the
format: current FreeBSD kernel version and date/timestamp, example:

12.0-RELEASE-p10_2019-10-03_185233

This functionality can be disabled by setting 'CreateBootEnv' in
freebsd-update.conf to 'no'.

(cherry picked from commit f28f138905416c45ebaa6429f44a0b88a72f54b1)

2 years agobhyve: Use pci(4) to access I/O port BARs
Mark Johnston [Sat, 14 Aug 2021 14:42:34 +0000 (10:42 -0400)]
bhyve: Use pci(4) to access I/O port BARs

This removes the dependency on /dev/io.

PR: 251046
Reviewed by: jhb
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 42375556e5b2e68746d999b43d124040b6affb91)

2 years agopci: Add an ioctl to perform I/O to BARs
Mark Johnston [Sat, 14 Aug 2021 14:41:43 +0000 (10:41 -0400)]
pci: Add an ioctl to perform I/O to BARs

This is useful for bhyve, which otherwise has to use /dev/io to handle
accesses to I/O port BARs when PCI passthrough is in use.

Reviewed by: imp, kib
Discussed with: jhb
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 7e14be0b0717105f4b3b8c62df82a1e883d8ebb6)

2 years agoCleanup compiler warning flags in lib/libefivar/Makefile
Dimitry Andric [Thu, 26 Aug 2021 18:53:18 +0000 (20:53 +0200)]
Cleanup compiler warning flags in lib/libefivar/Makefile

There is no need to set -Wno-unused-parameter twice, and instead of
appending to CFLAGS, append to CWARNFLAGS instead. While here, add
-Wno-unused-but-set-variable for the sake of clang 13.0.0.

(cherry picked from commit f643997a1761689ef9108d69b86d42881ea0ab1c)

2 years agogoogletest: Silence warnings about deprecated implicit copy constructors
Dimitry Andric [Thu, 26 Aug 2021 20:06:49 +0000 (22:06 +0200)]
googletest: Silence warnings about deprecated implicit copy constructors

Our copy of googletest is rather stale, and causes a number of -Werror
warnings about implicit copy constructor definitions being deprecated,
because several classes have user-declared copy assignment operators.
Silence the warnings until we either upgrade or remove googletest.

(cherry picked from commit d396c67f26b079c2808002c07212d9df9818a11b)

2 years agoEnable rc.d/jail within jails
Dan Langille [Sun, 15 Aug 2021 16:53:16 +0000 (12:53 -0400)]
Enable rc.d/jail within jails

Jails with jails is a supported. This change allows the script to run
upon startup with a jail. Without this, jails are not automatically
started within jails.

(cherry picked from commit 35cf9fecbd80f56e39524f480240acfd953c93e1)

2 years agoext2fs(5): Correct a typo in an error message
Gordon Bergling [Sun, 22 Aug 2021 05:58:22 +0000 (07:58 +0200)]
ext2fs(5): Correct a typo in an error message

- s/talbes/tables/

(cherry picked from commit 47f880ebeb3092b1b7bbc6d75e82532e43bbf010)

2 years agoloader: loader_lua can run command_more twice
Toomas Soome [Sat, 21 Aug 2021 18:17:18 +0000 (21:17 +0300)]
loader: loader_lua can run command_more twice

When we quit pager, the return value 1 is returned and command_more()
interprets it as error.

when lua loader gets error from command, it will try to
interpret it once more, so we get the same file shown once more.

There is no reason why we should return error from command_more().

(cherry picked from commit 7b0d05d56dfaad4e1d5a19727e34252072913d17)

2 years agols: prevent no-color build from complaining when COLORTERM is non-empty
Piotr Pawel Stefaniak [Wed, 18 Aug 2021 20:47:37 +0000 (22:47 +0200)]
ls: prevent no-color build from complaining when COLORTERM is non-empty

(cherry picked from commit ced2dcadccfcff8f7991b3cb5f6f70d6710eadfb)

2 years agosh: fix NO_HISTORY build
Piotr Pawel Stefaniak [Wed, 18 Aug 2021 20:40:39 +0000 (22:40 +0200)]
sh: fix NO_HISTORY build

(cherry picked from commit 35b253d9d238c46a710a0cd7ba027ec87ba7c8ba)

2 years agomount.h: improve a comment about flags
Piotr Pawel Stefaniak [Sat, 14 Aug 2021 20:07:09 +0000 (22:07 +0200)]
mount.h: improve a comment about flags

(cherry picked from commit c66e9307ea9520f3d6e4d38dc842a99a31ae80bf)

2 years agostyle.9: remove an outdated comment about indent(1)
Piotr Pawel Stefaniak [Tue, 17 Aug 2021 15:56:41 +0000 (17:56 +0200)]
style.9: remove an outdated comment about indent(1)

(cherry picked from commit f49931c1423e1c9454214f82bbb3ec30d0fee57d)

2 years agofstyp: add BeFS support
Piotr Pawel Stefaniak [Tue, 17 Aug 2021 15:07:31 +0000 (17:07 +0200)]
fstyp: add BeFS support

A simple support for detecting BeFS (BeOS) filesystem

Submitted by: Miguel Gocobachi
Differential Revision: https://reviews.freebsd.org/D29917

(cherry picked from commit 0e92585cde5101506720ca1b904372317b7d84b6)

2 years agoloader: FB console does leave garbage on screen while scrolling
Toomas Soome [Sat, 21 Aug 2021 11:25:36 +0000 (14:25 +0300)]
loader: FB console does leave garbage on screen while scrolling

Scrolling screen will leave "trail" of chars from first column.
Apparently caused by cursor location mismanagement.
Make sure we do not [attempt to] set cursor out of the screen.

(cherry picked from commit e5a50b03297fa09652b3cf319bc6e863392554e0)

2 years agosched_ule(4): Pre-seed sched_random().
Alexander Motin [Mon, 2 Aug 2021 14:50:34 +0000 (10:50 -0400)]
sched_ule(4): Pre-seed sched_random().

I don't think it changes anything, but why not.

While there, make cpu_search_highest() use all 8 lower load bits for
noise, since it does not use cs_prefer and the code is not shared
with cpu_search_lowest() any more.

MFC after: 1 month

(cherry picked from commit ca34553b6f631ec4ec5ae9f3825e3196e172c35d)

2 years agosched_ule(4): Use trylock when stealing load.
Alexander Motin [Mon, 2 Aug 2021 02:42:01 +0000 (22:42 -0400)]
sched_ule(4): Use trylock when stealing load.

On some load patterns it is possible for several CPUs to try steal
thread from the same CPU despite randomization introduced.  It may
cause significant lock contention when holding one queue lock idle
thread tries to acquire another one.  Use of trylock on the remote
queue allows both reduce the contention and handle lock ordering
easier.  If we can't get lock inside tdq_trysteal() we just return,
allowing tdq_idled() handle it.  If it happens in tdq_idled(), then
we repeat search for load skipping this CPU.

On 2-socket 80-thread Xeon system I am observing dramatic reduction
of the lock spinning time when doing random uncached 4KB reads from
12 ZVOLs, while IOPS increase from 327K to 403K.

MFC after: 1 month

(cherry picked from commit 8bb173fb5bc33a02d5a4670c9a60bba0ece07bac)

2 years agosched_ule(4): Reduce duplicate search for load.
Alexander Motin [Mon, 2 Aug 2021 02:07:51 +0000 (22:07 -0400)]
sched_ule(4): Reduce duplicate search for load.

When sched_highest() called for some CPU group returns nothing, idle
thread calls it for the parent CPU group.  But the parent CPU group
also includes the CPU group we've just searched, and unless there is
a race going on, it is unlikely we find anything new this time.

Avoid the double search in case of parent group having only two sub-
groups (the most prominent case). Instead of escalating to the parent
group run the next search over the sibling subgroup and escalate two
levels up after if that fail too.  In case of more than two siblings
the difference is less significant, while searching the parent group
can result in better decision if we find several candidate CPUs.

On 2-socket 40-core Xeon system I am measuring ~25% reduction of CPU
time spent inside cpu_search_highest() in both SMT (2x20x2) and non-
SMT (2x20) cases.

MFC after: 1 month

(cherry picked from commit 2668bb2add8d11c56524ce9014b510412f8f6aa9)

2 years agoRefactor/optimize cpu_search_*().
Alexander Motin [Thu, 29 Jul 2021 01:18:50 +0000 (21:18 -0400)]
Refactor/optimize cpu_search_*().

Remove cpu_search_both(), unused for many years.  Without it there is
less sense for the trick of compiling common cpu_search() into separate
cpu_search_lowest() and cpu_search_highest(), so split them completely,
making code more readable.  While there, split iteration over children
groups and CPUs, complicating code for very small deduplication.

Stop passing cpuset_t arguments by value and avoid some manipulations.
Since MAXCPU bump from 64 to 256, what was a single register turned
into 32-byte memory array, requiring memory allocation and accesses.
Splitting struct cpu_search into parameter and result parts allows to
even more reduce stack usage, since the first can be passed through
on recursion.

Remove CPU_FFS() from the hot paths, precalculating first and last CPU
for each CPU group in advance during initialization.  Again, it was
not a problem for 64 CPUs before, but for 256 FFS needs much more code.

With these changes on 80-thread system doing ~260K uncached ZFS reads
per second I observe ~30% reduction of time spent in cpu_search_*().

MFC after: 1 month

(cherry picked from commit aefe0a8c32d370f2fdd0d0771eb59f8845beda17)

2 years agoAMD-vi: Fortify IVHD device_identify process
Ka Ho Ng [Mon, 19 Apr 2021 08:07:03 +0000 (16:07 +0800)]
AMD-vi: Fortify IVHD device_identify process

- Use malloc(9) to allocate ivhd_hdrs list. The previous assumption
  that there are at most 10 IVHDs in a system is not true. A counter
  example would be a system with 4 IOMMUs, and each IOMMU is related
  to IVHDs type 10h, 11h and 40h in the ACPI IVRS table.
- Always scan through the whole ivhd_hdrs list to find IVHDs that has
  the same DeviceId but less prioritized IVHD type.

Sponsored by: The FreeBSD Foundation
MFC with: 74ada297e897
Reviewed by: grehan
Approved by: lwhsu (mentor)
Differential Revision: https://reviews.freebsd.org/D29525

(cherry picked from commit 6fe60f1d5c39c94fc87534e9dd4e9630594e0bec)

2 years agovmm: Bump vmname buffer in struct vm to VM_MAX_NAMELEN + 1
Ka Ho Ng [Mon, 2 Aug 2021 09:54:40 +0000 (17:54 +0800)]
vmm: Bump vmname buffer in struct vm to VM_MAX_NAMELEN + 1

In hw.vmm.create sysctl handler the maximum length of vm name is
VM_MAX_NAMELEN. However in vm_create() the maximum length allowed is
only VM_MAX_NAMELEN - 1 chars. Bump the length of the internal buffer to
allow the length of VM_MAX_NAMELEN for vm name.

Reviewed by: grehan
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D31372

(cherry picked from commit df95cc76affbbf114c9ff2e4ee011b6f162aa8bd)

2 years agotmpfs: Fix error being cleared after commit c12118f6cec0
Ka Ho Ng [Tue, 24 Aug 2021 16:35:29 +0000 (00:35 +0800)]
tmpfs: Fix error being cleared after commit c12118f6cec0

In tmpfs_link() error was erroneously cleared in commit c12118f6cec0.

Sponsored by: The FreeBSD Foundation
MFC with: c12118f6cec0

(cherry picked from commit a48416f844e3007b4e9f6df125e25cf3a1daad62)

2 years agotmpfs: Fix styles
Ka Ho Ng [Tue, 24 Aug 2021 13:09:21 +0000 (21:09 +0800)]
tmpfs: Fix styles

A lot of return statements were in the wrong style before this commit.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit c12118f6cec0ca5f720be6c06d6c59d551461e5a)

2 years agosound: Add an example of basic sound application
Goran Mekić [Wed, 4 Aug 2021 10:04:54 +0000 (18:04 +0800)]
sound: Add an example of basic sound application

This is an example demonstrating the usage of the OSS-compatible APIs
provided by the sound(4) subsystem. It reads frames from a dsp node and
writes them to the same dsp node.

Reviewed by: hselasky, bcr
Differential revision: https://reviews.freebsd.org/D30149

(cherry picked from commit 21d854658801f6ddb91de3a3c3384e90f5d920f2)

2 years agovfs: Add get_write_ioflag helper to calculate ioflag
Ka Ho Ng [Thu, 12 Aug 2021 09:35:34 +0000 (17:35 +0800)]
vfs: Add get_write_ioflag helper to calculate ioflag

Converted vn_write to use this helper.

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

(cherry picked from commit c15384f8963191a238cb4a33382b4d394f1ac0b4)

2 years agointel ethernet: Use ether_gen_addr(9)
Kevin Bowling [Fri, 20 Aug 2021 14:45:30 +0000 (07:45 -0700)]
intel ethernet: Use ether_gen_addr(9)

Use ether_gen_addr(9) for VF MAC generation

Reviewed by: Intel Networking (erj), kevans
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31616

(cherry picked from commit 0e5811a2a9a1b4a7e0c79b73e3b9b9d15d481577)

2 years agonfsd: Fix sanity check for NFSv4.2 Allocate operations
Rick Macklem [Thu, 12 Aug 2021 23:48:28 +0000 (16:48 -0700)]
nfsd: Fix sanity check for NFSv4.2 Allocate operations

The NFSv4.2 Allocate operation sanity checks the aa_offset
and aa_length arguments.  Since they are assigned to variables
of type off_t (signed) it was possible for them to be negative.
It was also possible for aa_offset+aa_length to exceed OFF_MAX
when stored in lo_end, which is uint64_t.

This patch adds checks for these cases to the sanity check.

(cherry picked from commit 06afb53bcd7b6a928bc90acb820383302ea8be9e)

2 years agoApply clang fix for assertion failure compiling multimedia/minitube
Dimitry Andric [Sat, 21 Aug 2021 21:03:37 +0000 (23:03 +0200)]
Apply clang fix for assertion failure compiling multimedia/minitube

Merge commit 79f9cfbc21e0 from llvm git (by Yaxun (Sam) Liu):

  Do not merge LocalInstantiationScope for template specialization

  A lambda in a function template may be recursively instantiated. The recursive
  lambda will cause a lambda function instantiated multiple times, one inside another.
  The inner LocalInstantiationScope should not be marked as MergeWithParentScope
  since it already has references to locals properly substituted, otherwise it causes
  assertion due to the check for duplicate locals in merged LocalInstantiationScope.

  Reviewed by: Richard Smith

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

Reported by: yuri
PR: 257978

(cherry picked from commit efa485d5c390b745f53761da9159721243c48b7b)

2 years agocrunch: drop WARNS override
Kyle Evans [Thu, 19 Aug 2021 06:33:13 +0000 (01:33 -0500)]
crunch: drop WARNS override

crunchide and crunchgen now build fine with default WARNS

(cherry picked from commit d59c5e023d558161e4f519b88d5209d8bab18bc7)

2 years agocrunchgen: fix remaining issues under WARNS=6
Kyle Evans [Thu, 19 Aug 2021 06:22:16 +0000 (01:22 -0500)]
crunchgen: fix remaining issues under WARNS=6

Entirely variables that should be static, save for one 'no previous
declaration' in mkskel.sh.

(cherry picked from commit bfd70233c3e2bc5c29db6f96fb90b58439908d29)

2 years agocrunchide: static'ify remaining non-exported functions
Kyle Evans [Thu, 19 Aug 2021 06:29:02 +0000 (01:29 -0500)]
crunchide: static'ify remaining non-exported functions

(cherry picked from commit 7ff87026d65c77f90391ead3f2fc752223d16e01)

2 years agocrunchide: address complaints from WARNS=6
Kyle Evans [Thu, 19 Aug 2021 06:17:36 +0000 (01:17 -0500)]
crunchide: address complaints from WARNS=6

- One (1) constify
- One (1) argument is unused
- One (1) local shadows a global
- Various globals that should be static

(cherry picked from commit dd7c7ff192d07912fb7f5874868649c3aa05944a)

2 years agocrunchgen: sprinkle some const-poisoning around
Kyle Evans [Thu, 19 Aug 2021 06:13:13 +0000 (01:13 -0500)]
crunchgen: sprinkle some const-poisoning around

(cherry picked from commit db7f7446b5bcb26c7aaf13c8151b4ae8051c5732)

2 years agopkg: use specific CONFSNAME_${file} for FreeBSD.conf
Kyle Evans [Thu, 18 Feb 2021 04:10:46 +0000 (22:10 -0600)]
pkg: use specific CONFSNAME_${file} for FreeBSD.conf

Setting CONFSNAME directly is a little more complicated for downstream
consumers, as any additional CONFS that are added here will inherit the
group name by default.  This is perhaps arguably a design flaw in CONFS
because inheriting NAME will never give a good result when additional
files are added, but this is a low-effort change.

While we're here, pull FreeBSD.conf.${branch} out into a PKGCONF
variable so one can just drop a new repo config in entirely with a new
naming scheme. CONFSNAME gets set based on chopping anything off after
".conf", so that, e.g.:

- FooBSD.conf => FooBSD.conf
- FooBSD.conf.internal => FooBSD.conf

(cherry picked from commit d35164539b14a6d14fb587e58a0c7a1668d7643a)

2 years agopkg: allow multiple add arguments again
Kyle Evans [Thu, 18 Feb 2021 03:41:53 +0000 (21:41 -0600)]
pkg: allow multiple add arguments again

While pkg(7) add only handles a single 'add' argument, pkg-add(8) fully
handles multiple arguments.

Stop rejecting it, just turn off local-bootstrap mode and proceed to
remote bootstrap if we need it.

While we're here, check if the first argument to pkg add is even a pkg
package. If it's not, also do remote bootstrap instead. Future work
could improve this altogether by picking out a pkg package out of many
and local bootstrap then pass the rest through to the newly installed
pkg.

(cherry picked from commit 40b9f924b189ce8fa871db600b4abc99b03c6a65)

2 years agomalloc(9): Document/complete aligned variants
Adam Fenn [Mon, 2 Aug 2021 20:33:31 +0000 (15:33 -0500)]
malloc(9): Document/complete aligned variants

Comments on a pending kvmclock driver suggested adding a
malloc_aligned() to complement malloc_domainset_aligned(); add it now,
and document both.

(cherry picked from commit 6162cf885c00a0893a0961415f1829942343dcc1)
(cherry picked from commit 04cc0c393c317b6d5e28c8dc80cd1b5ea071f28f)

2 years agodevclass_alloc_unit: move "at" hint test to after device-in-use test
Adam Fenn [Mon, 2 Aug 2021 16:27:17 +0000 (11:27 -0500)]
devclass_alloc_unit: move "at" hint test to after device-in-use test

Only perform this expensive operation when the unit number is a
potential candidate (i.e. not already in use), thereby reducing device
scan time on systems with many devices, unit numbers, and drivers.

Sponsored by: NetApp, Inc.
Sponsored by: Klara, Inc.
X-NetApp-PR: #61

(cherry picked from commit 8ca384eb1d429aae866f53abfadafc71ab009dc6)

2 years agortsold: make it work on if_vlan interfaces
Luiz Otavio O Souza [Thu, 19 Aug 2021 09:48:04 +0000 (11:48 +0200)]
rtsold: make it work on if_vlan interfaces

Reviewed by: kp
Obtained from: pfsense
MFC after: 1 week

(cherry picked from commit 1a4d7030bbfec0f830e87bf7c2810f049f8ca8ac)

2 years agolagg: don't update link layer addresses on destroy
Luiz Otavio O Souza [Tue, 17 Aug 2021 14:23:50 +0000 (16:23 +0200)]
lagg: don't update link layer addresses on destroy

When the lagg is being destroyed it is not necessary update the
lladdr of all the lagg members every time we update the primary
interface.

Reviewed by: scottl
Obtained from: pfSense
MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D31586

(cherry picked from commit c138424148f900dc449c757869453120ae3277f3)

2 years agoipfw: use unsigned int for dummynet bandwidth
Luiz Otavio O Souza [Tue, 17 Aug 2021 07:54:40 +0000 (09:54 +0200)]
ipfw: use unsigned int for dummynet bandwidth

This allows the maximum value of 4294967295 (~4Gb/s) instead of previous
value of 2147483647 (~2Gb/s).

Reviewed by: np, scottl
Obtained from: pfSense
MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D31582

(cherry picked from commit 20ffd88ed54fe3fd098ac30bd221275b2a14f52c)

2 years agodhclient: remove patching of static values in BPF programs
Franco Fichtner [Thu, 19 Aug 2021 13:08:59 +0000 (09:08 -0400)]
dhclient: remove patching of static values in BPF programs

Reviewed by: markj

(cherry picked from commit 5851803f4bcab48bddfe1600bda3906c4f83fad5)

2 years agodhclient: skip_to_semi() consumes semicolon already
Franco Fichtner [Thu, 19 Aug 2021 13:11:38 +0000 (09:11 -0400)]
dhclient: skip_to_semi() consumes semicolon already

When invalid statement is found the next statement is skipped even if it
is valid.

Reviewed by: markj

(cherry picked from commit a313b5240a477e0d04294ffd170408d954181daa)

2 years agolibsa: cstyle cleanup of dosfs.c
Toomas Soome [Thu, 19 Aug 2021 14:33:24 +0000 (17:33 +0300)]
libsa: cstyle cleanup of dosfs.c

No functional changes intended.

(cherry picked from commit 3ec0714d6db0060113f6cadac6f4e44640603e8f)

2 years agoloader: open file list should be dynamic
Toomas Soome [Sat, 31 Jul 2021 08:09:48 +0000 (11:09 +0300)]
loader: open file list should be dynamic

Summary:
Open file list is currently created as statically allocated array
(64 items). Once this array is filled up, loader will not be able
to operate with files. In most cases, this mechanism is good enough,
but the problem appears, when we have many disks with zfs pool(s).
In current loader implementation, all discovered zfs pool
configurations are kept in memory and disk devices open - consuming
the open file array. Rewrite the open file mechanism to use
dynamically allocated list.

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

(cherry picked from commit 97cbd5e722389a575e820c4e03f38053308f08ea)

2 years agokern: remove deprecated makesyscalls.sh
Kyle Evans [Thu, 29 Jul 2021 03:18:13 +0000 (22:18 -0500)]
kern: remove deprecated makesyscalls.sh

makesyscalls was rewritten in Lua and introduced in d3276301ab.  In the
time since, no objections have risen and a warning was introduced long
ago on invocation of makesyscalls.sh that it would be removed before
FreeBSD 13. Belatedly follow through on that.

(cherry picked from commit e3707726c168eeb0ba06d13873dd71590b77d604)

2 years agoinit: execute /etc/rc.final after all user processes have terminated
Kyle Evans [Tue, 20 Jul 2021 10:40:30 +0000 (05:40 -0500)]
init: execute /etc/rc.final after all user processes have terminated

This can be useful for, e.g., unmounting filesystems that were needed
for shutdown.

Sponsored by: NetApp, Inc.
Sponsored by: Klara, Inc.
X-NetApp-PR: #63

(cherry picked from commit 4d1597691916240b9023ee9f15e249503abf67fd)

2 years agokenv: allow listing of static kernel environments
Kyle Evans [Sun, 20 Jun 2021 19:36:10 +0000 (14:36 -0500)]
kenv: allow listing of static kernel environments

The early environment is typically cleared, so these new options
need the PRESERVE_EARLY_KENV kernel config(8) option. These environments
are reported as missing by kenv(1) if the option is not present in the
running kernel.

(cherry picked from commit db0f26439357b78863e61985acd1e5acf75ce73d)

2 years agokern: add an option for preserving the early kenv
Kyle Evans [Sun, 20 Jun 2021 19:29:31 +0000 (14:29 -0500)]
kern: add an option for preserving the early kenv

Some downstream configurations do not store secrets in the
early (loader/static) environments and desire a way to preserve these
for diagnostic reasons.  Provide an option to do so.

(cherry picked from commit 7a129c973b5ba0fa916dfa658d523bec66dbd02d)

2 years agokenv: s/dump/list/ to clarify meaning
Kyle Evans [Mon, 21 Jun 2021 03:11:26 +0000 (22:11 -0500)]
kenv: s/dump/list/ to clarify meaning

The contents of the kenv will be dumped to stdout, while dump could have
also meant 'discard'. Call it 'list' instead.

(cherry picked from commit 46438b5366f9405beb6f76474a5aae822352f012)

2 years agoe1000: Update intel shared code
Kevin Bowling [Thu, 19 Aug 2021 14:59:34 +0000 (07:59 -0700)]
e1000: Update intel shared code

Sync the e1000 shared code with DPDK shared code
"cid-gigabit.2020.06.05.tar.gz released by ND"

Primary focus was on client platforms (ich8lan). More work remains here
but we need an Intel contact for client networking.

Reviewed by: grehan, Intel Networking (erj, earlier rev)
Obtained from: DPDK <http://git.dpdk.org/dpdk/tree/drivers/net/e1000/base>
MFC after: 1 week
Sponsored by: me
Differential Revision: https://reviews.freebsd.org/D31547

(cherry picked from commit fc7682b17f3738573099b8b03f5628dcc8148adb)

2 years agoiflib: Improve mapping of TX/RX queues to CPUs
Patrick Kelsey [Mon, 26 Apr 2021 04:25:59 +0000 (00:25 -0400)]
iflib: Improve mapping of TX/RX queues to CPUs

iflib now supports mapping each (TX,RX) queue pair to the same CPU
(default), to separate CPUs, or to a pair of physical and logical CPUs
that share the same L2 cache.  The mapping mechanism supports unequal
numbers of TX and RX queues, with the excess queues always being
mapped to consecutive physical CPUs.  When the platform cannot
distinguish between physical and logical CPUs, all are treated as
physical CPUs.  See the comment on get_cpuid_for_queue() for the
entire matrix.

The following device-specific tunables influence the mapping process:
dev.<device>.<unit>.iflib.core_offset       (existing)
dev.<device>.<unit>.iflib.separate_txrx     (existing)
dev.<device>.<unit>.iflib.use_logical_cores (new)

The following new, read-only sysctls provide visibility of the mapping
results:
dev.<device>.<unit>.iflib.{t,r}xq<n>.cpu

When an iflib driver allocates TX softirqs without providing reference
RX IRQs, iflib now binds those TX softirqs to CPUs using the above
mapping mechanism (that is, treats them as if they were TX IRQs).
Previously, such bindings were left up to the grouptaskqueue code and
thus fell outside of the iflib CPU mapping strategy.

Reviewed by: kbowling
Tested by: olivier, pkelsey
MFC after: 3 weeks
Differential Revision: https://reviews.freebsd.org/D24094

(cherry picked from commit ca7005f1893d199b7c28d5b159e1bdbb55e74543)

2 years agodhclient: support supersede statement for option 54
Fabian Kurtz [Wed, 18 Aug 2021 17:12:48 +0000 (10:12 -0700)]
dhclient: support supersede statement for option 54

PR: 217978
Reported by: Franco Fichtner <franco@opnsense.org>
Reviewed by: markj
Obtained from: OPNsense
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31503

(cherry picked from commit 0a539a0f005e8acbe4974ede30aa928099c988b9)

2 years agogre: simplify RSS ifdefs
Franco Fichtner [Wed, 18 Aug 2021 17:05:29 +0000 (10:05 -0700)]
gre: simplify RSS ifdefs

Use the early break to avoid else definitions. When RSS gains a
runtime option previous constructs would duplicate and convolute
the existing code.

While here init flowid and skip magic numbers and late default
assignment.

Reviewed by: melifaro, kbowling
Obtained from: OPNsense
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31584

(cherry picked from commit bb250fae9e9e278b681cf3a71ced718700ecf74c)

2 years agoiflib: emulate counters in netmap mode
Stephan de Wit [Wed, 18 Aug 2021 07:17:43 +0000 (00:17 -0700)]
iflib: emulate counters in netmap mode

When iflib devices are in netmap mode the driver
counters are no longer updated making it look from
userspace tools that traffic has stopped.

Reported by: Franco Fichtner <franco@opnsense.org>
Reviewed by: vmaffione, iflib (erj, gallatin)
Obtained from: OPNsense
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31550

(cherry picked from commit 66fa12d8fb61485780f32f0226e79d3389567496)

2 years agorpc(3): Correct a few common typos in source code comments
Gordon Bergling [Sun, 22 Aug 2021 06:16:09 +0000 (08:16 +0200)]
rpc(3): Correct a few common typos in source code comments

- s/therfore/therefor/
- s/activte/active/

Obtained from: NetBSD

(cherry picked from commit 0d55bc8eb2ab9508c43e135616ca887ed719ea9a)

2 years agoMark some sysctls as CTLFLAG_MPSAFE.
Alexander Motin [Wed, 11 Aug 2021 02:17:53 +0000 (22:17 -0400)]
Mark some sysctls as CTLFLAG_MPSAFE.

MFC after: 2 weeks

(cherry picked from commit 67f508db84b8b789db37c60972f255574417b8ed)

2 years agoMark some sysctls as CTLFLAG_MPSAFE.
Alexander Motin [Wed, 11 Aug 2021 00:44:27 +0000 (20:44 -0400)]
Mark some sysctls as CTLFLAG_MPSAFE.

MFC after: 2 weeks

(cherry picked from commit b776de6796fa0cd1b7dfaad75402e10907d47f29)

2 years agogeom(4): Mark all sysctls as CTLFLAG_MPSAFE.
Alexander Motin [Wed, 11 Aug 2021 00:18:46 +0000 (20:18 -0400)]
geom(4): Mark all sysctls as CTLFLAG_MPSAFE.

This code does not use Giant lock for very long time.

MFC after: 2 weeks

(cherry picked from commit c2da954203c0feb933d3be304710e0346c9ed222)

2 years agocam(4): Mark all sysctls as CTLFLAG_MPSAFE.
Alexander Motin [Wed, 11 Aug 2021 00:05:40 +0000 (20:05 -0400)]
cam(4): Mark all sysctls as CTLFLAG_MPSAFE.

This code does not use Giant lock for very long time.

MFC after: 2 weeks

(cherry picked from commit 303477d3253007bb5732deed2daea86b2cbd9aa8)

2 years agobhyve: Fix vq_getchain() error handling bugs in various device models
Mark Johnston [Tue, 24 Aug 2021 18:10:08 +0000 (14:10 -0400)]
bhyve: Fix vq_getchain() error handling bugs in various device models

Reviewed by: grehan, khng
Approved by: so
Security: CVE-2021-29631
Security: FreeBSD-SA-21:13.bhyve

(cherry picked from commit 71fbc6faed62e8eb5864f7c40839740f5e9f5558)

2 years agoFix multiple OpenSSL vulnerabilities.
Gordon Tetlow [Tue, 24 Aug 2021 18:03:46 +0000 (11:03 -0700)]
Fix multiple OpenSSL vulnerabilities.

Approved by: so
Security: SA-21:16.openssl
Security: CVE-2021-3711
Security: CVE-2021-3712

(cherry picked from commit be158ffe54dcc4a633652685afc5e37894e10ea0)

2 years agoFix libfetch out of bounds read.
Gordon Tetlow [Tue, 24 Aug 2021 17:59:01 +0000 (10:59 -0700)]
Fix libfetch out of bounds read.

Approved by: so
Security: SA-21:15.libfetch
Security: CVE-2021-36159

(cherry picked from commit 3be62d49ae2b6f9050f39fe74210c88f35901fa5)

2 years agoFix remote code execution in ggatec(8).
Gordon Tetlow [Tue, 24 Aug 2021 17:40:49 +0000 (10:40 -0700)]
Fix remote code execution in ggatec(8).

Approved by:    so
Security:       SA-21:14.ggatec
Security:       CVE-2021-29630

(cherry picked from commit 515216929c40169cc72b62466ff9238682661613)

2 years agoipfw: fix possible data race between jump cache reading and updating.
Andrey V. Elsukov [Tue, 17 Aug 2021 08:08:28 +0000 (11:08 +0300)]
ipfw: fix possible data race between jump cache reading and updating.

Jump cache is used to reduce the cost of rule lookup for O_SKIPTO and
O_CALLRETURN actions. It uses rules chain id to check correctness of
cached value. But due to the possible race, there is the chance that
one thread can read invalid value. In some cases this can lead to out
of bounds access and panic.

Use thread fence operations to constrain the reordering of accesses.
Also rename jump_fast and jump_linear functions to jump_cached and
jump_lookup_pos respectively.

Submitted by: Arseny Smalyuk
Obtained from: Yandex LLC
Sponsored by: Yandex LLC
Differential Revision: https://reviews.freebsd.org/D31484

(cherry picked from commit 322e5efda8578bb9c0a0ab0ef785cd1e1c222c85)