]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
2 years agoshutdown: unmount filesystems after swapoff
Konstantin Belousov [Sun, 28 Nov 2021 01:52:46 +0000 (03:52 +0200)]
shutdown: unmount filesystems after swapoff

(cherry picked from commit 08bb51f8d60c552d1f7c202cc2eb267ed480e541)

2 years agoswapoff_one(): only check free pages count manually turning swap off
Konstantin Belousov [Fri, 26 Nov 2021 23:22:27 +0000 (01:22 +0200)]
swapoff_one(): only check free pages count manually turning swap off

(cherry picked from commit 0190c38b9dfaa16de1bc61e829b9a1221fed7896)

2 years agocitrus_prop.c: do not ignore sign
Konstantin Belousov [Sun, 28 Nov 2021 03:03:49 +0000 (05:03 +0200)]
citrus_prop.c: do not ignore sign

(cherry picked from commit 181751a8b6ef580c44d49ef3cac1c6627bfa461e)

2 years agolibc/tests/stdlib/dynthr_mod/dynthr_mod.c: mark dummy as used
Konstantin Belousov [Sun, 28 Nov 2021 03:25:28 +0000 (05:25 +0200)]
libc/tests/stdlib/dynthr_mod/dynthr_mod.c: mark dummy as used

(cherry picked from commit a64a3b798825bc176ae052fc3ead88566b60ba7d)

2 years agonetbsd h_raw.c test: fake use of sum to avoid warning
Konstantin Belousov [Sun, 28 Nov 2021 03:35:45 +0000 (05:35 +0200)]
netbsd h_raw.c test: fake use of sum to avoid warning

(cherry picked from commit e8b6309c70f0d751e626f8babbad68a16a95577c)

2 years agot_mlock.c: Remove null_errno, it is write-only
Konstantin Belousov [Sun, 28 Nov 2021 03:28:29 +0000 (05:28 +0200)]
t_mlock.c: Remove null_errno, it is write-only

(cherry picked from commit 631607ac2965e8c6dcc0f21effc9b36fcb530558)

2 years agolibc/stdio/vfwscanf.c::convert_wstring(): wcp0 is write-only
Konstantin Belousov [Sun, 28 Nov 2021 03:16:08 +0000 (05:16 +0200)]
libc/stdio/vfwscanf.c::convert_wstring(): wcp0 is write-only

(cherry picked from commit c8a4a49d582f539c73ef436ceb9d623dd9f20221)

2 years agolibc/x86/__vdso_gettc.c::tsc_selector_idx(): cpu_id is calculated but not used
Konstantin Belousov [Sun, 28 Nov 2021 03:14:20 +0000 (05:14 +0200)]
libc/x86/__vdso_gettc.c::tsc_selector_idx(): cpu_id is calculated but not used

(cherry picked from commit 4b6f4db3410d3d00c5e0e597243bb7d945356213)

2 years agoacl_delete_entry(): remove write-only variable
Konstantin Belousov [Sun, 28 Nov 2021 03:12:42 +0000 (05:12 +0200)]
acl_delete_entry(): remove write-only variable

(cherry picked from commit 959c7ab51ed2bcb7b9622194d47b461dc19919f5)

2 years agosetproctitle_internal(): remove kbuf local, it is write-only
Konstantin Belousov [Sun, 28 Nov 2021 02:51:45 +0000 (04:51 +0200)]
setproctitle_internal(): remove kbuf local, it is write-only

(cherry picked from commit 412fd7a34cf99727f0aa5c70fd694cf06094d831)

2 years agolibc/rpc/getrpcent.c: Mark write-only variables as unused
Konstantin Belousov [Sun, 28 Nov 2021 03:53:05 +0000 (05:53 +0200)]
libc/rpc/getrpcent.c: Mark write-only variables as unused

(cherry picked from commit 16b238b74004f9cde53c6305d760f9e485e9cd91)

2 years agolibc/net/nscachedcli.c: remove write-only variables
Konstantin Belousov [Sun, 28 Nov 2021 03:57:12 +0000 (05:57 +0200)]
libc/net/nscachedcli.c: remove write-only variables

(cherry picked from commit 0e00befcaf6614c513fb32485ea9a2b188169bc2)

2 years agolibc/net/getservent.c: Mark write-only variables as unused
Konstantin Belousov [Sun, 28 Nov 2021 03:52:33 +0000 (05:52 +0200)]
libc/net/getservent.c: Mark write-only variables as unused

(cherry picked from commit 346eaa41f89aaf1545b89f77a88fd1cdd3c37456)

2 years agolibc/net/getprotoent.c: Mark write-only variables as unused
Konstantin Belousov [Sun, 28 Nov 2021 03:48:05 +0000 (05:48 +0200)]
libc/net/getprotoent.c: Mark write-only variables as unused

(cherry picked from commit f6d403743c9eb1facdfcc0fdfbec74fb19dbbc21)

2 years agolibc/net/getnetnamadr.c: Mark write-only variables as unused
Konstantin Belousov [Sun, 28 Nov 2021 03:45:52 +0000 (05:45 +0200)]
libc/net/getnetnamadr.c: Mark write-only variables as unused

(cherry picked from commit 1c4f305d21c069ebfdab6baada0837f7ecc810ea)

2 years agolibc/net/gethostnamadr.c: mark write-only variables as __unused
Konstantin Belousov [Sun, 28 Nov 2021 03:22:24 +0000 (05:22 +0200)]
libc/net/gethostnamadr.c: mark write-only variables as __unused

(cherry picked from commit 024547c9bd6f7e65d383199aab80dae08824ae48)

2 years agolibc/gen/getpwent.c: plug warnings about write-only variables
Konstantin Belousov [Sun, 28 Nov 2021 02:50:18 +0000 (04:50 +0200)]
libc/gen/getpwent.c: plug warnings about write-only variables

