]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
14 months agohwpmc(4): more detailed SYNOPSYS
Mitchell Horne [Fri, 16 Jun 2023 16:38:03 +0000 (13:38 -0300)]
hwpmc(4): more detailed SYNOPSYS

Include some boilerplate similar to other section 4 man pages,
describing how to load the module at boot-time or include it in the
kernel.

Reviewed by: jkoshy, emaste
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D40542

14 months agohwpmc(4): remove paragraph about Pentium Pro handling
Mitchell Horne [Fri, 16 Jun 2023 16:34:02 +0000 (13:34 -0300)]
hwpmc(4): remove paragraph about Pentium Pro handling

Support for these CPUs was removed in 2018 (e92a1350b50e).

Reviewed by: jkoshy, emaste
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D40541

14 months agonetlink: convert to IfAPI.
Alexander V. Chernikov [Fri, 16 Jun 2023 15:58:57 +0000 (15:58 +0000)]
netlink: convert to IfAPI.

Convert to IfAPI everything except `IF_AFDATA_WLOCK` usage in neigh.c.

Reviewed By: jhibbits
Differential Revision: https://reviews.freebsd.org/D40577

14 months agoifnet: fix if_strings.h build check
Alexander V. Chernikov [Fri, 16 Jun 2023 15:54:29 +0000 (15:54 +0000)]
ifnet: fix if_strings.h build check

14 months agonetlink: dump interface capabilities with other interface data.
Alexander V. Chernikov [Fri, 16 Jun 2023 14:56:39 +0000 (14:56 +0000)]
netlink: dump interface capabilities with other interface data.

This change exports interface capabilities using the standard
Netlink attribute type, bitset, and switches `ifconfig(8)` to use
it when displaying interface data.
Bitset comes in two representations. The first one is "compact",
where the bits are exported via two arrays - "mask" listing the
"valid" bits and "values, providing the values for those bits.
The second one is more verbose, listing each bit as a separate item,
with its name, id and value. The latter option is handy when submitting
update requests.

The support for setting capabilities will be added in the upcoming diffs.

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

14 months agoperiodic: Honor kern.localbase
Juraj Lutter [Tue, 6 Jun 2023 11:40:49 +0000 (13:40 +0200)]
periodic: Honor kern.localbase

Take kern.localbase into account with fallback to /usr/local and
also allow for LOCALBASE/etc/periodic.conf (similarly to what
many other utilities do).

Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D40435
MFC after: 2 weeks

14 months agoifconfig: fix armv6 build
Alexander V. Chernikov [Fri, 16 Jun 2023 08:23:14 +0000 (08:23 +0000)]
ifconfig: fix armv6 build

14 months agovm_phys: Fix typo in 9e8174289236
Alan Cox [Fri, 16 Jun 2023 08:12:42 +0000 (03:12 -0500)]
vm_phys: Fix typo in 9e8174289236

14 months agoipfw: add state/comment tests
Alexander V. Chernikov [Fri, 16 Jun 2023 07:24:19 +0000 (07:24 +0000)]
ipfw: add state/comment tests

14 months agoifconfig: use default (more rigid) WARNS level.
Alexander V. Chernikov [Wed, 14 Jun 2023 13:21:17 +0000 (13:21 +0000)]
ifconfig: use default (more rigid) WARNS level.

It helps catch more errors at compile time.

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

14 months agoifconfig: remove global 'ifr' usage from ifmedia.c & remove 'ifr'.
Alexander V. Chernikov [Wed, 14 Jun 2023 13:04:10 +0000 (13:04 +0000)]
ifconfig: remove global 'ifr' usage from ifmedia.c & remove 'ifr'.

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

14 months agoifconfig: remove (most of) the usages of global 'struct ifreq ifr'.
Alexander V. Chernikov [Wed, 14 Jun 2023 13:00:49 +0000 (13:00 +0000)]
ifconfig: remove (most of) the usages of global 'struct ifreq ifr'.

It is hard to reason about the contents of 'ifr' at any given time
as nearly every function sets random fields or pointers in this
structure.
Use local on-stack clean 'struct ifreq' for each function instead.

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

14 months agovm_phys: add binary segment search
Doug Moore [Fri, 16 Jun 2023 06:43:45 +0000 (01:43 -0500)]
vm_phys: add binary segment search

Replace several sequential searches for a segment that contains a
phyiscal address with a call to a function that does it by binary
search.  In vm_page_reclaim_contig_domain_ext, find the first segment
to reclaim from, and reclaim from each subsequent appropriate segment.
Eliminate vm_phys_scan_contig.

Reviewed by: alc, markj
Differential Revision: https://reviews.freebsd.org/D40058

14 months agobhyve: add basic CRB interface for TPM devices
Corvin Köhne [Mon, 29 Aug 2022 10:10:43 +0000 (12:10 +0200)]
bhyve: add basic CRB interface for TPM devices

Add a basic emulation for the command and response buffer interface of
TPM devices. This commit only implements some CRB register and resets
them.

Reviewed by: markj
MFC after: 1 week
Sponsored by: Beckhoff Automation GmbH & Co. KG
Differential Revision: https://reviews.freebsd.org/D40456

14 months agobhyve: add basic TPM passthrough emulation
Corvin Köhne [Mon, 15 May 2023 12:04:15 +0000 (14:04 +0200)]
bhyve: add basic TPM passthrough emulation

At the moment, the emulation only opens a file descriptor to the TPM
device. Some subsequent commits will read and write from it.

Reviewed by: markj
MFC after: 1 week
Sponsored by: Beckhoff Automation GmbH & Co. KG
Differential Revision: https://reviews.freebsd.org/D40455

