]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
22 months agounbound: Update version to 1.16.2
Cy Schubert [Sat, 6 Aug 2022 08:59:22 +0000 (01:59 -0700)]
unbound: Update version to 1.16.2

Chase 790c6b245151 to update the version to 1.16.2.

Reported by: "Herbert J. Skuhra" <herbert@gojira.at>

(cherry picked from commit e34667e44941027ff7655d57c2a79cdeb52008d5)

22 months agounbound: Vendor import 1.16.2
Cy Schubert [Sat, 6 Aug 2022 01:44:40 +0000 (18:44 -0700)]
unbound: Vendor import 1.16.2

Security update to unbound.

PR:             265645
Security:       CVE-2022-30698, CVE-2022-30699
Security:       bc43a578-14ec-11ed-856e-d4c9ef517024

Merge commit '9b76d32f2310b735dbeb896cbf2776cad61f23e8' into main

(cherry picked from commit 790c6b245151d6d5a26b84e5f34fee61453e2e60)

22 months agounbound: Update version strings to 1.16.1
Cy Schubert [Sun, 17 Jul 2022 13:54:32 +0000 (06:54 -0700)]
unbound: Update version strings to 1.16.1

The last number of unbound upgrades failed to manually update the
version strings in usr.sbin/unbound/config.h. This commit fixes that.

Reported by: "Herbert J. Skuhra" <herbert@gojira.at>
Fixes: 0a92a9fca737edafbad03ee5a8efebe302851cff
a39a5a6905612447def27b66ffe73b9d11efd80c
9cf5bc93f6ba1711ae7bf96a982a2b3c8b073a18
273016e836aa378789612e0a0e08d50f28be778e
24e365220007c415f495cf8dcb228ece6002b8b7
5469a9953005a9a4d4aad7be88545d441622e9a0

(cherry picked from commit 752b6daecc88d729aa5fc66bf8938ee2fd2f092e)

22 months agounbound: Vendor import 1.16.1
Cy Schubert [Wed, 13 Jul 2022 19:30:14 +0000 (12:30 -0700)]
unbound: Vendor import 1.16.1

Merge commit 'd57351465531b38689892ec862de2725b52842dd' into unbound/main2

(cherry picked from commit 0a92a9fca737edafbad03ee5a8efebe302851cff)

22 months agobce(4): Fix two typos in kernel messages
Gordon Bergling [Sat, 6 Aug 2022 09:32:29 +0000 (11:32 +0200)]
bce(4): Fix two typos in kernel messages

- s/bufferred/buffered/

(cherry picked from commit 1ffd352bc25bb74eb4026c271dea1410e0098fb3)

22 months agoaltera/sdcard: Catch up with commit 5a96b88f05d1
Mark Johnston [Mon, 8 Aug 2022 18:20:33 +0000 (14:20 -0400)]
altera/sdcard: Catch up with commit 5a96b88f05d1

This is a direct commit to stable/13 since the driver is not present in
main.

Fixes: 5a96b88f05d1 ("kerneldump: remove physical from dump routines")

22 months agoatomic: Add some type checking to plain atomic_load/store helpers
Mark Johnston [Mon, 25 Jul 2022 21:48:46 +0000 (17:48 -0400)]
atomic: Add some type checking to plain atomic_load/store helpers

Reviewed by: rpokala, mjg, imp, kib
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 30253da1a982285b0ae6e89e22369a61cf9266eb)

22 months agoi386: fix pmap_trm_arena_last atomic load type
Mateusz Guzik [Mon, 18 Jul 2022 18:42:40 +0000 (18:42 +0000)]
i386: fix pmap_trm_arena_last atomic load type

Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit f5ad538d90673b0247b571deb38825bc6822cf20)

22 months agoasmc: Add support for MacBookPro6,2
ed crowe [Mon, 25 Jul 2022 15:35:46 +0000 (11:35 -0400)]
asmc: Add support for MacBookPro6,2

Modify asmc_sms_printintr() to be silent when the ambient light sensor
interrupt fires on this model, since the messages can otherwise fill up
the dmesg.

PR: 265005
Reviewed by: markj

(cherry picked from commit 3416f5cde7a7e01b25b5f5fd240ae8aa12fd70bf)

22 months agoiommu_gas: Eliminate redundant parameters and push down lock acquisition
Alan Cox [Fri, 29 Jul 2022 06:14:46 +0000 (01:14 -0500)]
iommu_gas: Eliminate redundant parameters and push down lock acquisition

Since IOMMU map entries store a reference to the domain in which they
reside, there is no need to pass the domain to iommu_gas_free_entry(),
iommu_gas_free_space(), and iommu_gas_free_region().

Push down the acquisition and release of the IOMMU domain lock into
iommu_gas_free_space() and iommu_gas_free_region().

Both of these changes allow for simplifications in the callers of the
functions without really complicating the functions themselves.
Moreover, the latter change eliminates the direct use of the IOMMU
domain lock from the x86-specific DMAR code.

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

(cherry picked from commit 4670f90846d49027bf23435a30895a74264f1e79)

22 months agox86/iommu: Reduce DMAR lock contention
Alan Cox [Tue, 26 Jul 2022 06:04:54 +0000 (01:04 -0500)]
x86/iommu: Reduce DMAR lock contention

Replace the DMAR unit's tlb_flush TAILQ by a custom list implementation
that enables dmar_qi_task() to dequeue entries without holding the DMAR
lock.

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

(cherry picked from commit 42736dc44dd0151546db3f2e145ae1cfd4546fe1)

22 months agox86/iommu: Correct a recent change to iommu_domain_unload_entry()
Alan Cox [Tue, 26 Jul 2022 04:53:15 +0000 (23:53 -0500)]
x86/iommu: Correct a recent change to iommu_domain_unload_entry()

Correct 8bc367384745.  When iommu_domain_unload_entry() performs a
synchronous IOTLB invalidation, it must call dmar_domain_free_entry()
to remove the entry from the domain's RB_TREE.

Push down the acquisition and release of the DMAR lock into the
recently introduced function dmar_qi_invalidate_sync_locked() and
remove the _locked suffix.

MFC with: 8bc367384745

(cherry picked from commit c251563470831c34cf53242936425a0d4d995edf)

22 months agoiommu_gas: consolidate find_space helpers
Doug Moore [Sun, 10 Jul 2022 19:24:23 +0000 (14:24 -0500)]
iommu_gas: consolidate find_space helpers

Merge lowermatch and uppermatch into find_space.  Eliminate uppermatch
recursion.  Merge match_insert into match_one and eliminate some
redundant calculation.  Move some initialization out of find_space and
into map (and out from under a lock).

Reviewed by: kib (previous version), alc
MFC after: 3 weeks
Differential Revision: https://reviews.freebsd.org/D35440

(cherry picked from commit e0e8d0c8d69459c7128e6fd4fb537892445ce710)

22 months agodev/iommu: Include offset in maxaddr check.
Doug Moore [Wed, 20 Apr 2022 22:24:11 +0000 (17:24 -0500)]
dev/iommu: Include offset in maxaddr check.

If iommu_gas_match_one has to adjust for a boundary crossing, its
check against maxaddr includes 'offset' in its calculation, to ensure
that the allocated memory does not exceed the max address. However, if
there's no boundary crossing adjustment, then the maxaddr check
disregards 'offset'. Fix that.

Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D34978

(cherry picked from commit 11fced21ccea1b80327d159a4c27046cb1f46952)

22 months agox86/iommu: Shrink the critical section in dmar_qi_task()
Alan Cox [Mon, 18 Jul 2022 00:56:39 +0000 (19:56 -0500)]
x86/iommu: Shrink the critical section in dmar_qi_task()

It is safe to test and clear the Invalidation Wait Descriptor
Complete flag before acquiring the DMAR lock in dmar_qi_task(),
rather than waiting until the lock is held.

Reviewed by: kib
MFC after: 2 weeks

(cherry picked from commit 4eaaacc75535befdb9894cca4e0d8da376328fa4)

22 months agoiommu_gas: Eliminate a possible case of use-after-free
Alan Cox [Fri, 22 Jul 2022 17:00:26 +0000 (12:00 -0500)]
iommu_gas: Eliminate a possible case of use-after-free

Eliminate a possible case of use-after-free in an error handling path
after a mapping failure.  Specifically, eliminate IOMMU_MAP_ENTRY_QI_NF
and instead perform the IOTLB invalidation synchronously.  Otherwise,
when iommu_domain_unload_entry() is called and told not to free the
IOMMU map entry, the caller could free the entry before dmar_qi_task()
is finished with it.

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

(cherry picked from commit 8bc3673847453ca51237b5c85fe57f3f02e17a4b)

