]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
17 months agocontrib/tzdata: import tzdata 2022g
Philip Paeps [Wed, 30 Nov 2022 01:36:28 +0000 (09:36 +0800)]
contrib/tzdata: import tzdata 2022g

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

tzdata 2022g and later split America/Ciudad_Juarez from America/Ojinaga.
Ensure this file is removed in builds WITHOUT_ZONEINFO.

(cherry picked from commit cf1ad5351036884e0a2e21d1bc9b712448467741)
(cherry picked from commit 821549a9dfdf69f533feb84914b09450cd7311b6)

17 months agoUpdate resolv.conf(5) "not necessary" language.
Pau Amma [Mon, 21 Nov 2022 00:19:55 +0000 (00:19 +0000)]
Update resolv.conf(5) "not necessary" language.

While there, fix mandoc -T lint warnings.

PR: 262492
Differential Revision: https://reviews.freebsd.org/D37449
MFC after: 1 week
Reviewed by: gjb
Approved by: gjb (mentor)

(cherry picked from commit e8261bba4e18ab95fe958e195b07a66df1b8d855)

Clarify what's normally not required.

Reported by: karels
Reviewed by: carlavilla, karels (informally)
Approved by: carlavilla (mentor), gjb (mentor, implicitly)
Differential Revision: https://reviews.freebsd.org/D37483

(cherry picked from commit 06703946d0be0baaf0f2a88f85e2dd5354e861da)

18 months agobhyve: build DSDT table by basl
Corvin Köhne [Wed, 6 Apr 2022 09:10:40 +0000 (11:10 +0200)]
bhyve: build DSDT table by basl

Building the DSDT table by basl will allow it to be loaded by qemu's
ACPI table loader.

Building the DSDT is complex and basl doesn't support it yet. For that
reason, it's still compiled by iasl. It's just a bit restructured.
Upcoming commits will restructure the builds of all other ACPI tables in
a similar way. So, this commit is done for consistency reasons. We're
starting with DSDT because it doesn't point to any other tables and it's
the last one in our current build list.

Reviewed by: jhb, markj (older version)
Approved by: manu (mentor)
MFC after: 2 weeks
Sponsored by: Beckhoff Automation GmbH & Co. KG
Differential Revision: https://reviews.freebsd.org/D36993

(cherry picked from commit b922cf4fe340bc48355fdde8823dc472841445b3)

18 months agobhyve: add basl support for common table header
Corvin Köhne [Wed, 6 Apr 2022 09:10:40 +0000 (11:10 +0200)]
bhyve: add basl support for common table header

Most ACPI tables are using the same header. Make it easy to create this
header by creating a function for it.

Reviewed by: jhb, markj (older version)
Approved by: manu (mentor)
MFC after: 2 weeks
Sponsored by: Beckhoff Automation GmbH & Co. KG
Differential Revision: https://reviews.freebsd.org/D36992

(cherry picked from commit 2fb0f352b977aeb34650081e51454b0b637c5ace)

18 months agobhyve: use basl to load ACPI tables
Corvin Köhne [Fri, 4 Nov 2022 11:30:37 +0000 (12:30 +0100)]
bhyve: use basl to load ACPI tables

Load the blobs compiled by iasl into a basl_table. The basl_table is a
temporary buffer which copies the ACPI tables into guest memory for us.
This allows us in the future to pass the blobs over the qemu fwcfg
interface to the guest.

Reviewed by: jhb, markj
Approved by: manu (mentor)
MFC after: 2 weeks
Sponsored by: Beckhoff Automation GmbH & Co. KG
Differential Revision: https://reviews.freebsd.org/D36986

(cherry picked from commit 22a2e94f3805195bf8195c81f7fda4157ebae372)

18 months agoping: Fix handling of IP packet sizes
Tom Jones [Thu, 17 Nov 2022 10:31:38 +0000 (10:31 +0000)]
ping: Fix handling of IP packet sizes

Ping reads raw IP packets to parse ICMP responses. When reading the
IP Header Len (IHL) ping was was taking the value from the provided
packet without any validation. This could lead to remotely triggerable
stack corruption.

Validate the IHL against expected and recieved data sizes when reading
from the received packet and when reading any quoted packets from within
the ICMP response.

Approved by: so
Reviewed by: markj, asomers
Security: FreeBSD-SA-22:15.ping
Security: CVE-2022-23093
Sponsored by:   NetApp, Inc.
Sponsored by:   Klara, Inc.
X-NetApp-PR:    #77
Differential Revision: https://reviews.freebsd.org/D37195

(cherry picked from commit 46d7b45a267b3d78c5054b210ff7b6c55bfca42b)

18 months agobhyve: Drop volatile qualifiers from xhci hw struct fields
Mark Johnston [Fri, 11 Nov 2022 15:01:52 +0000 (10:01 -0500)]
bhyve: Drop volatile qualifiers from xhci hw struct fields

This fixes a warning raised by the removal of the volatile qualifier
from &trb->qwTrb0 in the following snippet:

xfer_block = usb_data_xfer_append(xfer,
     (void *)(trbflags & XHCI_TRB_3_IDT_BIT ?
 &trb->qwTrb0 : XHCI_GADDR(sc, trb->qwTrb0)),
     trb->dwTrb2 & 0x1FFFF, (void *)addr, ccs);

The use of volatile appears to be inherited from the kernel driver's
definitions of the same structures.  It makes some sense, since USB TRBs
and related structures live in guest memory, but bhyve device models
generally don't volatile-qualify accesses to guest memory and I can't
see how they are required for correctness here.  Moreover, XHCI_GADDR
does not return volatile pointers so we're already being inconsistent.
Just drop the qualifiers to address the warning.

MFC after: 2 weeks
Reviewed by: corvink, jhb
Differential Revision: https://reviews.freebsd.org/D37290

(cherry picked from commit 691e23e6c5d9f46828cafbce156909d14bce635c)

18 months agobhyve: Cast away const when fetching a config nvlist
Mark Johnston [Fri, 11 Nov 2022 15:02:42 +0000 (10:02 -0500)]
bhyve: Cast away const when fetching a config nvlist

Silence a warning from the compiler about "const" being discarded.  The
warning is correct: nvlist values are supposed to be immutable.
However, fixing this properly will require some contortions on behalf of
consumers who look up a subtree of the config and modify it.  Per a
discussion on freebsd-virtualization@, the solution will probably be to
outright replace the use of nvlists for VM configuration, but until that
happens let's document the problem and silence the warning.

No functional change intended.

MFC after: 2 weeks
Reviewed by: corvink, jhb
Differential Revision: https://reviews.freebsd.org/D37293

(cherry picked from commit 719e307f80c724a39814557e35ac890c75dcd402)

18 months agobhyve: Drop volatile qualifiers from virtio rings
Mark Johnston [Fri, 11 Nov 2022 15:02:10 +0000 (10:02 -0500)]
bhyve: Drop volatile qualifiers from virtio rings

The qualifiers are there presumably because these rings are mapped into
the guest, but they do not appear to be required for correctness, and
bhyve generally doesn't qualify accesses to guest memory this way.
Moreover, the qualifiers are discarded by snapshot code, causing clang
to emit warnings.  Just stop using volatile here.

MFC after: 2 weeks
Reviewed by: corvink, jhb
Differential Revision: https://reviews.freebsd.org/D37291

(cherry picked from commit 593200c23b57ea6977bf5084b91fc5c63dacbb80)

18 months agobhyve: Drop volatile qualifiers from snapshot code
Mark Johnston [Fri, 11 Nov 2022 15:02:26 +0000 (10:02 -0500)]
bhyve: Drop volatile qualifiers from snapshot code

They accomplish nothing since the qualifier is casted away in calls to
memcpy() and copyin()/copyout().  No functional change intended.

MFC after: 2 weeks
Reviewed by: corvink, jhb
Differential Revision: https://reviews.freebsd.org/D37292

(cherry picked from commit 8b1adff8bcbdf0e58878431c6ed5a14553178d4d)

18 months agobhyve: add basl support for pointers
Corvin Köhne [Wed, 6 Apr 2022 09:10:39 +0000 (11:10 +0200)]
bhyve: add basl support for pointers