14 months agobhyve: add basic TPM emulation struct
Corvin Köhne [Mon, 15 May 2023 11:49:42 +0000 (13:49 +0200)]
bhyve: add basic TPM emulation struct

This struct will be used to implement various TPM emulations like a TPM
passthrough or a virtual TPM.

Reviewed by: markj
MFC after: 1 week
Sponsored by: Beckhoff Automation GmbH & Co. KG
Differential Revision: https://reviews.freebsd.org/D40454

14 months agobhyve: use assert for missing TPM version
Corvin Köhne [Thu, 15 Jun 2023 08:36:37 +0000 (10:36 +0200)]
bhyve: use assert for missing TPM version

The TPM version config node should always be set. If it's not set,
there's a bug in our code. An assertion is the correct way to check for
this.

Reviewed by: markj
MFC after: 1 week
Sponsored by: Beckhoff Automation GmbH & Co. KG
Differential Revision: https://reviews.freebsd.org/D40558

14 months agobhyve: pass address of OpRegion to the guest
Corvin Köhne [Wed, 10 May 2023 11:44:28 +0000 (13:44 +0200)]
bhyve: pass address of OpRegion to the guest

Don't allow access to the physical ASLS register. It contains a host
address which is meaningless for the guest. Additionally, it allows the
guest to safely rewrite this register.

This is the last commit required for GVT-d. Nevertheless, it might not
work due to missing firmware support.

MFC after: 1 week
Sponsored by: Beckhoff Automation GmbH & Co. KG
Differential Revision: https://reviews.freebsd.org/D26209

14 months agobhyve: copy OpRegion into guest memory
Corvin Köhne [Wed, 10 May 2023 11:39:56 +0000 (13:39 +0200)]
bhyve: copy OpRegion into guest memory

This makes the OpRegion accessible by the guest. However, the guest
doesn't know the address of the OpRegion. This will be fixed by an
upcoming commit.

The range of the OpRegion is added to the e820 table. This allows the
guest firmware to easily pick up this range and to reserve it properly.

Reviewed by: markj
MFC after: 1 week
Sponsored by: Beckhoff Automation GmbH & Co. KG
Differential Revision: https://reviews.freebsd.org/D40041

14 months agobhyve: read OpRegion address and size for GVT-d
Corvin Köhne [Wed, 10 May 2023 11:38:02 +0000 (13:38 +0200)]
bhyve: read OpRegion address and size for GVT-d

The OpRegion provides some configuration bits and ACPI methods used by
some Intel drivers. The guest needs access to it. In the first step,
we're reading it's address and size.

Reviewed by: jhb
MFC after: 1 week
Sponsored by: Beckhoff Automation GmbH & Co. KG
Differential Revision: https://reviews.freebsd.org/D40040

14 months agobhyve: emulate graphics stolen memory register
Corvin Köhne [Thu, 11 May 2023 09:18:56 +0000 (11:18 +0200)]
bhyve: emulate graphics stolen memory register

This register contains a host physical address. This address is
meaningless for the guest. We have to emulate it and set it to a valid
guest physical address.

Reviewed by: markj
MFC after: 1 week
Sponsored by: Beckhoff Automation GmbH & Co. KG
Differential Revision: https://reviews.freebsd.org/D40060

14 months agobhyve: allocate guest memory for graphics stolen memory
Corvin Köhne [Thu, 11 May 2023 09:10:07 +0000 (11:10 +0200)]
bhyve: allocate guest memory for graphics stolen memory

The graphics stolen memory is only GPU accessible. So, we don't have to
copy any data to it as the guest will be unable to access it anyway. We
just have to allocate and reserve some memory. That's done by adding an
E820 entry for the graphics stolen memory. The guest firmware will pick
up the E820 and reserve this range.

Note that we try to reuse the host address as Intel states that newer
Tiger Lake platforms need this [1].

[1]
https://github.com/projectacrn/acrn-hypervisor/blob/e28d6fbfdfd556ff1bc3ff330e41d4ddbaa0f897/devicemodel/hw/pci/passthrough.c#L626-L629

Reviewed by: markj
MFC after: 1 week
Sponsored by: Beckhoff Automation GmbH & Co. KG
Differential Revision: https://reviews.freebsd.org/D40059

14 months agobhyve: read out graphics stolen memory address and size
Corvin Köhne [Thu, 11 May 2023 08:53:15 +0000 (10:53 +0200)]
bhyve: read out graphics stolen memory address and size

This is the first step to emulate the graphics stolen memory register.

Note that the graphics stolen memory is somehow confusing. On the one
hand the Intel Open Source HD Graphics Programmers' Reference Manual
states that it's only GPU accessible. As the CPU can't access the area,
the guest shouldn't need it. On the other hand, the Intel GOP driver
refuses to work properly, if it's not set to a proper address.

Intel itself maps it into the guest by EPT [1]. At the moment, we're not
aware of any situation where this EPT mapping is required, so we don't
do it yet.

Intel also states that the Windows driver for Tiger Lake reads the
address of the graphics stolen memory [2]. As the GVT-d code doesn't
support Tiger Lake in its first implementation, we can't check how it
behaves. We should keep an eye on it.

[1]
https://github.com/projectacrn/acrn-hypervisor/blob/e28d6fbfdfd556ff1bc3ff330e41d4ddbaa0f897/devicemodel/hw/pci/passthrough.c#L655-L657
[2]
https://github.com/projectacrn/acrn-hypervisor/blob/e28d6fbfdfd556ff1bc3ff330e41d4ddbaa0f897/devicemodel/hw/pci/passthrough.c#L626-L629

Reviewed by: markj
MFC after: 1 week
Sponsored by: Beckhoff Automation GmbH & Co. KG
Differential Revision: https://reviews.freebsd.org/D40039