22 months agoiommu: Shrink the iommu map entry structure
Alan Cox [Mon, 11 Jul 2022 03:52:52 +0000 (22:52 -0500)]
iommu: Shrink the iommu map entry structure

Eliminate the unroll_entry field from struct iommu_map_entry, shrinking
the struct by 16 bytes on 64-bit architectures.

Reviewed by: kib
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D35769

(cherry picked from commit db0110a536bf70c1ff55f3b3f46a0b5a9af46058)

22 months agox86/iommu: Eliminate redundant wrappers
Alan Cox [Sat, 16 Jul 2022 04:25:11 +0000 (23:25 -0500)]
x86/iommu: Eliminate redundant wrappers

Reviewed by: kib
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D35832

(cherry picked from commit da55f86c61462b119fd1306d12411989d6610650)

22 months agoiommu_gas: Avoid double unmapping on error
Alan Cox [Thu, 21 Jul 2022 06:53:54 +0000 (01:53 -0500)]
iommu_gas: Avoid double unmapping on error

In the extremely unlikely case that the iommu_gas_map_region() call in
bus_dma_iommu_load_ident() failed, we would attempt to unmap the failed
entry twice, first in iommu_gas_map_region(), and a second time in the
caller.  Once is enough, and twice is problematic because it leads to a
second RB_REMOVE call on the same tree node.  Like it or not, RB_TREE
does not handle that possibility.

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

(cherry picked from commit dfabdacb279ca603d008a0e7e952c5c59ac51da4)

22 months agoswap_pager: Reduce the scope of the object lock in putpages
Alan Cox [Tue, 19 Jul 2022 03:28:07 +0000 (22:28 -0500)]
swap_pager: Reduce the scope of the object lock in putpages

We don't need to hold the object lock while allocating swap space, so
don't.

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

(cherry picked from commit 54291f7d6506e6c6087433c5bbdb2224b6cef23b)

22 months ago[libm] Correct comments in s_cbrt[l].c
Steve Kargl [Thu, 4 Aug 2022 17:31:57 +0000 (19:31 +0200)]
[libm] Correct comments in s_cbrt[l].c

Damian McGuckin <damianm at esi dot com dot au> noted that the accuracy
claims in the code for cbrt(3) and cbrtl(3) were incorrect. Fix the
comments to more accurately describe the accuracies.

PR: 265603
MFC after: 3 days

(cherry picked from commit 369ea0520a3061c07400d7cd32172efb6af39815)

22 months agotools/uma/smrstress: fix kthread exit
Konstantin Belousov [Sat, 30 Jul 2022 18:54:34 +0000 (21:54 +0300)]
tools/uma/smrstress: fix kthread exit

(cherry picked from commit 4690e20eed17a6e79a67a8d10874fdc67a1c4ccf)

22 months agosqlite3: Vendor import of sqlite3 3.39.0
Cy Schubert [Thu, 7 Jul 2022 13:04:21 +0000 (06:04 -0700)]
sqlite3: Vendor import of sqlite3 3.39.0

Changes at https://www.sqlite.org/releaselog/3_39_0.html.

Obtained from https://www.sqlite.org/2022/sqlite-autoconf-3390000.tar.gz

Merge commit '2380f7c9781e64d137f0712a8fb185dee648ed8c' into new_merge

(cherry picked from commit 70b56f4b92877578741e5aba2a72d6088cb13ecb)

22 months agoif_vlan: avoid hash table thrashing when adding and removing entries
David Sips [Fri, 22 Jul 2022 17:17:04 +0000 (19:17 +0200)]
if_vlan: avoid hash table thrashing when adding and removing entries

vlan_remhash() uses incorrect value for b.

When using the default value for VLAN_DEF_HWIDTH (4), the VLAN hash-list table
expands from 16 chains to 32 chains as the 129th entry is added. trunk->hwidth
becomes 5. Say a few more entries are added and there are now 135 entries.
trunk-hwidth will still be 5. If an entry is removed, vlan_remhash() will
calculate a value of 32 for b. refcnt will be decremented to 134. The if
comparison at line 473 will return true and vlan_growhash() will be called. The
VLAN hash-list table will be compressed from 32 chains wide to 16 chains wide.
hwidth will become 4. This is an error, and it can be seen when a new VLAN is
added. The table will again be expanded. If an entry is then removed, again
the table is contracted.

If the number of VLANS stays in the range of 128-512, each time an insert
follows a remove, the table will expand. Each time a remove follows an
insert, the table will be contracted.

The fix is simple. The line 473 should test that the number of entries has
decreased such that the table should be contracted using what would be the new
value of hwidth. line 467 should be:

b = 1 << (trunk->hwidth - 1);

PR: 265382
Reviewed by: kp
MFC after: 2 weeks
Sponsored by: NetApp, Inc.

(cherry picked from commit 151abc80cde778bc18b91c334d07fbd52bbb38fb)

22 months agofind.1: Correct the markup
Gordon Bergling [Tue, 2 Aug 2022 06:33:20 +0000 (08:33 +0200)]
find.1: Correct the markup

- ASCII is an acronym and there is no ascii(8) manual page
- Reference ascii(7) in the SEE ALSO section

Reported by: karels
X-MFC with: 321dc6ee7e81

(cherry picked from commit 93b8510c3697d56630066dd61c7bbd466e617bd1)

22 months agofind.1: Fix mandoc warnings and mention a useful manpage
Gordon Bergling [Sun, 31 Jul 2022 14:38:10 +0000 (16:38 +0200)]
find.1: Fix mandoc warnings and mention a useful manpage

- new sentence, new line
- unknown AT&T UNIX version: At v7
- no blank before trailing delimiter
- reference the ASCII(8) manual page

(cherry picked from commit 321dc6ee7e81e1b06db725f218db08a8aca47d31)

22 months agoriscv: Avoid passing invalid addresses to pmap_fault()
Mark Johnston [Thu, 28 Jul 2022 13:38:52 +0000 (09:38 -0400)]
riscv: Avoid passing invalid addresses to pmap_fault()

After the addition of SV48 support, VIRT_IS_VALID() did not exclude
addresses that are in the SV39 address space hole but not in the SV48
address space hole.  This can result in mishandling of accesses to that
range when in SV39 mode.

Fix the problem by modifying VIRT_IS_VALID() to use the runtime address
space bounds.  Then, if the address is invalid, and pcb_onfault is set,
give vm_fault_trap() a chance to veto the access instead of panicking.

PR: 265439
Reviewed by: jhb
Reported and tested by: Robert Morris <rtm@lcs.mit.edu>
Fixes: 31218f3209ac ("riscv: Add support for enabling SV48 mode")
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 828ea49debe34fddf63cb648b9e57871a34158b6)

22 months agohidbus(4): Align refcount checks for hidbus_intr_start() and hidbus_intr_stop().
Hans Petter Selasky [Thu, 23 Jun 2022 13:44:25 +0000 (15:44 +0200)]
hidbus(4): Align refcount checks for hidbus_intr_start() and hidbus_intr_stop().

No functional change intended.

Discussed with: wulf @
Sponsored by: NVIDIA Networking

(cherry picked from commit c019a1690b85062729c775e2c820716edf5c37ea)

22 months agoAdd ELFCOMPRESS_ZSTD ELF compression constant
Ed Maste [Tue, 28 Jun 2022 13:06:12 +0000 (09:06 -0400)]
Add ELFCOMPRESS_ZSTD ELF compression constant

ELFCOMPRESS_ZSTD indicates that an ELF section is compressed with zstd.
It is the second compression type, after the existing ELFCOMPRESS_ZLIB.
Zstd generally provides a compelling tradeoff of speed and compression
(other algorithms may compress slightly better but take a lot longer,
or run faster but do not compress nearly as well).

See https://groups.google.com/g/generic-abi/c/satyPkuMisk for details.
ELFCOMPRESS_ZSTD will be supported in a future Clang/LLVM update.  ELF
Tool Chain tools also need updating.

Reviewed by: Fangrui Song
MFC after: 1 week
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 05b6744c446c2d274738fbb27a3ded1bf9f9f1d1)

22 months agolibc: ANSIfy div / ldiv function definitions
Ed Maste [Thu, 28 Jul 2022 14:17:33 +0000 (10:17 -0400)]
libc: ANSIfy div / ldiv function definitions

MFC after: 1 week
Sponsored by: The FreeBSD Foundation

(cherry picked from commit a8a43edc0f856167c483b554a89a868f53a6ce25)

22 months agosockets: fix setsockopt(SO_RCVTIMEO) on a listening socket
Gleb Smirnoff [Wed, 3 Aug 2022 23:28:38 +0000 (16:28 -0700)]
sockets: fix setsockopt(SO_RCVTIMEO) on a listening socket