(cherry picked from commit 701473ef9468cf0f0482fb2c62344637dbdcce96)

2 years agolibc/gen/getgrent.c: plug warnings about write-only variables
Konstantin Belousov [Sun, 28 Nov 2021 02:46:56 +0000 (04:46 +0200)]
libc/gen/getgrent.c: plug warnings about write-only variables

(cherry picked from commit 075fa5a9a8a3a140541ef07142ed5b721264c0e9)

2 years agoUpdate OptionalObsoleteFiles.inc after 021385aba562
Alex Richardson [Mon, 11 Oct 2021 10:46:30 +0000 (11:46 +0100)]
Update OptionalObsoleteFiles.inc after 021385aba562

I forgot to update this file so make delete-old would incorrectly remove
the newly-installed LLVM binutils. While touching the file also update
for 8e1c989abbd1 since ObsoleteFiles.inc now inludes the tablegen binaries.

Reported by: Herbert J. Skuhra <herbert@gojira.at>
Reviewed By: emaste, imp

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

(cherry picked from commit 88c027338f182e2af56d0dbabd4a94fbca6f091a)

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

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

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

(cherry picked from commit 8e1c989abbd1db4dac5b2149886012d43e27b9a9)

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

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

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

Reviewed By: emaste

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

(cherry picked from commit 021385aba56279febcfdcc64d23673a0106ae45d)

2 years agozfs: Fix a deadlock between page busy and the teardown lock
Mark Johnston [Sat, 20 Nov 2021 16:21:25 +0000 (11:21 -0500)]
zfs: Fix a deadlock between page busy and the teardown lock

When rolling back a dataset, ZFS has to purge file data resident in the
system page cache.  To do this, it loops over all vnodes for the
mountpoint and calls vn_pages_remove() to purge pages associated with
the vnode's VM object.  Each page is thus exclusively busied while the
dataset's teardown write lock is held.

When handling a page fault on a mapped ZFS file, FreeBSD's page fault
handler busies newly allocated pages and then uses VOP_GETPAGES to fill
them.  The ZFS getpages VOP acquires the teardown read lock with vnode
pages already busied.  This represents a lock order reversal which can
lead to deadlock.

To break the deadlock, observe that zfs_rezget() need only purge those
pages marked valid, and that pages busied by the page fault handler are,
by definition, invalid.  Furthermore, ZFS pages always transition from
invalid to valid with the teardown lock held, and ZFS never creates
partially valid pages.  Thus, zfs_rezget() can use the new
vn_pages_remove_valid() to skip over pages busied by the fault handler.

PR: 258208
Tested by: pho
Reviewed by: avg, sef, kib
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 705a6ee2b6112c3a653b2bd68f961a8b5b8071a4)

2 years agoetc/defaults/rc.conf: Add -i flag to rtsol/rtsold
Colin Percival [Mon, 22 Nov 2021 21:51:43 +0000 (13:51 -0800)]
etc/defaults/rc.conf: Add -i flag to rtsol/rtsold

This disables the random (between zero and one seconds) delay before
rtsol and rtsold send a a Router Solicitation packet.  This delay is
specified as a SHOULD by RFC 4861 for avoidance of network congestion,
but network speeds have increased enough in the 25 years since this
first appeared (in RFC 1970) that it seems unnecessary as a default
at this point.

This speeds up the FreeBSD boot process by an average of 500 ms.

Reviewed by: kp
Relnotes: yes
Sponsored by: https://www.patreon.com/cperciva
Differential Revision: https://reviews.freebsd.org/D33089

(cherry picked from commit e29711da2352dae50c575ab884399a6147e9444d)

2 years agorandomdev: Remove 100 ms sleep from write routine
Colin Percival [Sat, 13 Nov 2021 16:38:09 +0000 (08:38 -0800)]
randomdev: Remove 100 ms sleep from write routine

This was introduced in 2014 along with the comment (which has since
been deleted):
/* Introduce an annoying delay to stop swamping */

Modern cryptographic random number generators can ingest arbitrarily
large amounts of non-random (or even maliciously selected) input
without losing their security.

Depending on the number of "boot entropy files" present on the system,
this can speed up the boot process by up to 1 second.

Reviewed by: cem
Sponsored by: https://www.patreon.com/cperciva
Differential Revision: https://reviews.freebsd.org/D32984

(cherry picked from commit 1580afcd6eaf803192f014f3658036cbd49a6e3c)

2 years agouefi(8): loader.efi does not search for loader.efi
Colin Percival [Thu, 21 Oct 2021 20:15:57 +0000 (13:15 -0700)]
uefi(8): loader.efi does not search for loader.efi

This man page formerly referred to boot1.efi searching for loader.efi;
when boot1.efi was obsoleted in favour of having loader.efi launched
directly, this was left claiming that loader.efi searched for
loader.efi.

Reviewed by: bcran
Fixes: db8b56134506 Rework UEFI ESP generation
Differential Revision: https://reviews.freebsd.org/D32334

(cherry picked from commit 6fa58bfb3ecfad4aece948fd7e6a8ca3d60a18c2)

2 years agorc: Hook zfskeys to the build
Mateusz Piotrowski [Mon, 29 Nov 2021 15:13:09 +0000 (16:13 +0100)]
rc: Hook zfskeys to the build

Reviewed by: allanjude
Approved by: allanjude (src)
MFC after: 3 days
Sponsored by: Modirum MDPay
Differential Revision: https://reviews.freebsd.org/D33230

(cherry picked from commit bfb7a31b6a22f4a2c6fb9881bd1e3ae7523a2290)

2 years agorc.subr.8: Document changes to load_rc_config
Mateusz Piotrowski [Mon, 29 Nov 2021 15:02:32 +0000 (16:02 +0100)]
rc.subr.8: Document changes to load_rc_config