14 months agobhyve: add empty GVT-d emulation
Corvin Köhne [Wed, 10 May 2023 10:31:50 +0000 (12:31 +0200)]
bhyve: add empty GVT-d emulation

Don't emulate anything yet. Just check if the user would like to pass an
Intel GPU to the guest.

Reviewed by: jhb, markj
MFC after: 1 week
Sponsored by: Beckhoff Automation GmbH & Co. KG
Differential Revision: https://reviews.freebsd.org/D40038

14 months agoSYSCALL_MODULE(9): fix references to modfind(2) and modstat(2)
Ka Ho Ng [Thu, 15 Jun 2023 19:37:53 +0000 (15:37 -0400)]
SYSCALL_MODULE(9): fix references to modfind(2) and modstat(2)

Sponsored by: Juniper Networks, Inc.
Reviewed by: delphij
MFC after: 1 week

14 months agoasa: Add some unit tests.
Dag-Erling Smørgrav [Thu, 15 Jun 2023 19:23:26 +0000 (19:23 +0000)]
asa: Add some unit tests.

MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D40564

14 months agoasa: Read from stdin if *argv is "-".
Dag-Erling Smørgrav [Thu, 15 Jun 2023 19:23:22 +0000 (19:23 +0000)]
asa: Read from stdin if *argv is "-".

MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D40563

14 months agoasa: Error out if writing to stdout failed.
Dag-Erling Smørgrav [Thu, 15 Jun 2023 19:23:19 +0000 (19:23 +0000)]
asa: Error out if writing to stdout failed.

MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D40562

14 months agobhyve: Sort SRCS
Mark Johnston [Thu, 15 Jun 2023 16:21:54 +0000 (12:21 -0400)]
bhyve: Sort SRCS

No functional change intended.

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

14 months agoarm64: Make a debug print conditional on bootverbose
Mark Johnston [Thu, 15 Jun 2023 16:13:05 +0000 (12:13 -0400)]
arm64: Make a debug print conditional on bootverbose

It doesn't seem particularly useful to have it enabled by default, and
it spits several dozen lines into the dmesg on a test system.

Reviewed by: andrew
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D40499

14 months agobhyve: Remove special no-op handling for I/O port 0x488
Mark Johnston [Thu, 15 Jun 2023 16:12:25 +0000 (12:12 -0400)]
bhyve: Remove special no-op handling for I/O port 0x488

This appears to have been reserved for some kind of debug hook, but it's
not implemented and appears never to have been used.

Reviewed by: corvink, jhb
MFC after: 1 week
Sponsored by: Innovate UK
Differential Revision: https://reviews.freebsd.org/D40555

14 months agodtrace/arm64: Fix user memory access routines
Mark Johnston [Thu, 15 Jun 2023 16:39:21 +0000 (12:39 -0400)]
dtrace/arm64: Fix user memory access routines

Use unprivileged loads to access user memory.  Without this, the
accesses trap and various dtrace actions such as ustack() fail.

Reviewed by: andrew
MFC after: 1 week
Sponsored by: Innovate UK
Differential Revision: https://reviews.freebsd.org/D40540

14 months agodtrace/arm64: Store the fault address when suppressing a page fault
Mark Johnston [Thu, 15 Jun 2023 16:11:11 +0000 (12:11 -0400)]
dtrace/arm64: Store the fault address when suppressing a page fault

Reviewed by: andrew
Sponsored by: Innovate UK
Differential Revision: https://reviews.freebsd.org/D40539

14 months agoarm64: Remove struct arm64_frame
Mark Johnston [Thu, 15 Jun 2023 16:10:44 +0000 (12:10 -0400)]
arm64: Remove struct arm64_frame

It was used in one place and was added specifically to support dtrace
stack unwinding code.  Write an equivalent expression using struct
unwind_state instead.  No functional change intended.

Reviewed by: andrew
MFC after: 1 week
Sponsored by: Innovate UK
Differential Revision: https://reviews.freebsd.org/D40538

14 months agoarmv8crypto: Avoid overriding -march when compiling some source files
Mark Johnston [Thu, 15 Jun 2023 16:10:19 +0000 (12:10 -0400)]
armv8crypto: Avoid overriding -march when compiling some source files

At least one downstream (CheriBSD) overrides -march here.  Instead of
hard-coding the target, simply append the crypto extension to whatever's
already there.

No functional change intended.

Reviewed by: imp, andrew
MFC after: 1 week
Sponsored by: Innovate UK
Differential Revision: https://reviews.freebsd.org/D40537

14 months agooce(4): deprecate
Brooks Davis [Wed, 14 Jun 2023 17:55:54 +0000 (18:55 +0100)]
oce(4): deprecate

The Emulex OneConnect NIC driver hasn't seen any commits other than ioctl
bug fixes (some severe) and sweeping commits since 2016.  There is no
indication of new parts since 2014 or earlier.  As such, deprecate the
driver with the aim of removing it prior to FreeBSD 15.

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

14 months agooce(4): Don't directly access usespace
Brooks Davis [Wed, 14 Jun 2023 17:55:41 +0000 (18:55 +0100)]
oce(4): Don't directly access usespace

Replace direct stores to userspace addresses (never safe and broken on
modern CPUs) with a copyout.  Use a static assert on the size to ensure
we don't overflow the field.

Reviewed by: markj, jhb
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D40519

14 months agompi3mr: Add bare-bones manual
Warner Losh [Wed, 14 Jun 2023 22:12:28 +0000 (16:12 -0600)]
mpi3mr: Add bare-bones manual

