]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
18 months agoImprove handling of missing '.' and '..' in UFS directories.
Kirk McKusick [Wed, 17 Aug 2022 21:19:59 +0000 (14:19 -0700)]
Improve handling of missing '.' and '..' in UFS directories.

(cherry picked from commit 6bae6625e0e06816c80ac4971dfccf0643abe3f0)

Sponsored by: The FreeBSD Foundation

18 months agoExplicitly initialize rather than reading newly allocated UFS inodes.
Kirk McKusick [Sat, 13 Aug 2022 20:50:08 +0000 (13:50 -0700)]
Explicitly initialize rather than reading newly allocated UFS inodes.

(cherry picked from commit 6b9d4fbb7fe550788d82168e7beeabcd5ad238ce)

Sponsored by: The FreeBSD Foundation

18 months agoCorrectness cleanups in fsck_ffs(8).
Kirk McKusick [Sat, 13 Aug 2022 20:27:37 +0000 (13:27 -0700)]
Correctness cleanups in fsck_ffs(8).

(cherry picked from commit 6e821c35d68d4041640b27419837464ffab65cff)

Sponsored by: The FreeBSD Foundation

18 months agoFix compilation issue when kernel built without FFS defined.
Kirk McKusick [Sun, 4 Dec 2022 05:20:39 +0000 (21:20 -0800)]
Fix compilation issue when kernel built without FFS defined.

This is not cherry-picked because it occurs only in 13 and not
in 14 or later kernels.

Reported by:  Boris Korzun
Tested by:    Boris Korzun
PR:           263979
Sponsored by: The FreeBSD Foundation

18 months agofetch: support EAI_ADDRFAMILY error, correct two error messages
Mike Karels [Wed, 2 Nov 2022 15:59:09 +0000 (10:59 -0500)]
fetch: support EAI_ADDRFAMILY error, correct two error messages

With the change to return EAI_ADDRFAMILY from getaddrinfo(), fetch
would print "Unknown resolver error" for that error.  Add that error
and its string to libfetch's table, using an #ifdef just in case.
Correct error strings for EAI_NODATA (although it is currently unused)
and EAI_NONAME.  Should maybe rework the code to use gai_strerror(3),
but that doesn't map directly, and the current strings are shortened.

Reviewed in https://reviews.freebsd.org/D37139 with related changes.

Reviewed by:    bz

(cherry picked from commit 631b82aca0fd41c8e0d48eebdb9c4e38b7306472)

18 months agogetaddrinfo: distinguish missing addrs from unresolvable names
Mike Karels [Wed, 2 Nov 2022 15:57:59 +0000 (10:57 -0500)]
getaddrinfo: distinguish missing addrs from unresolvable names

Rework getaddrinfo(3) to return different error values for unresolvable
names (same as before, EAI_NONAME) and those without a requested addr
(EAI_ADDRFAMILY) when using DNS.  This is implemented via an added
error in the nsswitch layer, NS_ADDRFAMILY, which is used only by
getaddrinfo().  The error is passed through nsdispatch(3), but that
routine has no changes to handle this error.  The error originates in
the getaddrinfo DNS layer called via nsdispatch(), and is processed
by the search layer that calls nsdispatch().

While here, add a little style to returns near those that were
modified.

Reviewed in https://reviews.freebsd.org/D37139 with related changes.

Reviewed by:    bz

(cherry picked from commit 144361386696582c04592f200a4c2e3339c81a25)

18 months agogai_strerror.[c3]: re-enable EAI_ADDRFAMILY, EAI_NODATA
Mike Karels [Wed, 2 Nov 2022 15:55:32 +0000 (10:55 -0500)]
gai_strerror.[c3]: re-enable EAI_ADDRFAMILY, EAI_NODATA

gai_strerror.c still has messages for EAI_ADDRFAMILY and EAI_NODATA,
but not the man page.  Re-add to the man page, and update comments
in the source.  Document the errors that are not in RFC 3493 or
POSIX.

Reviewed in https://reviews.freebsd.org/D37139 with related changes.

Reviewed by:    bz, pauamma

(cherry picked from commit e34adc71d3724a8b1add483310efbc63db9290a6)

