]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
19 months agokboot: Use unsigned long long.
Warner Losh [Fri, 2 Dec 2022 19:41:01 +0000 (12:41 -0700)]
kboot: Use unsigned long long.

For the 64-bit platforms, this is a nop. Currently kboot only supports
64-bit platforms, though. If we support 32-bit in the future, this will
become important.

Noticed by: rpokala
Sponsored by: Netflix

19 months agokboot: Enhance hostdisk
Warner Losh [Fri, 2 Dec 2022 18:28:08 +0000 (11:28 -0700)]
kboot: Enhance hostdisk

Added missing functionality to allow us to boot off of things like
/dev/nvme0n1p2 successfully. And to list all available devices and
partitions with 'lsdev'.

Sponsored by: Netflix

19 months agokboot: amd64 use /sys/firmware/memmap to find free memory
Warner Losh [Fri, 2 Dec 2022 18:10:42 +0000 (11:10 -0700)]
kboot: amd64 use /sys/firmware/memmap to find free memory

Use the system's firmware memory map to find a good place to put the
kernel that won't stomp on anything else. While this uses obstensibly MI
interfaces to get this data, arm64 doesn't have this, nor does
powerpc64, so place it here.

Sponsored by: Netflix

19 months agokboot: move to using devparse
Warner Losh [Fri, 2 Dec 2022 18:10:06 +0000 (11:10 -0700)]
kboot: move to using devparse

We can use devparse directly now. No need to invent a kboot_parsedev
that just does what devparse does now that we've refactored.

Sponsored by: Netflix

19 months agokboot: Create routines to read Linux tiny files
Warner Losh [Fri, 2 Dec 2022 18:05:58 +0000 (11:05 -0700)]
kboot: Create routines to read Linux tiny files

Most of the files in /sys/ and /proc/ are small with one value. Create
two routines to help us read the file and decode that value.

Sponsored by: Netflix

19 months agofull-test: Start of a full testing suite.
Warner Losh [Fri, 2 Dec 2022 17:47:32 +0000 (10:47 -0700)]
full-test: Start of a full testing suite.

full-test.sh aims to be a test suite generator for the boot loader. It
tries to grab artifacts from the web and then constructs minimal boot
environments from that as well as writing qemu-system-* using scripts
that facilitates testing all the ways we can boot... At least all the
ways that we an boot that qemu can emulate.

This is very much a work in progress, and likely could use a good
cleanup at some point.

Sponsored by: Netflix

19 months agoAdd test notes
Warner Losh [Fri, 2 Dec 2022 17:47:29 +0000 (10:47 -0700)]
Add test notes

Add notes on how to test things. This will likely need to be fleshed out
more in the future, but this is a good start.

Sponsored by: Netflix

19 months agodevd: Warn for deprecated 'kern' system type
Warner Losh [Fri, 2 Dec 2022 17:47:22 +0000 (10:47 -0700)]
devd: Warn for deprecated 'kern' system type

One year ago, I deprecated 'kern' in favor of 'kernel' for the system
name for some power events. I'm about to remove it from the kernel, but
realized there's been no warning generated for users. Preserve POLA by
converting on the fly here and issuing a warning for 14.x, and an fatal
error after we branch 15. Make compiling it an error on 16 to remove
the gross hack after we branch.

Sponsored by: Netflix
Reviewed by: bapt
Differential Revision: https://reviews.freebsd.org/D37584

19 months agonewbus: Remove deprecated "kern" system name for resume events.
Warner Losh [Fri, 2 Dec 2022 17:47:01 +0000 (10:47 -0700)]
newbus: Remove deprecated "kern" system name for resume events.

The new "kernel" system name is the one that's documented and has
been generated for a year now. Remove the old one now that 14.0
is getting close.

Sponsored by: Netflix
Reviewed by: bapt
Differential Revision: https://reviews.freebsd.org/D37582

19 months agoAllow any user to read the NFS stats, for example with nfsstat(1).
Alan Somers [Thu, 1 Dec 2022 21:08:01 +0000 (14:08 -0700)]
Allow any user to read the NFS stats, for example with nfsstat(1).

This was originally allowed by 3cea29603d3 (2011).  But it got broken by
693957f8861 (2016) and apparently nobody noticed.

MFC after: 1 week
Sponsored by: Axcient
Reviewed by: rmacklem, ken
Differential Revision: https://reviews.freebsd.org/D37589

19 months agoif_ovpn: remove peer limit
Kristof Provost [Mon, 28 Nov 2022 09:16:24 +0000 (10:16 +0100)]
if_ovpn: remove peer limit

Replace the fixed-sized array by an RB_TREE. This should both speed up
lookups and remove the 128 peer limit.

Reviewed by: zlei
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D37524

19 months agoheimdal: Fix bus fault when zero-length request received
Cy Schubert [Thu, 1 Dec 2022 00:11:18 +0000 (16:11 -0800)]
heimdal: Fix bus fault when zero-length request received

Zero length client requests result in a bus fault when attempting to
free malloc()ed pointers within the requests softc. Return an error
when the request is zero length.

PR: 268062
Reported by: Robert Morris <rtm@lcs.mit.edu>
MFC after: 3 days

19 months agoheimdal: Add additional checks for bad kadmind input
Cy Schubert [Wed, 30 Nov 2022 23:53:49 +0000 (15:53 -0800)]
heimdal: Add additional checks for bad kadmind input

Check return codes for bad input.

MFC after: 3 days

19 months agolinuxkpi: Introduce module_param() of type `bint`
Jean-Sébastien Pédron [Thu, 1 Dec 2022 14:03:00 +0000 (15:03 +0100)]
linuxkpi: Introduce module_param() of type `bint`