Since e27961a496322e2590da29f3c5fe710b269e6754, load_rc_config does not
require a service name as its first argument. This change was documented
in the rc.subr script in 0b9c2e7ac58caac0413aa36749e4c212514d142d. Let's
update the manual page as well.

MFC after: 3 days

(cherry picked from commit 5d21348dfd95bdc19290dd172c5352e3787e86a5)

2 years agoapic.4: Fix a typo
Mateusz Piotrowski [Sat, 27 Nov 2021 12:25:30 +0000 (13:25 +0100)]
apic.4: Fix a typo

MFC after: 3 days

(cherry picked from commit aa798fc2f17eea83c20c18f144fa5c07c1a9a25f)

2 years agoos-release: Quote variables as documented in the manual
Mateusz Piotrowski [Tue, 23 Nov 2021 10:26:47 +0000 (11:26 +0100)]
os-release: Quote variables as documented in the manual

Variables must be quoted if they contain non-alphanumeric characters.

Warner noted in the review that the lack of quoting causing problems
here is rather an edge case. I believe that it's worth adding the quotes
here anyway because this is what the specification says and there is no
good reason not to follow it.

Reviewed by: imp
Approved by: imp (src)
MFC after: 7 days

(cherry picked from commit 169e06fa7852810f4ced2cce7a3c14ca9443bf39)

2 years agomlx5: Correct a typo in a sysctl description
Gordon Bergling [Thu, 2 Dec 2021 09:51:18 +0000 (10:51 +0100)]
mlx5: Correct a typo in a sysctl description

- s/parameteres/parameters/

(cherry picked from commit c937fb286fed530ec1777a6734a1841d6031875b)

2 years agobce(4): Fix a typo in a sysctl description
Gordon Bergling [Thu, 2 Dec 2021 15:12:34 +0000 (16:12 +0100)]
bce(4): Fix a typo in a sysctl description

- s/duirng/during/

(cherry picked from commit 25d0ccbe1018814064d60432012bc2ef70054e58)

2 years agokern: Correct a typo in a sysctl description
Gordon Bergling [Thu, 2 Dec 2021 09:54:15 +0000 (10:54 +0100)]
kern: Correct a typo in a sysctl description

- s/osbolete/obsolete/

(cherry picked from commit fe96f62d61a537ec576d4c6ff8f8fd6c31570446)

2 years agolinker_kldload_busy(): allow recursion
Konstantin Belousov [Fri, 12 Nov 2021 19:45:06 +0000 (21:45 +0200)]
linker_kldload_busy(): allow recursion

PR: 259748

(cherry picked from commit 4f924a786ae08af496dfe55230f8fe1e2ca16150)

2 years agoext2: Check for e2fs_first_dblock in ext2_compute_sb_data()
Neel Chauhan [Tue, 16 Nov 2021 22:59:26 +0000 (14:59 -0800)]
ext2: Check for e2fs_first_dblock in ext2_compute_sb_data()

This prevents a kernel panic on a damaged ext2 superblock.

PR: 259107
Reported by: Robert Morris <rtm@lcs.mit.edu>
Differential Revision: https://reviews.freebsd.org/D33029

(cherry picked from commit 3dd3a395ba975d0fbe13320e6e69fb85b037da5e)

2 years agorouting: Use the same index space for both nexthop and nexthop groups.
Alexander V. Chernikov [Wed, 6 Oct 2021 19:07:54 +0000 (19:07 +0000)]
routing: Use the same index space for both nexthop and nexthop groups.

This simplifies userland object handling along with kernel-level
 nexthop handling in fib algo framework.

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

(cherry picked from commit 7e64580b5f477ba4523799f26d1178f611f5d6cb)

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

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

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

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

(cherry picked from commit 4b631fc832acf1bab24aa88aa06229d368d8e131)

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

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

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

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

Change the code to perform the following:

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

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

(cherry picked from commit 936f4a42fa2a23d21f8f14a8c33627a8207b4b3b)

2 years agoAdd gone_in(9) man page
Ed Maste [Wed, 9 Jun 2021 17:19:16 +0000 (13:19 -0400)]
Add gone_in(9) man page

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

(cherry picked from commit d8aeab4b45a94b3e1ab4396235e4426747e310fe)

2 years agoCI: use amd64 EDK II firmware included with QEMU
Ed Maste [Sat, 26 Jun 2021 00:10:34 +0000 (20:10 -0400)]
CI: use amd64 EDK II firmware included with QEMU

QEMU (now) includes a prebuilt EDK II firmare in edk2-x86_64-code.fd.
Use that instead of requring a standalone uefi-edk2-qemu-x86_64 package.

Reviewed by: imp
MFC after: 3 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D30915

(cherry picked from commit 7d9794b34bcd465a380f05b02ccfea469dd0a48e)

2 years agoif_hn: Fix a few typos in comments and a sysctl description
Gordon Bergling [Tue, 30 Nov 2021 09:35:14 +0000 (10:35 +0100)]
if_hn: Fix a few typos in comments and a sysctl description

- s/segement/segment/

(cherry picked from commit b15a632c418f6532fe7c3002b4085c61b1e278b0)

2 years agonetinet: Fix a common typo in source code comments
Gordon Bergling [Tue, 30 Nov 2021 09:37:20 +0000 (10:37 +0100)]
netinet: Fix a common typo in source code comments

- s/segement/segment/

(cherry picked from commit 1dadeab36762c26f92f60bc43b1bf3854aa13d88)

2 years agonetinet6: Fix a typo in a sysctl description
Gordon Bergling [Tue, 30 Nov 2021 06:24:44 +0000 (07:24 +0100)]
netinet6: Fix a typo in a sysctl description

- remove a double 'a'

(cherry picked from commit 3cf59750eb3e9d548235ecef34fffd275b6d9463)

2 years agomips: Fix a typo in a source code comment
Gordon Bergling [Tue, 30 Nov 2021 09:41:46 +0000 (10:41 +0100)]
mips: Fix a typo in a source code comment

