]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
21 months agocontrib/tzdata: import tzdata 2022b and 2022c
Philip Paeps [Thu, 11 Aug 2022 02:48:24 +0000 (10:48 +0800)]
contrib/tzdata: import tzdata 2022b and 2022c

Changes: https://github.com/eggert/tz/blob/2022b/NEWS
Changes: https://github.com/eggert/tz/blob/2022c/NEWS

The tzdata2022b import restored the zoneinfo/GMT link.
Don't delete it again with 'make delete-old'.

(cherry picked from commit 9f9fc6bb8028ea29da6b04c338c750cedc3040f3)
(cherry picked from commit f5d5282cf7d1181f933626dcdc3525db0d70a266)
(cherry picked from commit 5f33eb7266f938857ce2fc9ea59679ea46a0694b)

21 months agortld: fix display of the mapbase for the traced objects
Konstantin Belousov [Sun, 14 Aug 2022 14:57:40 +0000 (17:57 +0300)]
rtld: fix display of the mapbase for the traced objects

(cherry picked from commit 008475d3c83aecb496b2b08086427f68b2f741d5)

21 months agobasic_signal test: temporarily skip trap_signal_test on i386
Li-Wen Hsu [Tue, 16 Aug 2022 22:03:37 +0000 (06:03 +0800)]
basic_signal test: temporarily skip trap_signal_test on i386

This case crashes a bhyve VM.

PR: 265889
Sponsored by: The FreeBSD Foundation

(cherry picked from commit c04721e35ff0e8220c88d5b10f068dba18629f7e)
(cherry picked from commit beeeb40bca06c8ebc8953274bbc5759fb432fab2)

21 months agoacpi(4): mention NONE as possible setting for hw.acpi.power_button_state
Yuri Pankov [Sun, 11 Apr 2021 20:17:06 +0000 (23:17 +0300)]
acpi(4): mention NONE as possible setting for hw.acpi.power_button_state

Reviewed by: manpages (gbe)
Differential Revision: https://reviews.freebsd.org/D29577

(cherry picked from commit 970ffdcefe89c6814f14e2dd59565346e32f8c18)

21 months agoatomic: Add plain atomic_load/store_bool()
Mark Johnston [Tue, 9 Aug 2022 20:08:29 +0000 (16:08 -0400)]
atomic: Add plain atomic_load/store_bool()

Reviewed by: kib
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 2bed73739aac352299222a18f669a03544c7c9e2)

21 months agoicmp6: Improve validation of PMTU
Kornel Dulęba [Tue, 16 Aug 2022 08:16:50 +0000 (10:16 +0200)]
icmp6: Improve validation of PMTU

Currently we accept any pmtu between IPV6_MMTU(1280B) and the link mtu.
In some network topologies could allow a bad actor to perform a DOS attack.
Contrary to IPv4 in IPv6 oversized packets are dropped, and a ICMP
PACKET_TOO_BIG message is sent back to the sender.
After receiving an ICMPv6 packet with pmtu bigger than the
current one the victim will start sending frames that will be dropped
a router with reduced MTU.
Although it will eventually receive another message with correct pmtu,
an attacker can still just inject their spoofed packets frequently
enough to overwrite the correct value.
This issue is described in detail in RFC8201, section 6.
Fix this by checking the current pmtu, and accepting the new one only
if it's smaller.

Approved by: mw(mentor)
Reviewed by: tuexen
MFC after: 1 week
Sponsored by: Stormshield
Obtained from: Semihalf
Differential Revision: https://reviews.freebsd.org/D35871

(cherry picked from commit 82042465c3b5477fc4f44be36077eab11b6b511b)

21 months agorelease: ensure enforce_chs sysctl is 0
Ed Maste [Tue, 19 Jul 2022 20:47:49 +0000 (16:47 -0400)]
release: ensure enforce_chs sysctl is 0

We do not want CHS-based alignment for VM or SD card release images.

(Other images use makefs/mkimg, not kernel gpart and so do not depend
on this sysctl.)

Sponsored by: The FreeBSD Foundation
Approved by: re (gjb)
MFC after: 1 week