The mpi3mr driver is written by Broadcom for the 9600 Series 24G PCIe
4.0 Tri-Mode RAID Adapters and eHBAs boards. This is 3rd-Generation
Tri-Mode x8 and x16 NVMe/SAS/SATA (although Broadcom/Avago did muddy the
waters by having multiple 2nd generations cards and referring to them
inconsistently).

Sponsored by: Netflix

14 months agompi3mr: 3rd Generation Tri-Mode NVMe/SAS/SATA MegaRaid / eHBA
Sumit Saxena [Wed, 14 Jun 2023 22:22:30 +0000 (16:22 -0600)]
mpi3mr: 3rd Generation Tri-Mode NVMe/SAS/SATA MegaRaid / eHBA

This is Broadcom's mpi3mr driver for FreeBSD version 8.6.0.2.0.
The mpi3mr driver supports Broadcom SAS4116-based cards in the 9600
series: 9670W-16i, 9670-24i, 9660-16i, 9620-16i, 9600-24i, 9600-16i,
9600W-16e, 9600-16e, 9600-8i8e.

Initially only available as a module and on amd64/arm64, since that's
how it has been tested to date. Future commits will add it to the kernel
build and may expand the architectures it is supported on.

Co-authored-by: Chandrakanth Patil <chandrakanth.patil@broadcom.com>
Feedback-by: ken (prior versions)
Reviewed-by: imp
RelNotes: yes
Differential-Revision: https://reviews.freebsd.org/D36771
Differential-Revision: https://reviews.freebsd.org/D36772

14 months agoipfw: use function return value to fetch insn argument.
Alexander V. Chernikov [Thu, 15 Jun 2023 06:46:42 +0000 (06:46 +0000)]
ipfw: use function return value to fetch insn argument.

This is a prerequsite for splitting compile_rule() into smaller
chunks.

MFC after: 2 weeks

14 months agoipfw: add eaction tests
Alexander V. Chernikov [Thu, 15 Jun 2023 06:36:16 +0000 (06:36 +0000)]
ipfw: add eaction tests

MFC after: 2 weeks

14 months agoroute.8: mention DXR in FIB_ALGO section
Marko Zec [Thu, 15 Jun 2023 05:21:51 +0000 (07:21 +0200)]
route.8: mention DXR in FIB_ALGO section

While here, add a sentence describing DPDK DIR24-8 principle of
operation.

MFC after: 2 weeks.

14 months agocaroot: update the root bundle
Kyle Evans [Thu, 15 Jun 2023 04:26:23 +0000 (23:26 -0500)]
caroot: update the root bundle

Summary:
- Zero (0) newly trusted
- Five (5) modified
- Nine (9) distrusted

MFC after: 3 days

14 months agoresizewin: Stop printing bogus NUL to TTY
Jessica Clarke [Wed, 14 Jun 2023 22:58:36 +0000 (23:58 +0100)]
resizewin: Stop printing bogus NUL to TTY

A char array has an implicit NUL terminating it, which sizeof will
include, so we need to subtract 1 here. Printing a NUL can cause issues
for things like CI environments that aren't expecting it, especially
with recent Jenkins being stricter about not putting NUL in XML files.

Fixes: 3d222369acbe ("Add a small tool, resizewin(1), to query terminal for window size")
MFC after: 1 week

14 months agotcp: add missing static keywords
Gleb Smirnoff [Wed, 14 Jun 2023 21:21:28 +0000 (14:21 -0700)]
tcp: add missing static keywords

Without them compilation with -O0 would produce kernel modules
that depend on symbol that doesn't exist.

14 months agoEC2: Default to "uefi-preferred" boot mode
Colin Percival [Wed, 7 Jun 2023 22:17:12 +0000 (15:17 -0700)]
EC2: Default to "uefi-preferred" boot mode

In EC2, UEFI boots faster than BIOS, but not all amd64 instance types
support UEFI.  AMIs need to have their boot mode designated, which
created a dilemma: Faster boots, or wider compatibility?

The recently added "uefi-preferred" option solves this: AMIs can be
marked to use UEFI where it's available, but fall back to BIOS on
instance types which do not support UEFI.

This uses bsdec2-image-upload 1.4.6, which recently landed in the
ports tree.

PR: 265697
Reviewed by: delphij, imp
MFC after: 1 week
Sponsored by: https://www.patreon.com/cperciva
Differential Revision: https://reviews.freebsd.org/D40470

14 months agohwpmc: flatten conditional in pmc_process_exit()
Mitchell Horne [Wed, 14 Jun 2023 16:33:46 +0000 (13:33 -0300)]
hwpmc: flatten conditional in pmc_process_exit()

Use a goto to clarify the control flow when there is no process
descriptor. This wins back a level of indentation.

No functional change intended.

Reviewed by: jkoshy
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D40518

14 months agohwpmc: split out PMC_OP_PMCRW
Mitchell Horne [Wed, 14 Jun 2023 16:33:41 +0000 (13:33 -0300)]
hwpmc: split out PMC_OP_PMCRW

Split out the functional logic from the syscall handler into a helper
function. This keeps it separate from the syscall control-flow logic,
resulting in better readability overall. It also wins back a level of
indentation.

Reviewed by: jkoshy
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D40294

14 months agohwpmc: split out PMC_OP_PMCRELEASE
Mitchell Horne [Wed, 14 Jun 2023 16:33:35 +0000 (13:33 -0300)]
hwpmc: split out PMC_OP_PMCRELEASE

Split out the functional logic from the syscall handler into a helper
function. This keeps it separate from the syscall control-flow logic,
resulting in better readability overall. It also wins back a level of
indentation.

Reviewed by: jkoshy
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D40293

14 months agohwpmc: split out PMC_OP_PMCALLOCATE
Mitchell Horne [Wed, 14 Jun 2023 16:33:27 +0000 (13:33 -0300)]
hwpmc: split out PMC_OP_PMCALLOCATE