Some ACPI tables like XSDT contain pointers to other ACPI tables. When
an ACPI table is loaded by qemu's loader, the address in the guest
memory is unknown. For that reason, the qemu loader supports patching
those pointers. Basl keeps track of all pointers and causes the qemu
loader to patch all pointers.

The qemu ACPI table loader is unsupport yet. However, in a future commit
bhyve will use dynamic ACPI table offsets based on the size and
alignment requirements of each ACPI table. Therefore, tracking ACPI
table pointer is required too.

Reviewed by: jhb
Approved by: manu (mentor)
MFC after: 2 weeks
Sponsored by: Beckhoff Automation GmbH & Co. KG
Differential Revision: https://reviews.freebsd.org/D36991

(cherry picked from commit 49b947c01db3efd7587b17d4d7f47675e91dc2ad)

18 months agobhyve: add basl support for checksums
Corvin Köhne [Wed, 6 Apr 2022 09:10:39 +0000 (11:10 +0200)]
bhyve: add basl support for checksums

The qemu ACPI table loader patches the ACPI tables. After patching them,
checksums aren't correct any more. It has to calculate a new checksum
for the ACPI table. For that reason, basl has to keep track of checksums
and has to cause the qemu loader to create new checksums for the tables.

The qemu ACPI table loader isn't supported yet. However, the address of
all tables is unknown as long as bhyve hasn't finished ACPI table
creation. So, the checksum of tables which include pointer to other
tables are unknown too. This requires tracking of checksums too.

Reviewed by: jhb
Approved by: manu (mentor)
MFC after: 2 weeks
Sponsored by: Beckhoff Automation GmbH & Co. KG
Differential Revision: https://reviews.freebsd.org/D36990

(cherry picked from commit 29578470314c09d4ae3163f151da7d4684fb1428)

18 months agobhyve: add basl support for length fields
Corvin Köhne [Wed, 6 Apr 2022 09:10:39 +0000 (11:10 +0200)]
bhyve: add basl support for length fields

ACPI tables have different layouts. So, there's no common position for
the length field. When tables are build by basl, the length is unknown
at the beginning. It has to be set after building the table.

Reviewed by: jhb
Approved by: manu (mentor)
MFC after: 2 weeks
Sponsored by: Beckhoff Automation GmbH & Co. KG
Differential Revision: https://reviews.freebsd.org/D36989

(cherry picked from commit 3a766cd0f1fed90df8f3fd010357e36e050bceb2)

18 months agobhyve: add basl support for generic addresses
Corvin Köhne [Fri, 4 Nov 2022 13:30:53 +0000 (14:30 +0100)]
bhyve: add basl support for generic addresses

In upcoming commits, bhyve will build some ACPI tables by it's own.
Therefore, it should be capable of appending GENERIC_ADDRESS structs to
ACPI tables.

Reviewed by: jhb, markj
Approved by: manu (mentor)
MFC after: 2 weeks
Sponsored by: Beckhoff Automation GmbH & Co. KG
Differential Revision: https://reviews.freebsd.org/D36988

(cherry picked from commit 995374a6553dbdfbdaffbc5f5a5ceff08a437cd7)

18 months agobhyve: add basl support for int values
Corvin Köhne [Fri, 4 Nov 2022 12:48:13 +0000 (13:48 +0100)]
bhyve: add basl support for int values

In upcoming commits, bhyve will build some ACPI tables by it's own.
Therefore, it should be capable of appending int values to ACPI tables.

Reviewed by: jhb, markj (older version)
Approved by: manu (mentor)
MFC after: 2 weeks
Sponsored by: Beckhoff Automation GmbH & Co. KG
Differential Revision: https://reviews.freebsd.org/D36987

(cherry picked from commit e22f5ce2bf4c1a53a1551ae855f42d582eeda20e)

18 months agobhyve: add table dump functions for basl
Corvin Köhne [Fri, 4 Nov 2022 11:26:34 +0000 (12:26 +0100)]
bhyve: add table dump functions for basl

Developing an ACPI table compiler isn't quite easy. It's helpful if you
can take a look at the ACPI tables created by the compiler.

The dump functions can either dump a ACPI table which was copied into
guest memory or a ACPI table provided for qemu's ACPI table loader.

Reviewed by: jhb, markj
Approved by: manu (mentor)
MFC after: 2 weeks
Sponsored by: Beckhoff Automation GmbH & Co. KG
Differential Revision: https://reviews.freebsd.org/D36985

(cherry picked from commit ac3c2b3e38fb03b0d0e26ffa0527735575984ba2)

18 months agobhyve: add basic basl implementation
Corvin Köhne [Fri, 4 Nov 2022 11:24:49 +0000 (12:24 +0100)]
bhyve: add basic basl implementation

Basl is the bhyve ASL compiler. At the moment, it's just a small wrapper
to call iasl, the Intel ASL compiler. As bhyve will gain support for
qemu's ACPI table loader in the future, it has to create ACPI tables on
it's own. Therefore, it makes sense to create a new file which keeps the
code for basl.

This first implementation of basl supports creating an ACPI table by
appending raw bytes to it. It's also capable of loading all tables into
guest memory.

Reviewed by: jhb, markj (older version)
Approved by: manu (mentor)
MFC after: 2 weeks
Sponsored by: Beckhoff Automation GmbH & Co. KG
Differential Revision: https://reviews.freebsd.org/D36984

(cherry picked from commit 21bbc28426d6b88adfdd8c66d0bc936652e0191d)

18 months agovmm: remove unneccessary rendezvous assertion
Corvin Köhne [Thu, 17 Nov 2022 06:51:51 +0000 (07:51 +0100)]
vmm: remove unneccessary rendezvous assertion

When a vcpu sees that a rendezvous is in progress, it exits and tries to
handle the rendezvous. The vcpu doesn't check if it's part of the
rendezvous or not. If the vcpu isn't part of the rendezvous, the
rendezvous could be done before it reaches the assertion. This will
cause a panic.

The assertion isn't needed at all because vm_handle_rendezvous properly
handles a spurious rendezvous. So, we can just remove it.

PR: 267779
Reviewed by: jhb, markj
Tested by: bz
Approved by: manu (mentor)
MFC after: 1 week
Sponsored by: Beckhoff Automation GmbH & Co. KG
Differential Revision: https://reviews.freebsd.org/D37417

(cherry picked from commit fde8ce889201bf7fe86d7a3b3dfe2abf27cd2d73)

18 months agolinuxkpi: Resolve duplicate global symbol name to fix LINT kernel build.
Hans Petter Selasky [Tue, 20 Sep 2022 20:36:08 +0000 (22:36 +0200)]
linuxkpi: Resolve duplicate global symbol name to fix LINT kernel build.

seq_printf() is defined in both spl_procfs_list.c and linux_seq_file.c .
Fix this by renaming the LinuxKPI ones and use macros to invoke the
correct function.

Reported by: jfree@
Differential Revision:  https://reviews.freebsd.org/D35883
MFC after: 1 week
Sponsored by: NVIDIA Networking

(cherry picked from commit cbda8bed15a0de596f72a360debc968343cdc3ce)

18 months agoLinuxKPI: Add pci_power querying for drm-kmod
Jake Freeland [Thu, 6 Oct 2022 08:15:41 +0000 (10:15 +0200)]
LinuxKPI: Add pci_power querying for drm-kmod

Adds a few struct members and a function to get i915_runtime_pm_status()
to compile in drm-kmod.

Differential Revision: https://reviews.freebsd.org/D36749
Sponsored by:   Google, Inc. (GSoC 2022)

(cherry picked from commit 4cb3cb2de2065bccbab65b0139c1be65f1da3fdf)

18 months agolinuxkpi: drm-kmod debugfs support
Jake Freeland [Tue, 20 Sep 2022 17:41:10 +0000 (19:41 +0200)]
linuxkpi: drm-kmod debugfs support

This diff extends LinuxKPI to support simple attribute files in debugfs.
These simple attributes are an essential component for compiling drm-kmod
with CONFIG_DEBUG_FS enabled.
This will allow for easier graphics driver debugging using
Intel's igt-gpu-tools.

Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D35883
Sponsored by: Google, Inc. (GSoC 2022)

(cherry picked from commit f697b9432d9c7aa4c5ab5f5445ef5dc1bd40ce00)