(cherry-picked from commit c261510ef5fce9eaf4c30685c317c1f8ec415eda)

22 months agouhsoctl.1: Fix the man page date
Gordon Bergling [Sun, 31 Jul 2022 10:27:10 +0000 (12:27 +0200)]
uhsoctl.1: Fix the man page date

- STYLE: normalizing date format to: August 12, 2009

(cherry picked from commit 2bf1b9984f0786335571c697185c822d6960cf04)

22 months agouefi(8): Fix a typo in a source code comment
Gordon Bergling [Sun, 31 Jul 2022 10:14:54 +0000 (12:14 +0200)]
uefi(8): Fix a typo in a source code comment

- s/intrrupt/interrupt/

(cherry picked from commit 98b610b506781fe04e2bedccce9069db0b7a563e)

22 months agoqlnxe(4): Fix a typo in a source code comment
Gordon Bergling [Sun, 31 Jul 2022 09:35:07 +0000 (11:35 +0200)]
qlnxe(4): Fix a typo in a source code comment

- s/pedning/pending/

(cherry picked from commit 37519e3ff390ae0c648513156aef7f1fe31bf4d2)

22 months agocxgb(4): Fix a typo in a source code comment
Gordon Bergling [Sun, 31 Jul 2022 07:59:03 +0000 (09:59 +0200)]
cxgb(4): Fix a typo in a source code comment

- s/collissions/collisions/

Obtained from: NetBSD

(cherry picked from commit 6c73ba1a280b1992cdd8d30910f1f99c4b65d87a)

22 months agobluetooth(3): Fix a typo in a source code comment
Gordon Bergling [Sun, 31 Jul 2022 10:13:13 +0000 (12:13 +0200)]
bluetooth(3): Fix a typo in a source code comment

- s/intrrupt/interrupt/

(cherry picked from commit e24fd6d664091dbdf35e5fa77f276613b2e21691)

22 months agovmd: Add 8086:A77F PCI ID for all Intel Raptor Lake SKUs
Neel Chauhan [Fri, 29 Jul 2022 18:06:06 +0000 (11:06 -0700)]
vmd: Add 8086:A77F PCI ID for all Intel Raptor Lake SKUs

Summary:
This is based on the Linux kernel commit
922bfd001d1ac02111ebbe0524aaab6ca7925521.

Reviewed by: mav (src)
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D35996

(cherry picked from commit b07a48d4f3a175db53ba21a40f27ef0c1a6d0a11)

22 months agoule: unbreak UP builds
Mateusz Guzik [Sat, 16 Jul 2022 12:45:09 +0000 (12:45 +0000)]
ule: unbreak UP builds

Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 6eeba7dbd63c30704a713a2a8cdc5233600ef63b)

22 months agoSuppress possible unused variable warning for icl_soft.c
Dimitry Andric [Wed, 27 Jul 2022 19:00:22 +0000 (21:00 +0200)]
Suppress possible unused variable warning for icl_soft.c

With clang 15, the following -Werror warning is produced on i386:

    sys/dev/iscsi//icl_soft.c:1277:6: error: variable 'i' set but not used [-Werror,-Wunused-but-set-variable]
            int i;
                ^

The 'i' variable is used later in the icl_soft_conn_pdu_get_bio()
function, via the PHYS_TO_DMAP() macro. However, on i386 and some other
architectures, this macro is defined to panic immediately, so in those
cases, 'i' is indeed not used. Suppress the warning by marking 'i' as
unused.

MFC after: 3 days

(cherry picked from commit 02a226ac342f0fb622e654e461c41f4f588f4186)

22 months agoRemove unnecessary terminating slash in iscsi module Makefile
Dimitry Andric [Wed, 27 Jul 2022 19:04:22 +0000 (21:04 +0200)]
Remove unnecessary terminating slash in iscsi module Makefile

The additional slash causes double slashes in the filenames that
eventually get passed to the compiler.

MFC after: 3 days

(cherry picked from commit dfddfe29d85c5c60b30db3c9dec32e4d8270bd49)

22 months agoAdjust function definition in isa's pnp.c to avoid clang 15 warning
Dimitry Andric [Wed, 27 Jul 2022 19:02:51 +0000 (21:02 +0200)]
Adjust function definition in isa's pnp.c to avoid clang 15 warning

With clang 15, the following -Werror warning is produced:

    sys/isa/pnp.c:118:24: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    pnp_send_initiation_key()
                           ^
                            void

This is because pnp_send_initiation_key() is declared with a (void)
argument list, but defined with an empty argument list. Make the
definition match the declaration.

MFC after: 3 days

(cherry picked from commit 24e8823ef579b99b32c00a7a126a78f91727498a)

22 months agosched_ule: Ensure we hold the thread lock when modifying td_flags
Mark Johnston [Mon, 18 Jul 2022 19:50:45 +0000 (15:50 -0400)]
sched_ule: Ensure we hold the thread lock when modifying td_flags

The load balancer may force a running thread to reschedule and pick a
new CPU.  To do this it sets some flags in the thread running on a
loaded CPU.  But the code assumed that a running thread's lock is the
same as that of the corresponding runqueue, and there are small windows
where this is not true.  In this case, we can end up with non-atomic
modifications to td_flags.

Since this load balancing is best-effort, simply give up if the thread's
lock doesn't match; in this case the thread is about to enter the
scheduler anyway.

Reviewed by: kib
Reported by: glebius
Fixes: e745d729be60 ("sched_ule(4): Improve long-term load balancer.")
Sponsored by: The FreeBSD Foundation

(cherry picked from commit bd980ca847b76439bd27a4144cf0dd69d48b33af)

22 months agosched_ule: Use the correct atomic_load variant for tdq_lowpri
Mark Johnston [Thu, 14 Jul 2022 19:34:02 +0000 (15:34 -0400)]
sched_ule: Use the correct atomic_load variant for tdq_lowpri

Reported by: tuexen
Fixes: 11484ad8a2b0 ("sched_ule: Use explicit atomic accesses for tdq fields")

(cherry picked from commit 6cbc4ceb7aa0042e969be7c782436391c579cc3a)

22 months agosched_ule: Use explicit atomic accesses for tdq fields
Mark Johnston [Thu, 14 Jul 2022 14:43:53 +0000 (10:43 -0400)]
sched_ule: Use explicit atomic accesses for tdq fields

Different fields in the tdq have different synchronization protocols.
Some are constant, some are accessed only while holding the tdq lock,
some are modified with the lock held but accessed without the lock, some
are accessed only on the tdq's CPU, and some are not synchronized by the
lock at all.

Convert ULE to stop using volatile and instead use atomic_load_* and
atomic_store_* to provide the desired semantics for lockless accesses.
This makes the intent of the code more explicit, gives more freedom to
the compiler when accesses do not need to be qualified, and lets KCSAN
intercept unlocked accesses.

Thus:
- Introduce macros to provide unlocked accessors for certain fields.
- Use atomic_load/store for all accesses of tdq_cpu_idle, which is not
  synchronized by the mutex.
- Use atomic_load/store for accesses of the switch count, which is
  updated by sched_clock().
- Add some comments to fields of struct tdq describing how accesses are
  synchronized.

No functional change intended.

Reviewed by: mav, kib
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 11484ad8a2b01049b3e4f25c0fae6041c2060629)

22 months agox86: Add a required store-load barrier in cpu_idle()
Mark Johnston [Thu, 14 Jul 2022 14:24:25 +0000 (10:24 -0400)]
x86: Add a required store-load barrier in cpu_idle()

ULE's tdq_notify() tries to avoid delivering IPIs to the idle thread.
In particular, it tries to detect whether the idle thread is running.
There are two mechanisms for this:
- tdq_cpu_idle, an MI flag which is set prior to calling cpu_idle().  If
  tdq_cpu_idle == 0, then no IPI is needed;
- idle_state, an x86-specific state flag which is updated after
  cpu_idleclock() is called.

The implementation of the second mechanism is racy; the race can cause a
CPU to go to sleep with pending work.  Specifically, cpu_idle_*() set
idle_state = STATE_SLEEPING, then check for pending work by loading the
tdq_load field of the CPU's runqueue.  These operations can be reordered
so that the idle thread observes tdq_load == 0, and tdq_notify()
observes idle_state == STATE_RUNNING.

Some counters indicate that the idle_state check in tdq_notify()
frequently elides an IPI.  So, fix the problem by inserting a fence
after the store to idle_state, immediately before idling the CPU.

PR: 264867
Reviewed by: mav, kib, jhb
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 03f868b163ad46d6f7cb03dc46fb83ca01fb8f69)