Split out the large chunk of functional logic from the syscall handler
into a helper function. This keeps it separate from the syscall
control-flow logic, resulting in better readability overall. It also
wins back a level of indentation.

Flip the return values of the pmc_can_allocate_row() and
pmc_can_allocate_rowindex() functions to boolean types, like their
naming implies. We weren't actually using the error codes they were
returning.

While here, make some small style cleanups. No functional change
intended.

Reviewed by: jkoshy
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D40292

14 months agohwpmc: split out PMC_OP_PMCATTACH/PMC_OP_PMCDETACH
Mitchell Horne [Wed, 14 Jun 2023 16:32:11 +0000 (13:32 -0300)]
hwpmc: split out PMC_OP_PMCATTACH/PMC_OP_PMCDETACH

Begin splitting out the large chunks of functional logic from the
syscall handler into separate helper functions. This keeps it separate
from the syscall control-flow logic, resulting in better readability
overall. It also wins back a level of indentation.

For this and the similar changes to follow, try to keep copyin() and
copyout() calls outside of the helper functions. The changes are
intended to have no functional impact, but do address style issues.

Reviewed by: jkoshy
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D40291

14 months agohwpmc: split out PMC_FN_PROCESS_EXEC
Mitchell Horne [Wed, 14 Jun 2023 16:32:01 +0000 (13:32 -0300)]
hwpmc: split out PMC_FN_PROCESS_EXEC

Move the functionality into a separate helper function. All other
actions in pmc_hook_handler() already have this.

While here make some small style improvements. Restructure one for loop.

Reviewed by: jkoshy
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D40333

14 months agohwpmc_mod.c: misc style cleanup
Mitchell Horne [Wed, 14 Jun 2023 16:31:36 +0000 (13:31 -0300)]
hwpmc_mod.c: misc style cleanup

Everything else I found worthy of adjustment.

 - Order local variable declarations per style(9)
 - Make use of __unused annotations rather than cast to void
 - Remove unnecessary casts
 - Add (void) casts to PMC class methods where the return value is
   ignored
 - A couple instances of reordering statements for clarity
 - Prefer bool type where applicable
 - unsigned int -> u_int
 - Use uintmax_t/%j in printf calls
 - Formatting of comments

Reviewed by: jkoshy
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D40517

14 months agohwpmc_mod.c: prototype style
Mitchell Horne [Wed, 14 Jun 2023 16:31:30 +0000 (13:31 -0300)]
hwpmc_mod.c: prototype style

Improve alphabetical organization, grouping, and whitespace.

Reviewed by: jkoshy
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D40516

14 months agohwpmc_mod.c: conditional and loop style
Mitchell Horne [Wed, 14 Jun 2023 16:31:24 +0000 (13:31 -0300)]
hwpmc_mod.c: conditional and loop style

 - Explicitly check the value in conditional statements, per style(9)
 - Add braces around more loops and conditionals, wherever it appears
   (to me) to aid legibility
 - Expand some assignments within if statements
 - Fix formatting around list-type FOREACH macros

Reviewed by: jkoshy
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D40515

14 months agohwpmc_mod.c: whitespace style cleanup
Mitchell Horne [Wed, 14 Jun 2023 16:31:15 +0000 (13:31 -0300)]
hwpmc_mod.c: whitespace style cleanup

Handle a few things related to spacing:
 - Remove redundant/superfluous blank lines (and add a couple where
   helpful)
 - Add spacing around binary operators
 - Remove spacing after casts and before goto labels
 - Adjustments for line width of 80 chars
 - Tab/space character issues

Reviewed by: jkoshy
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D40514

14 months agohwpmc_mod.c: return statement style
Mitchell Horne [Wed, 14 Jun 2023 16:31:06 +0000 (13:31 -0300)]
hwpmc_mod.c: return statement style

Reviewed by: jkoshy
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D40513

14 months agohpwmc: add __pmcdbg_used annotation
Mitchell Horne [Wed, 14 Jun 2023 16:30:32 +0000 (13:30 -0300)]
hpwmc: add __pmcdbg_used annotation

For variables which are only used in PMCDBG* macros.

Reviewed by: jkoshy, emaste
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D40288

14 months agoifconfig: fix ifconfig crash when compiled w/WITHOUT_NETLINK.
Alexander V. Chernikov [Wed, 14 Jun 2023 10:37:07 +0000 (10:37 +0000)]
ifconfig: fix ifconfig crash when compiled w/WITHOUT_NETLINK.

Properly update the recently-introduced `ctx->ifname` when iterating
over interfaces.

Reported by: Gary Jennejohn <garyj@gmx.de>
MFC after: 2 weeks

14 months agoifconfig: fix -Wunused warnings
Alexander V. Chernikov [Wed, 14 Jun 2023 07:59:01 +0000 (07:59 +0000)]
ifconfig: fix -Wunused warnings

MFC after: 2 weeks

14 months agoifconfig: remove 'newaddr' global variable
Alexander V. Chernikov [Wed, 14 Jun 2023 07:51:27 +0000 (07:51 +0000)]
ifconfig: remove 'newaddr' global variable

Differential Revision: https://reviews.freebsd.org/D40441
MFC after: 2 weeks

14 months agoifconfig: start ifconfig context from main()
Alexander V. Chernikov [Wed, 14 Jun 2023 07:40:12 +0000 (07:40 +0000)]
ifconfig: start ifconfig context from main()

Differential Revision: https://reviews.freebsd.org/D40440
MFC after: 2 weeks

14 months agoifconfig: fix comparison in printmimo().
Alexander V. Chernikov [Wed, 14 Jun 2023 07:38:53 +0000 (07:38 +0000)]
ifconfig: fix comparison in printmimo().