18 months agolinuxkpi: Add strndup_user
Jake Freeland [Tue, 20 Sep 2022 17:38:37 +0000 (19:38 +0200)]
linuxkpi: Add strndup_user

Reviewed by: hselasky, markj
Differential Revision: https://reviews.freebsd.org/D36350
Sponsored by: Google, Inc. (GSoC 2022)

(cherry picked from commit a11195df34f7b14740447869263d3acf8d72af42)

18 months agolinuxkpi: Add EPOLL aliases
Jake Freeland [Tue, 20 Sep 2022 17:37:08 +0000 (19:37 +0200)]
linuxkpi: Add EPOLL aliases

Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D36527
Sponsored by: Google, Inc. (GSoC 2022)

(cherry picked from commit a06eeeaa1d0d62ea293a0bc73f813e5a98ccd405)

18 months agolinuxkpi: Add down_read_killable()
Jake Freeland [Tue, 20 Sep 2022 17:35:19 +0000 (19:35 +0200)]
linuxkpi: Add down_read_killable()

Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D36528
Sponsored by: Google, Inc. (GSoC 2022)

(cherry picked from commit f0b0f28f35e79d8777f4ba89d5065d3665b43866)

18 months agoiwlwifi: fix hang on unloading driver
Bjoern A. Zeeb [Tue, 22 Nov 2022 17:29:41 +0000 (17:29 +0000)]
iwlwifi: fix hang on unloading driver

f808c43ad9234670770601ba32a7426b00bbf528 introduced a FreeBSD specific
behaviour to wait for firmware load completion before returning from
loading the driver.  This does no longer allow iwl_drv_stop to detect
that startup has completed and it will wait indefinitely for a
completion event that will not happen.
We could change the complete() call to a complete_all() but to avoid
confusion, future side effects, and for simplicity daisy-chain two
complete events in FreeBSD.

PR: 267869
Reported by: Peter Much (pmc citylink.dinoex.sub.org)
Tested by: Peter Much (pmc citylink.dinoex.sub.org)
Sponsored by: The FreeBSD Foundation

(cherry picked from commit bee60c98974593d25aa18743f9413a78e0d57dc9)

18 months agoLinuxKPI: add memset_startat macro
Bjoern A. Zeeb [Mon, 14 Nov 2022 23:26:22 +0000 (23:26 +0000)]
LinuxKPI: add memset_startat macro

Add a memset_startat() macro which sets a pattern from a struct member
to the end of the struct.   Needed by a wireless driver.

Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D37389

(cherry picked from commit 5d310ea8c5f98bbf53078ec632f6441f54dc9e44)

18 months agoLinuxKPI: in efi.h include queue.h
Bjoern A. Zeeb [Tue, 15 Nov 2022 23:08:05 +0000 (23:08 +0000)]
LinuxKPI: in efi.h include queue.h

sys/linker.h needs sys/queue.h;  this gets another wireless driver
closer to compiling on main.

(cherry picked from commit 325ba120558e9ccfa9bb876c20d9c1a4463930e9)

18 months agoLinuxKPI: add virt_to_phys()
Bjoern A. Zeeb [Mon, 7 Nov 2022 13:31:39 +0000 (13:31 +0000)]
LinuxKPI: add virt_to_phys()

Add virt_to_phys() as a define to vtophys().
This is used by a wireless driver for dma related work; sigh.

Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D37301

(cherry picked from commit b5c3819c7b57d7e3aa94f1db779648bb9723c1f5)

18 months agoLinuxKPI: implement cpumask_of()
Bjoern A. Zeeb [Mon, 31 Oct 2022 14:33:58 +0000 (14:33 +0000)]
LinuxKPI: implement cpumask_of()

Add a static set of cpumasks for all (possible) cpus with only the one
indexed cpu enabled in each set.
This is needed for cpumask_of(_cpuid) which returns a cpumask (cpuset)
with only cpu _cpuid enabled and is used by one wireless driver at least.

Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D37223

(cherry picked from commit e2361e04b02aafa927c32c4f5a39e6fd96196082)

18 months agoLinuxKPI: 802.11: enable WME support
Bjoern A. Zeeb [Mon, 7 Nov 2022 12:39:46 +0000 (12:39 +0000)]
LinuxKPI: 802.11: enable WME support

Most of the WME code has been there disabled for months.  One of the
reasons was that it lead to crashes early on.  It is now understood
that the crashes are independent event and we can enable WME.
Update the code and deal with the calls from net80211 and adjust the
updates to when mac80211 drivers expect them, coherently put it under
LKPI_80211_WME and enable the define locally.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 4a67f1df8bdf70bc4a54ae212563dedfe4546e8d)

18 months agoLinuxKPI: add devm_request_irq()
Bjoern A. Zeeb [Sun, 30 Oct 2022 17:41:53 +0000 (17:41 +0000)]
LinuxKPI: add devm_request_irq()

Add devm_request_irq() needed by a driver.  Turns out all we need
is a wrapper with the right arguments to lkpi_request_irq().

Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D37217

(cherry picked from commit 6e8d6761312e92227a87e0e07b51f89ff81a24b3)

18 months agoLinuxKPI: add linux/leds.h
Bjoern A. Zeeb [Sun, 30 Oct 2022 17:05:52 +0000 (17:05 +0000)]
LinuxKPI: add linux/leds.h

This is just a dummy enum and struct in order to make drivers compile
more happily as some parts are simply not hidden behind #ifdefs and
this avoids a longer-term maintenance problem.

Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D37215

(cherry picked from commit a62d5ff5b04cb8657028c090764c3044178c4ccd)

18 months agoLinuxKPI: string.h implement memcpy_and_pad()
Bjoern A. Zeeb [Mon, 31 Oct 2022 22:17:00 +0000 (22:17 +0000)]
LinuxKPI: string.h implement memcpy_and_pad()

Add a memcpy variant which takes length of source and destination
buffers and a padding character in case there is free space in the
destination.  This is used by a wireless driver.

Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D37226

(cherry picked from commit 6a647ae51409cd56cc4a78d0a64ba3ff3aa3aac0)

18 months agoLinuxKPI: 802.11: pass internal variable to lkpi_80211_mo_sta_state()
Bjoern A. Zeeb [Mon, 31 Oct 2022 23:53:26 +0000 (23:53 +0000)]
LinuxKPI: 802.11: pass internal variable to lkpi_80211_mo_sta_state()

With mac80211 operations (MO) tracing on we have seen some ill-ordered
executions of MO functions.  In order to limit visibility of the mac80211
sta, pass the internal version into lkpi_80211_mo_sta_state() and only
there convert to the argument needed.  This mostly eases tracing and
debugging.

Sposnored by: The FreeBSD Foundation

(cherry picked from commit e7fe037310eda2018da6dde78e3be525d71bed03)

18 months agoLinuxKPI: 802.11 update header files
Bjoern A. Zeeb [Mon, 31 Oct 2022 22:09:25 +0000 (22:09 +0000)]
LinuxKPI: 802.11 update header files

Adjust struct members, add more (for HE dummy) defines, add more
(wrapper) functions in order to acoomodate another driver.

(cherry picked from commit 1d70218e9e1a27915a5d6ac434c226c8861f64f2)

18 months agoLinuxKPI: 802.11: update struct member types
Bjoern A. Zeeb [Mon, 31 Oct 2022 22:24:08 +0000 (22:24 +0000)]
LinuxKPI: 802.11: update struct member types

Update struct member types for ongoing work towards HT support.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 05e640dc9e13015735d25366fc0e088939f1e099)

18 months agoLinuxKPI: add timekeeping.h, another dummy (empty) header file
Bjoern A. Zeeb [Sun, 30 Oct 2022 17:21:26 +0000 (17:21 +0000)]
LinuxKPI: add timekeeping.h, another dummy (empty) header file

The file is included by a driver but it seems we don't need to implement
anything here.

(cherry picked from commit cca40d7cc737d4808b25a0a958169bf757f0ee1f)

18 months agoLinuxKPI: seq_file add "private" versions.
Bjoern A. Zeeb [Sat, 22 Oct 2022 18:07:37 +0000 (18:07 +0000)]
LinuxKPI: seq_file add "private" versions.

Add __seq_open_private() and seq_release_private() needed by iwlwifi
debugfs support.