- s/segement/segment/

(cherry picked from commit 1b0602f2db94a4789da33302fbadfe5a57454277)

2 years agotcp(4): Fix a typo in a sysctl description
Gordon Bergling [Tue, 30 Nov 2021 06:17:30 +0000 (07:17 +0100)]
tcp(4): Fix a typo in a sysctl description

- s/entires/entries/

(cherry picked from commit b4aa9cb2175221d31ce06cf91bd9a6b34ebe868e)

2 years agoficl: Fix a typo in a comment
Gordon Bergling [Tue, 30 Nov 2021 09:36:29 +0000 (10:36 +0100)]
ficl: Fix a typo in a comment

- s/segement/segment/

(cherry picked from commit 54c1a65736ec012b583ade1d53c477e182c574e4)

2 years agoxen(4): Fix two typos in source code comments
Gordon Bergling [Tue, 30 Nov 2021 09:39:42 +0000 (10:39 +0100)]
xen(4): Fix two typos in source code comments

- s/segement/segment/

(cherry picked from commit e3080a9cca1b94ded20b42b653b97e49306d94d2)

2 years agoinet(3): Fix two typos in sysctl descriptions
Gordon Bergling [Tue, 30 Nov 2021 09:21:47 +0000 (10:21 +0100)]
inet(3): Fix two typos in sysctl descriptions

- s/sequental/sequential/

(cherry picked from commit 27c4abc7cde0be8f9fdd8ac7725e9910b0cbf5d4)

2 years agompr(4): Fix a typo in a source code comment
Gordon Bergling [Tue, 30 Nov 2021 09:40:50 +0000 (10:40 +0100)]
mpr(4): Fix a typo in a source code comment

- s/segement/segment/

(cherry picked from commit ddeb702f7b29d967f86ae705b5604c4fa81bb908)

2 years agoelf(3): Fix a typo in a sysctl description
Gordon Bergling [Tue, 30 Nov 2021 09:38:34 +0000 (10:38 +0100)]
elf(3): Fix a typo in a sysctl description

- s/segement/segment/

(cherry picked from commit c8ca80e22381e68f7cc23e8822f3ef5e6a68c3c0)

2 years agonvme(4): Correct a typo in a sysctl description
Gordon Bergling [Tue, 30 Nov 2021 09:26:25 +0000 (10:26 +0100)]
nvme(4): Correct a typo in a sysctl description

- s/printting/printing/

(cherry picked from commit 5f8ccf6515288fd98896eaf0511eedd654cd3530)

2 years agovfs: Fix a typo in a sysctl description
Gordon Bergling [Tue, 30 Nov 2021 06:28:40 +0000 (07:28 +0100)]
vfs: Fix a typo in a sysctl description

- s/dependecies/dependencies/

(cherry picked from commit b6f4818a7ee41a4f81f8fd68a2c9820ebf65bd1d)

2 years agorelease: move installworld before installkernel
Ed Maste [Mon, 5 Apr 2021 17:16:01 +0000 (13:16 -0400)]
release: move installworld before installkernel

To support -DNO_ROOT work.  The top-level installworld target creates a
new METALOG starting with `#mtree 2.0` so it needs to be first, to avoid
overwriting installkernel METALOG entries.

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

(cherry picked from commit 4bbfa3d3baf70492ad4c3eacace0f966f3ca7070)

2 years agogvinum: add deprecation notice
Ed Maste [Fri, 26 Mar 2021 15:26:22 +0000 (11:26 -0400)]
gvinum: add deprecation notice

Vinum is a Logical Volume Manager that was introduced in FreeBSD 3.0,
and for FreeBSD 5 was ported to geom(4) as gvinum. gvinum has had no
specific development at least as far back as 2010, and has a number of
known bugs which are unlikely to be resolved.

Add a deprecation notice to raise awareness but state that vinum "may
not be" available in FreeBSD 14.  Either it will be removed and the
notice will be updated to "is not" available, or someone will step up
to fix issues and maintain it and we will remove the notice.

Reviewed by: imp (earlier version)
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D29424

(cherry picked from commit b218441ac074d9cb9417e284980bf87f79a89585)

2 years agoAllow minidumps to be performed on the live system
Mitchell Horne [Wed, 17 Nov 2021 15:35:59 +0000 (11:35 -0400)]
Allow minidumps to be performed on the live system

Add a boolean parameter to minidumpsys(), to indicate a live dump. When
requested, take a snapshot of important global state, and pass this to
the machine-dependent minidump function. For now this includes the
kernel message buffer, and the bitset of pages to be dumped. Beyond
this, we don't take much action to protect the integrity of the dump
from changes in the running system.

A new function msgbuf_duplicate() is added for snapshotting the message
buffer. msgbuf_copy() is insufficient for this purpose since it marks
any new characters it finds as read.

For now, nothing can actually trigger a live minidump. A future patch
will add the mechanism for this. For simplicity and safety, live dumps
are disallowed for mips.

Reviewed by: markj, jhb
MFC after: 2 weeks
Sponsored by: Juniper Networks, Inc.
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D31993

(cherry picked from commit 588ab3c7745480778281ce2ab086eacfb487e413)

2 years agominidump: Use the provided dump bitset
Mitchell Horne [Wed, 17 Nov 2021 15:35:18 +0000 (11:35 -0400)]
minidump: Use the provided dump bitset

When constructing the set of dumpable pages, use the bitset provided by
the state argument, rather than assuming vm_page_dump invariably. For
normal kernel minidumps this will be a pointer to vm_page_dump, but when
dumping the live system it will not.

To do this, the functions in vm_dumpset.h are extended to accept the
desired bitset as an argument. Note that this provided bitset is assumed
to be derived from vm_page_dump, and therefore has the same size.

Reviewed by: kib, markj, jhb
MFC after: 2 weeks
Sponsored by: Juniper Networks, Inc.
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D31992