Differential Revision: https://reviews.freebsd.org/D40301
MFC after: 2 weeks

14 months agofwget: Always install packages
Emmanuel Vadot [Wed, 14 Jun 2023 07:17:55 +0000 (09:17 +0200)]
fwget: Always install packages

This wasn't done before as -y wasn't added to the pkg install line.

Sponsored by: Beckhoff Automation GmbH & Co. KG

14 months agotcpdump: fix build with WITHOUT_PF=1
Gleb Smirnoff [Wed, 14 Jun 2023 03:58:36 +0000 (20:58 -0700)]
tcpdump: fix build with WITHOUT_PF=1

Fixes: ee67461e56828dd1f8de165947ba83f6d9148a87

14 months agoFix build with gcc12.
Xin LI [Wed, 14 Jun 2023 03:24:07 +0000 (20:24 -0700)]
Fix build with gcc12.

14 months agonss_tacplus: Support setting the login class.
Dag-Erling Smørgrav [Tue, 13 Jun 2023 16:06:27 +0000 (16:06 +0000)]
nss_tacplus: Support setting the login class.

MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: thj
Differential Revision: https://reviews.freebsd.org/D40376

14 months agolibtacplus: Allow additional AV pairs to be configured.
Dag-Erling Smørgrav [Tue, 13 Jun 2023 16:04:22 +0000 (16:04 +0000)]
libtacplus: Allow additional AV pairs to be configured.

* Replace hand-rolled input tokenizer with openpam_readlinev() which supports line continuations and has better quoting and escaping.
* Simplify string handling by merging struct clnt_str and struct srvr_str into just struct tac_str.
* Each server entry in the configuration file can now have up to 255 AV pairs which will be appended to the ones returned by the server in response to a successful authorization request.

This allows nss_tacplus(8) to be used with servers which do not provide identity information beyond confirming the existence of the user.

This adds a dependency on libpam, however libtacplus is currently only used by pam_tacplus(8) (which is already always used with libpam) and the very recently added nss_tacplus(8) (which is extremely niche).  In the longer term it might be a good idea to split this out into a separate library.

MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: pauamma_gundo.com, markj
Differential Revision: https://reviews.freebsd.org/D40285
Relnotes: yes

14 months agonetlink: fix failing TestRtNlAddIfaddrLo::test_add_6 tests.
Alexander V. Chernikov [Tue, 13 Jun 2023 15:24:24 +0000 (15:24 +0000)]
netlink: fix failing TestRtNlAddIfaddrLo::test_add_6 tests.

Recent netlink commit added hook for calling IPv6 code upon implicit
inteface bring-up on adding first interface address. This hook handles
link-local ifa addition for the loopback interface, resulting in
failed assertion in the loopback tests.

Fix the tests by fixing the assert.

14 months agoUPDATING: Add note about nvd aliases
Warner Losh [Tue, 13 Jun 2023 15:23:58 +0000 (09:23 -0600)]
UPDATING: Add note about nvd aliases

Add note about nvd alias disabling to UPDATING so it's easily at hand.

Sponsored by: Netflix

14 months agonvd/nda: Add release notes info.
Warner Losh [Tue, 13 Jun 2023 15:17:57 +0000 (09:17 -0600)]
nvd/nda: Add release notes info.

Sponsored by: Netflix

14 months agodummynet tests: attempt to provoke wf2q+ use-after-free
Kristof Provost [Mon, 12 Jun 2023 13:12:37 +0000 (15:12 +0200)]
dummynet tests: attempt to provoke wf2q+ use-after-free

Attempt to provoke known use-after-free issues with WF2Q+.

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

14 months agodummynet: fix wf2q use-after-free
Kristof Provost [Mon, 12 Jun 2023 13:05:41 +0000 (15:05 +0200)]
dummynet: fix wf2q use-after-free

When we clean up a wf2q+ queue we need to ensure that we remove it from
the correct heap. If we leave a queue pointer behind in an unexpected
heap we'll later write to it, causing a use-after-free and unpredictable
panics.

Teach the dummynet heap code to verify that we're removing the correct
object so we can safely attempt to remove objects not contained in the
heap.

Remove a to-be-removed queue from all heaps.

Also don't continue the enqueue function if we're not finding the queue
on the idle heap as we'd expect.

While here also remove the empty heap warning, because this is now
expected to happen.

See also: https://redmine.pfsense.org/issues/14433
Sponsored by: Rubicon Communications, LLC ("Netgate")

14 months agodummynet: remove unused field from dn_pkt_tag
Kristof Provost [Thu, 8 Jun 2023 13:53:02 +0000 (15:53 +0200)]
dummynet: remove unused field from dn_pkt_tag

ip6opt is never used, so remove it, slightly reducing memory use for
each packet tag.

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

14 months agokinst: rename t_kinst to t_kinst_tramp
Christos Margiolis [Tue, 13 Jun 2023 12:46:45 +0000 (15:46 +0300)]
kinst: rename t_kinst to t_kinst_tramp

The forthcoming RISC-V and ARM64 ports of kinst introduce a new field
named "t_kinst_curprobe", so "t_kinst" (which points to a trampoline)
becomes a misleading name.

No functional change intended.

Reviewed by: markj
Approved by: markj (mentor)
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D40507

14 months agokinst: hide KINST_TRAMPCHUNK_SIZE from ISA-specific headers
Christos Margiolis [Tue, 13 Jun 2023 12:46:33 +0000 (15:46 +0300)]
kinst: hide KINST_TRAMPCHUNK_SIZE from ISA-specific headers

Reviewed by: markj
Approved by: markj (mentor)
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D40505