18 months agonetdb.h: re-enable EAI_ADDRFAMILY, EAI_NODATA
Mike Karels [Wed, 2 Nov 2022 15:43:04 +0000 (10:43 -0500)]
netdb.h: re-enable EAI_ADDRFAMILY, EAI_NODATA

EAI_ADDRFAMILY and EAI_NODATA are not in RFC 3493, but are available
and used in many other systems.  It is desirable to have at least one
of them in order to distinguish between names that do not resolve and
those that do not have the requested address type.  A change to
getaddrinfo() will use EAI_ADDRFAMILY.  Both were "#if 0"; re-enable,
conditioned on __BSD_VISIBLE, and update comments.  Also add comments
and __BSD_VISIBLE conditional for the last three EAI errors, which
are not in the RFC or POSIX.  Note, all of these are available in
NetBSD and OpenBSD, and EAI_ADDRFAMILY and EAI_NODATA are available
in Linux (glibc).

Reviewed in https://reviews.freebsd.org/D37139 with related changes.

Reviewed by: bz

(cherry picked from commit 40e4e12bd84154626d5b46c3e862c79da25bc403)

18 months agoAdd support for adding default routes for other FIBs
Andrew Fengler [Wed, 12 May 2021 01:59:10 +0000 (01:59 +0000)]
Add support for adding default routes for other FIBs

Make rc.d/routing read defaultrouter_fibN and ipv6_defaultrouter_fibN, and
set it as the default gateway for FIB N, where N is from 1 to (net.fibs - 1)
This allows adding gateways for multiple FIBs in the same format as the main
gateway. (FIB 0)

Reviewed by: olivier, rgrimes, bcr (man page)
Sponsored by: ScaleEngine Inc.
Differential Revision: https://reviews.freebsd.org/D22706

(cherry picked from commit 30659d1dcbcc92016833f0956461314ed501ac83)

18 months agovfs_vnops.c: Fix blksize for ZFS
Rick Macklem [Thu, 17 Nov 2022 01:37:22 +0000 (17:37 -0800)]
vfs_vnops.c: Fix blksize for ZFS

Since ZFS reports _PC_MIN_HOLE_SIZE as 512 (although it
appears that an unwritten region must be at least f_iosize
to remain unallocated), vn_generic_copy_file_range()
uses 4096 for the copy blksize for ZFS, reulting in slow copies.

For most other file systems, _PC_MIN_HOLE_SIZE and f_iosize
are the same value, so this patch modifies the code to
use f_iosize for most cases.  It also documents in comments
why the blksize is being set a certain way, so that the code
does not appear to be doing "magic math".

(cherry picked from commit 4ee16246f97825e893e0a4a4499d1bbe5bc07b6a)

18 months agoMFV: expat 2.5.0
Xin LI [Fri, 18 Nov 2022 06:10:01 +0000 (22:10 -0800)]
MFV: expat 2.5.0

(cherry picked from commit dc58b3fca5e7a7bb1e9aa640667944d0fe0601cd)

18 months agoMFV: xz-embedded 3f438e15109229bb14ab45f285f4bff5412a9542
Xin LI [Fri, 18 Nov 2022 06:04:57 +0000 (22:04 -0800)]
MFV: xz-embedded 3f438e15109229bb14ab45f285f4bff5412a9542

(cherry picked from commit cd3a777bca91669fc4711d1eff66c40f3f62a223)

18 months agoMFV: Merge xz 5.2.8
Xin LI [Thu, 17 Nov 2022 04:36:06 +0000 (20:36 -0800)]
MFV: Merge xz 5.2.8

Relnotes: yes
(cherry picked from commit 9e6bbe47a503137f1698232070cb4c1a4f14be10)

18 months agoheimdal: Check return code from _hdb_fetch_kvno()
Cy Schubert [Sat, 26 Nov 2022 20:18:03 +0000 (12:18 -0800)]
heimdal: Check return code from _hdb_fetch_kvno()

A malformed principal will cause kadmind to segfault. The PR
addresses only when chpass is requested but delete is also affected.
Fix both.