(cherry picked from commit 10fe6f80a6c871ba317ddc2684cecb8f02096943)

2 years agominidump: Use provided msgbuf pointer
Mitchell Horne [Wed, 17 Nov 2021 15:34:13 +0000 (11:34 -0400)]
minidump: Use provided msgbuf pointer

Don't assume we are dumping the global message buffer, but use the one
provided by the state argument. While here, drop superfluous
cast to char *.

Reviewed by: markj, jhb
MFC after: 2 weeks
Sponsored by: Juniper Networks, Inc.
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D31991

(cherry picked from commit 1d2d1418b492359921716aaa41e93750969b6e1f)

2 years agominidump: reduce the amount direct accesses to page tables
Mitchell Horne [Wed, 17 Nov 2021 15:30:43 +0000 (11:30 -0400)]
minidump: reduce the amount direct accesses to page tables

During a live dump, we may race with updates to the kernel page tables.
This is generally okay; we accept that the state of the system while
dumping may be somewhat inconsistent with its state when the dump was
invoked. However, when walking the kernel page tables, it is important
that we load each PDE/PTE only once while operating on it. Otherwise, it
is possible to have the relevant PTE change underneath us. For example,
after checking the valid bit, but before reading the physical address.

Convert the loads to atomics, and add some validation around the
physical addresses, to ensure that we do not try to dump a non-existent
or non-canonical physical address.

Similarly, don't read kernel_vm_end more than once, on the off chance
that pmap_growkernel() is called between the two page table walks.

Reviewed by: kib, markj
MFC after: 2 weeks
Sponsored by: Juniper Networks, Inc.
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D31990

(cherry picked from commit 681bd71047f184282d10d5ec9c1770882d525eb8)

2 years agominidump: Parameterize minidumpsys()
Mitchell Horne [Wed, 17 Nov 2021 15:26:59 +0000 (11:26 -0400)]
minidump: Parameterize minidumpsys()

The minidump code is written assuming that certain global state will not
change, and rightly so, since it executes from a kernel debugger
context. In order to support taking minidumps of a live system, we
should allow copies of relevant global state that is likely to change to
be passed as parameters to the minidumpsys() function.

This patch does the work of parameterizing this function, by adding a
struct minidumpstate argument. For now, this struct allows for copies of
the kernel message buffer, and the bitset that tracks which pages should
be dumped (vm_page_dump). Follow-up changes will actually make use of
these arguments.

Notably, dump_avail[] does not need a snapshot, since it is not expected
to change after system initialization.

The existing minidumpsys() definitions are renamed, and a thin MI
wrapper is added to kern_dump.c, which handles the construction of
the state struct. Thus, calling minidumpsys() remains as simple as
before.

Reviewed by: kib, markj, jhb
Sponsored by: Juniper Networks, Inc.
Sponsored by: Klara, Inc.
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D31989

(cherry picked from commit 1adebe3cd6b1eb0973969e2c4c5d41f174caa304)

2 years agoamd64: provide PHYS_IN_DMAP() and VIRT_IN_DMAP()
Mitchell Horne [Wed, 17 Nov 2021 15:29:02 +0000 (11:29 -0400)]
amd64: provide PHYS_IN_DMAP() and VIRT_IN_DMAP()

It is useful for quickly checking an address against the DMAP region.
These definitions exist already on arm64 and riscv.

Reviewed by: kib, markj
MFC after: 3 days
Sponsored by: Juniper Networks, Inc.
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D32962

(cherry picked from commit 90d4da62259299a8d91fed1121be97ac5b7b6b3c)

2 years agotwsi: compile in support for debug messages, disabled by default
Andriy Gapon [Fri, 26 Nov 2021 06:52:56 +0000 (08:52 +0200)]
twsi: compile in support for debug messages, disabled by default

Debug messages can now be enabled per driver instance via a new sysctl.
Also, debug messages in TWSI_READ and TWSI_WRITE require debug level
greater than 1 as they are mostly redundant because callers of those
functions already log most interesting results.

NB: the twsi drivers call their device iichb, so the new sysctl will
appear under dev.iichb.N.

(cherry picked from commit a2793d6182256b8edf647c11c642ad3c7c83809e)

2 years agotwsi: remove write-only softc field
Andriy Gapon [Fri, 26 Nov 2021 06:45:12 +0000 (08:45 +0200)]
twsi: remove write-only softc field

(cherry picked from commit f00bc54f62c455c7ed44afee736c3c64873a305a)

2 years agotwsi: add more of status definitions
Andriy Gapon [Fri, 26 Nov 2021 06:30:22 +0000 (08:30 +0200)]
twsi: add more of status definitions

For completeness and for future use.

(cherry picked from commit de86f339cdda0a10130033ff1771fb13cfacd9d0)

2 years agotwsi: sort headers, remove unneeded
Andriy Gapon [Fri, 26 Nov 2021 06:28:41 +0000 (08:28 +0200)]
twsi: sort headers, remove unneeded

(cherry picked from commit 26559dd1770bb49c68f58a5fbcea3b4c96534c94)

2 years agousb/u3g: Add support for Quectel EM05.
Hans Petter Selasky [Thu, 25 Nov 2021 14:27:50 +0000 (15:27 +0100)]
usb/u3g: Add support for Quectel EM05.

Pull Request: https://github.com/freebsd/freebsd-src/pull/565
Sponsored by: NVIDIA Networking

(cherry picked from commit 0229172a65765392f566ae1cdc730615ab504e15)

2 years agolink_elf_obj: Process global ifunc relocs after other global relocs
Mark Johnston [Thu, 25 Nov 2021 21:52:17 +0000 (16:52 -0500)]
link_elf_obj: Process global ifunc relocs after other global relocs

This is needed to ensure that resolvers that reference global symbols
return correct results.

Reviewed by: kib
Sponsored by: The FreeBSD Foundation