22 months agosched_ule: Enable preemption of curthread in the load balancer
Mark Johnston [Thu, 14 Jul 2022 14:23:43 +0000 (10:23 -0400)]
sched_ule: Enable preemption of curthread in the load balancer

The load balancer executes from statclock and periodically tries to move
threads among CPUs in order to balance load.  It may move a thread to
the current CPU (the loader balancer always runs on CPU 0).  When it
does so, it may need to schedule preemption of the interrupted thread.
Use sched_setpreempt() to do so, same as sched_add().

PR: 264867
Reviewed by: mav, kib, jhb
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 0927ff78147b4d00a75054bbad299946208e1e91)

22 months agosched_ule: Fix racy loads of pc_curthread
Mark Johnston [Thu, 14 Jul 2022 14:21:28 +0000 (10:21 -0400)]
sched_ule: Fix racy loads of pc_curthread

Thread switching used to be atomic with respect to the current CPU's
tdq lock.  Since commit 686bcb5c14ab that is no longer the case.  Now
sched_switch() does this:

1.  lock tdq (might already be locked)
2.  maybe put the current thread in the tdq, choose a new thread to run
2a. update tdq_lowpri
3.  unlock tdq
4.  switch CPU context, update curthread

Some code paths in ULE will load pc_curthread from a remote CPU with
that CPU's tdq lock held, usually to inspect its priority.  But, as of
the aforementioned commit this is racy.

The problem I noticed is in tdq_notify(), which optionally sends an IPI
to a remote CPU when a new thread is added to its runqueue.  If the new
thread's priority is higher (lower) than the currently running thread's
priority, then we deliver an IPI.  But inspecting
pc_curthread->td_priority doesn't work, since pc_curthread might be
between steps 3 and 4 above.  If pc_curthread's priority is higher than
that of the newly added thread, but pc_curthread is switching to a
lower-priority thread, then tdq_notify() might fail to deliever an IPI,
leaving a high priority thread stuck on the runqueue for longer than it
should.  This can cause multi-millisecond stalls in
interactive/ithread/realtime threads.

Fix this problem by modifying tdq_add() and tdq_move() to return the
value of tdq_lowpri before the addition of the new thread.  This ensures
that tdq_notify() has the correct priority value to compare against.

The other two uses of pc_curthread are susceptible to the same race.  To
fix the one in sched_rem()->tdq_setlowpri() we need to have an exact
value for curthread.  Thus, introduce a new tdq_curthread field to the
tdq which gets updated any time a new thread is selected to run on the
CPU.  Because this field is synchronized by the thread lock, its
priority reflects the correct lowpri value for the tdq.

PR: 264867
Fixes: 686bcb5c14ab ("schedlock 4/4")
Reviewed by: mav, kib, jhb
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 6d3f74a14a83b867c273c6be2599da182a9b9ec7)

22 months agoloader: fix powerpc64le ofw loader
Alfredo Dal'Ava Junior [Fri, 29 Jul 2022 08:03:30 +0000 (05:03 -0300)]
loader: fix powerpc64le ofw loader

This is similar to 5d48fb3b16c1496bf415fee620c61cc944b0326d.
With LLVM14 the .data.rel.ro ELF section appears after .data,
making loader behave erractly and kernel is not loaded.
This patch makes ensures the correct order.

Based on discussion at:
            https://github.com/llvm/llvm-project/issues/56306

MFC after: 1 day
Sponsored by: Instituto de Pesquisas Eldorado (eldorado.org.br)

(cherry picked from commit 0df5a06864b351ac44a87246acc473e446da1163)

22 months agorb_tree: fine-tune rebalancing code
Doug Moore [Mon, 4 Jul 2022 17:28:35 +0000 (12:28 -0500)]
rb_tree: fine-tune rebalancing code

Change parts of RB_INSERT_COLOR and RB_REMOVE_COLOR to reduce the
number of operations, by, in some cases, flipping two color bits at a
time instead of flipping each individually, in separate operations,
and by using a switch statement to replace a sequence of if-elses.
Rewrite RB_SET_PARENT to generate fewer instructions.  These changes
reduce the code size by over 100 bytes on some architectures.

Also, allow RB users to define a preprocessor symbol to generate
RB_REMOVE_COLOR code that matches the implementation described in the
original weak-AVL paper in one particular case, instead of the still
correct, but slightly more efficient implementation of that case
currently implemented.

Reviewed by: alc
MFC after: 3 weeks
Differential Revision: https://reviews.freebsd.org/D35524

(cherry picked from commit 2120d7f57aa0ee48d0be7a4309072bb332d568dd)

22 months agorb_tree: optimize tree rotation
Doug Moore [Sat, 25 Jun 2022 07:40:16 +0000 (02:40 -0500)]
rb_tree: optimize tree rotation

The RB_ROTATE macros begin with fetching a field via a pointer. In
most cases, that value is one that has already been pulled into a
register, and the compiler cannot infer that. So, to eliminate those
needless fetches, have the caller of the RB_ROTATE macros present the
data in the third macro parameter, rather than having the macro fetch
it.

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

(cherry picked from commit 61c74fb66f1bef776923cbd5b2a62fb06b003f0c)

22 months agorb_tree: silence coverity
Doug Moore [Thu, 30 Jun 2022 17:27:33 +0000 (12:27 -0500)]
rb_tree: silence coverity

Add comments to RB_INSERT_COLOR to silence coverity warnings about the
use of an uninitialized variable.  Since other static analyzers will
complain too, add a comment to explain why the complaints are unwarranted.

Reviewed by: markj
MFC after: 3 weeks
Differential Revision: https://reviews.freebsd.org/D35671

(cherry picked from commit 91b30f7ad22642979b56a56b211843cbd9d35984)

22 months agoAdjust function definitions in xen's control.c to avoid clang 15 warnings
Dimitry Andric [Tue, 26 Jul 2022 12:11:09 +0000 (14:11 +0200)]
Adjust function definitions in xen's control.c to avoid clang 15 warnings

With clang 15, the following -Werror warnings are produced:

    sys/dev/xen/control/control.c:188:15: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    xctrl_poweroff()
                  ^
                   void
    sys/dev/xen/control/control.c:194:13: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    xctrl_reboot()
                ^
                 void
    sys/dev/xen/control/control.c:207:14: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    xctrl_suspend()
                 ^
                  void
    sys/dev/xen/control/control.c:344:12: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    xctrl_crash()
               ^
                void

This is because xctrl_poweroff(), xctrl_reboot(), xctrl_suspend(), and
xctrl_crash() are declared with (void) argument lists, but defined with
empty argument lists. Make the definitions match the declarations.

MFC after: 3 days

(cherry picked from commit a6c803048fd8d4209fb1d52cd3c455a6752109b7)

22 months agoFix unused variable warning in xen's blkfront.c
Dimitry Andric [Tue, 26 Jul 2022 12:01:26 +0000 (14:01 +0200)]
Fix unused variable warning in xen's blkfront.c

With clang 15, the following -Werror warning is produced:

    sys/dev/xen/blkfront/blkfront.c:602:6: error: variable 'sbp' set but not used [-Werror,-Wunused-but-set-variable]
            int sbp;
                ^

The 'sbp' variable was used in the for loop later in the xb_dump()
function, but refactoring in e4808c4b2dba got rid of it. Remove the
variable since it no longer serves any purpose.

MFC after:      3 days

(cherry picked from commit e635220e1a330560ee547069054d81c4cf0b7839)

22 months agoAdjust function definition in geom_subr.c to avoid clang 15 warnings
Dimitry Andric [Tue, 26 Jul 2022 14:01:04 +0000 (16:01 +0200)]
Adjust function definition in geom_subr.c to avoid clang 15 warnings

With clang 15, the following -Werror warning is produced:

    sys/geom/geom_subr.c:484:16: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    g_wither_washer()
                   ^
                    void

This is because g_wither_washer() is declared with a (void) argument
list, but defined with an empty argument list. Make the definition match
the declaration.

MFC after: 3 days

(cherry picked from commit bfa9298765167bde0eacc538cc5a5bae4cdd7ed3)

22 months agoAdjust check_struct_sizes() definition to avoid clang 15 warning
Dimitry Andric [Tue, 26 Jul 2022 11:20:58 +0000 (13:20 +0200)]
Adjust check_struct_sizes() definition to avoid clang 15 warning

With clang 15, the following -Werror warning is produced:

    sys/dev/smartpqi/smartpqi_helper.c:374:19: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    check_struct_sizes()
                      ^
                       void

This is because check_struct_sizes() is declared with a (void) argument
list, but defined with an empty argument list. Make the definition match
the declaration.