PR: 268002
Reported by: Robert Morris <rtm@lcs.mit.edu>

(cherry picked from commit 671f55828d038e17fb29fd115b88e7cdf53500c3)

18 months agoheimdal: Add missing iprop error checks.
Cy Schubert [Sat, 26 Nov 2022 18:19:55 +0000 (10:19 -0800)]
heimdal: Add missing iprop error checks.

Inspired by upstream 9d6dd21256f87988605fa75172be9cc92535064c.

Obtained from: Heimdal 9d6dd21256f87988605fa75172be9cc92535064c

(cherry picked from commit 5040a7a9aa67861a095bae6edfbc67572cd24457)

18 months agoheimdal: Add missing kadmind error checks
Cy Schubert [Sat, 26 Nov 2022 17:48:31 +0000 (09:48 -0800)]
heimdal: Add missing kadmind error checks

Inspired by: Heimdal commmit 1b213c1082be4ef5a1c23928d614c762f837dbe7

(cherry picked from commit 80999dcd5bdebd0beb2591a1de3f6db9767c0066)

18 months agoheimdal: Add missing kadm5 error checks
Cy Schubert [Sat, 26 Nov 2022 17:06:09 +0000 (09:06 -0800)]
heimdal: Add missing kadm5 error checks

Obtained from: Heimdal commit 4a0e01f9edabe36d0f2cab188078dd29fa5aaf02

(cherry picked from commit 879b0e9cd2ada8f815e208d31feb4b7c05ba7e4a)

18 months agoheimdal: Add missing kadm5 error checks
Cy Schubert [Sat, 26 Nov 2022 16:48:51 +0000 (08:48 -0800)]
heimdal: Add missing kadm5 error checks

Generally obtained from upstream 655c057769f56bd8cdb7d16e93f1e7a7cb260342.

PR: 267944, 267972
Obtained from: Heimdal commit 655c057769f56bd8cdb7d16e93f1e7a7cb260342

(cherry picked from commit 780f663df3a0fc30da5f0680c128087b1a05ea40)

18 months agoheimdal: Fix uninitialized pointer dereference
Cy Schubert [Fri, 25 Nov 2022 23:29:14 +0000 (15:29 -0800)]
heimdal: Fix uninitialized pointer dereference

krb5_ret_preincipal() returns a non-zero return code when
a garbage principal is passed to it. Unfortunately ret_principal_ent()
does not check the return code, with garbage pointing to what would
have been the principal. This results in a segfault when free() is
called.

PR: 267944, 267972
Reported by: Robert Morris <rtm@lcs.mit.edu>

(cherry picked from commit e13150e28c93d9e74f419dcd17d2e2bad41715ad)

18 months agoheimdal: Handle other types of garbage data
Cy Schubert [Thu, 24 Nov 2022 15:07:43 +0000 (07:07 -0800)]
heimdal: Handle other types of garbage data

In addition to garbage realm data, also handle garbage dbname, acl_file,
stash_file, and invalid bitmask garbage data.

PR: 267912
Reported by: Robert Morris <rtm@lcs.mit.edu>

(cherry picked from commit 91db848212e3b95cc689a1e8133a1d550b524919)

18 months agoheimdal: Fix NULL dereference when mangled realm message
Cy Schubert [Thu, 24 Nov 2022 14:22:13 +0000 (06:22 -0800)]
heimdal: Fix NULL dereference when mangled realm message

Fix a NULL dereference in _kadm5_s_init_context() when the client
sends a mangled realm message.

PR: 267912
Reported by: Robert Morris <rtm@lcs.mit.edu>

(cherry picked from commit 05bc50bdb1c1ddbbeb853ea4b184aced0eca9b3f)

18 months agoheimdal: The version string must always contain a terminating NUL
Cy Schubert [Mon, 21 Nov 2022 15:33:08 +0000 (07:33 -0800)]
heimdal: The version string must always contain a terminating NUL

Should the sender send a string without a terminating NUL, ensure that
the NUL terminates the string regardless.

And while at it only process the version string when bytes are returned.

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

(cherry picked from commit d7e8666ffb9967a92709a2d2ded4d31568ab1473)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)

19 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)