14 months agoproc.h: capitalize letter in TD_LOCKS_DEC
Christos Margiolis [Tue, 13 Jun 2023 12:46:20 +0000 (15:46 +0300)]
proc.h: capitalize letter in TD_LOCKS_DEC

The other related macros capitalize "thread" as well, so use the same
style. No functional change intended.

Reviewed by: markj
Approved by: markj (mentor)
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D40506

14 months agonamei: Reset the lookup to start from the real root for abs symlink target
Dmitry Chagin [Tue, 13 Jun 2023 12:24:25 +0000 (15:24 +0300)]
namei: Reset the lookup to start from the real root for abs symlink target

Since fd745e1d Linux ABI specifies alternative root directory to reroot
lookups. First, an attempt is made to lookup the file in /ABI/original-path.
If that fails, the lookup is done in /original-path. In case of lookup
symbolic link with leading / in target namei() fails due to reroot reloads
original file name.
To avoid this handle restart in a special maner, without origin path name
reloading.

Reported by: Goran Mekić, Vincent Milum Jr
Tested by: Goran Mekić
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D40479

14 months agonamei: Add a comment explaining ISRESTARTED flag
Dmitry Chagin [Tue, 13 Jun 2023 12:22:09 +0000 (15:22 +0300)]
namei: Add a comment explaining ISRESTARTED flag

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

14 months agoipfw: simplify action case parser
Alexander V. Chernikov [Wed, 7 Jun 2023 08:31:52 +0000 (08:31 +0000)]
ipfw: simplify action case parser

Remove "goto charg" from the action parser.
This is a prerequisite for the further split of the gigantic
compile_rule().

Differential Revision: https://reviews.freebsd.org/D40490
MFC after: 2 weeks

14 months agoipfw(8): add ioctl/instruction generation tests
Alexander V. Chernikov [Sun, 11 Jun 2023 08:12:04 +0000 (08:12 +0000)]
ipfw(8): add ioctl/instruction generation tests

Differential Revision: https://reviews.freebsd.org/D40488
MFC after: 2 weeks

14 months agostress2: Added a regression test for mksnap_ffs(8)
Peter Holm [Tue, 13 Jun 2023 09:01:43 +0000 (11:01 +0200)]
stress2: Added a regression test for mksnap_ffs(8)

14 months agolinuxkpi: advance platform_device
Corvin Köhne [Tue, 31 Jan 2023 08:18:38 +0000 (09:18 +0100)]
linuxkpi: advance platform_device

These are required by some linux driver like:
https://github.com/beckhoff/bbapi

Reviewed by: manu
MFC after: 1 week
Sponsored by: Beckhoff Automation GmbH & Co. KG
Differential Revision: https://reviews.freebsd.org/D39554

14 months agoWrite out corrected superblock when creating a UFS/FFS snapshot.
Kirk McKusick [Tue, 13 Jun 2023 07:21:43 +0000 (00:21 -0700)]
Write out corrected superblock when creating a UFS/FFS snapshot.

When taking a snapshot on a UFS version 1 filesystem we need to
call ffs_oldfscompat_write() to unwind any in-memory changes that
were made to the superblock before writing it. The cause of this bug
was that the trimmed down maximum file size was not being reverted.

PR:           271352
Tested-by: Peter Holm
MFC-after:    1 week
Sponsored-by: The FreeBSD Foundation
14 months agoifconfig(8): add the dotted format for MAC addresses.
Trond Endrestol [Tue, 13 Jun 2023 06:36:16 +0000 (06:36 +0000)]
ifconfig(8): add the dotted format for MAC addresses.

MFC after: 2 weeks
PR: 261572

14 months agoifconfig: remove global_args variable.
Alexander V. Chernikov [Tue, 13 Jun 2023 06:25:10 +0000 (06:25 +0000)]
ifconfig: remove global_args variable.

This variable was temporarily introduced in the beginning of the
code cleanup. Use on-stack instance in main() instead.

Reviewed By: kp
Differential Revision: https://reviews.freebsd.org/D40439
MFC after: 2 weeks

14 months agoifconfig: remove global 'name' variable.
Alexander V. Chernikov [Tue, 13 Jun 2023 06:22:29 +0000 (06:22 +0000)]
ifconfig: remove global 'name' variable.

Consistenly use newly-added 'ctx->ifname' as the name of the current
target interface.

Reviewed By: kp
Differential Revision: https://reviews.freebsd.org/D40438
MFC after: 2 weeks

14 months agoifconfig: pass if_ctx instead of socket to the tunnel handlers.
Alexander V. Chernikov [Tue, 13 Jun 2023 06:19:50 +0000 (06:19 +0000)]
ifconfig: pass if_ctx instead of socket to the tunnel handlers.

This is a pre-requisite for the global 'name' variable removal.

Reviewed By: kp
Differential Revision: https://reviews.freebsd.org/D40432
MFC after: 2 weeks

14 months agoifconfig: remove global 'printifname' variable.
Alexander V. Chernikov [Tue, 13 Jun 2023 06:18:05 +0000 (06:18 +0000)]
ifconfig: remove global 'printifname' variable.

This variable was used to print the created interface name in the
atexit(3) handler. The interface name was calculated in the
ifclonecreate() by matching old & new names.

This change alter the implementation the following way:
1) the function responsible for the interface creation (ifcreate_ioctl)
 updates all necessary state internally. This removes the need for the
 name manipulation hack in wlan_create().
2) As atexit(3) handler does not accept any parameters, explicitly store
 the name to print in the ifname_to_print variable read by the atexit(3)
 handler.

Reviewed By: kp
Differential Revision: https://reviews.freebsd.org/D40431
MFC after: 2 weeks