MFC after: 3 days

(cherry picked from commit fb1c21688c5702d0bc50d67359dee4af12d0c693)

22 months agoFix unused variable warning in netipsec's key_debug.c
Dimitry Andric [Tue, 26 Jul 2022 19:21:44 +0000 (21:21 +0200)]
Fix unused variable warning in netipsec's key_debug.c

With clang 15, the following -Werror warning is produced:

    sys/netipsec/key_debug.c:923:9: error: variable 'j' set but not used [-Werror,-Wunused-but-set-variable]
            int i, j;
                   ^

The 'j' variable was in key_debug.c when it was first added, but it
appears to have been a debugging aid that has never been used, so remove
it.

MFC after: 3 days

(cherry picked from commit c01fdd7a9f316c8c04786441ca0113be002b96be)

22 months agoAdjust function definitions in netipsec's key.c to avoid clang 15 warnings
Dimitry Andric [Tue, 26 Jul 2022 19:15:37 +0000 (21:15 +0200)]
Adjust function definitions in netipsec's key.c to avoid clang 15 warnings

With clang 15, the following -Werror warnings are produced:

    sys/netipsec/key.c:6432:15: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    key_getcomb_ah()
                  ^
                   void
    sys/netipsec/key.c:6489:19: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    key_getcomb_ipcomp()
                      ^
                       void

This is because key_getcomb_ah() and key_getcomb_ipcomp() are declared
with (void) argument lists, but defined with empty argument lists. Make
the definitions match the declarations.

MFC after: 3 days

(cherry picked from commit 8bd2887be5105010e73fc35ddd25021e186811b8)

22 months agoFix unused variable warning in usb's atp.c
Dimitry Andric [Tue, 26 Jul 2022 19:46:02 +0000 (21:46 +0200)]
Fix unused variable warning in usb's atp.c

With clang 15, the following -Werror warning is produced:

    sys/dev/usb/input/atp.c:2018:11: error: variable 'n_vertical_scrolls' set but not used [-Werror,-Wunused-but-set-variable]
            u_int8_t n_vertical_scrolls = 0;
                     ^

The 'n_vertical_scrolls' variable is no longer used after 197b9a2ef003,
so remove it.

MFC after: 3 days

(cherry picked from commit b621f3cf2d2c30880c49afe37598e0f550afb181)

22 months agoatp: Remove unused variable.
John Baldwin [Fri, 8 Apr 2022 00:01:29 +0000 (17:01 -0700)]
atp: Remove unused variable.

(cherry picked from commit 197b9a2ef0037e02721fec27a707e34a4d06d2c6)

22 months agoAdjust function definition in geom_io.c to avoid clang 15 warnings
Dimitry Andric [Tue, 26 Jul 2022 14:00:08 +0000 (16:00 +0200)]
Adjust function definition in geom_io.c to avoid clang 15 warnings

With clang 15, the following -Werror warning is produced:

    sys/geom/geom_io.c:272:10: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    g_io_init()
             ^
              void

This is because g_io_init() is declared with a (void) argument list, but
defined with an empty argument list. Make the definition match the
declaration.

MFC after: 3 days

(cherry picked from commit 165a32121cc775719b55dc0f8b66259b0fbf8325)

22 months agoAdjust function definitions in ufs_dirhash.c to avoid clang 15 warnings
Dimitry Andric [Tue, 26 Jul 2022 19:32:20 +0000 (21:32 +0200)]
Adjust function definitions in ufs_dirhash.c to avoid clang 15 warnings

With clang 15, the following -Werror warnings are produced:

    sys/ufs/ufs/ufs_dirhash.c:1303:16: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    ufsdirhash_init()
                   ^
                    void
    sys/ufs/ufs/ufs_dirhash.c:1319:18: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    ufsdirhash_uninit()
                     ^
                      void

This is because ufsdirhash_init() and ufsdirhash_uninit() are declared
with (void) argument lists, but defined with empty argument lists. Make
the definitions match the declarations.

MFC after: 3 days

(cherry picked from commit ed1d5f95a599635e2af4a78ce96bfcdf8a3b7a47)

22 months agoFix unused variable warning in sfxge's ef10_tx.c
Dimitry Andric [Tue, 26 Jul 2022 13:17:05 +0000 (15:17 +0200)]
Fix unused variable warning in sfxge's ef10_tx.c

With clang 15, the following -Werror warning is produced:

    sys/dev/sfxge/common/ef10_tx.c:345:15: error: variable 'eqp' set but not used [-Werror,-Wunused-but-set-variable]
            efx_qword_t *eqp;
                         ^

The 'eqp' variable is passed as an argument to the EFSYS_BAR_WC_WRITEQ()
macro, but currently this macro ignores the argument, similar to its
other _esbp argument. Silence the warning by casting the _eqp argument
to void in the macro.

MFC after: 3 days

(cherry picked from commit a79731b9453320af6fcf5ec16fa5de900dadbce8)

22 months agoAdjust function definition in nhop_ctl.c to avoid clang 15 warnings
Dimitry Andric [Tue, 26 Jul 2022 18:26:46 +0000 (20:26 +0200)]
Adjust function definition in nhop_ctl.c to avoid clang 15 warnings

With clang 15, the following -Werror warning is produced:

    sys/net/route/nhop_ctl.c:508:21: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    alloc_nhop_structure()
                        ^
                         void

This is alloc_nhop_structure() is declared with a (void) argument list,
but defined with an empty argument list. Make the definition match the
declaration.

MFC after: 3 days

(cherry picked from commit a8adf13a637d8c5af742220e6dac0561c6449126)

22 months agoAdjust function definitions in kern_cons.c to avoid clang 15 warnings
Dimitry Andric [Tue, 26 Jul 2022 14:03:35 +0000 (16:03 +0200)]
Adjust function definitions in kern_cons.c to avoid clang 15 warnings

With clang 15, the following -Werror warnings are produced:

    sys/kern/kern_cons.c:201:14: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    cninit_finish()
                 ^
                  void
    sys/kern/kern_cons.c:376:7: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    cngrab()
          ^
           void
    sys/kern/kern_cons.c:389:9: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    cnungrab()
            ^
             void
    sys/kern/kern_cons.c:402:9: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    cnresume()
            ^
             void

This is because cninit_finish(), cngrab(), cnungrab(), and cnresume()
are declared with (void) argument lists, but defined with empty argument
lists. Make the definitions match the declarations.

MFC after: 3 days

(cherry picked from commit 9806e82a23924f32dc5976bc8687fbbe293a140b)

22 months agoFix unused variable warning in amd64's pmap.c
Dimitry Andric [Tue, 26 Jul 2022 19:53:08 +0000 (21:53 +0200)]
Fix unused variable warning in amd64's pmap.c

With clang 15, the following -Werror warning is produced:

    sys/amd64/amd64/pmap.c:8274:22: error: variable 'freed' set but not used [-Werror,-Wunused-but-set-variable]
            int allfree, field, freed, i, idx;
                                ^

The 'freed' variable is only used when PV_STATS is defined. Ensure it is
only declared and set in that case.

MFC after: 3 days

(cherry picked from commit 7a1f289bd2949e5867c7f0396c35f02f179dc8bd)

22 months agoAdjust playinit() definition to avoid clang 15 warning
Dimitry Andric [Tue, 26 Jul 2022 11:43:46 +0000 (13:43 +0200)]
Adjust playinit() definition to avoid clang 15 warning

With clang 15, the following -Werror warning is produced:

    sys/dev/speaker/spkr.c:182:9: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    playinit()
            ^
             void

This is because playinit() is declared with a (void) argument list, but
defined with an empty argument list. Make the definition match the
declaration.

MFC after: 3 days

(cherry picked from commit 57c46916e145581807333bc06a08e9532721bd8f)

22 months agoFix unused variable warning in ffs_snapshot.c
Dimitry Andric [Tue, 26 Jul 2022 19:30:41 +0000 (21:30 +0200)]
Fix unused variable warning in ffs_snapshot.c

With clang 15, the following -Werror warning is produced:

    sys/ufs/ffs/ffs_snapshot.c:204:7: error: variable 'redo' set but not used [-Werror,-Wunused-but-set-variable]
            long redo = 0, snaplistsize = 0;
                 ^

The 'redo' variable is only used when DIAGNOSTIC is defined. Ensure it
is only declared and set in that case.

MFC after: 3 days

(cherry picked from commit c9dde6f0c713a027266c52cf94a33a086348c566)

22 months agoSuppress -Wstrict-prototypes for several zlib files
Dimitry Andric [Tue, 26 Jul 2022 18:24:58 +0000 (20:24 +0200)]
Suppress -Wstrict-prototypes for several zlib files