In Linux, this limits the accepted value to -1, 0 and 1.
In FreeBSD, this remains a signed integer with no specific constraints.

This change is a requirement to update our DRM drivers to Linux 5.12.

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

19 months agolinuxkpi: Add `PCIE_SPEED_{32,64}_0GT` PCI-E bus speed constants
Jean-Sébastien Pédron [Thu, 1 Dec 2022 14:00:54 +0000 (15:00 +0100)]
linuxkpi: Add `PCIE_SPEED_{32,64}_0GT` PCI-E bus speed constants

This change is a requirement to update our DRM drivers to Linux 5.12.

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

19 months agolinuxkpi: Add `cmpxchg64()` in <asm/atomic.h>
Jean-Sébastien Pédron [Thu, 1 Dec 2022 13:59:16 +0000 (14:59 +0100)]
linuxkpi: Add `cmpxchg64()` in <asm/atomic.h>

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

19 months agolinuxkpi: Add `seqcount_mutex_t` support in <linux/seqlock.h>
Jean-Sébastien Pédron [Thu, 1 Dec 2022 13:58:27 +0000 (14:58 +0100)]
linuxkpi: Add `seqcount_mutex_t` support in <linux/seqlock.h>

To achieve that, the header uses the C11 type generic selection keyboard
_Generic() because the macros are supposed to work with seqcount_t
and seqcount_mutex_t.

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

19 months agonet: add if_allocdescr() to permit updating iface description from the kernel
Alexander V. Chernikov [Wed, 30 Nov 2022 13:49:07 +0000 (13:49 +0000)]
net: add if_allocdescr() to permit updating iface description from the kernel

Reviewed by: kp,zlei
Differential Revision: https://reviews.freebsd.org/D37566
MFC after: 2 weeks

19 months agorx8803: Improve probing logic
Kornel Dulęba [Thu, 1 Dec 2022 05:41:41 +0000 (06:41 +0100)]
rx8803: Improve probing logic

Add a PNP macro in order to load this driver automatically.
While here check if the device is enabled in DT before probing it.

Reviewed by: wma
Sponsored by: Alstom
Obtained from: Semihalf
Differential Revision: https://reviews.freebsd.org/D37579

19 months agolm75: Refactor code to fix io error
Jakub Kolodziej [Thu, 1 Dec 2022 08:02:52 +0000 (09:02 +0100)]
lm75: Refactor code to fix io error

Use correct resolution by compat table. If dtb is not defined use default 9 bit mode.
11 bit detection is called if 9 bit mode is used.
Sysctl resolution variable is added to change resolution in case.
Some sensors didn't pull ACK while reading from nonexistent registers and it caused I2C
read error and detect failure, so now detect failure does not cause driver break.

Obtained from: Semihalf
Sponsored by: Alstom
Differential revision: https://reviews.freebsd.org/D37497

19 months agokillall(1): allow sending signals to processes with control terminal on pts(4)
Daniel Dowse [Thu, 1 Dec 2022 02:42:35 +0000 (04:42 +0200)]
killall(1): allow sending signals to processes with control terminal on pts(4)

PR: 268093
Reviewed by: kib
MFC after: 1 week

19 months agopowerpc/mpc85xx: Add compat strings for P5040 PCIe
Justin Hibbits [Thu, 1 Dec 2022 00:41:26 +0000 (19:41 -0500)]
powerpc/mpc85xx: Add compat strings for P5040 PCIe

Submitted by: widelec (widelec@morphos.pl)
MFC after: 1 week

19 months agogoogletest: remove unused auto_ptr warning suppression
Ed Maste [Tue, 29 Nov 2022 19:38:41 +0000 (14:38 -0500)]
googletest: remove unused auto_ptr warning suppression

lib/googletest used -Wno-deprecated-declarations to silence warnings
about usage of deprecated std::auto_ptr, but auto_ptr is not (now) used
anywhere in googletest.

Reviewed by: jhb
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D37561

19 months agoarm64/machdep: Reserve memory when we find Linux EFI reserved memory table
Warner Losh [Wed, 30 Nov 2022 23:28:51 +0000 (16:28 -0700)]
arm64/machdep: Reserve memory when we find Linux EFI reserved memory table

When Linux loads a new kernel via kexec, somtiems it must reserve memory
for devices that are still active (and typically can't be reset or
shutdown). When present, this table is a linked list of ranges that are
still in use that the OS must avoid using.

Mark these areas as reserved.

This is part of the GICv3 workaround code where we must use the PA
addresses already programmed into the GICv3 when we take over. This part
ensure we don't allocate the mmeory for anything else.

Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D37440

19 months agoarm64/machdep: Add parameter to the EFI table walking code
Warner Losh [Wed, 30 Nov 2022 23:28:01 +0000 (16:28 -0700)]
arm64/machdep: Add parameter to the EFI table walking code

It would be nice to be able to pass an arbitrary pointer to the callback
code. Add one, and pass NULL in all the places that we do that today.
As noted by andrew@, we should likely refactor this into MI code and use
it here and amd64, but for the future.

Sponsored by: Netflix
Reviewed by: rpokala
Differential Revision: https://reviews.freebsd.org/D37439

19 months agoSilence GCC warnings when using libc++ headers.
John Baldwin [Wed, 30 Nov 2022 22:50:35 +0000 (14:50 -0800)]
Silence GCC warnings when using libc++ headers.

GCC 12 raises warnings about literal operator suffixes not preceded by
'_' in libc++ headers such as <string_view> as it doesn't recognize
libc++ headers being an implementation of the standard.

GCC 12 also warns about clang-specific pragmas in <locale>.

Disabling these warnings globally for all C++ code is not ideal, but
is a better option than patching libc++ headers to ignore these
warnings.

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