14 months agoifconfig: eliminate global 'verbose' and 'printkey' variables
Alexander V. Chernikov [Tue, 13 Jun 2023 06:15:13 +0000 (06:15 +0000)]
ifconfig: eliminate global 'verbose' and 'printkey' variables

Reviewed By: kp
Differential Revision: https://reviews.freebsd.org/D40427
MFC after: 2 weeks

14 months agoifconfig: add if_ctx argument to the generic and ifclone callbacks.
Alexander V. Chernikov [Tue, 13 Jun 2023 06:10:41 +0000 (06:10 +0000)]
ifconfig: add if_ctx argument to the generic and ifclone callbacks.

This is the continuation of the ifconfig cleanup work. This change is
a pre-requsite for the next changes removing some of the global variables.
It will also help in implementing functionality via Netlink instead of ioctl.
No functional changes intended.
* vxlan_cb() was removed as it contained no code
* ioctl_ifcreate() was renamed to ifcreate_ioctl() to follow the other
netlink/ioctl function naming. Netlink and ioctl provide _different_
interfaces and it's not possible to have a unified interface object
that can be filled by either netlink or ioctl implementations. With that
in mind, I'm leaning more to the function_<nl|ioctl> postfix pattern,
than doing ioctl_ or netlink_ prefix.

Reviewed By: kp
Differential Revision: https://reviews.freebsd.org/D40426
MFC after: 2 weeks

14 months agoroute(8): teach route to attach to jails
Yan Ka, Chiu [Tue, 13 Jun 2023 06:05:17 +0000 (06:05 +0000)]
route(8): teach route to attach to jails

Add -j <jail> flag to route(8) to allow route to perform actions in
a Jail.

Differential Revision: https://reviews.freebsd.org/D40377
MFC after: 2 weeks

14 months agoktest: make ktest work with Netlink loaded as a module.
Alexander V. Chernikov [Thu, 1 Jun 2023 07:25:41 +0000 (07:25 +0000)]
ktest: make ktest work with Netlink loaded as a module.

MFC after: 2 weeks

14 months agoexpand_number: Tighten check of unit.
Xin LI [Tue, 13 Jun 2023 04:08:32 +0000 (21:08 -0700)]
expand_number: Tighten check of unit.

The current code silently ignores characters after the unit as long
the unit themselves were recognized. This commit makes expand_number(3)
to fail with EINVAL if buf did not terminate after the unit character.

Historically, the function accepts and ignores "B" as a SI unit, this
behavior is preserved and e.g. KB, MB are still accepted as aliases of
K and M, document this behavior in the manual page.

While I am there, also write a few test cases to validate the behavior.

Reviewed-by: emaste
MFC-after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D40482

14 months agonvme: Switch to nda by default
Warner Losh [Tue, 13 Jun 2023 03:37:10 +0000 (21:37 -0600)]
nvme: Switch to nda by default

We already run nda by default on all the !x86 architectures. Switch the
default to nda. nda created nvd compatibility links by default, so this
should be a nop. If this causes problems for your application, set
hw.nvme.use_nvd=1 in your loader.conf.

Sponsored by: Netflix

14 months agomac(9): update SEE ALSO
Mitchell Horne [Mon, 12 Jun 2023 18:59:00 +0000 (15:59 -0300)]
mac(9): update SEE ALSO

Rather than maintaining an incomplete list of MAC modules references,
just reference mac(4), where such a list can be found.

Reviewed by: Mina Galić <freebsd@igalic.co>
Reviewed by: Pau Amma <pauamma@gundo.com>
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D40485

14 months agomac(4): update the references to MAC modules
Mitchell Horne [Mon, 12 Jun 2023 18:56:34 +0000 (15:56 -0300)]
mac(4): update the references to MAC modules

Add entries for mac_ntpd(4) and mac_priority(4) to the table of MAC
modules.

Drop the entry for mac_none(4) from the list, but retain the
cross-reference in SEE ALSO. This module has no functional impact and is
of minimal interest to users. Add a new cross-reference to the similar
mac_stub(4), limited to SEE ALSO for the same reasoning.

Reviewed by: Pau Amma <pauamma@gundo.com>
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D40483

14 months agoamd64/arm64 pmap: Stop requiring the accessed bit for superpage promotion
Alan Cox [Wed, 31 May 2023 23:10:41 +0000 (18:10 -0500)]
amd64/arm64 pmap: Stop requiring the accessed bit for superpage promotion

Stop requiring all of the PTEs to have the accessed bit set for superpage
promotion to occur.  Given that change, add support for promotion to
pmap_enter_quick(), which does not set the accessed bit in the PTE that
it creates.

Since the final mapping within a superpage-aligned and sized region of a
memory-mapped file is typically created by a call to pmap_enter_quick(),
we now achieve promotions in circumstances where they did not occur
before, for example, the X server's read-only mapping of libLLVM-15.so.

See also https://www.usenix.org/system/files/atc20-zhu-weixi_0.pdf

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

14 months agowg(4): add Matt Macy back to AUTHORS section
Ed Maste [Mon, 12 Jun 2023 17:54:56 +0000 (13:54 -0400)]
wg(4): add Matt Macy back to AUTHORS section

Matt did the initial in-kernel FreeBSD driver port.  The driver would
not exist without that work and some of it remains, even if the driver
was largely rewritten and reworked before being added back to the tree.

Authors remain in alphabetical order by surname.

Sponsored by: The FreeBSD Foundation

14 months agoqatfw: Don't build if WITH_SOURCELESS_UCODE is defined
Mark Johnston [Mon, 12 Jun 2023 17:47:51 +0000 (13:47 -0400)]
qatfw: Don't build if WITH_SOURCELESS_UCODE is defined