Clang 15 is more strict about function definitions not matching
declarations, and zlib has a lot of these, but since it is contributed
code (and in K&R style to boot), suppress those warnings instead.

MFC after: 3 days

(cherry picked from commit e83ffec3af2e71cc64348d58481c87db9efbac92)

22 months agoAdjust function definition in ufs_dirhash.c to avoid clang 15 warnings
Dimitry Andric [Tue, 26 Jul 2022 19:22:58 +0000 (21:22 +0200)]
Adjust function definition in ufs_dirhash.c to avoid clang 15 warnings

With clang 15, the following -Werror warning is produced:

    sys/ufs/ufs/ufs_dirhash.c:1252:18: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    ufsdirhash_lowmem()
                     ^
                      void

This is ufsdirhash_lowmem() is declared with a (void) argument list, but
defined with an empty argument list. Make the definition match the
declaration.

MFC after: 3 days

(cherry picked from commit 08c16dd4bf6ee5649a86fa472104f89b3fbfe71a)

22 months agoAdjust function definitions in route_ctl.c to avoid clang 15 warnings
Dimitry Andric [Tue, 26 Jul 2022 18:28:25 +0000 (20:28 +0200)]
Adjust function definitions in route_ctl.c to avoid clang 15 warnings

With clang 15, the following -Werror warnings are produced:

    sys/net/route/route_ctl.c:130:17: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    vnet_rtzone_init()
                    ^
                     void
    sys/net/route/route_ctl.c:139:20: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    vnet_rtzone_destroy()
                       ^
                        void

This is because vnet_rtzone_init() and vnet_rtzone_destroy() are
declared with (void) argument lists, but defined with empty argument
lists. Make the definitions match the declarations.

MFC after: 3 days

(cherry picked from commit 5e1097f83cbe353839888c0aad8e31bb62b8e9a4)

22 months agoSuppress unused variable warning for zfs_fm.c
Dimitry Andric [Tue, 26 Jul 2022 20:07:42 +0000 (22:07 +0200)]
Suppress unused variable warning for zfs_fm.c

With clang 15, the following -Werror warning is produced:

    sys/contrib/openzfs/module/zfs/zfs_fm.c:256:6: error: variable 'cnt' set but not used [-Werror,-Wunused-but-set-variable]
            int cnt = 0;
                ^

The 'cnt' variable does not seem to be used for anything, but since this
is contributed code, suppress the warning instead.

MFC after: 3 days

(cherry picked from commit e726e7105685f99b066fcc3908c07157599cd290)

22 months agoFix unused variable warning in ieee80211_proto.c
Dimitry Andric [Tue, 26 Jul 2022 19:05:36 +0000 (21:05 +0200)]
Fix unused variable warning in ieee80211_proto.c

With clang 15, the following -Werror warning is produced:

    sys/net80211/ieee80211_proto.c:1070:34: error: variable 'num_mixed' set but not used [-Werror,-Wunused-but-set-variable]
            int num_vaps = 0, num_pure = 0, num_mixed = 0;
                                            ^

The 'num_mixed' variable was in ieee80211_proto.c when the function
vap_update_ht_protmode() was added, but it was never used for anything,
so remove it.

MFC after: 3 days

(cherry picked from commit 9319211f96c6f11959c76f1d565a744ab37b0031)

22 months agoAdjust function definition in subr_autoconf.c to avoid clang 15 warnings
Dimitry Andric [Tue, 26 Jul 2022 15:27:54 +0000 (17:27 +0200)]
Adjust function definition in subr_autoconf.c to avoid clang 15 warnings

With clang 15, the following -Werror warning is produced:

    sys/kern/subr_autoconf.c:119:34: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    run_interrupt_driven_config_hooks()
                                     ^
                                      void

This is because run_interrupt_driven_config_hooks() is declared with a
(void) argument list, but defined with an empty argument list. Make the
definition match the declaration.

MFC after: 3 days

(cherry picked from commit 3c8f0790dd038ce646f140b7aad23b4e698c0522)

22 months agoAdjust function definitions in sysv_msg.c to avoid clang 15 warnings
Dimitry Andric [Tue, 26 Jul 2022 17:46:15 +0000 (19:46 +0200)]
Adjust function definitions in sysv_msg.c to avoid clang 15 warnings

With clang 15, the following -Werror warnings are produced:

    sys/kern/sysv_msg.c:213:8: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    msginit()
           ^
            void
    sys/kern/sysv_msg.c:316:10: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    msgunload()
             ^
              void

This is because msginit() and msgunload() are declared with (void)
argument lists, but defined with empty argument lists. Make the
definitions match the declarations.

MFC after: 3 days

(cherry picked from commit 78cfed2de70d023acb452c06dbd1ffd8341f4608)

22 months agoAdjust function definition in vfs_bio.c to avoid clang 15 warnings
Dimitry Andric [Tue, 26 Jul 2022 17:48:20 +0000 (19:48 +0200)]
Adjust function definition in vfs_bio.c to avoid clang 15 warnings

With clang 15, the following -Werror warning is produced:

    sys/kern/vfs_bio.c:3430:11: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    buf_daemon()
              ^
               void

This is because buf_daemon() is declared with a (void) argument list,
but defined with an empty argument list. Make the definition match the
declaration.

MFC after: 3 days

(cherry picked from commit a387bd1b6a0e18d7abafcbb5ae1870be0604ff15)

22 months agoAdjust function definition in nd6.c to avoid clang 15 warnings
Dimitry Andric [Tue, 26 Jul 2022 19:10:58 +0000 (21:10 +0200)]
Adjust function definition in nd6.c to avoid clang 15 warnings

With clang 15, the following -Werror warning is produced:

    sys/netinet6/nd6.c:247:12: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    nd6_destroy()
               ^
                void

This is nd6_destroy() is declared with a (void) argument list, but
defined with an empty argument list. Make the definition match the
declaration.

MFC after: 3 days

(cherry picked from commit 50207b2de9a53491c2b5ee9b96689333f5c46de5)

22 months agoAdjust function definitions in kern_resource.c to avoid clang 15 warnings
Dimitry Andric [Tue, 26 Jul 2022 14:14:50 +0000 (16:14 +0200)]
Adjust function definitions in kern_resource.c to avoid clang 15 warnings

With clang 15, the following -Werror warnings are produced:

    sys/kern/kern_resource.c:1212:10: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    lim_alloc()
             ^
              void
    sys/kern/kern_resource.c:1365:11: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    uihashinit()
              ^
               void

This is because lim_alloc() and uihashinit() are declared with (void)
argument lists, but defined with empty argument lists. Make the
definitions match the declarations.

MFC after: 3 days

(cherry picked from commit f2eb09b089bcdf546ed3fd4c2c59d9df02c585d8)

22 months agoAdjust function definition in acpi_timer.c to avoid clang 15 warnings
Dimitry Andric [Tue, 26 Jul 2022 19:35:07 +0000 (21:35 +0200)]
Adjust function definition in acpi_timer.c to avoid clang 15 warnings

With clang 15, the following -Werror warning is produced:

    sys/dev/acpica/acpi_timer.c:402:16: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    acpi_timer_test()
                   ^
                    void

This is because acpi_timer_test() is declared with a (void) argument
list, but defined with an empty argument list. Make the definition match
the declaration.

MFC after: 3 days

(cherry picked from commit c45bc02560b0f632f8e085679512a588bfcb3384)

22 months agoFix unused variable warning in xen's blkback.c
Dimitry Andric [Tue, 26 Jul 2022 12:02:36 +0000 (14:02 +0200)]
Fix unused variable warning in xen's blkback.c

With clang 15, the following -Werror warning is produced:

    sys/dev/xen/blkback/blkback.c:1561:12: error: variable 'req_seg_idx' set but not used [-Werror,-Wunused-but-set-variable]
                    u_int                    req_seg_idx;
                                             ^

The 'req_seg_idx' variable was used in the for loop later in the
xbb_dispatch_io() function, but refactoring in 112cacaee408 got rid of
it. Remove the variable since it no longer serves any purpose.

MFC after: 3 days

(cherry picked from commit 39e12a7591bf2ed4b2fae48e19f3af3a3cdcb196)

22 months agoAdjust sctp_drain() definition to avoid clang 15 warning
Dimitry Andric [Tue, 26 Jul 2022 11:19:39 +0000 (13:19 +0200)]
Adjust sctp_drain() definition to avoid clang 15 warning

With clang 15, the following -Werror warning is produced:

    sys/netinet/sctp_pcb.c:6946:11: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    sctp_drain()
              ^
               void

This is because sctp_drain() is declared with a (void) argument list,
but defined with an empty argument list. Make the definition match the
declaration.