(cherry picked from commit 6b6367ba8fd2b29de29ce08e7432291e807c3bc0)

21 months agoDelay GEOM disk_create() until CAM periph probe completes.
Alexander Motin [Thu, 14 Jul 2022 19:38:14 +0000 (15:38 -0400)]
Delay GEOM disk_create() until CAM periph probe completes.

Before this patch CAM periph drivers called both disk_alloc() and
disk_create() same time on periph creation.  But then prevented disks
from opening until the periph probe completion with cam_periph_hold().
As result, especially if disk misbehaves during the probe, GEOM event
thread, triggered to taste the disk, got blocked on open attempt,
potentially for a long time, unable to process other events.

This patch moves disk_create() call from periph creation to the end of
the probe. To allow disk_create() calls from non-sleepable CAM contexts
some of its duties requiring memory allocations are moved either back
to disk_alloc() or forward to g_disk_create(), so now disk_alloc() and
disk_add_alias() are the only disk methods that require sleeping.  If
disk fails during the probe disk_create() may just be skipped, going
directly to disk_destroy().  Other method calls during that time are
just ignored.  Since GEOM may now see the disks after CAM bus scan is
already completed, introduce per-periph boot hold functions. Enclosure
driver already had such mechanism, so just generalize it.

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

(cherry picked from commit 90bcc81bc35e89049a94a12c259b0c53fcf7a299)

21 months agonvme: Print CRD, M and DNR status bits on errors.
Alexander Motin [Fri, 5 Aug 2022 14:58:19 +0000 (10:58 -0400)]
nvme: Print CRD, M and DNR status bits on errors.

It may help with some issues debugging.

MFC after: 1 week

(cherry picked from commit a69c0964625f4e20a7d5f22d51e036e13eedbeeb)

21 months agoacpi_apei: Add sysctl to mute corrected errors.
Alexander Motin [Fri, 5 Aug 2022 17:45:35 +0000 (13:45 -0400)]
acpi_apei: Add sysctl to mute corrected errors.

Setting hw.acpi.apei.log_corrected to 0 will mute corrected errors logging.

MFC after: 1 week

(cherry picked from commit 52a54b96ed1b7c0a1c04fc7651a1fc036bdc5bbc)

21 months agomca: Add sysctl to mute corrected errors.
Alexander Motin [Fri, 5 Aug 2022 17:40:57 +0000 (13:40 -0400)]
mca: Add sysctl to mute corrected errors.

Setting hw.mca.log_corrected to 0 will mute corrected errors logging
except ones marked as reaching Yellow threshold by hardware.

MFC after: 1 week

(cherry picked from commit ac64943ca8514382289e6054e8127726a7c40ea3)

21 months agoMerge libcxxrt commit 5d8a15823a103bbc27f1bfdcf2b5aa008fab57dd
Mark Johnston [Mon, 8 Aug 2022 16:30:56 +0000 (12:30 -0400)]
Merge libcxxrt commit 5d8a15823a103bbc27f1bfdcf2b5aa008fab57dd

  Fix two bugs in __cxa_end_cleanup()

  Per the EHABI32 specification, __cxa_end_cleanup must take care to
  preserve registers before calling _Unwind_Resume().  So, libcxxrt uses
  an assembly stub which preserves caller-saved registers around the call
  to __cxa_get_cleanup().  But:
  - it failed to restore them properly,
  - it did not preserve the link register.

  Fix both of these problems.  This is needed to fix exception unwinding
  on FreeBSD with LLVM 14.  Note that r4 is callee-saved but is pushed
  onto the stack to preserve stack pointer alignment.

Sponsored-by: The FreeBSD Foundation
(cherry picked from commit cbd1e83154af8bae3daa3919bb2746d587436515)

21 months agoDeprecate minigzip(1) in preparation of removing it from base system.
Xin LI [Sun, 31 Jul 2022 22:16:22 +0000 (15:16 -0700)]
Deprecate minigzip(1) in preparation of removing it from base system.

Reviewed by: emaste, pauamma
Differential Revision: https://reviews.freebsd.org/D36000