(cherry picked from commit b11e6fd75b1bb9d337b0edab14d160ff65b11aae)

2 years agomake_dev.9: Fix a typo
Mark Johnston [Thu, 25 Nov 2021 16:32:30 +0000 (11:32 -0500)]
make_dev.9: Fix a typo

(cherry picked from commit cc7decfcf93be2a9e78923cc9782fd913f70b78e)

2 years agork_spi: declare support for rk3328
Andriy Gapon [Thu, 25 Nov 2021 21:12:11 +0000 (23:12 +0200)]
rk_spi: declare support for rk3328

Tested on Rock64 using the onboard SPI flash.

(cherry picked from commit 8c12ee5021e293c992a7b54215fda1edfbebaa25)

2 years agoswap_pager: lock vnode in swapdev_strategy()
Konstantin Belousov [Wed, 24 Nov 2021 11:26:46 +0000 (13:26 +0200)]
swap_pager: lock vnode in swapdev_strategy()

(cherry picked from commit b19740f4ce7a542783f87de2fee48476a7801d86)

2 years agoswapon: extend the region where the swap vnode is locked
Konstantin Belousov [Wed, 24 Nov 2021 03:06:02 +0000 (05:06 +0200)]
swapon: extend the region where the swap vnode is locked

(cherry picked from commit 6ddf41faa6f54738db9b3f313086974b6403d680)

2 years agoswap pager: lock vnode around VOP_CLOSE()
Konstantin Belousov [Tue, 23 Nov 2021 09:16:53 +0000 (11:16 +0200)]
swap pager: lock vnode around VOP_CLOSE()

(cherry picked from commit a6d04f34a4db6ff3fd5431ae10d4b877337fc138)

2 years agomountd: Fix handling of usernames that start with a digit
Rick Macklem [Thu, 18 Nov 2021 21:35:25 +0000 (13:35 -0800)]
mountd: Fix handling of usernames that start with a digit

yocalebo_gmail.com submitted a patch for mountd.c that
fixes the case where a username starts with a digit.
Without this patch, the username that starts with a
digit is misinterpreted as a numeric uid.
With this patch, any string that does not entirely
convert to a decimal number via strtoul() is considered
a user/group name.

(cherry picked from commit f4bf849bb894f4934b8df6c04a820dfa52e9576c)

2 years agorc.conf.5: Add entries for NFS
Rick Macklem [Thu, 18 Nov 2021 15:59:34 +0000 (07:59 -0800)]
rc.conf.5: Add entries for NFS

Entries for a few recently defined rc variables
were missing from rc.conf.5.  This patch adds
those.

It was not obvious to me what the ordering is,
so I added them to the area where other nfsd
related variables are.  I can easily move them.

I also replaced "are" with "is", since it seems to
read better.

This is a content change.

(cherry picked from commit 9dae2d03bc644be38196cf76c55039af1a7c1ba6)

2 years agonfsd: Add a new rc variable nfs_server_maxio
Rick Macklem [Wed, 17 Nov 2021 00:02:53 +0000 (16:02 -0800)]
nfsd: Add a new rc variable nfs_server_maxio

Since vfs.nfsd.srvmaxio can only be set when nfsd.ko
is loaded, but nfsd is not running, setting it in
/etc/sysctl.conf is not feasible when "options NFSD"
was not specified for the kernel.

This patch adds a new rc variable nfs_server_maxio,
which sets vfs.nfsd.srvmaxio at the correct time.

rc.conf.5 will be patched separately.

(cherry picked from commit 5509bad74e44eed3b9d54fbd74d3752b88428147)

2 years agopowerpc64le: add LINT64LE kernel config
Alfredo Dal'Ava Junior [Mon, 29 Nov 2021 15:08:26 +0000 (12:08 -0300)]
powerpc64le: add LINT64LE kernel config

Add configuration file to be used by "FreeBSD-<branch>-powerpc64le-LINT"
CI/Jenkins job

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

(cherry picked from commit e671037b3c49734566e7e0af74ba1a64f45b77a2)

2 years agopowerpc64: make autoboot possible on powernv machines
Alfredo Dal'Ava Junior [Fri, 26 Nov 2021 00:02:53 +0000 (21:02 -0300)]
powerpc64: make autoboot possible on powernv machines

It's required to specify a default boot option in order to make
petitboot's autoboot feature work.

Tested on Raptor Blackbird

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

(cherry picked from commit b6644f529ca4c13975727c5625415fcc30c60af6)

2 years agopf tests: Test PR259689
Kristof Provost [Mon, 8 Nov 2021 12:28:43 +0000 (13:28 +0100)]
pf tests: Test PR259689

We didn't populate dyncnt/tblcnt, so `pfctl -sr -vv` might not have the
table element count.

PR: 259689
MFC after: 3 weeks
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D32893

(cherry picked from commit 2de49deeca0b1377664dee2cd0a43ee7cf6b4bc4)

2 years agopf: ensure we populate dyncnt/tblcnt in struct pf_addr_wrap
Kristof Provost [Mon, 8 Nov 2021 12:25:20 +0000 (13:25 +0100)]
pf: ensure we populate dyncnt/tblcnt in struct pf_addr_wrap

PR: 259689
MFC after: 3 weeks
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D32892

(cherry picked from commit 218a8a491c4980dcc941908f9505d37e7f052868)

2 years agonet tests: basic if_stf test
Kristof Provost [Fri, 5 Nov 2021 14:20:19 +0000 (15:20 +0100)]
net tests: basic if_stf test

Test the 6to4 code.

MFC after: 3 weeks
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D32850

(cherry picked from commit eb5e0755f7496d1328d572b4d181c70b39152f08)

2 years agoif_stf: style(9) pass
Kristof Provost [Fri, 5 Nov 2021 10:20:16 +0000 (11:20 +0100)]
if_stf: style(9) pass