19 months agoudp[6]_multi_input: Don't unlock freed inp.
John Baldwin [Wed, 30 Nov 2022 22:38:51 +0000 (14:38 -0800)]
udp[6]_multi_input: Don't unlock freed inp.

If udp[6]_append() returns non-zero, it is because the inp has gone
away (inpcbrele_rlocked returned 1 after running the tunnel function).

Reviewed by: ae
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D37511

19 months agoether_demux: Defer stripping the Ethernet header.
John Baldwin [Wed, 30 Nov 2022 22:38:51 +0000 (14:38 -0800)]
ether_demux: Defer stripping the Ethernet header.

This avoids having to undo it before invoking NetGraph's orphan input
hook.

Reviewed by: ae, melifaro
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D37510

19 months agostand/ofw: Refactor ofw parsedev
Warner Losh [Wed, 30 Nov 2022 22:10:23 +0000 (15:10 -0700)]
stand/ofw: Refactor ofw parsedev

Both ofw_disk and ofw_net use the same parsedev routine, except for the
string passed in to match the ofw device node's type. Create a routine
to do that and connect these two users up to that.

Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D37560

19 months agostand/ofw: Use devparse
Warner Losh [Wed, 30 Nov 2022 22:10:18 +0000 (15:10 -0700)]
stand/ofw: Use devparse

Retire the custom parsedev routine and use the standard devparse.

Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D37559

19 months agoofw/disk: Add parsedev support
Warner Losh [Wed, 30 Nov 2022 22:10:11 +0000 (15:10 -0700)]
ofw/disk: Add parsedev support

Add a parsedev support for OpenFirmware disks. We must look at
characteristics of the OFW node to know if we match this device (so
supply a match routine) or not. Add a parsing routine to allocate
devdesc for OpenFirmware disks as well.

Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D37558

19 months agostand/ofw: Subclass devnet to cope with ofw's unique needs
Warner Losh [Wed, 30 Nov 2022 22:10:05 +0000 (15:10 -0700)]
stand/ofw: Subclass devnet to cope with ofw's unique needs

We need to match devices in a slightly special way: We have to look up
the path and see if the device is a 'network' device in order to use it.

Sponsored by: Netflix
Tested by: grehan@ (with tweaks to my original patch)
Differential Revision: https://reviews.freebsd.org/D37557

19 months agostand/ofw: Add ofw_path_to_handle
Warner Losh [Wed, 30 Nov 2022 22:10:00 +0000 (15:10 -0700)]
stand/ofw: Add ofw_path_to_handle

ofw_path_to_handle converts a path string to a phandle_t. It searches
down the path for the first device whose type matches the passed-in
string.

Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D37556

19 months agostand: Implement ofw disk print routine
Warner Losh [Wed, 30 Nov 2022 22:09:56 +0000 (15:09 -0700)]
stand: Implement ofw disk print routine

Have lsdev show openfirmware devices.

Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D37555

19 months agostand: Add dv_match
Warner Losh [Wed, 30 Nov 2022 22:09:51 +0000 (15:09 -0700)]
stand: Add dv_match

On OpenFirmware, and possibly kboot, we use full path names for the
objects that are the 'device'. kboot uses a hack of knowing that all
disk device nodes start with '/dev', but this generalizes it for
OpenFirmware where both 'block' and 'network' devices live in the same
namespace and one must ask the OF node its type to know if this device
type matches.

For drivers that don't specify, the current convention of using
strncmp() is retained. This is done only in devparse(), but everything
uses it directly (or will soon).

Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D37554

19 months agostand: parsedev API change: devspec now points to start of full device name
Warner Losh [Wed, 30 Nov 2022 22:09:36 +0000 (15:09 -0700)]
stand: parsedev API change: devspec now points to start of full device name

To support more flexible device matching, we now pass in the full
devspec to the parsedev routines. For everything execpt uboot, this is
just a drop in (since everything except uboot and openfirmware always
uses disk...: and/or zfs:, but openfirmware isn't really affected).

uboot we kludge around it by subtracting 4 from where the rest of the
device name starts. This is unforunate, and can compute the address one
before the string. But we never dereference that address. uboot needs
more work, and this is an acceptable UB until that other work happens.

OFW doesn't really use the parsedev routines these days (since none of
the supported device uses this... yet). It too needs more work, but it
needs device matching support first.

Sponsored by: Netflix
Reviewed by: delphij
Differential Revision: https://reviews.freebsd.org/D37553

19 months agostand: create devinit
Warner Losh [Wed, 30 Nov 2022 22:09:29 +0000 (15:09 -0700)]
stand: create devinit

devinit() marches through all the devices, calling the inint routines if
any exist. Replace all the identical copies of this code.

Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D37349

19 months agostand/ofw: ofw_disk isn't really a disk
Warner Losh [Wed, 30 Nov 2022 22:09:23 +0000 (15:09 -0700)]
stand/ofw: ofw_disk isn't really a disk

The rest of the code in the tree assumes that a DEVT_DISK uses a
disk_devdesc to represent the device. However ofw_disk diesn't, so we
can't use disk_fmtdev, nor disk_parsedev. ofw needs to have a
dv_match-like routine to use devpasrse, though, since we have two
drivers (net and block) that claim the same sort of devices (eg
/path/to/ofw-dev) based on the device-type property. In the interim, we
can't use devmatch and ofw_disk's and the default net driver's parsing
is offloaded ofw_parsedev.

Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D37347

19 months agozfs: Remove devicename_stubs
Warner Losh [Wed, 30 Nov 2022 22:09:18 +0000 (15:09 -0700)]
zfs: Remove devicename_stubs

We no longer need the zfs stubs since we're no longer referencing these
functions outside of zfs.c.

Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D37345

19 months agostand: make zfs_parsedev static
Warner Losh [Wed, 30 Nov 2022 22:09:14 +0000 (15:09 -0700)]
stand: make zfs_parsedev static