Sponsored by: The FreeBSD Foundation
Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D37089

(cherry picked from commit b5a81075903b3d97265151960b731210c0e80244)

18 months agoLinuxKPI: 802.11: add MO tracing
Bjoern A. Zeeb [Sun, 23 Oct 2022 21:48:22 +0000 (21:48 +0000)]
LinuxKPI: 802.11: add MO tracing

Add a macro to each implemented mac80211 operation.  This currently
turns into a printf if LINUXKPI_80211_DEBUG is defined but in the
future could become a different probe as well.
This is helpful for quick analysis and boot-time problem debugging
when DTrace and other frameworks may be harder to use.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 64d3da006376576201677809474f8cebf061c81c)

18 months agoLinuxKPI: add MSEC_PER_SEC
Bjoern A. Zeeb [Sat, 22 Oct 2022 18:01:30 +0000 (18:01 +0000)]
LinuxKPI: add MSEC_PER_SEC

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

(cherry picked from commit d3975204e4af9b42af864ff27e8546ac767adfcd)

18 months agoLinuxKPI: 802.11: add changes to support debugfs in iwlwifi
Bjoern A. Zeeb [Sat, 22 Oct 2022 20:42:35 +0000 (20:42 +0000)]
LinuxKPI: 802.11: add changes to support debugfs in iwlwifi

Add new fields (also have to move a struct up, no changes there)
in order to make iwlwifi debugfs support compile.

Sposnored by: The FreeBSD Foundation

(cherry picked from commit 0080f30ff16ec955f2b8b400c1c89645d6ef65ec)

18 months agoiwlwifi: prepare to support debugfs
Bjoern A. Zeeb [Sat, 22 Oct 2022 17:40:17 +0000 (17:40 +0000)]
iwlwifi: prepare to support debugfs

Import two files left out initially from the driver needed for debugfs
support [1].  Adjust the driver further to make it compile on FreeBSD.
This is currently turned off and needs more LinuxKPI/lindebugfs work.
Being in the tree will allow us to collaboratively work on it and
then we can enable it for good.

Obtained from: Linux wireless-testing (tag: wt-2022-10-19) [1]
2c9078b9abcb884e27360340aaa7dfd4c0de29b3
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 92daf3a606e655f3db4508c76c733c340d9d3a68)

18 months agoiwlwifi: constify another argument of iwl_print_hex_dump()
Bjoern A. Zeeb [Sat, 22 Oct 2022 17:33:18 +0000 (17:33 +0000)]
iwlwifi: constify another argument of iwl_print_hex_dump()

This is needed when enabling debugfs as it passes a const in which
would otherwise be dropped.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 71ebd2d00b9618325ef6d0bb8c224d3d5f32160a)

18 months agoRemove disused /cdrom toplevel dir from hier(7).
Pau Amma [Tue, 22 Nov 2022 22:56:46 +0000 (22:56 +0000)]
Remove disused /cdrom toplevel dir from hier(7).

While here, fix igor and mandoc -T lint low-hanging fruit in hier(7)

Reviewed by: danfe (D37473), gjb (mentor)
Approved by: gjb (mentor)
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D37472
Differential Revision: https://reviews.freebsd.org/D37473

(cherry picked from commit 720e0e0ff1d3d47bd8a5a7bb23353e4b5da71048)
(cherry picked from commit 88be8b8e54797db2fc0c3134890d1918aea2c087)

18 months agoamd64 libc: add missed GNU-stack annotation to memmove/memcpy
Konstantin Belousov [Fri, 18 Nov 2022 02:24:34 +0000 (04:24 +0200)]
amd64 libc: add missed GNU-stack annotation to memmove/memcpy

(cherry picked from commit ae507c25de5ab327fca6578d2bd015aa4792b20d)

18 months agolibm: Add feenableexcept and fedisableexcept to library on powerpc
Justin Hibbits [Fri, 13 May 2022 22:18:25 +0000 (17:18 -0500)]
libm: Add feenableexcept and fedisableexcept to library on powerpc

Summary:
These functions are missing from the library itself, and exist solely in
the header.  This breaks a few ports that expect libm to have the
symbols in the library itself.

Reviewers: imp, emaste, kib

Reviewed By: kib

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

(cherry picked from commit 448c505c33cc334193590f3844406d6a74f26e2a)

18 months agomsun fixes for SPE
Justin Hibbits [Wed, 5 May 2021 14:20:56 +0000 (09:20 -0500)]
msun fixes for SPE

Summary:
Fix FPU exception management for powerpcspe.  Bits are in a different place from
the standard FPSCR, so we need to handle the shifting differences.  Also,
there's no concept of a "software exception" raise, so we need to do exceptional
math to trigger the exception from software.

Reviewed By: alfredo
Differential Revision: https://reviews.freebsd.org/D22824

(cherry picked from commit 6640579610856168a64e12c097ce012c46648e00)

18 months agoDon't panic when tasting a disk with sectorsize=0
Alan Somers [Wed, 9 Nov 2022 02:59:50 +0000 (19:59 -0700)]
Don't panic when tasting a disk with sectorsize=0

This can sometimes happen with broken HDDs.

Sponsored by: Axcient
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D37313

(cherry picked from commit 05d0f4308caaa3e9b8cbcbb30b2d7f39dd367a57)

18 months agoctld: if adding a target fails, retry it on the next reload
Alan Somers [Wed, 12 Oct 2022 22:44:09 +0000 (16:44 -0600)]
ctld: if adding a target fails, retry it on the next reload

If the admin creates more CTL ports than kern.cam.ctl.max_ports, then
adding some will fail.  If he then removes some ports and does
"service ctld reload", he would expect that the new ports would get
added in the newly-freed port space. But they don't, because ctld
assigned them port numbers during their first creation attempts.

Fix this bug by removing newly created ports from ctld's internal list
if the kernel rejects them for any reason.  That way, a subsequent
config reload will attempt to add them again, possibly with new port
numbers.

Sponsored by: Axcient
Reviewed by: jhb, mav
Differential Revision: https://reviews.freebsd.org/D36974

(cherry picked from commit 15b3e3bb7efcbf7c29ab76e9ea7990c17df790e6)

18 months agofusefs: fix VOP_ADVLOCK with SEEK_END
Alan Somers [Tue, 11 Oct 2022 23:00:07 +0000 (17:00 -0600)]
fusefs: fix VOP_ADVLOCK with SEEK_END

When the user specifies SEEK_END, unlike SEEK_CUR, VOP_ADVLOCK must
adjust lock offsets itself.

Sort-of related to bug 266886.

Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D37040

(cherry picked from commit f6e5319550f60170840f1a07a9cbdd45b5014a21)

18 months agobhyve/kdblayout: add some missing keys to german layout
Corvin Köhne [Tue, 15 Nov 2022 06:46:09 +0000 (07:46 +0100)]
bhyve/kdblayout: add some missing keys to german layout

The '/' and '§' keys are missing in the german keyboard layout.

Reviewed by: markj
Approved by: manu (mentor)
MFC after: 1 week
Sponsored by: Beckhoff Automation GmbH & Co. KG
Differential Revision: https://reviews.freebsd.org/D37386

(cherry picked from commit eff8d0347713c52bed70179610df1be7c8badbe6)

18 months agopkgbase: bhyve: Tag the kbdlayout file to be in the bhyve package
Emmanuel Vadot [Wed, 26 Jan 2022 12:17:52 +0000 (13:17 +0100)]
pkgbase: bhyve: Tag the kbdlayout file to be in the bhyve package

(cherry picked from commit 9acd521dbd0a7f37d282096647ae2785a37e9cb1)

18 months agobhyve: Fix some warnings in the ps2 emulation code
Mark Johnston [Sat, 22 Oct 2022 17:35:40 +0000 (13:35 -0400)]
bhyve: Fix some warnings in the ps2 emulation code

- Include headers containing prototypes for exported functions.
- Initialize all fields of the extended translation table.
- Qualify an unexported translation table as static.
- Fix error handling for a read(2).
- Fix some style bugs.

No functional change intended.

MFC after: 1 week

(cherry picked from commit 33dfef5cf3df138026491ac5725d55a23ae410f7)