As stated in style(9): "Values in return statements should be enclosed
in parentheses."

MFC after: 3 weeks
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D32848

(cherry picked from commit 3576121c8b1fcaa31b3a45ea52ff83f7c5855266)

2 years agoif_stf: enable use in vnet jails
Kristof Provost [Fri, 5 Nov 2021 11:01:37 +0000 (12:01 +0100)]
if_stf: enable use in vnet jails

The cloner must be per-vnet so that cloned interfaces get destroyed when
the vnet goes away. Otherwise we fail assertions in vnet_if_uninit():

panic: vnet_if_uninit:475 tailq &V_ifnet=0xfffffe01665fe070 not empty
cpuid = 19
time = 1636107064
KDB: stack backtrace:
db_trace_self_wrapper() at db_trace_self_wrapper+0x2b/frame 0xfffffe015d0cac60
vpanic() at vpanic+0x187/frame 0xfffffe015d0cacc0
panic() at panic+0x43/frame 0xfffffe015d0cad20
vnet_if_uninit() at vnet_if_uninit+0x7b/frame 0xfffffe015d0cad30
vnet_destroy() at vnet_destroy+0x170/frame 0xfffffe015d0cad60
prison_deref() at prison_deref+0x9b0/frame 0xfffffe015d0cadd0
sys_jail_remove() at sys_jail_remove+0x119/frame 0xfffffe015d0cae00
amd64_syscall() at amd64_syscall+0x12e/frame 0xfffffe015d0caf30
fast_syscall_common() at fast_syscall_common+0xf8/frame 0xfffffe015d0caf30
--- syscall (508, FreeBSD ELF64, sys_jail_remove), rip = 0x8011e920a, rsp = 0x7fffffffe788, rbp = 0x7fffffffe810 ---
KDB: enter: panic

MFC after: 3 weeks
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D32849

(cherry picked from commit 8e45fed3aefd00ff544efce8fedeba5e099d3d01)

2 years agonetinet: Remove unneeded mb_unmapped_to_ext() calls
Mark Johnston [Wed, 24 Nov 2021 18:20:09 +0000 (13:20 -0500)]
netinet: Remove unneeded mb_unmapped_to_ext() calls

in_cksum_skip() now handles unmapped mbufs on platforms where they're
permitted.

Reviewed by: glebius, jhb
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 44775b163bfa902ea96658343e852062e2e67a8e)

2 years agonetinet: Implement in_cksum_skip() using m_apply()
Mark Johnston [Wed, 24 Nov 2021 18:19:54 +0000 (13:19 -0500)]
netinet: Implement in_cksum_skip() using m_apply()

This allows it to work with unmapped mbufs.  In particular,
in_cksum_skip() calls no longer need to be preceded by calls to
mb_unmapped_to_ext() to avoid a page fault.

PR: 259645
Reviewed by: gallatin, glebius, jhb
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 0d9c3423f59bb305301f5a5bc7c8f5daf7b7aa52)

2 years agonetinet: Deduplicate most in_cksum() implementations
Mark Johnston [Wed, 24 Nov 2021 18:19:44 +0000 (13:19 -0500)]
netinet: Deduplicate most in_cksum() implementations

in_cksum() and related routines are implemented separately for each
platform, but only i386 and arm have optimized versions.  Other
platforms' copies of in_cksum.c are identical except for style
differences and support for big-endian CPUs.

Deduplicate the implementations for the rest of the platforms.  This
will make it easier to implement in_cksum() for unmapped mbufs.  On arm
and i386, define HAVE_MD_IN_CKSUM to mean that the MI implementation is
not to be compiled.

No functional change intended.

Reviewed by: kp, glebius
Sponsored by: The FreeBSD Foundation

(cherry picked from commit ecbbe831445a4b94279e5932828d60076e4ca444)

2 years agonetinet: Remove in_cksum.c
Mark Johnston [Wed, 24 Nov 2021 18:19:34 +0000 (13:19 -0500)]
netinet: Remove in_cksum.c

It does not get compiled into the kernel.  No functional change
inteneded.

Reviewed by: kp, glebius, cy
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 5195bcc2126b302802643f5204d1030e5893fb62)

2 years agonatd: Remove uneeded in_cksum.h includes
Mark Johnston [Wed, 24 Nov 2021 18:30:28 +0000 (13:30 -0500)]
natd: Remove uneeded in_cksum.h includes

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 517373f7230207e60e4561bc44c8b3c44acea963)

2 years agonetinet: Remove in_cksum_update()
Mark Johnston [Wed, 24 Nov 2021 18:15:40 +0000 (13:15 -0500)]
netinet: Remove in_cksum_update()

It was never implemented on powerpc or riscv and appears to have been
unused since it was added in 1998.  No functional change intended.

Reviewed by: kp, glebius, cy
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 09100f936be0684aa8caef441b96345960fd9c72)

2 years agosafexcel: Fix -Wunused-but-set-variable warnings
Mark Johnston [Wed, 24 Nov 2021 18:30:39 +0000 (13:30 -0500)]
safexcel: Fix -Wunused-but-set-variable warnings

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 60c95f316374fdd383f70b50e98ad097460accf3)

2 years agoldconfig(8): check for no-args command line after options are parsed
Konstantin Belousov [Fri, 19 Nov 2021 04:07:58 +0000 (06:07 +0200)]
ldconfig(8): check for no-args command line after options are parsed

(cherry picked from commit 3ede04c78c7c726ed79a39d22c65a58d0ecc5d00)

2 years agoldconfig: use libexec/rtld-elf/rtld_paths.h
Konstantin Belousov [Fri, 19 Nov 2021 03:45:31 +0000 (05:45 +0200)]
ldconfig: use libexec/rtld-elf/rtld_paths.h

(cherry picked from commit af9115870670f508c11b3d173bcff5116d8ef320)