It's now unreferenced outside of zfs.c.

Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D37344

19 months agostand/ofw: Access the parsing routine more directly
Warner Losh [Wed, 30 Nov 2022 22:09:09 +0000 (15:09 -0700)]
stand/ofw: Access the parsing routine more directly

We don't need to check if something is a ZFS device. Instead, if the
found device has a parse routine, call it. Otherwise, just copy the
path.

Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D37343

19 months agostand/userboot: Move to using common devparse()
Warner Losh [Wed, 30 Nov 2022 22:09:05 +0000 (15:09 -0700)]
stand/userboot: Move to using common devparse()

We no longer need to have to hand-code this for each boot loader since
devparse() handles them all with dv_parsedev().

Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D37342

19 months agostand/i386: Move to using common devparse()
Warner Losh [Wed, 30 Nov 2022 22:09:00 +0000 (15:09 -0700)]
stand/i386: Move to using common devparse()

We no longer need to have to hand-code this for each boot loader since
devparse() handles them all with dv_parsedev().

Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D37341

19 months agostand/efi: Move to using common devparse()
Warner Losh [Wed, 30 Nov 2022 22:08:55 +0000 (15:08 -0700)]
stand/efi: Move to using common devparse()

We no longer need to have to hand-code this for each boot loader since
devparse() handles them all with dv_parsedev().

Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D37340

19 months agostand: For all disk drivers, connect dv_parsedev to disk_parsedev
Warner Losh [Wed, 30 Nov 2022 22:08:51 +0000 (15:08 -0700)]
stand: For all disk drivers, connect dv_parsedev to disk_parsedev

Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D37339

19 months agostand/zfs: Connect dv_parsedev to zfs_parsedev
Warner Losh [Wed, 30 Nov 2022 22:08:47 +0000 (15:08 -0700)]
stand/zfs: Connect dv_parsedev to zfs_parsedev

Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D37348

19 months agostand: Introduce devparse to parse device / path strings
Warner Losh [Wed, 30 Nov 2022 22:08:42 +0000 (15:08 -0700)]
stand: Introduce devparse to parse device / path strings

devparse is now the preferred interface to use to parse device
strings or device:/path strings. It parses the passed in string,
mallocs the device's particular devdesc string and returns the
'remainder' of the device:/path for further processing.

Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D37338

19 months agostand: Introduce new dv_parsedev routine
Warner Losh [Wed, 30 Nov 2022 22:08:36 +0000 (15:08 -0700)]
stand: Introduce new dv_parsedev routine

Allow device classes to define a parsing routine. Most device classes
already have these routines, but there's much duplication in their
use. Define an interface for a common routine to parse an individual
device. By convetion, files have the form "[device:]/path/to/file"
where device is optional (filled in to be the value of currdev)
and it starts with the dv_name field of the device, with the rest
of the name up to the device (typically a unit number, but disks
add partition inforation, and other devices may do artibtrary
otehr things).

Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D37337

19 months agostand: Change zfs_parsedev() API
Warner Losh [Wed, 30 Nov 2022 22:08:22 +0000 (15:08 -0700)]
stand: Change zfs_parsedev() API

Change the first argument to zfs_parsedev() to be a pointer to a struct
devdesc *. This now gets filled in with a malloc'd structure that's
returned to the caller that the caller is repsonsible for freeing. Most
nplaces in the tree passed in a malloc'd pointer anyway, and this moves
knowledge of zfs_devdesc more firmly into the zfs.c code.

Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D37336

19 months agostand: Change disk_parsedev() API
Warner Losh [Wed, 30 Nov 2022 22:08:15 +0000 (15:08 -0700)]
stand: Change disk_parsedev() API

Change the first argument to disk_parsedev() to be a pointer to a struct
devdesc *. This now gets filled in with a malloc'd structure that's
returned to the caller that the caller is repsonsible for freeing. Most
places in the tree passed in a malloc'd pointer anyway, and this moves
knowledge of disk_devdesc more firmly into the disk.[ch] code.

Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D37335

19 months ago[skip ci] document first appearance of fhlink et al
Alan Somers [Wed, 30 Nov 2022 17:23:22 +0000 (10:23 -0700)]
[skip ci] document first appearance of fhlink et al

MFC after: 1 week
Sponsored by: Axcient
Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D37575

19 months agovmm: Remove stale comment for vm_rendezvous.
John Baldwin [Wed, 30 Nov 2022 21:06:46 +0000 (13:06 -0800)]
vmm: Remove stale comment for vm_rendezvous.

Support for rendezvous outside of a vcpu context (vcpuid of -1) was
removed in commit 949f0f47a4e7, and the vm, vcpuid argument pair was
replaced by a single struct vcpu pointer in commit d8be3d523dd5.

Reported by: andrew

19 months agoEnable -Wdate-time warning
Ed Maste [Wed, 9 Feb 2022 22:10:03 +0000 (17:10 -0500)]
Enable -Wdate-time warning

This produces an "expansion of date or time macro is not reproducible"
warning or error upon use of __DATE__ or __TIME__.

Provide NO_WDATE_TIME for ports or 3rd party software to opt out.

This is a recommit of 489d7a8528ca, which was reverted (by baf8cbcd97a6)
due to ports build failures.

PR: 267902 [exp-run]
Reviewed by: markj
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D29580

19 months agostand/zlib: Zlib still uses K&R function definitions
Warner Losh [Wed, 30 Nov 2022 18:08:24 +0000 (11:08 -0700)]
stand/zlib: Zlib still uses K&R function definitions

So add ${NO_WDEPRECATED_NON_PROTOTYPE} to the CFLAGS of those
files. This can be removed when we import a zlib that's free of this
anachronism.