(cherry picked from commit 0404b8c88fd857aae9ecf73ab9e1b1c2a8fd7ae1)

21 months agonet80211: Remove tautological state display
Cy Schubert [Tue, 19 Jul 2022 04:10:40 +0000 (21:10 -0700)]
net80211: Remove tautological state display

When printing the current state name and the old state numeric value,
both are always the same. Remove the redundant ostate. It is always
the same as iv_state.

Reviewed by: bz
Differential Revision: https://reviews.freebsd.org/D35849

(cherry picked from commit 4f158a444ee7365454cc3ea1547b1b5c323dae55)

21 months agorc.d/wpa_supplicant: Remove the sleep to improve boot time
Cy Schubert [Sun, 12 Jun 2022 19:02:47 +0000 (12:02 -0700)]
rc.d/wpa_supplicant: Remove the sleep to improve boot time

bapt@ had discovered a noticeable boot improvement without the sleep.
Without the sleep does not affect warm or cold boot however a
service netif restart may cause dhclient to spend a few extra seconds
to rerequest the DHCP request.

Reported by: bapt
Reviewed by: bapt
Differential Revision: https://reviews.freebsd.org/D35457

(cherry picked from commit 116679b39cb94fdb94c02dceb1c2cae719bd3f42)

21 months agoinstallworld: improve portability of ldd use
Brooks Davis [Fri, 1 Jul 2022 07:33:16 +0000 (08:33 +0100)]
installworld: improve portability of ldd use

b3b462229f97 added a case statement to ignore lines containing strings
in square brackets such as "[vdso]" and "[preloaded]". On MacOS
Monterey where /bin/sh may be zsh, this fails with:

/bin/sh: -c: line 0: syntax error near unexpected token `;;'

Invoke grep in the pipeline to remove such lines instead.

Reviewed by: emaste
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D35618

(cherry picked from commit bda5d2a45c8dcc9bbeb71cddeef930ffa6a47f23)

22 months agoAdd "heard" to the dictionary
Ed Maste [Mon, 8 Aug 2022 18:57:32 +0000 (14:57 -0400)]
Add "heard" to the dictionary

PR: 265671
Reported by: J.R. Oldroyd
MFC after: 3 days

(cherry picked from commit 711ee0591832857c4484dbc05f0d8e03e9c760e4)

22 months agobridge tests: Tests using pft_ping.py require scapy
Mark Johnston [Thu, 4 Aug 2022 13:41:52 +0000 (09:41 -0400)]
bridge tests: Tests using pft_ping.py require scapy

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 121e120883a227ce27a12f33699fac4e5bdec6a4)

22 months agofile: Move code to share fdtol structs into kern_descrip.c
Mark Johnston [Thu, 4 Aug 2022 13:39:25 +0000 (09:39 -0400)]
file: Move code to share fdtol structs into kern_descrip.c

This ensures the filedesc-to-leader code is consistently encapsulated in
kern_descrip.c.

No functional change intended.

Reviewed by: kib
Sponsored by: The FreeBSD Foundation

(cherry picked from commit d07675a9352efce5e997e987080b3f98bbfdac96)

22 months agodomain: Use designated constants for timeout periods
Mark Johnston [Wed, 3 Aug 2022 00:31:29 +0000 (20:31 -0400)]
domain: Use designated constants for timeout periods

No functional change intended.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 852695416c856abf6197d0345c1f6f9e3a70beab)

22 months agoctfconvert: Give bitfield types names distinct from the base type
Mark Johnston [Wed, 3 Aug 2022 00:32:17 +0000 (20:32 -0400)]
ctfconvert: Give bitfield types names distinct from the base type

CTF integers have an explicit width and so can be used to represent
bitfields.  Bitfield types emitted by ctfconvert(1) share the name of
the base integer type, so a struct field with type "unsigned int : 15"
will have a type named "unsigned int".

To avoid ambiguity when looking up types by name, add a suffix to names
of bitfield types to distinguish them from the base type.  Then, if
ctfmerge happens to order bitfield types before the corresponding base
type in a CTF file, a name lookup will return the base type, which is
always going to be the desired behaviour.

PR: 265403
Reported by: cy
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 1165fc9a526630487a1feb63daef65c5aee1a583)

22 months agodtrace tests: Override RLIMIT_CORE for a test which triggers a core dump
Mark Johnston [Wed, 3 Aug 2022 00:32:04 +0000 (20:32 -0400)]
dtrace tests: Override RLIMIT_CORE for a test which triggers a core dump

Sponsored by: The FreeBSD Foundation

(cherry picked from commit e1700a36a9471a623c89f3112d69234ee6ac7fae)

22 months agodtrace tests: Rename some test type names to avoid a conflict
Mark Johnston [Wed, 3 Aug 2022 00:32:08 +0000 (20:32 -0400)]
dtrace tests: Rename some test type names to avoid a conflict

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 6a05f1438145c2d8c3d0e29e1d5e24a05d394453)

22 months agoDB_COMMAND(9): update to mention additional macros
Mitchell Horne [Tue, 5 Jul 2022 14:55:18 +0000 (11:55 -0300)]
DB_COMMAND(9): update to mention additional macros

Document the existing alias definitions, and augment the example with
one of these. Also, describe the purpose of the newly added _FLAGS
variations of these command definitions.

Make some small style improvements to appease mandoc -Tlint.

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

(cherry picked from commit b83d53cb687e65372dd23496578c436243b11c93)
(cherry picked from commit 62bca9c4df3af8ddeb08f910959fdf6d5084679f)

22 months agoddb: use _FLAGS command macros where appropriate
Mitchell Horne [Tue, 5 Jul 2022 14:47:55 +0000 (11:47 -0300)]
ddb: use _FLAGS command macros where appropriate

Some command definitions were forced to use DB_FUNC in order to specify
their required flags, CS_OWN or CS_MORE. Use the new macros to simplify
these.

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

(cherry picked from commit 258958b3c7e017266080ae7fc9e3d8e64b6450d4)

22 months agoddb: add _FLAGS command variants
Mitchell Horne [Thu, 30 Jun 2022 15:58:22 +0000 (12:58 -0300)]
ddb: add _FLAGS command variants

Provide _FLAGS variants of the various command definition macros, in
anticipation of adding a new flag. This can also be used for some
existing commands which require special flag values.

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

(cherry picked from commit 7ce58d4e8c0cfcb42ec404aed6185b5eb7eef8a8)

22 months agodb_command.c: use designated initializers
Mitchell Horne [Tue, 5 Jul 2022 14:45:47 +0000 (11:45 -0300)]
db_command.c: use designated initializers

Provide separate helper macros for regular commands and next-level table
commands as they are mutually exclusive. This ensures proper
initialization of each element and allows us to exclude some redundant
fields, such as specifying .more = NULL for every regular command.

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

(cherry picked from commit 8a0994823365740f4d92842c2d6f7f524310ba64)

22 months agodb_command.c: style
Mitchell Horne [Tue, 5 Jul 2022 14:44:36 +0000 (11:44 -0300)]
db_command.c: style

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

(cherry picked from commit 4f2ad6243f15ef325aa8daa680949b0ee1076c6e)

22 months agoriscv: implement db_show_mdpcpu()
Mitchell Horne [Mon, 4 Oct 2021 20:47:49 +0000 (17:47 -0300)]
riscv: implement db_show_mdpcpu()

This prints the machine-dependent members of struct pcpu when executing
the 'show pcpu' or 'show all pcpu' ddb(4) commands.

MFC after: 3 days

(cherry picked from commit 4fffc56c6e4c97aa76b31060e806ccdafb1afacd)

22 months agobus_if: provide a default null rescan method
Mitchell Horne [Tue, 21 Jun 2022 13:29:53 +0000 (10:29 -0300)]
bus_if: provide a default null rescan method

There is an existing helper function, bus_null_rescan(), but most
drivers won't use it except to override an inherited rescan method. It
also returns the same error as an empty method. Make this the default
rescan method in bus_if.m and return a more sensible error code.

This gives a slightly more meaningful error message when attempting
'devctl rescan' on buses and devices alike:
  "Device not configured" --> "Operation not supported by device"

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

(cherry picked from commit 36a8572ee8f5db7ecb64bedc5738a363ec7cad36)
(cherry picked from commit 29afffb942b159511ad7d5ea5d086851f65ef4a0)

22 months agorelease: fix alignment for arm SoCs
Glen Barber [Mon, 8 Aug 2022 14:59:29 +0000 (10:59 -0400)]
release: fix alignment for arm SoCs

Submitted by: Mark Millard
Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 45add40717c24ef0b5418664fae1718b15a0422b)

22 months agortld-elf: Fix leaks and wild frees in origin_subst
Jessica Clarke [Tue, 12 Jul 2022 16:47:47 +0000 (17:47 +0100)]
rtld-elf: Fix leaks and wild frees in origin_subst

55abf23dd36b inverted the value passed to origin_subst_one when rolling
up the existing code into a loop. If the first token is found ($ORIGIN),
this results in a wild free of part of strtab. Processing the second
token works fine and will act how the first should have regardless of
whether found, allocating memory for the string without freeing.
Processing subsequent tokens however will then leak, regardless of
whether found, as they will also believe they need to allocate memory
and can't free the string.

Found by: CHERI
Reviewed by: kib, markj
Fixes: 55abf23dd36b ("rtld: make token substitution table-driven")
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D35792

(cherry picked from commit becd9908beb8f1b47ddc6628cb005185a26ec85c)

22 months agoinet6(4): Fix a typo in a source code comment
Gordon Bergling [Sun, 7 Aug 2022 12:20:52 +0000 (14:20 +0200)]
inet6(4): Fix a typo in a source code comment

- s/Unreachablity/Unreachability/

(cherry picked from commit cd33039749356f613013ebf02795cafc0aba1968)

22 months agonullfs(5): Fix a typo in a source code comment
Gordon Bergling [Sun, 7 Aug 2022 12:04:53 +0000 (14:04 +0200)]
nullfs(5): Fix a typo in a source code comment

- s/examing/examining/

(cherry picked from commit 4c399b044fc66b02e37110ca5c1f4ce0e3beb9d1)

22 months agolibutil: Fix mandoc warnings
Gordon Bergling [Sun, 7 Aug 2022 14:30:24 +0000 (16:30 +0200)]
libutil: Fix mandoc warnings

- missing comma before name
- possible typo in section name: Sh CAVEAT instead of CAVEATS
- useless macro: Tn
- blank line in fill mode, using .sp
- no blank before trailing delimiter: Dv NULL?

(cherry picked from commit 816ca3d10fd2f0c9283005a189fac156071d748d)

22 months agolibpathconv: bump man page dates
Gordon Bergling [Tue, 9 Aug 2022 08:05:31 +0000 (10:05 +0200)]
libpathconv: bump man page dates

- bump the man page dates to the date of mandoc fixes

Reported by: rpokala
X-MFC with: 094517119c62c23369d545a7475ae982d86330a3

(cherry picked from commit 948168c778e872552da7b3ef22a6d55df1215ed2)

22 months agolibpathconv: Fix mandoc warnings in abs2rel(3) and rel2abs(3)
Gordon Bergling [Sun, 7 Aug 2022 12:53:53 +0000 (14:53 +0200)]
libpathconv: Fix mandoc warnings in abs2rel(3) and rel2abs(3)

- cannot parse date, using it verbatim: Dec 15, 1997"
- sections out of conventional order: Sh SEE ALSO
- possible typo in section name: Sh EXAMPLE instead of EXAMPLES
- AUTHORS section without An macro

(cherry picked from commit 094517119c62c23369d545a7475ae982d86330a3)

22 months agodebugnet: Fix a typo in a source code comment
Gordon Bergling [Sun, 7 Aug 2022 14:07:01 +0000 (16:07 +0200)]
debugnet: Fix a typo in a source code comment

- s/paramaters/parameters/

(cherry picked from commit b2b1bb041056e45acae537feb6d1b28d22f53a2a)

22 months agomfiutil.8: Fix some mandoc warnings
Gordon Bergling [Sun, 7 Aug 2022 15:24:48 +0000 (17:24 +0200)]
mfiutil.8: Fix some mandoc warnings

- new sentence, new line
- no blank before trailing delimiter

(cherry picked from commit 75f8dcc831bf80c7efc93d3461699f95033c1d28)

22 months agoisci(4): Fix a typo in a source code comment
Gordon Bergling [Sun, 7 Aug 2022 14:05:08 +0000 (16:05 +0200)]
isci(4): Fix a typo in a source code comment

- s/paramater/parameter/

(cherry picked from commit 0702f4f0409e39d6b85b0b008a4e4cdf9690beb9)

22 months agonet80211(4): Fix a typo in a source code comment
Gordon Bergling [Sun, 7 Aug 2022 14:00:07 +0000 (16:00 +0200)]
net80211(4): Fix a typo in a source code comment

- s/paramaters/parameters/

(cherry picked from commit 044169efe0b7f8a3c30f33ae081054def91acc7d)

22 months agovnode(9): Fix a typo in a source code comment
Gordon Bergling [Sun, 7 Aug 2022 14:08:43 +0000 (16:08 +0200)]
vnode(9): Fix a typo in a source code comment

- s/paramater/parameter/

(cherry picked from commit fa1ac9693a6d9253edb139358f79cacdd45bc10a)

22 months agothread_create(): call cpu_copy_thread() after td_pflags is zeroed
Konstantin Belousov [Sun, 7 Aug 2022 17:00:02 +0000 (20:00 +0300)]
thread_create(): call cpu_copy_thread() after td_pflags is zeroed

(cherry picked from commit 1b0a4974c5004216daf4a2ac4375074ce56bc55b)

22 months agotree.3: explain RB_FIND() and RB_NFIND()
Konstantin Belousov [Mon, 1 Aug 2022 09:43:10 +0000 (12:43 +0300)]
tree.3: explain RB_FIND() and RB_NFIND()

(cherry picked from commit 08349b18ea26d1e191333f9b3550cd95b09cfe34)

22 months agovm_fault: Shoot down shared mappings in vm_fault_copy_entry()
Mark Johnston [Mon, 25 Jul 2022 20:53:21 +0000 (16:53 -0400)]
vm_fault: Shoot down shared mappings in vm_fault_copy_entry()

As in vm_fault_cow(), it's possible, albeit rare, for multiple vm_maps
to share a shadow object.  When copying a page from a backing object
into the shadow, all mappings of the source page must therefore be
removed.  Otherwise, future operations on the object tree may detect
that the source page is fully shadowed and thus can be freed.

Approved by: so
Security: FreeBSD-SA-22:11.vm
Reviewed by: alc, kib
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D35635

(cherry picked from commit 5c50e900ad779fccbf0a230bfb6a68a3e93ccf60)

22 months agoelf_note_prpsinfo: handle more failures from proc_getargv()
Konstantin Belousov [Fri, 3 Jun 2022 08:21:23 +0000 (11:21 +0300)]
elf_note_prpsinfo: handle more failures from proc_getargv()

Resulting sbuf_len() from proc_getargv() might return 0 if user mangled
ps_strings enough. Also, sbuf_len() API contract is to return -1 if the
buffer overflowed. The later should not occur because get_ps_strings()
checks for catenated length, but check for this subtle detail explicitly
as well to be more resilent.

The end result is that p_comm is used in this situations.

Approved by: so
Security: FreeBSD-SA-22:09.elf
Reported by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
Reviewed by: delphij, markj
admbugs: 988
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D35391

(cherry picked from commit 00d17cf342cd9f4f8fd1dcd79c8caec359145532)

22 months agobsd-family-tree: fix a typo for NetBSD 9.3 release date
Sergey A. Osokin [Sun, 7 Aug 2022 13:57:14 +0000 (09:57 -0400)]
bsd-family-tree: fix a typo for NetBSD 9.3 release date

Reported by: Adrian Steinmann <ast@NetBSD.org>
Fixes: a3d933cc4f2300b476151c2dd3fa455882f3aa97

(cherry picked from commit ffcec862aaea0f1984767f2c9614c8b3dbc846ae)

22 months agobsd-family-tree: add NetBSD 9.3
Sergey A. Osokin [Sat, 6 Aug 2022 19:02:42 +0000 (15:02 -0400)]
bsd-family-tree: add NetBSD 9.3

Add NetBSD 9.3, it's been released two days ago.

(cherry picked from commit a3d933cc4f2300b476151c2dd3fa455882f3aa97)

22 months agobsd-family-tree: OpenBSD 7.1 and DragonFly BSD 6.2.2
Sergey A. Osokin [Sat, 6 Aug 2022 18:56:22 +0000 (14:56 -0400)]
bsd-family-tree: OpenBSD 7.1 and DragonFly BSD 6.2.2

Add two releases to the tree.

(cherry picked from commit 69893a0e8fc87fec294f597c81e27c52a5c6af0c)

22 months agobsd-family-tree: FreeBSD 13.1
Warner Losh [Wed, 18 May 2022 00:02:42 +0000 (18:02 -0600)]
bsd-family-tree: FreeBSD 13.1

Now that 13.1 has been announced, add today's date UTC as the release
date.

(cherry picked from commit f8f1e9cd1ceeac4d3a9d2f703f937f67148bd513)

22 months agobsd-family-tree: Update various URLs in file
Elliott Mitchell [Fri, 1 Apr 2022 14:28:28 +0000 (08:28 -0600)]
bsd-family-tree: Update various URLs in file

Been some time since 364fe18b8c8 when the URL was first in this file.
Update from svnweb to cgit for the URL listed at the end of this file.
In addition, update all URLs to HTTPS. Replace two URLs with links to
archive.org as the original URLs are no longer valid.

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

(cherry picked from commit 2b68a79b73d7a5b9ed43ad199413705f5935f01c)

22 months agozlib: Fix a bug when getting a gzip header extra field with inflate().
Mark Adler [Sat, 30 Jul 2022 22:51:11 +0000 (15:51 -0700)]
zlib: Fix a bug when getting a gzip header extra field with inflate().

If the extra field was larger than the space the user provided with
inflateGetHeader(), and if multiple calls of inflate() delivered
the extra header data, then there could be a buffer overflow of the
provided space. This commit assures that provided space is not
exceeded.

(cherry picked from zlib commit eff308af425b67093bab25f80f1ae950166bece1)
(cherry picked from zlib commit 1eb7682f845ac9e9bf9ae35bbfb3bad5dacbd91d)

(cherry picked from commit dc3509f1aafcd966f3dd9226115cf94b691ff3c7)
(cherry picked from commit 2969066f73fc67a614144ac09b9f3f5291937fed)

22 months agoipsec: replace SECASVAR mtx by rmlock
Kristof Provost [Thu, 23 Jun 2022 20:35:29 +0000 (22:35 +0200)]
ipsec: replace SECASVAR  mtx by rmlock

This mutex is a significant point of contention in the ipsec code, and
can be relatively trivially replaced by a read-mostly lock.
It does require a separate lock for the replay protection, which we do
here by adding a separate mutex.

This improves throughput (without replay protection) by 10-15%.

MFC after: 3 weeks
Sponsored by: Orange Business Services
Differential Revision: https://reviews.freebsd.org/D35763

(cherry picked from commit 0361f165f2193a098cfbfeef3a58ec2f1eaac0a1)

22 months agolib9p: Remove potential buffer overwrite in l9p_puqids()
Konrad Sewiłło-Jopek [Mon, 8 Aug 2022 16:25:48 +0000 (12:25 -0400)]
lib9p: Remove potential buffer overwrite in l9p_puqids()

Structure l9p_f_wralk reserves at most L9P_MAX_WELEM entries
and that number actually set the maximum we can safely use.

PR: 265385
Reviewed by: markj

(cherry picked from commit 2dd83b3f0507fc7bc64b908fb88f285a3b9663c8)

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)