18 months agoAppend Keyboard Layout specified option for using VNC.
Michael Reifenberger [Thu, 20 Jan 2022 22:44:04 +0000 (23:44 +0100)]
Append Keyboard Layout specified option for using VNC.
Part two: Append bhyve -K option for specified keyboard layout
with layout setting files every languages.
Since the cmd option '-k' was used in the meantime
it was changed to '-K'

PR: 246121
Submitted by: koinec@yahoo.co.jp
Reviewed by: grehan@
Differential Revision: https://reviews.freebsd.org/D29473

MFC after: 4 weeks

(cherry picked from commit 19eaa01beaba68ed4c70c44127955f5c9b331cb9)

18 months agoAppend Keyboard Layout specified option for using VNC.
Michael Reifenberger [Wed, 21 Apr 2021 10:38:26 +0000 (12:38 +0200)]
Append Keyboard Layout specified option for using VNC.
Part one: supporting QEMU Extended Keyboard Event Message

PR:             246121
Submitted by:   koinec@yahoo.co.jp
Differential Revision: https://reviews.freebsd.org/D29430

(cherry picked from commit b563ff5d4f812df198ade6991834782a5d35af08)

18 months agonvmecontrol: Fix condition when print number of Firmware Slots and Firmware Slot1...
Wanpeng Qian [Mon, 14 Nov 2022 12:59:11 +0000 (13:59 +0100)]
nvmecontrol: Fix condition when print number of Firmware Slots and Firmware Slot1 Readonly.

The Number of Firmware Slots should never be zero. So, a Firmware Slot 1
should always exist. For that reason, always print the Number of
Firmware Slots and the Firmware Slot 1 Read-Only value.

Reviewed by: imp
Approved by: manu (mentor)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D34700

(cherry picked from commit 0fd43b0c6a76d7be4d9673837a7d7099b6a29ace)

18 months agobhyve: abort and return FEATURE_NOT_SAVEABLE while set feature with a save flag for...
Wanpeng Qian [Mon, 14 Nov 2022 13:02:44 +0000 (14:02 +0100)]
bhyve: abort and return FEATURE_NOT_SAVEABLE while set feature with a save flag for NVMe controller.

Currently bhyve's NVMe controller cannot save feature values cross
reboot. It should return a FEATURE_NOT_SAVEABLE error when the command
specifies a save flag.

Quote from NVMe specification, page 205:

https://nvmexpress.org/wp-content/uploads/NVM-Express-1_4-2019.06.10-Ratified.pdf

If the Feature Identifier specified in the Set Features command is not
saveable by the controller and the controller receives a Set Features
command with the Save bit set to one, then the command shall be aborted
with a status of Feature Identifier Not Saveable.

Reviewed by: chuck (older version)
Approved by: manu (mentor)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D32767

(cherry picked from commit 8ab99dbea16728f3e34137310587a6aeb3f3d317)

18 months agobhyve: return FEATURE_NOT_CHANGEABLE for unimplemented feature of NVMe controller
Wanpeng Qian [Mon, 14 Nov 2022 13:06:34 +0000 (14:06 +0100)]
bhyve: return FEATURE_NOT_CHANGEABLE for unimplemented feature of NVMe controller

Set Feature is a feature specified function. Currently only some
features have the set procedure. For features that are not handled by
the controller, we should return a FEATURE_NOT_CHANGEABLE error message.

Approved by: manu (mentor)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D32802

(cherry picked from commit 05a21658eb15463af9427fc1f7825b2aa244b9d5)

18 months agobhyve: nvme controller obey async event setting when reporting critical temperature
Wanpeng Qian [Mon, 14 Nov 2022 13:08:52 +0000 (14:08 +0100)]
bhyve: nvme controller obey async event setting when reporting critical temperature

Async event report is controlled by async event configuration feature
setting. When reporting a critical temperature warning, check the async
event configuration.

Approved by: manu (mentor)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D37355

(cherry picked from commit 10846c53c4569bdf6d6e2b88739a56a8273bce7f)

18 months agodhclient(8): Verify lease-, renewal- and rebinding-time option sizes.
Hans Petter Selasky [Mon, 14 Nov 2022 14:20:09 +0000 (15:20 +0100)]
dhclient(8): Verify lease-, renewal- and rebinding-time option sizes.

Else out-of-bound reads and undefined behaviour may happen.
The current code only checked for the presence of the first of four bytes.
Make sure the fields in question have the minium size required.

No functional change intended.

Reviewed by: rrs@
Sponsored by: NVIDIA Networking

(cherry picked from commit 3492caf512ae090816b4ffa275be43b2f5cfc460)

18 months agogeom_part: Check number of GPT entries and size of GPT entry
Zhenlei Huang [Tue, 18 Oct 2022 15:03:02 +0000 (11:03 -0400)]
geom_part: Check number of GPT entries and size of GPT entry

Current specification does not have upper limit of the number of
partition entries and the size of partition entry. In
799eac8c3df597179bbb3b078362f3ff03993a1a Andrey V. Elsukov introduced a
limit maximum number of GPT entries to 4k, but that is for write routine
(gpart create) only. When attaching disks that have large number of GPT
entries exceeding the limit, or disks with large size of partition
entry, it is still possible to exhaust kernel memory.

1. Reuse the limit of the maximum number of partition entries.
2. Limit the maximum size of GPT entry to 1k.

In current specification (2.10) the size of GPT entry is 128 *
2^n while n >= 0, and the size - 128 is reserved. 1k should be
sufficient enough for foreseen future.

PR: 266548
Discussed with: imp
Reviewed by: markj
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D36717

(cherry picked from commit 5be5d0d5cb2657d7668f4ca0f8543198cf8d759b)

18 months agobhyve: Simplify control flow in the xhci device model
Mark Johnston [Mon, 14 Nov 2022 20:08:45 +0000 (15:08 -0500)]
bhyve: Simplify control flow in the xhci device model

We only need to call pci_xhci_xfer_complete() when handling a transfer
to the control endpoint, so move that code into the epid == 1 block and
eliminate a goto.  Also remove an unneeded reinitialization of
setup_trb.

No functional change intended.

MFC after: 1 week
Reviewed by: corvink, jhb
Differential Revision: https://reviews.freebsd.org/D37287

(cherry picked from commit c4c368fb3ecc426660f79b1c25f18d0401ff96fc)

18 months agoksan: Build sanitizer runtimes without stack-smashing protection
Mark Johnston [Mon, 7 Nov 2022 21:07:26 +0000 (16:07 -0500)]
ksan: Build sanitizer runtimes without stack-smashing protection

On arm64 with per-thread stack canaries enabled (the PERTHREAD_SSP
option), the compiler may load curthread->td_md.md_canary in function
prologues.  This is not safe in data_abort(); see commit 2c10be9e06d4.
Thus, sanitizer runtimes must also avoid accessing the current thread's
canary.

Since SSP has limited utility in sanitizer runtimes, simply disable it
unconditionally to avoid unpleasant surprises in the future.

MFC after: 2 weeks
Sponsored by: Juniper Networks, Inc.
Sponsored by: Klara, Inc.

(cherry picked from commit 3c0e9169a357f6d99b80c02dd27210d742797cf2)

18 months agovirtio: Silence a -Wunused warning
Mark Johnston [Mon, 14 Nov 2022 20:07:34 +0000 (15:07 -0500)]
virtio: Silence a -Wunused warning

Remove virtio_swap_endian().  htole*() are nops on little-endian
platforms.  No functional change intended.

MFC after: 1 week
Reviewed by: corvink, jhb
Differential Revision: https://reviews.freebsd.org/D37298

(cherry picked from commit db494ceb65ef301c8fb48f57b60c4f7a9cfebba5)

18 months agoiommu_gas: drop fini cleanup loop
Doug Moore [Sat, 29 Oct 2022 17:56:06 +0000 (12:56 -0500)]
iommu_gas: drop fini cleanup loop

Assertions suggest that the loop in iommu_gas_fini_domain is executed
zero times, so remove it.

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

(cherry picked from commit a2c57c60d9e2667744357fdadd79a98ce64d3ad9)

18 months agoiommu_gas: start space search from 1st free space
Doug Moore [Sat, 29 Oct 2022 05:50:44 +0000 (00:50 -0500)]
iommu_gas: start space search from 1st free space