Sponsored by: Netflix
Reviewed by: jhb
Differential Revision: https://reviews.freebsd.org/D37516

19 months agoclang: Define NO_WDEPRECATED_NON_PROTOTYPE for clang 15
Warner Losh [Wed, 30 Nov 2022 18:08:16 +0000 (11:08 -0700)]
clang: Define NO_WDEPRECATED_NON_PROTOTYPE for clang 15

Clang 15 enforces function definitions using the C89 form rather than
the K&R form. While not strictly a prototype (which is only for a
declaration), use the name that mirror's clang's warning name. Much code
in contrib still uses K&R function definitions, so invent this for
compiling there.

Sponsored by: Netflix
Reviewed by: jhb
Differential Revision: https://reviews.freebsd.org/D37515

19 months agonetlink: suppress sending NLMSG_ERROR if NLMSG_DONE is already sent
Alexander V. Chernikov [Wed, 30 Nov 2022 12:15:23 +0000 (12:15 +0000)]
netlink: suppress sending NLMSG_ERROR if NLMSG_DONE is already sent

Netlink has a confirmation/error reporting mechanism for the sent
messages. Kernel explicitly acks each messages if requested (NLM_F_ACK)
 or if message processing results in an error.
Similarly, for multipart messages - typically dumps, where each message
 represents a single object like an interface or a route - another
 message, NLMSG_DONE is used to indicate the end of dump and the
 resulting status.
As a result, successfull dump ends with both NLMSG_DONE and NLMSG_ERROR
 messages.
RFC 3549 does not say anything specific about such case.
Linux adopted an optimisation which suppresses NLMSG_ERROR message
 when NLMSG_DONE is already sent. Certain libraries/applications like
 libnl depends on such behavior.

Suppress sending NLMSG_ERROR if NLMSG_DONE is already sent, by
 setting newly-added 'suppress_ack' flag in the writer and checking
 this flag when generating ack.

This change restores libnl compatibility.