MFC after: 3 days

(cherry picked from commit 24e13a49faabb22ece97dc8e4718caf8f6bad84c)

22 months agoAdjust function definitions in geom_event.c to avoid clang 15 warnings
Dimitry Andric [Tue, 26 Jul 2022 13:58:31 +0000 (15:58 +0200)]
Adjust function definitions in geom_event.c to avoid clang 15 warnings

With clang 15, the following -Werror warnings are produced:

    sys/geom/geom_event.c:261:13: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    g_run_events()
                ^
                 void
    sys/geom/geom_event.c:405:12: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    g_do_wither()
               ^
                void
    sys/geom/geom_event.c:449:13: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    g_event_init()
                ^
                 void

This is because g_run_events(), g_do_wither(), and g_event_init() are
declared with (void) argument lists, but defined with empty argument
lists. Make the definitions match the declarations.

MFC after: 3 days

(cherry picked from commit ac3153434fcc3ddcbb47c7f397a1bc34fd0e0dcb)

22 months agoAdjust function definitions in kern_dtrace.c to avoid clang 15 warnings
Dimitry Andric [Tue, 26 Jul 2022 14:11:05 +0000 (16:11 +0200)]
Adjust function definitions in kern_dtrace.c to avoid clang 15 warnings

With clang 15, the following -Werror warnings are produced:

    sys/kern/kern_dtrace.c:64:18: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    kdtrace_proc_size()
                     ^
                      void
    sys/kern/kern_dtrace.c:87:20: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    kdtrace_thread_size()
                       ^
                        void

This is because kdtrace_proc_size() and kdtrace_thread_size() are
declared with (void) argument lists, but defined with empty argument
lists. Make the definitions match the declarations.

MFC after: 3 days

(cherry picked from commit db8ea61ae261cc060f423dea050bf943bcad6793)

22 months agoAdjust ng_{name,ID}_rehash() definitions to avoid clang 15 warnings
Dimitry Andric [Mon, 25 Jul 2022 11:04:29 +0000 (13:04 +0200)]
Adjust ng_{name,ID}_rehash() definitions to avoid clang 15 warnings

With clang 15, the following -Werror warnings are produced:

    sys/netgraph/ng_base.c:981:15: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    ng_name_rehash()
                  ^
                   void
    sys/netgraph/ng_base.c:1012:13: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    ng_ID_rehash()
                ^
                 void

This is because ng_name_rehash() and ng_ID_rehash() are declared with
(void) argument lists, but defined with empty argument lists. Make the
definitions match the declarations.

MFC after: 3 days

(cherry picked from commit dba7f4aa0909d8c31a0ca0ad0d1208fabfaa9352)

22 months agoAdjust sctp_init_sysctls() definition to avoid clang 15 warning
Dimitry Andric [Mon, 25 Jul 2022 20:07:49 +0000 (22:07 +0200)]
Adjust sctp_init_sysctls() definition to avoid clang 15 warning

With clang 15, the following -Werror warning is produced:

    sys/netinet/sctp_sysctl.c:55:18: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    sctp_init_sysctls()
                     ^
                      void

This is because sctp_init_sysctls() is declared with a (void) argument
list, but defined with an empty argument list. Make the definition match
the declaration.

MFC after: 3 days

(cherry picked from commit 205798564926589ed621b88d1853429d00de6de0)

22 months agoAdjust function definitions in if_pfsync.c to avoid clang 15 warnings
Dimitry Andric [Mon, 25 Jul 2022 18:53:32 +0000 (20:53 +0200)]
Adjust function definitions in if_pfsync.c to avoid clang 15 warnings

With clang 15, the following -Werror warnings are produced:

    sys/netpfil/pf/if_pfsync.c:2439:21: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    pfsync_pointers_init()
                        ^
                         void
    sys/netpfil/pf/if_pfsync.c:2453:23: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    pfsync_pointers_uninit()
                          ^
                           void
    sys/netpfil/pf/if_pfsync.c:2503:12: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    pfsync_init()
               ^
                void
    sys/netpfil/pf/if_pfsync.c:2524:14: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    pfsync_uninit()
                 ^
                  void

This is because pfsync_pointers_init(), pfsync_pointers_uninit(),
pfsync_init(), and pfsync_uninit() are declared with (void) argument
lists, but defined with empty argument lists. Make the definitions match
the declarations.

MFC after: 3 days

(cherry picked from commit 766f3c8032a95f344823bea70bb7f794f9939d33)

22 months agoFix unused variable warnings in sctp_indata.c
Dimitry Andric [Mon, 25 Jul 2022 19:15:52 +0000 (21:15 +0200)]
Fix unused variable warnings in sctp_indata.c

With clang 15, the following -Werror warnings are produced:

    sys/netinet/sctp_indata.c:3309:6: error: variable 'tot_retrans' set but not used [-Werror,-Wunused-but-set-variable]
            int tot_retrans = 0;
                ^
    sys/netinet/sctp_indata.c:3842:20: error: variable 'resend' set but not used [-Werror,-Wunused-but-set-variable]
            int inflight = 0, resend = 0, inbetween = 0, acked = 0, above = 0;
                              ^
    sys/netinet/sctp_indata.c:3842:47: error: variable 'acked' set but not used [-Werror,-Wunused-but-set-variable]
            int inflight = 0, resend = 0, inbetween = 0, acked = 0, above = 0;
                                                         ^
    sys/netinet/sctp_indata.c:3842:58: error: variable 'above' set but not used [-Werror,-Wunused-but-set-variable]
            int inflight = 0, resend = 0, inbetween = 0, acked = 0, above = 0;
                                                                    ^

The 'tot_retrans' variable was used in sctp_strike_gap_ack_chunks(), but
refactoring in 493d8e5a830e got rid of it. Remove the variable since it
no longer serves any purpose.

The 'resend', 'acked', and 'above' variables are only used when
INVARIANTS is undefined. Ensure they are only declared and set in that
case.

MFC after: 3 days

(cherry picked from commit 05b3a4282c408f495add570bbca12242dd006279)

22 months agoFix unused variable warning in sctp_output.c
Dimitry Andric [Mon, 25 Jul 2022 19:50:40 +0000 (21:50 +0200)]
Fix unused variable warning in sctp_output.c

With clang 15, the following -Werror warning is produced:

    sys/netinet/sctp_output.c:9367:33: error: variable 'cnt_thru' set but not used [-Werror,-Wunused-but-set-variable]
            int no_fragmentflg, bundle_at, cnt_thru;
                                           ^

The 'cnt_thru' variable was in sctp_output.c when it was first added,
but appears to have been a debugging aid that has never been used, so
remove it.

MFC after: 3 days

(cherry picked from commit 9057feddc4b05d2b2b29e4db274c28af3d574d76)

22 months agoAdjust function definitions in pf.c to avoid clang 15 warnings
Dimitry Andric [Mon, 25 Jul 2022 17:59:59 +0000 (19:59 +0200)]
Adjust function definitions in pf.c to avoid clang 15 warnings

With clang 15, the following -Werror warnings are produced:

    sys/netpfil/pf/pf.c:985:19: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    pf_mtag_initialize()
                      ^
                       void
    sys/netpfil/pf/pf.c:995:14: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    pf_initialize()
                 ^
                  void
    sys/netpfil/pf/pf.c:1089:16: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    pf_mtag_cleanup()
                   ^
                    void
    sys/netpfil/pf/pf.c:1096:11: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    pf_cleanup()
              ^
               void
    sys/netpfil/pf/pf.c:1989:27: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    pf_purge_expired_src_nodes()
                              ^
                               void
    sys/netpfil/pf/pf.c:2174:24: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    pf_purge_unlinked_rules()
                           ^
                            void

This is because pf_mtag_initialize(), pf_initialize(),
pf_mtag_cleanup(), pf_cleanup(), pf_purge_expired_src_nodes(), and
pf_purge_unlinked_rules() are declared with (void) argument lists, but
defined with empty argument lists. Make the definitions match the
declarations.

MFC after: 3 days

(cherry picked from commit 503b5870c018ec342be1396896560b720945d7e5)

22 months agoFix unused variable warning in if_pfsync.c
Dimitry Andric [Mon, 25 Jul 2022 18:15:51 +0000 (20:15 +0200)]
Fix unused variable warning in if_pfsync.c

With clang 15, the following -Werror warning is produced:

    sys/netpfil/pf/if_pfsync.c:2153:9: error: variable 'sent' set but not used [-Werror,-Wunused-but-set-variable]
            int i, sent = 0;
                   ^

The 'sent' variable was used in the for loop later in the
pfsync_bulk_update() function, but refactoring in 4fc65bcbe3fb7 got rid
of it. Remove the variable since it no longer serves any purpose.