Maintain a pointer to an element in the domain map that is left of any
sufficiently large free gap in the tree and start the search for free
space there, rather than at the root of the tree. On find_space, move
that pointer to the leftmost leaf in the subtree of nodes with
free_down greater than or equal to the minimum allocation size before
starting the search for space from that pointer. On removal of a node
with address less than that pointer, update that pointer to point to
the predecessor or successor of the removed node.

In experiments with netperf streaming, this reduces by about 40% the
number of map entries examined in first-fit allocation.

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

(cherry picked from commit 8b221ca631c2d28584a4b6207dc107d8ff5a1b2f)

18 months agotcp_rack: Add a manual page
Gordon Bergling [Mon, 7 Nov 2022 11:28:39 +0000 (12:28 +0100)]
tcp_rack: Add a manual page

- add a manual page for tcp_rack(4)
- link it in the tcp(4) and tcp_bbr(4) man pages
- hook it up to build in the Makefile

Reviewed by: pauamma
Differential Revision: https://reviews.freebsd.org/D37209

(cherry picked from commit bdbc05bea995d73465def1ab31bb3b2b37b37a93)

18 months agoFix for tunefs(8) unable to add a UFS/FFS soft update journal.
Kirk McKusick [Sat, 12 Nov 2022 23:36:07 +0000 (15:36 -0800)]
Fix for tunefs(8) unable to add a UFS/FFS soft update journal.

The reported bug is UFS: bad file descriptor: soft update journaling
can not be enabled on some FreeBSD-provided disk images – failed
to write updated cg.

The UFS library (libufs(3)) failed to reopen its disk descriptor
when first attempting to update a cylinder group. The error only
occurred when trying to add journaling to a filesystem whose first
cylinder group was too full to hold the journal.

PR:           259090
MFC after:    1 week
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 5c7ba6bdf83fda82cce70f384e2ec8218f13002e)

18 months agoUpdate pkgbase metalog tool README to match installed filename
Ed Maste [Wed, 16 Nov 2022 19:31:26 +0000 (14:31 -0500)]
Update pkgbase metalog tool README to match installed filename

The pkgbase metalog tool is named metalog_reader.lua.  (One may argue
that a better name could be chosen, but the README should match in any
case.)

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 1f3b4f38a6803019dadb3baba8d4be159924671a)

18 months agopkgbase: report type for duplicated METALOG entries
Ed Maste [Thu, 17 Nov 2022 14:15:20 +0000 (09:15 -0500)]
pkgbase: report type for duplicated METALOG entries

Duplicate METALOG file entries are more of a concern than duplicate
directories.  The metalog check tool previously did not include the
entry type in the warnings, making it hard to find the ones of concern.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit b751fc75bb989ea737c9f1c440d2601e1ed95092)

18 months agopkgbase: examine METALOG files relative to stage root directory
Ed Maste [Wed, 16 Nov 2022 19:53:42 +0000 (14:53 -0500)]
pkgbase: examine METALOG files relative to stage root directory

Previously we stripped the '.' from the beginning of each METALOG entry
to determine the path to stat.  This meant that we examined files on the
build host, not the staged files.

Instead, strip off the last part of the specified METALOG pathname to
find the stage root directory, and stat files relative to that.

Reviewed by: bapt
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D37412

(cherry picked from commit bca4d27052bf5735725449cd0be51bd58cf0cb80)

18 months agobuild: Use `rm -fv` for BATCH_DELETE_OLD_FILES
Ed Maste [Mon, 24 Oct 2022 18:06:41 +0000 (14:06 -0400)]
build: Use `rm -fv` for BATCH_DELETE_OLD_FILES

It's possible to have files with odd permissions in the tmproot (or
sysroot), causing rm to prompt for each one during e.g. buildworld.
Add -f to forcibly delete these.

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

(cherry picked from commit 470fb726f3d242fed42592bc59263c9d49226073)

18 months agosshd: sync tracing disable with upstream
Ed Maste [Mon, 7 Nov 2022 17:17:15 +0000 (12:17 -0500)]
sshd: sync tracing disable with upstream

Old versions of FreeBSD do not support using id 0 to refer to the
current pid for procctl, so pass getpid() explicitly.

Although this is not required in current FreeBSD branches I am merging
it to reduce differences with upstream.

Obtained from: OpenSSH commit 0f7e1eba5525

(cherry picked from commit 4232f36eda60406642fc6cfef605b6d38fc0a7c0)
(cherry picked from commit 733bf3b108f8b69295778bab5f7d680b9a8e6dba)

18 months agognu diff3: apply patch to committed src, rather than at build time
Ed Maste [Fri, 11 Nov 2022 19:48:40 +0000 (14:48 -0500)]
gnu diff3: apply patch to committed src, rather than at build time

This appears to be a leftover from the time we used a less-capable VCS.

Reviewed by: delphij
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D37368

(cherry picked from commit 3a13b5ac83a100ebb5a0da0579e418f19b3b630b)

18 months agobhyve nvme: Check return value of mapped memory
Chuck Tuffli [Sun, 14 Aug 2022 14:45:21 +0000 (07:45 -0700)]
bhyve nvme: Check return value of mapped memory

Fuzzing of bhyve using hyfuzz discovered a way to cause a segmentation
fault in the NVMe emulation. If a guest specifies a physical address in
either the PRP1 or PRP2 field of a command that cannot be mapped from
guest to host, the function paddr_guest2host() returns a NULL pointer.
The NVMe emulation did not check for this error case, which allowed for
the segmentation fault to occur.

Fix is to check for a return value of NULL and indicate an error back to
the guest (Data Transfer error). While in the area, slightly refactor
the write/read blockif function to use a common error exit path.

PR: 256317,256319,256320,256321,256322

(cherry picked from commit 3d3678627c3112c94d174a8c51d8c058d02befb3)

18 months agobhyve nvme: Switch to POSIX standard functions
Chuck Tuffli [Wed, 17 Aug 2022 00:16:06 +0000 (17:16 -0700)]
bhyve nvme: Switch to POSIX standard functions

Switch bzero to memset and bcopy to memcpy

(cherry picked from commit 6391be30894460c03a70e0321e99b2bdcda8eebf)

18 months agobhyve nvme: Support minimal Controller list
Chuck Tuffli [Tue, 16 Aug 2022 16:15:53 +0000 (09:15 -0700)]
bhyve nvme: Support minimal Controller list

Controllers must support the Identify Controller list if they support
Namespace Management. But the UNH NVMe tests use this command regardless
of whether the device under test supports Namespace Management.

This implementation returns an empty Controller list (i.e., Number of
Identifiers is zero).

Fixes UNH Test 1.1.2

(cherry picked from commit 715f82e4f5c51c04314904dee8090c8abbbe2156)

18 months agobhyve nvme: Fix reported SANICAP value
Chuck Tuffli [Tue, 16 Aug 2022 16:14:43 +0000 (09:14 -0700)]
bhyve nvme: Fix reported SANICAP value

The NVMe specification only allows Controllers compliant with the
revision 1.3 and earlier specification to report a value of 0x0 in the
No-Deallocate Modifies Media After Sanitize (NODMMAS) field.

For our revision 1.4 Controller, report that media is not modified after
Sanitize as the implementation does not implement Sanitize.

Fixes UNH Test 1.1.2

(cherry picked from commit ec0efe34dd486359d57bc1e792a0e4f9280f66d7)

18 months agobhyve nvme: Fix firmware read only initialization
Wanpeng Qian [Sun, 14 Aug 2022 15:30:06 +0000 (08:30 -0700)]
bhyve nvme: Fix firmware read only initialization

Summary:
Code was using the mask value without the shift.

Test Plan: Within FreeBSD/Linux guest, Identify NVMe controller to check the result.

(cherry picked from commit 9f678cfcb42d1d0ce3898b0e38bb147a3e14834a)

18 months agobhyve: Fix Number of Power States Supported value
WanpengQian [Sun, 14 Aug 2022 15:26:42 +0000 (08:26 -0700)]
bhyve: Fix Number of Power States Supported value

Summary:
Set Number of Power States Supported to indicate 1 power state. Keep the
Power State Descriptor data structures as zero to indicate "Not
reported".