Before:
```
~ nl-link-list
Error: Unable to allocate link cache: Message sequence number mismatch
````

After:
```
~ nl-link-list
vtnet0 ether 52:54:00:14:e3:19 <broadcast,multicast,up,running>
lo0 ieee1394 <loopback,multicast,up,running>
```

Reviewed by: bapt,pauamma
Tested by: bapt
Differential Revision: https://reviews.freebsd.org/D37565

19 months agoOptionalObsoleteFiles.inc: add zoneinfo/America/Ciudad_Juarez
Philip Paeps [Wed, 30 Nov 2022 01:47:03 +0000 (09:47 +0800)]
OptionalObsoleteFiles.inc: add zoneinfo/America/Ciudad_Juarez

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

MFC after: 1 day

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

MFC after: 1 day

19 months agoImport tzdata 2022g
Philip Paeps [Wed, 30 Nov 2022 01:31:56 +0000 (09:31 +0800)]
Import tzdata 2022g

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

19 months agolibc: remove unneeded sys/types.h include from several synopses
Guilherme Janczak [Mon, 28 Nov 2022 22:57:37 +0000 (00:57 +0200)]
libc: remove unneeded sys/types.h include from several synopses

PR: 268028
Reviewed by: kib
Discussed with: imp
MFC after: 1 week

19 months agoofw_net: Use c99 initializers
Warner Losh [Tue, 29 Nov 2022 21:47:02 +0000 (14:47 -0700)]
ofw_net: Use c99 initializers

Update to use c99 initializers, although there's no plans to change
anything that this would make easier...

Sponsored by: Netflix
Reviewed by: zlei
Differential Revision: https://reviews.freebsd.org/D37442

19 months agonet80211: fix IEEE80211_DEBUG_REFCNT builds
Bjoern A. Zeeb [Tue, 29 Nov 2022 18:21:05 +0000 (18:21 +0000)]
net80211: fix IEEE80211_DEBUG_REFCNT builds

Remove the KPI/KBI changes from ieee80211_node.h and always use the
macros to pass in __func__ and __LINE__ to the functions.
The actual implementations are prefixed by "_" rather than suffixed
by "_debug" as they no longer are "debug"-specific.

Some of the select functions were not actually using the passed in
func, line options; however they are calling other functions which
use them.  Directly call the internal implementation in those cases
passing the arguments on.

Use a file-local __debrefcnt_used define to mark the arguments __unused
in cases when we compile without IEEE80211_DEBUG_REFCNT and hope the
toolchain is intelligent enough to not pass them at all in those cases.

Also _ieee80211_free_node() now has a conflict so make the previous
_ieee80211_free_node() the new __ieee80211_free_node().

Add IEEE80211_DEBUG_REFCNT to the NOTES file on amd64 to keep exercising
the option.

Sponsored by: The FreeBSD Foundation
X-MFC: never
Discussed on: freebsd-wireless
Reviewed by: adrian
Differential Revision: https://reviews.freebsd.org/D37529

19 months agocsh: install hard link with same mode as target
Ed Maste [Wed, 23 Nov 2022 17:14:18 +0000 (12:14 -0500)]
csh: install hard link with same mode as target

Previously when using NO_ROOT we recorded METALOG entries for the /.cshrc
hard link with a different file mode than the link target, which is not
permitted.

We cannot just set LINKMODE here as it would also apply to the hard link
for the tcsh binary.

Reviewed by: brooks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D37499

19 months agonewbus: Comment style nit
Warner Losh [Tue, 29 Nov 2022 20:04:39 +0000 (13:04 -0700)]
newbus: Comment style nit

Sponsored by: Netflix

19 months agostand/ofw: Use strpbrk instead of two strchrs
Warner Losh [Tue, 29 Nov 2022 20:02:40 +0000 (13:02 -0700)]
stand/ofw: Use strpbrk instead of two strchrs

No need to call strchr twice, when one call to strpbrk will do the
job.. Test booted with qemu-powerpc + mac99 successfully.
Minor style(9) tweaks as well.

Sponsored by: Netflix

19 months agoxen/acpi: only evaluate Processor objects matching online CPUs
Roger Pau Monné [Tue, 29 Nov 2022 15:21:51 +0000 (16:21 +0100)]
xen/acpi: only evaluate Processor objects matching online CPUs

Current Xen Processor driver will evaluate any Processor object on the
ACPI tables regardless of whether the processor is online or not.
Avoid doing so for processors that are not online, as evaluating
methods of processors that are not online could lead to accesses to
invalid memory, and in any case the data that the driver fetches from
the Processor ACPI object only makes sense for processors that are
online.

Note the CPU related data fetched from Xen using XENPF_get_cpuinfo
hypercall could be cached, I leave that as a future optimization.

Sponsored by: Citrix Systems R&D
Fixes: b93f47eaeef7 ('xen/acpi: upload Cx and Px data to Xen')
19 months agobsdinstall: Fix local_unbound option default on revisit
Jessica Clarke [Tue, 29 Nov 2022 03:09:51 +0000 (03:09 +0000)]
bsdinstall: Fix local_unbound option default on revisit

The variable used for the checklist's default value needs to correspond
to the rc.conf variable as that's what's being parsed to determine them.
In the case of local_unbound it's missing the _enable suffix and thus
always defaults to off on revisit.

Fixes: 58eb9abb3157 ("Add a line to the post-installation configuration dialog to enable the local_unbound service.")

19 months agobsdinstall: Fix issues parsing rc.conf.services on revisit
Jessica Clarke [Tue, 29 Nov 2022 02:56:25 +0000 (02:56 +0000)]
bsdinstall: Fix issues parsing rc.conf.services on revisit

There are a few issues here, some of which are hiding others. The first
is that we don't use double quotes around the command substitution so
every word in the conf file is treated as a separate argument to eval,
resulting in spaces being used in place of newlines and thus comments in
the file commenting out the rest of the file, not just to the end of
their line. In particular, we insert one comment just before the dumpdev
entry (the final one in the file) and so we never see dumpdev as set,
and thus set a default value of on for the menu.

The second issue is that, for dumpdev, it takes a value of AUTO not YES
when set, but we don't replace this with on when eval'ing, so then end
up giving AUTO to bsddialog which is interpreted the same as off (which
seems to match GPL dialog). Thus handle AUTO like YES otherwise it will
always appear as unchecked on revisit.

The final issue is that our case-insensitive YES/NO (and now AUTO)
replacements have no word boundaries around them so match the middle of
words too. As it happens this doesn't matter in practice at the moment,
but it could in future; currently the only effect is that it rewrites
moused_nondefault_enable to moused_offndefault_enable, but since this
variable is never read, only written based on moused(_enable) this is
harmless, but we should fix it in case a service comes along in future
that does get affected by it.

19 months agobsdinstall: Fix ntpd_sync_on_start service option
Jessica Clarke [Tue, 29 Nov 2022 00:57:38 +0000 (00:57 +0000)]
bsdinstall: Fix ntpd_sync_on_start service option

This installer option is currently totally useless, as it ends up
creating an ntpd_sync_on_start_enable="YES" entry in rc.conf, not an
ntpd_sync_on_start="YES" entry, as is the correct name. This can also be
noticed by revisiting the services menu, which parses the previously
written rc.conf.services file to set variables governing the default
menu entry values so that selecting OK regenerates the same file, as the
menu entry will use the correct variable name and thus think the entry
was not selected last time, defaulting back to off and losing the
setting.

Thus, add a special case in the loop for this option. The only other
entry that doesn't follow the *_enable pattern is dumpdev (even moused
does, it just also sets a second variable), but that also deviates in
terms of being explicitly set either way and using AUTO rather than YES,
hence why ntpd_sync_on_start follows a different pattern here and is
special-cased rather than introducing a whole new variable that governs
behaviour outside the loop.

Fixes: c153a35bfd71 ("bsdinstall: replace ntpdate by ntpd_sync_on_start")

19 months agobhyve: Avoid passing a possible garbage pointer to free().
John Baldwin [Tue, 29 Nov 2022 01:10:30 +0000 (17:10 -0800)]
bhyve: Avoid passing a possible garbage pointer to free().

All of the error paths in pci_vtcon_sock_add free the sock pointer.
However, sock is not initialized until part way through the function.
An early error would pass stack garbage to free().

Reviewed by: corvink, markj
Differential Revision: https://reviews.freebsd.org/D37491

19 months agobhyve: Appease warning about a potentially unaligned pointer.
John Baldwin [Tue, 29 Nov 2022 01:10:07 +0000 (17:10 -0800)]
bhyve: Appease warning about a potentially unaligned pointer.

When initializing the device model for a PCI pass through device that
uses MSI-X, bhyve reads the MSI-X capability from the real device to
save a copy in the emulated PCI config space.  It also saves a copy in
a local struct msixcap on the stack.  Since struct msixcap is packed,
GCC complains that casting a pointer to the struct to a uint32_t
pointer may result in an unaligned pointer.

This path is not performance critical, so to appease the compiler,
simply change the pointer to a char * and use memcpy to copy the 4
bytes read in each iteration of the loop.

Reviewed by: corvink, bz, markj
Differential Revision: https://reviews.freebsd.org/D37490

19 months agobhyve: Fix sign compare warnings in the NVMe device model.
John Baldwin [Tue, 29 Nov 2022 01:09:44 +0000 (17:09 -0800)]
bhyve: Fix sign compare warnings in the NVMe device model.

Reviewed by: corvink
Differential Revision: https://reviews.freebsd.org/D37489

19 months agobhyve: Avoid unlikely truncation of the blockif ident strings.
John Baldwin [Tue, 29 Nov 2022 01:09:15 +0000 (17:09 -0800)]
bhyve: Avoid unlikely truncation of the blockif ident strings.

The ident string for NVMe and VirtIO block deivces do not contain the
bus, and the various fields can potentially use up to three characters
when printed as unsigned values (full range of uint8_t) even if not
likely in practice.

Reviewed by: corvink, chuck
Differential Revision: https://reviews.freebsd.org/D37488

19 months agobhyve: Clear lid to 0 for internal device errors for NVMe AENs.
John Baldwin [Tue, 29 Nov 2022 01:08:57 +0000 (17:08 -0800)]
bhyve: Clear lid to 0 for internal device errors for NVMe AENs.

Reported by: GCC
Reviewed by: corvink, chuck, imp, markj
Differential Revision: https://reviews.freebsd.org/D37487

19 months agobhyve: Don't leak uninitialized bits in NVMe completion statuses.
John Baldwin [Tue, 29 Nov 2022 01:08:36 +0000 (17:08 -0800)]
bhyve: Don't leak uninitialized bits in NVMe completion statuses.

In some cases, some bits in the 16-bit status word were never
initialized.

Reported by: GCC
Reviewed by: corvink, chuck, markj
Differential Revision: https://reviews.freebsd.org/D37486

19 months agobhyve: Fix sign compare warnings in the e1000 device model.
John Baldwin [Tue, 29 Nov 2022 01:08:09 +0000 (17:08 -0800)]
bhyve: Fix sign compare warnings in the e1000 device model.

Adding a bare constant to a uint16_t promotes to a signed int which
triggers these warnings.  Changing the constant to be explicitly
unsigned instead promotes the expression to unsigned int.

Reviewed by: corvink, markj
Differential Revision: https://reviews.freebsd.org/D37485

19 months agobhyve basl: Use GCC pragmas.
John Baldwin [Tue, 29 Nov 2022 01:07:39 +0000 (17:07 -0800)]
bhyve basl: Use GCC pragmas.

These work with both clang and GCC.

Reviewed by: corvink, markj
Differential Revision: https://reviews.freebsd.org/D37484

19 months agodpaa: Don't assume the MDIO is on the same fman as the MAC
Justin Hibbits [Mon, 28 Nov 2022 22:03:15 +0000 (17:03 -0500)]
dpaa: Don't assume the MDIO is on the same fman as the MAC

The P5040 has the MDIO for FMAN2 on FMAN1 for some reason.  Instead of
trying to manually find the MDIO, use a real xref.

19 months agoLinuxKPI: 802.11: minor header updates
Bjoern A. Zeeb [Mon, 28 Nov 2022 21:21:06 +0000 (21:21 +0000)]
LinuxKPI: 802.11: minor header updates

- add comments for enum values constantly looked up, and another one to
  a net80211 equivalent (should possibly re-define those in the future?)
- add another nl80211_sta_info flag
- add enum environment_cap used in cfg80211.h in the future.

MFC after: 3 days

19 months agoLinuxKPI: SKB update
Bjoern A. Zeeb [Mon, 28 Nov 2022 20:54:57 +0000 (20:54 +0000)]
LinuxKPI: SKB update

- skb_reset_tail_pointer(): we do not do offsets so do a plain reset
- skb_add_rx_frag(): adjust data_len to keep track of the frag
- based on that implement skb_is_nonlinear() and skb_linearize()
- implement build_skb() and adjust linuxkpi_kfree_skb() and ddb macro.

Sponsored by: The FreeBSD Foundation (partially)
MFC after: 3 days

19 months agopf tests: test that reassembly is or is not performed as expected
Kristof Provost [Thu, 24 Nov 2022 09:25:40 +0000 (10:25 +0100)]
pf tests: test that reassembly is or is not performed as expected

We can now tell scrub rules to not reassemble packets. Test that this
affects packets being passed or dropped as expected.

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

19 months agopf: drop support for fragment crop|drop-ovl
Kristof Provost [Tue, 22 Nov 2022 13:43:59 +0000 (14:43 +0100)]
pf: drop support for fragment crop|drop-ovl

We removed the code for these modes back in 2015, but converted such
configurations to 'scrub fragment reassemble'. It's been long enough,
drop the backwards compatibility glue too.

Reviewed by: mjg
MFC after: never
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D37460

19 months agopf: allow scrub rules without fragment reassemble
Kristof Provost [Tue, 22 Nov 2022 13:23:27 +0000 (14:23 +0100)]
pf: allow scrub rules without fragment reassemble

scrub rules have defaulted to handling fragments for a long time, but
since we removed "fragment crop" and "fragment drop-ovl" in 64b3b4d611
this has become less obvious and more expensive ("reassemble" being the
more expensive option, even if it's the one the vast majority of users
should be using).

Extend the 'scrub' syntax to allow fragment reassembly to be disabled,
while retaining the other scrub behaviour (e.g. TTL changes, random-id,
..) using 'scrub fragment no reassemble'.

Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D37459

19 months agoLinuxKPI: SKB: implement skb_peek()
Bjoern A. Zeeb [Mon, 28 Nov 2022 18:47:08 +0000 (18:47 +0000)]
LinuxKPI: SKB: implement skb_peek()

Sponsored by: The FreeBSD Foundation
MFC after: 3 days

19 months agoLinuxKPI: iwlwifi: rtw88: rtw89: remove budget argument from netif_napi_add()
Bjoern A. Zeeb [Mon, 28 Nov 2022 15:12:58 +0000 (15:12 +0000)]
LinuxKPI: iwlwifi: rtw88: rtw89: remove budget argument from netif_napi_add()

In preparation for future updates remove the budget argument from the
netif_napi_add() in drivers and update LinuxKPI to reflect that it is
gone and only set it internally.  This required changes to the currently
committed wireless drivers based on LinuxKPI (iwlwifi, rtw88, rtw89).

Sponsored by: The FreeBSD Foundation
MFC after: 3 days

19 months agoLinuxKPI: ethtool.h add more definitions
Bjoern A. Zeeb [Sun, 30 Oct 2022 17:07:49 +0000 (17:07 +0000)]
LinuxKPI: ethtool.h add more definitions

While we do not currently use ethtool, add the definitions to avoid
other longer-term maintenance problems with drivers.

Also migrate ETH_GSTRING_LEN into here from if_ether.h as it seems this
is where it belongs.

MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D37214

19 months agoLinuxKPI,lindebugfs: add u8 base type and blob support
Bjoern A. Zeeb [Sat, 22 Oct 2022 18:12:16 +0000 (18:12 +0000)]
LinuxKPI,lindebugfs: add u8 base type and blob support

Add debugfs_create_u8() based on other already present implementations.
Add a read-only implementation for debugfs_create_blob().

Both are needed for iwlwifi debugfs support.

Sponsored by: The FreeBSD Foundation
MFC after: 3 days
OKed by: jfree (earlier version)
Differential Revision: https://reviews.freebsd.org/D37090

19 months agoLinuxKPI: add a no-op generic_file_llseek()
Bjoern A. Zeeb [Sat, 22 Oct 2022 20:27:42 +0000 (20:27 +0000)]
LinuxKPI: add a no-op generic_file_llseek()

This is needed for debugfs implementations in drivers.

Sponsored by: The FreeBSD Foundation
MFC after: 3 days
OKed by: jfree
Differential Revision: https://reviews.freebsd.org/D37092

19 months agoLinuxKPI: pci.h add more MSI related constanst and pci_is_enabled()
Bjoern A. Zeeb [Mon, 31 Oct 2022 22:14:10 +0000 (22:14 +0000)]
LinuxKPI: pci.h add more MSI related constanst and pci_is_enabled()

Add more MSI related constansts defined to our native defines and
pci_is_enabled().  All are needed for another wireless driver.

MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D37225

19 months agortw88: correct SRCS+= in Makefile
Bjoern A. Zeeb [Mon, 28 Nov 2022 15:48:44 +0000 (15:48 +0000)]
rtw88: correct SRCS+= in Makefile

Properly spell a SRCS+= for an optional file (this is why it stayed
unnoticed so far).

MFC after: 3 days

19 months agopw(8): fix combination of modes -N and -w random
Eugene Grosbein [Mon, 28 Nov 2022 14:22:39 +0000 (21:22 +0700)]
pw(8): fix combination of modes -N and -w random

The command "pw usermod nobody -Nw random" (or useradd)
generates random password and prints it in encrypted form
but skips choosen random string that makes not much sense
and contradicts the manual page pw.8

Fix it by showing random password in plain text with -N and
without it equally. Add yet another example of how to generate
pw-style random password.

MFC after: 2 weeks

19 months agosqlite3: Vendor import of sqlite3 3.40.0
Cy Schubert [Mon, 28 Nov 2022 14:08:46 +0000 (06:08 -0800)]
sqlite3: Vendor import of sqlite3 3.40.0

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

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

Merge commit 'ac50343d44f8dff1efe667b4713de4b1351a19e1' into main

19 months agoAM335x: Fix compatible name
Oskar Holmlund [Mon, 28 Nov 2022 07:13:18 +0000 (08:13 +0100)]
AM335x: Fix compatible name
In the DTS import from Linux 5.14 the compatible strings has changed for
the driver am335x_ecap.c && am335x_ehrpwm.c

Approved by: manu (mentor)
Differential revision: https://reviews.freebsd.org/D37502

19 months agosqlite3: Vendor import of sqlite3 3.40.0
Cy Schubert [Mon, 28 Nov 2022 00:03:49 +0000 (16:03 -0800)]
sqlite3: Vendor import of sqlite3 3.40.0

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

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

19 months agoRevert "Remove UPDATING entries from old branches."
Alexander Leidinger [Sun, 27 Nov 2022 21:10:09 +0000 (22:10 +0100)]
Revert "Remove UPDATING entries from old branches."

This reverts commit ff0c7816db696d31adc437134dcad45a70ad5889 as more
history than just from branch N-1 to N is requested/needed by some
downstram consumers.

Requested by: imp

19 months agoofw: Remove old K&R function declaration
Warner Losh [Sun, 27 Nov 2022 20:34:33 +0000 (13:34 -0700)]
ofw: Remove old K&R function declaration

We don't need to forward declar strchr anymore.

Sponsored by: Netflix

19 months agoofw: Cast function pointer to proper type
Warner Losh [Sun, 27 Nov 2022 20:23:28 +0000 (13:23 -0700)]
ofw: Cast function pointer to proper type

clang 15 insists that we call entry() via a function prototype. Rather
than copping out and using (...), cast it to the same prototype that's
used elsewhere (with tweaks to pointers to make them fit into that
prototype). No functional change.

Sponsored by: Netflix

19 months agoashldi3: Use C89-style function definition
Warner Losh [Sun, 27 Nov 2022 20:23:25 +0000 (13:23 -0700)]
ashldi3: Use C89-style function definition

Use the 'prototype' style function definition. No functional change.

Sponsored by: Netflix

19 months agomd5: Use c89 function definitions
Warner Losh [Sun, 27 Nov 2022 20:22:31 +0000 (13:22 -0700)]
md5: Use c89 function definitions

Use the c89 function definitions rather than the old K&R definitions.

Sponsored by: Netflix