MFC after: 3 days

(cherry picked from commit fb48e998501f8d1defecffb772121a4141cdc2b6)

22 months agoFix unused variable warning in sctp_timer.c
Dimitry Andric [Mon, 25 Jul 2022 20:06:28 +0000 (22:06 +0200)]
Fix unused variable warning in sctp_timer.c

With clang 15, the following -Werror warning is produced:

    sys/netinet/sctp_timer.c:510:6: error: variable 'recovery_cnt' set but not used [-Werror,-Wunused-but-set-variable]
            int recovery_cnt = 0;
                ^

The 'recovery_cnt' variable is only used when INVARIANTS is undefined.
Ensure it is only declared and set in that case.

MFC after: 3 days

(cherry picked from commit 5bfd8cf3691381c19296d76d7944d6c1df5f4a75)

22 months agoftpd(8): do not refer to now unused libxo(3)
Eugene Grosbein [Fri, 10 Jun 2022 14:03:07 +0000 (21:03 +0700)]
ftpd(8): do not refer to now unused libxo(3)

In 2018, the commit r328100 (0fdf7fa846b1a1b1679e86812a1b08b8cb623604)
removed libxo(3) support from ls(1), so ftpd has no reasons to link
with libxo since then.

(cherry picked from commit 796d48ec416863ab2826a1205365710635244023)

22 months agoifconfig.8: cleanup reminiscence about long gone ppp(4)
Eugene Grosbein [Mon, 11 Jul 2022 04:53:54 +0000 (11:53 +0700)]
ifconfig.8: cleanup reminiscence about long gone ppp(4)

Replace ppp(4) removed since FreeBSD 8.0-RELEASE with vlan(4).
While here, remove commented out reference to non-existing "egress"
interface group hiding since initial import of interface groups
from OpenBSD in 2006.

(cherry picked from commit 3c9ad9398fcdf5f49114fde978b7c837b7ebbc8d)

22 months agofind.1: small language fix after previous change
Eugene Grosbein [Fri, 22 Jul 2022 11:46:38 +0000 (18:46 +0700)]
find.1: small language fix after previous change

collate -> collation

(cherry picked from commit d6054ee652a56466277f87bb4bcb757105393c8c)

22 months agofind.1: explain why "find -s" may differ from "find | sort"
Eugene Grosbein [Fri, 22 Jul 2022 11:39:47 +0000 (18:39 +0700)]
find.1: explain why "find -s" may differ from "find | sort"

In short, that's because a directory name may end
with a character that goes before slash (/).

MFC after: 1 week

(cherry picked from commit 26a329f49fb4537d598e93f16054fd9e16f7e677)

22 months agonfsd: Fix CreateSession for an established ClientID
Rick Macklem [Wed, 13 Jul 2022 23:28:56 +0000 (16:28 -0700)]
nfsd: Fix CreateSession for an established ClientID

I mis-read the RFC w.r.t. handling of the sequenceid
when a CreateSession is done after the initial one
that confirms the ClientID.  Fortunately this does
not affect most extant NFSv4.1/4.2 clients, since
they only acquire a single session for TCP for a
ClientID (Solaris might be an exception?).

This patch fixes the server to handle this case,
where the RFC requires the sequenceid be incremented
for each CreateSession and is required to reply to
a retried CreateSession with a cached reply.
It adds a field to nfsclient called lc_prevsess,
which caches the sessionid, which is the only field
in a CreateSession reply that will change for a
retry, to implement this reply cache.

The recent commits up to d4a11b3e3bdd that mark
session slots bad when "intr" and/or "soft" mounts
are used by the client needs this server patch.
Without this patch, the client will do a full
recovery, including a new ClientID, losing all
byte range locks.  However, prior to the recent
client commits, the client would hang when all
session slots were bad, so even without this
patch it is not a regression.

PR: 260011
(cherry picked from commit 088ba4356a114416b1d68bf5ae3b3e0accf6d0df)

22 months agonfscl: Fix CreateSession for an established ClientID
Rick Macklem [Mon, 11 Jul 2022 23:50:34 +0000 (16:50 -0700)]
nfscl: Fix CreateSession for an established ClientID

Commit 981ef32230b2 added optional use of the session
slots marked bad to recover a new session when all
slots are marked bad.  The recovery worked against
a FreeBSD NFSv4.1/4.2 server, but not a Linux one.
It turns out that it was a bug in the FreeBSD client
and not the Linux server.

This patch fixes the client so that DeleteSession
followed by CreateSession after receiving a
NFSERR_BADSESSION error reply works against the
Linux server (and conforms to the RFC).

This also implies that the FreeBSD NFSv4.1/4.2
server needs to be fixed in a future commit.
Without the fix, the FreeBSD server does a full
recovery, including creation of a new ClientID,
but since "intr" mounts were broken, this does
not result in a regression.

This patch only affects the case where a CreateSession
is done for an already confirmed ClientID, which was
not being done prior to commit 981ef32230b2.

PR: 260011
(cherry picked from commit d4a11b3e3bddb1fa3bdd101e12aea6f5937356fa)

22 months agonfscl: Do not call nfscl_hasexpired() for NFSv4.1/4.2
Rick Macklem [Sun, 10 Jul 2022 20:56:38 +0000 (13:56 -0700)]
nfscl: Do not call nfscl_hasexpired() for NFSv4.1/4.2

Commit 981ef32230b2 enabled marking of potentially bad
session slots when an RPC is interrupted if the "intr"
mount option is used.  As such, it no longer makes
sense to call nfscl_hasexpired() for I/O operations that
reply NFSERR_BADSTATEID for NFSv4.1/4.2, which does a full
recovery of NFSv4 open state, destroying all byte range locks.
Recovery of open state should not be usually needed, since
the session slot has been marked potentially bad and,
although opens for the process that has been terminated via
a signal may be broken, locks for other processes will still
be valid.

This patch disables calls to nfscl_hasexpired for NFSv4.1/4.2
mounts, when I/O RPCs receive NFSERR_BADSTATEID replies.
It does not affect the behaviour of NFSv4.0 mounts nor
hard (non "intr") mounts.

PR: 260011
(cherry picked from commit 8f4a5fc6bc6c4e9e0739326199d73ee4401ebd58)

22 months agonfscl: Enable detection of bad session slots
Rick Macklem [Sun, 10 Jul 2022 20:33:19 +0000 (13:33 -0700)]
nfscl: Enable detection of bad session slots

To deal with broken session slots caused by the use of the
"soft" and/or "intr" mount options, nfsv4_sequencelookup()
has been modified to track the potentially broken session
slots (commit 40ada74ee1da).  Then, when all session slots
are potentially broken, nfsv4_sequencelookup() does a
DeleteSession operation, so that the NFSv4.1/4.2 server will
reply NFSERR_BADSESSION to uses of the session.
The client will then recover by doing a CreateSession to
acquire a new session.

This patch adds the code that marks potentially bad
slots, so that the above semantics become functional.
It has been successfully tested against a FreeBSD
NFSv4.1/4.2 server, but does not work against a Linux 5.15
NFSv4.1/4.2 server. (The Linux 5.15 server creates
a new session with the same sessionid as the destroyed
one and, as such, keeps returning NFSERR_BADSESSION.
I believe this is a bug in the Linux server.)

However, this should not cause a regression and will
make "intr" mounts fairly usable against the NFSv4.1/4.2
servers where it works.

PR: 260011
(cherry picked from commit 981ef32230b2fe46969c90b53864bdca4f1c3ae5)

22 months agonfscl: Replace "cred" with NULL to cleanup code
Rick Macklem [Mon, 11 Jul 2022 22:51:27 +0000 (15:51 -0700)]
nfscl: Replace "cred" with NULL to cleanup code

Commit 326bcf9394c7 added a new "cred" argument to nfscl_reqstart().
Fsinfo is a NFSv3 RPC and since the "cred" argument is not
used for NFSv3, it does not matter what is passed in.
However, to be consistent with the rest of the patch, change the
argument to NULL.

This patch should not result in a semantics change.

PR: 260011

(cherry picked from commit 2adb30740b12d4b80b8a1eb04b58ce0f6eb51de1)

22 months agonfscl: Initialize nfsess_badslots to zero
Rick Macklem [Sat, 9 Jul 2022 23:12:31 +0000 (16:12 -0700)]
nfscl: Initialize nfsess_badslots to zero

Commit 40ada74ee1da added a field to mark bad session slots.
This patch ensures that the field is initialized to 0.

PR: 260011
(cherry picked from commit 627f1555f571b5328637dbfbe441ed89c84db20c)