Test Plan:
Within FreeBSD/Linux guests, list the number of power states and check
the Max Power value.

(cherry picked from commit eae0210cdd2e22c2eb9bc652f2136b3386a663a4)

18 months agobhyve nvme: Fix out-of-bound IOV array access
Chuck Tuffli [Thu, 9 Jun 2022 18:19:32 +0000 (11:19 -0700)]
bhyve nvme: Fix out-of-bound IOV array access

Summary:
NVMe operations indicate the memory region(s) associated with a command
via physical region pages (PRPs). Since each PRP has a fixed size,
contiguous memory regions larger than the PRP size require multiple PRP
entries.

Instead of issuing a blockif call for each PRP, the NVMe emulation
concatenates multiple contiguous PRP entries into a single blockif
request. The test for contiguous regions has a bug such that it
mistakenly treats an initial PRP address of zero as a contiguous range
and concatenates it with the previous. But because there is no previous
IOV, the concatenation code corrupts the IO request structure and leads
to a segmentation fault when the blockif request completes.

Fix is to test for the existence of a previous range before trying to
concatenate the current range with the previous one.

While in the area, rename pci_nvme_append_iov_req()'s lba parameter to
offset to match its usage.

PR:             264177

(cherry picked from commit 88951aaaee73b87121b0f121224fe188a5b5e6e3)

18 months agowait for device mounts in zpool and dumpon
Chuck Tuffli [Fri, 5 Mar 2021 16:13:23 +0000 (08:13 -0800)]
wait for device mounts in zpool and dumpon

If the root file system is composed from multiple devices, wait for
devices to be ready before running zpool and dumpon rc scripts.

An example of this is if the bulk of the root file system exists on a
fast device (e.g. NVMe) but the /var directory comes from a ZFS dataset
on a slower device (e.g. SATA). In this case, it is possible that the
zpool import may run before the slower device has finished being probed,
leaving the system in an intermediate state.

Fix is to add root_hold_wait to the zpool and dumpon (which has a
similar issue) rc scripts.

PR: 242189

(cherry picked from commit f30f11f878fe2aa535cd286810d31c92793a3d95)

18 months agobhyve: Define an accessor for net backend private data
Mark Johnston [Fri, 11 Nov 2022 15:01:40 +0000 (10:01 -0500)]
bhyve: Define an accessor for net backend private data

Use it to silence warnings about potential unaligned accesses.  No
functional change intended.

Reviewed by: corvink, jhb
Differential Revision: https://reviews.freebsd.org/D37289

(cherry picked from commit 0ced97acb05197cb2ef30932786eab0512f77e07)

18 months agoFix to b999366aab4e for compilation on i386.
Kirk McKusick [Fri, 18 Nov 2022 05:03:01 +0000 (21:03 -0800)]
Fix to b999366aab4e for compilation on i386.

Reported by: jenkins, Philip Paeps

18 months agoOpenSSL: Regen assembly file for OpenSSSL 1.1.1s
Jung-uk Kim [Tue, 1 Nov 2022 23:12:09 +0000 (19:12 -0400)]
OpenSSL: Regen assembly file for OpenSSSL 1.1.1s

(cherry picked from commit f443d0802a21279387596ec2c9644d3e91ca0431)

18 months agoOpenSSL: Regen manual pages for OpenSSL 1.1.1s
Jung-uk Kim [Tue, 1 Nov 2022 23:38:40 +0000 (19:38 -0400)]
OpenSSL: Regen manual pages for OpenSSL 1.1.1s

(cherry picked from commit 93381ae06bb043a85d6b26459b511ccacc2045e2)

18 months agoOpenSSL: Merge OpenSSL 1.1.1s
Jung-uk Kim [Tue, 1 Nov 2022 22:58:59 +0000 (18:58 -0400)]
OpenSSL: Merge OpenSSL 1.1.1s

(cherry picked from commit cfc39718e9cc18943a6f8428c560b02c6f590b16)

18 months agortld: add support for the $LIB token
Konstantin Belousov [Thu, 10 Nov 2022 16:35:00 +0000 (18:35 +0200)]
rtld: add support for the $LIB token

MFC note: the arm soft case is not handled, it is probably worth
expanding $LIB to libsoft there.

(cherry picked from commit 8cc44a1e59f648eb5bea5afe6d9aa1d7f927c9d7)

18 months agostand: Compile out the extensive superblock diagnostic messages for BIOS loader
Warner Losh [Fri, 12 Aug 2022 17:08:36 +0000 (11:08 -0600)]
stand: Compile out the extensive superblock diagnostic messages for BIOS loader

The BIOS loader operates in a very constrained environment. The messages
for the super block integrity tests take up about 12k of space. Compile
them out for the BIOS loader, while leaving it intact for all other
loaders that aren't space constrained. These aren't used in the 'super
tiny' *boot* programs, so no adjustment is needed there.

We reply on the fact that (a) i386 doesn't support 32-bit UEFI booting
and (b) LIBSA_CPUARCH is "i386" when building on both i386 and when
we're building the 32-bit libsa32 library.

This saves about 12k of space for this constrained envrionment and will
take a bit of the pressure off some machines where the loader has grown
too big for their BIOS (see comments in i386/loader/Makefile for
details).

Sponsored by: Netflix
Reviewed by: mckusick
Differential Revision: https://reviews.freebsd.org/D36175

(cherry picked from commit 148211300870b3bd558bf70dc3bf7d7f78c657aa)

18 months agoDo comprehensive UFS/FFS superblock integrity checks when reading a superblock.
Kirk McKusick [Fri, 27 May 2022 19:21:11 +0000 (12:21 -0700)]
Do comprehensive UFS/FFS superblock integrity checks when reading a superblock.

Historically only minimal checks were made of a superblock when it
was read in as it was assumed that fsck would have been run to
correct any errors before attempting to use the filesystem. Recently
several bug reports have been submitted reporting kernel panics
that can be triggered by deliberately corrupting filesystem superblocks,
see Bug 263979 - [meta] UFS / FFS / GEOM crash (panic) tracking
which is tracking the reported corruption bugs.

This change upgrades the checks that are performed. These additional
checks should prevent panics from a corrupted superblock. Although
it appears in only one place, the new code will apply to the kernel
modules and (through libufs) user applications that read in superblocks.

Reported by:  Robert Morris and Neeraj
Reviewed by:  kib
Tested by:    Peter Holm
PR:           263979
Differential Revision: https://reviews.freebsd.org/D35219

(cherry picked from commit 076002f24d35962f0d21f44bfddd34ee4d7f015d)
(cherry picked from commit bc218d89200faa021def77732f3d9fde4f4dee13)
(cherry picked from commit 800a53b445e7eb113ba193b1ac98631299178529)
(cherry picked from commit 50dc4c7df4156863148e6a9609c03e852e2aeb35)
(cherry picked from commit f3f5368dfbef4514686ba2d67f01f314b275227e)
(cherry picked from commit 9e1f44d044a58fcd2caaca3f57e69cf6180db3dc)
(cherry picked from commit 5bc926af9fd1c47f74356734f731c68145e31c6f)
(cherry picked from commit 904347a00c1f9a29f3b17e6e676805036d2494f1)
(cherry picked from commit 36e08b0127f97928a2f2c062feed8df9087b2b35)
(cherry picked from commit 548045bf57c46cb2f4d43d3d7fa5d8ad37ec7f9a)
(cherry picked from commit 3e40d2cc61a00a7d69e99b0fda4040cd1df04c57)
(cherry picked from commit 184e3118c1057a97e16230baf0f0433adeeed723)
(cherry picked from commit f0be378a66a75ebf335e9388ef0d319a70064d94)
(cherry picked from commit 9dee5da7450e8530c9fec51c9a16ecd42da78e55)
(cherry picked from commit 82ee4e1c42d70345cbaa1f6dd1874ae98a004910)
(cherry picked from commit dcdba3460dd779a0180ec7769ab8cd47c932799e)
(cherry picked from commit 017367c1146a69baca6a1a0bea10b0cb02c72d85)
(cherry picked from commit 8435a9b20684ba8bcda3df31d06b4d5eac9431a7)