2 years agortld_paths.h: Provide _PATH_ELF32_HINTS string, unconditionally
Konstantin Belousov [Fri, 19 Nov 2021 03:44:33 +0000 (05:44 +0200)]
rtld_paths.h: Provide _PATH_ELF32_HINTS string, unconditionally

(cherry picked from commit f340188625d4e0e4db850becb0a9b25448053e10)

2 years agoldconfig(8): nostd/-s does nothing
Konstantin Belousov [Fri, 19 Nov 2021 05:21:21 +0000 (07:21 +0200)]
ldconfig(8): nostd/-s does nothing

(cherry picked from commit b828161d123bec894bc5a320ef26d6afc9b13ae8)

2 years agoldconfig: start of cleanup
Konstantin Belousov [Fri, 19 Nov 2021 03:35:50 +0000 (05:35 +0200)]
ldconfig: start of cleanup

(cherry picked from commit 3f2c6f5598410b7233b0acd1c804a0473fa1e9fa)

2 years agoldconfig: remove a comment which is another remnant of a.out support
Konstantin Belousov [Wed, 24 Nov 2021 20:44:20 +0000 (22:44 +0200)]
ldconfig: remove a comment which is another remnant of a.out support

(cherry picked from commit 83511ce5c473406e0661247e40971be28e218684)

2 years agoktls.4: fix openssl-devel port name
Sergey A. Osokin [Fri, 12 Nov 2021 14:31:48 +0000 (09:31 -0500)]
ktls.4: fix openssl-devel port name

PR: 259630
(cherry picked from commit b39a93b18ef17dcb1897186b1f01999337b9f8b9)

2 years agoevdev: Add parentheses around '-' expression in operand of '&'.
John Baldwin [Wed, 15 Sep 2021 16:03:18 +0000 (09:03 -0700)]
evdev: Add parentheses around '-' expression in operand of '&'.

This fixes a -Wparentheses error with GCC 9.

Reviewed by: wulf
Differential Revision: https://reviews.freebsd.org/D31947

(cherry picked from commit d99c87c8d54a02a229cbeaa19ec8784b1d5afbb9)

2 years agoHyper-V: vPCI: Prepopulate device bars
Wei Hu [Sat, 27 Nov 2021 06:42:34 +0000 (06:42 +0000)]
Hyper-V: vPCI: Prepopulate device bars

In recent Hyper-V releases on Windows Server 2022, vPCI code does not
initialize the last 4 bit of device bar registers. This behavior change
could result weird problems cuasing PCI code failure when configuring
bars.

Just write all 1's to those bars whose probed values are not the same
as current read ones. This seems to make Hyper-V vPCI and
pci_write_bar() to cooperate correctly on these releases.

Reported by: khng@freebsd.org
Tested by: khng@freebsd.org
MFC after: 2 weeks
Sponsored by: Microsoft

(cherry picked from commit 75412a521f60d4b0393c730ffb284e7c6ff9d2de)

2 years agosctp: Remove now-unneeded mb_unmapped_to_ext() calls
Mark Johnston [Tue, 16 Nov 2021 18:38:09 +0000 (13:38 -0500)]
sctp: Remove now-unneeded mb_unmapped_to_ext() calls

sctp_delayed_checksum() now handles unmapped mbufs, thanks to m_apply().

No functional change intended.

Reviewed by: tuexen
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 756bb50b6a867f3309ce76d76f1842a667dd303a)

2 years agosctp: Use m_apply() to calcuate a checksum for an mbuf chain
Mark Johnston [Tue, 16 Nov 2021 18:36:30 +0000 (13:36 -0500)]
sctp: Use m_apply() to calcuate a checksum for an mbuf chain

m_apply() works on unmapped mbufs, so this will let us elide
mb_unmapped_to_ext() calls preceding sctp_calculate_cksum() calls in
the network stack.

Modify sctp_calculate_cksum() to assume it's passed an mbuf header.
This assumption appears to be true in practice, and we need to know the
full length of the chain.

No functional change intended.

Reviewed by: tuexen, jhb
Sponsored by: The FreeBSD Foundation

(cherry picked from commit b4d758a0cc54d991d2bdf7f697ec0b6b3fd6230d)

2 years agombuf: Only allow extpg mbufs if the system has a direct map
Mark Johnston [Tue, 16 Nov 2021 18:31:04 +0000 (13:31 -0500)]
mbuf: Only allow extpg mbufs if the system has a direct map

Some upcoming changes will modify software checksum routines like
in_cksum() to operate using m_apply(), which uses the direct map to
access packet data for unmapped mbufs.  This approach of course does not
work on platforms without a direct map, so we have to disallow the use
of unmapped mbufs on such platforms.

I believe this is the right tradeoff: we only configure KTLS on amd64
and arm64 today (and one KTLS consumer, NFS TLS, requires a direct map
already), and the use of unmapped mbufs with plain sendfile is a recent
optimization.  If need be, m_apply() could be modified to create
CPU-private mappings of extpg mbuf pages as a fallback.

So, change mb_use_ext_pgs to be hard-wired to zero on systems without a
direct map.  Note that PMAP_HAS_DMAP is not a compile-time constant on
some systems, so the default value of mb_use_ext_pgs has to be
determined during boot.

Reviewed by: jhb
Discussed with: gallatin
Sponsored by: The FreeBSD Foundation

(cherry picked from commit fcaa890c4469118255d463495b4044eef484fa3e)

2 years agoext2fs: check for eh_depth in ext4_ext_check_header()
Neel Chauhan [Wed, 17 Nov 2021 00:25:04 +0000 (16:25 -0800)]
ext2fs: check for eh_depth in ext4_ext_check_header()

PR: 259112
Reported by: Robert Morris <rtm@lcs.mit.edu>
Reviewed by: fsu (src)
Differential Revision: https://reviews.freebsd.org/D33030

(cherry picked from commit be60d8f276fa20fc11ad814e54c9c2540f79c7da)