18 months agoheimdal: Fix: Too large time skew, client time 1970-01-01T01:00:00
Cy Schubert [Thu, 17 Nov 2022 15:43:29 +0000 (07:43 -0800)]
heimdal: Fix: Too large time skew, client time 1970-01-01T01:00:00

Part of ed549cb0c53f zeroed out a data structure in the resulting code-file
when a TUTCTime type was freed. This part of the patch applies to Heimdal
7.1+ and not our Heimdal 1.5.2.

PR: 267827
Reported by: Peter Much <pmc@citylink.dinoex.sub.org>
Tested by: Peter Much <pmc@citylink.dinoex.sub.org>
Fixes: ed549cb0c53f

(cherry picked from commit f556a05c49261af3d373c599d05fa250f3563b59)

18 months agoipfilter: Document count_mask_bits() arguments
Cy Schubert [Mon, 14 Nov 2022 23:58:02 +0000 (15:58 -0800)]
ipfilter: Document count_mask_bits() arguments

Document arguments input to count_mask_bits().

(cherry picked from commit 1ffab636dac8e52d4b3d5a2cb40c93a229404ffd)

18 months agoixgbe: workaround errata about UDP frames with zero checksum
Andrey V. Elsukov [Thu, 10 Nov 2022 09:34:40 +0000 (12:34 +0300)]
ixgbe: workaround errata about UDP frames with zero checksum

Intel 82599 has errata related to IPv4 UDP frames with zero checksum.
It reports such datagrams with L4 integrity errors in IXGBE_XEC
register. And after afb1aa4e6df2 commit such errors are reported
via IFCOUNTER_IERRORS. This confuses users, since actually all frames
are handled correctly by the system.
To workaround the problem, let's ignore the XEC register value for
82599 cards for now.

PR: 266048
Discussed with: erj
Sponsored by: Yandex LLC

(cherry picked from commit 8526120ad41ca47367b43f8f4459e0fa61285571)

18 months agonfsd: Make the pNFS server update Change for Setxattr/Rmxattr
Rick Macklem [Tue, 18 Oct 2022 22:47:07 +0000 (15:47 -0700)]
nfsd: Make the pNFS server update Change for Setxattr/Rmxattr

When the NFS server does the Setxattr or Rmxattr operation,
the Change attribute (va_filerev) needs to be updated.

Without this patch, that was not happening for the
pNFS server configuration.  This patch does a Setattr
against the DS file to make the Change attribute
change.

This bug was discovered during a recent IETF NFSv4 testing
event, where the Change attribute wasn't changed in the
operation reply.

(cherry picked from commit ae7816576e44412a8ae9daa92c210a6ba4f269dc)

18 months agonfsd: Make Setxattr/Removexattr NFSv4.2 ops IO_SYNC
Rick Macklem [Sun, 16 Oct 2022 20:27:32 +0000 (13:27 -0700)]
nfsd: Make Setxattr/Removexattr NFSv4.2 ops IO_SYNC

When the NFS server does Setxattr or Removexattr, the
operations must be done IO_SYNC. If a server
crashes/reboots immediately after replying it must
have the extended attribute changes.

Since UFS does extended attributes asynchronously
by default and there is no "ioflag" argument in
the VOP calls, follow the VOP calls with VOP_FSYNC(),
to ensure the operation has been done synchronously.

This was found by inspection while investigating a
bug discovered during a recent IETF NFSv4 testing
event, where the Change attribute wasn't changed
in the operation reply.

This bug will take further work for ZFS and the
pNFS server configuration, but is now fixed for
a non-pNFS UFS exported file system.

(cherry picked from commit 8063dc03202fad7d6bdf34976bc8556fa3f23fa1)

18 months agoheimdal: Fix multiple security vulnerabilities
Cy Schubert [Tue, 8 Nov 2022 08:53:29 +0000 (00:53 -0800)]
heimdal: Fix multiple security vulnerabilities

The following issues are patched:

 - CVE-2022-42898 PAC parse integer overflows
 - CVE-2022-3437 Overflows and non-constant time leaks in DES{,3} and arcfour
 - CVE-2021-44758 NULL dereference DoS in SPNEGO acceptors
 - CVE-2022-44640 Heimdal KDC: invalid free in ASN.1 codec

    Note that CVE-2022-44640 is a severe vulnerability, possibly a 10.0
    on the Common Vulnerability Scoring System (CVSS) v3, as we believe
    it should be possible to get an RCE on a KDC, which means that
    credentials can be compromised that can be used to impersonate
    anyone in a realm or forest of realms.

    Heimdal's ASN.1 compiler generates code that allows specially
    crafted DER encodings of CHOICEs to invoke the wrong free function
    on the decoded structure upon decode error.  This is known to impact
    the Heimdal KDC, leading to an invalid free() of an address partly
    or wholly under the control of the attacker, in turn leading to a
    potential remote code execution (RCE) vulnerability.

    This error affects the DER codec for all extensible CHOICE types
    used in Heimdal, though not all cases will be exploitable.  We have
    not completed a thorough analysis of all the Heimdal components
    affected, thus the Kerberos client, the X.509 library, and other
    parts, may be affected as well.

    This bug has been in Heimdal's ASN.1 compiler since 2005, but it may
    only affect Heimdal 1.6 and up.  It was first reported by Douglas
    Bagnall, though it had been found independently by the Heimdal
    maintainers via fuzzing a few weeks earlier.

    While no zero-day exploit is known, such an exploit will likely be
    available soon after public disclosure.

 - CVE-2019-14870: Validate client attributes in protocol-transition
 - CVE-2019-14870: Apply forwardable policy in protocol-transition
 - CVE-2019-14870: Always lookup impersonate client in DB

Sponsored by: so (philip)
Obtained from: so (philip)
Tested by: philip, cy

(cherry picked from commit ed549cb0c53f8438c52593ce811f6fcc812248e9)

18 months agoascii.7: Add full names of the control character set
Gordon Bergling [Sat, 12 Nov 2022 11:22:22 +0000 (12:22 +0100)]
ascii.7: Add full names of the control character set

Extent the manual page by the full names of the
control character set.

Obtained from: NetBSD

(cherry picked from commit b6d1ac7f01f35ff3c44f65d197414f92356e932b)

18 months agovipw.8: Add a FILES section
Gordon Bergling [Sat, 12 Nov 2022 11:56:29 +0000 (12:56 +0100)]
vipw.8: Add a FILES section

Mention passwd related files in the FILES section
of vipw(8).

Obtained from: OpenBSD

(cherry picked from commit 30a6c8a3a8a65074e531010f4adc8c1559f954ac)

18 months ago<crypto/chacha20_poly1305>: Fix operations with 8 byte nonce.
John Baldwin [Tue, 15 Nov 2022 01:24:56 +0000 (17:24 -0800)]
<crypto/chacha20_poly1305>: Fix operations with 8 byte nonce.

In head, the inline ChaCha20+Poly1305 API is implemented using the
software implementation backing OCF, but that requires API changes
that can't be MFC'd.  As a result, this API in stable/13 uses
libsodium directly.

However, libsodium's version of ChaCha20+Poly1305 with an 8 byte nonce
uses a different construction for the Poly1305 hash than is used for
the standard IETF AEAD cipher used for TLS and IPsec.  WireGuard's use
of an 8 byte nonce also uses the more standard construction.

Since the verison in stable/13 was using libsodium directly for the 8
byte nonce case, it was generating incorrect MACs for if_wg(4).  As a
workaround, change the direct API to always use the IETF API from
libsodium which uses 12 byte nonces.  This can be done by
zero-extending the provided 8 byte nonce to 12 bytes so long as the
passed in buffers are sufficiently small to not overflow a 4 byte
counter.

This fixes key negotiation for if_wg(4) on stable/13.  This is also
a direct commit to stable/13.

Reported by: Marek Zarychta <mzar@bpine64.dom.potoki.eu>

18 months agoatomic: Intercept atomic_(load|store)_bool for kernel sanitizers
Mark Johnston [Sat, 29 Oct 2022 15:02:02 +0000 (11:02 -0400)]
atomic: Intercept atomic_(load|store)_bool for kernel sanitizers

Fixes: 2bed73739aac ("atomic: Add plain atomic_load/store_bool()")

(cherry picked from commit 1f6b6cf1774c4f173df1cde3e5cff459f340c95f)