Commit graph

284506 commits

Author SHA1 Message Date
Kristof Provost 476f61217b pf: fix build without VIMAGE
Remove the name conflict between the pfsync_defer_tmo variable and
function.

This worked fine in kernels with VIMAGE (the default), but not in those
without.

Reported by:	des@
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2023-06-20 13:20:11 +02:00
Dag-Erling Smørgrav 91e03758de tarfs: Don't use IO_DIRECT when reading from tarball.
Sponsored by:	Juniper Networks, Inc.
Sponsored by:	Klara, Inc.
Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D40612
2023-06-20 10:02:10 +00:00
Corvin Köhne 35c8063ab1
bhyve: dos2unix
tpm_intf.h was incorrectly committed with dos line endings.

Fixes:			0917f925b4 ("bhyve: add basic CRB interface for TPM devices")
MFC after:		1 week
Sponsored by:		Beckhoff Automation GmbH & Co. KG
2023-06-20 11:52:43 +02:00
Kristof Provost f25ceb05af pf tests: make pfsync:defer test more robust
Set the defer timeout to 2.5 seconds, and only make sure that there's at
least a second of delay between the pfsync packet and the ping packet.
The intent is to allow the test to pass even when there's considerable
jitter on the timing measurement (e.g. when the test runs in a VM, such
as during the CI tests).

Allow the test to run in CI.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
2023-06-20 11:38:11 +02:00
Kristof Provost 6983b986e1 pf: allow defer timeout to be configured
Add the net.pfsync.defer_delay sysctl to allow the defer timeout (i.e.
how long pf holds onto packets waiting for the peer to ack the new
state) to be changed.

This is intended to make testing of the defer code more robust, by
allowing longer timeouts to mitigate scheduling/measurement jitter.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
2023-06-20 11:20:26 +02:00
Corvin Köhne 0daf5f02cf
bhyve/tpm: create crb thread for sending tpm commands
Commands send to a tpm are very slow. They can take up to several
seconds for completion. For that reason, create a thread which issues
the commands to the tpm device.

Reviewed by:		markj
MFC after:		1 week
Sponsored by:		Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D40458
2023-06-20 10:59:00 +02:00
Corvin Köhne 5ea98d3268
bhyve/tpm: build TPM2 table by tpm interface
Each tpm has a device specific table. Which table a tpm uses depends on
the tpm interface.

Reviewed by:		markj
MFC after:		1 week
Sponsored by:		Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D40457
2023-06-20 10:58:55 +02:00
Corvin Köhne 24a0fef9dc
bhyve: maintain RSDT and XSDT by basl
In a subsquent commit the TPM emulation will build it's own TPM2 table.
This needs to be registered to the RSDT and XSDT. Instead of making the
rsdt and xsdt variables global, we can simply add a helper to basl.

Reviewed by:		markj
MFC after:		1 week
Sponsored by:		Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D40559
2023-06-20 10:56:23 +02:00
Corvin Köhne 480bef9481
bhyve: add bootindex option for several devices
The bootindex option creates an entry in the "bootorder" fwcfg file.
This file can be picked up by the guest firmware to determine the
bootorder. Nevertheless, it's not guaranteed that the guest firmware
uses the bootorder. At the moment, our OVMF ignores the bootorder. This
will change in the future.

If guest firmware supports the "bootorder" fwcfg file and no device uses
the bootindex option, the boot order is determined by the firmware
itself. If one or more devices specify a bootindex, the first bootable
device with the lowest bootindex will be booted. It's not garanteed that
devices without a bootindex will be recognized as bootable from the
firmware in that case.

Reviewed by:		jhb
MFC after:		1 week
Sponsored by:		Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D39285
2023-06-20 10:51:58 +02:00
Corvin Köhne 6632a0a4e3
bhyve: add helper to create a bootorder
Qemu's fwcfg allows to define a bootorder. Therefore, the hypervisor has
to create a fwcfg item named bootorder, which has a newline seperated
list of boot entries. Qemu's OVMF will pick up the bootorder and applies
it.

Add the moment, bhyve's OVMF doesn't support a custom bootorder by
qemu's fwcfg. However, in the future bhyve will gain support for qemu's
OVMF. Additonally, we can port relevant parts from qemu's to bhyve's
OVMF implementation.

Reviewed by:		jhb, markj
MFC after:		1 week
Sponsored by:		Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D39284
2023-06-20 10:51:54 +02:00
Ed Maste 2e65cfd3ad Restore dummy WITHOUT_{CAPSICUM,CASPER} descriptions
The makeman CI job ensures that all options have description files.

Bring the CI job back to green by adding back WITHOUT_CAPSICUM and
WITHOUT_CASPER description files (that now state the assoicated options
have no effect).

Fixes: c24c117b96 ("Remove WITHOUT_{CAPSICUM,CASPER} options")
Sponsored by:	The FreeBSD Foundation
2023-06-19 23:20:49 -04:00
Colin Percival c24c117b96 Remove WITHOUT_{CAPSICUM,CASPER} options
At this point CAPSICUM and CASPER are merely forced on via the newly
added __REQUIRED_OPTIONS list; after stable/14 branches I'll sweep
the tree for MK_{CAPSICUM,CASPER}.

This change will not be MFCed.

Discussed on:	freebsd-arch
Differential Revision:	https://reviews.freebsd.org/D40592
2023-06-19 17:23:09 -07:00
Colin Percival bce9967915 options/makeman: Handle __REQUIRED_OPTIONS
Teach the code which generates src.conf.5 about __REQUIRED_OPTIONS;
without this change it gets confused and thinks that every option
turns the required options on.

Reviewed by:	sjg, imp
Differential Revision:	https://reviews.freebsd.org/D40591
2023-06-19 17:23:09 -07:00
Colin Percival b908f6c45e bsd.mkopt.mk: Add REQUIRED_OPTIONS list
Options on this list will be forced to 'yes'.  This is intended for use
as a transitional measure when an option is ceasing to be optional,
before all of the associated make logic is removed.

Differential Revision:	https://reviews.freebsd.org/D40590
2023-06-19 17:23:09 -07:00
Warner Losh 6bd922e154 camcontrol: Include stdbool.h rather than relying on namespace pollution
I have several environments, and at least one of them fails to build
because bool is undefined. Since we use bool, always include stdbool.h
rather than relying on any indirect definitions to pull it in.

Sponsored by:		Netflix
2023-06-19 14:54:32 -06:00
Warner Losh 90f05f6840 camcontrol: Zone fix two warnings
Remove a set but never used variable, and use the protocol variable for
its intended purpose.

Sponsored by:		Netflix
Reviewed by:		mav
Differential Revision:	https://reviews.freebsd.org/D40528
2023-06-19 14:51:07 -06:00
Warner Losh a960d3c07b cam: Remove duplicate definition for READ_DEFECT_DATA_10
This isn't needed by all devices and is only used by the da device (in
camcontrol). All the other da specific da scsi opcodes are only in
scsi_da.h.

Sponsored by:		Netflix
Reviewed by:		mav
Differential Revision:	https://reviews.freebsd.org/D40527
2023-06-19 14:45:43 -06:00
Warner Losh e8cdabb4e1 camcontrol: In defects make -S actually imply 12-byte command
camcontrol(8) says that -S to start at a different offset implies that
we're using the 12 byte command. But really, we're using the 10-byte
command. Fix this by setting use_12byte for -S.

Sponsored by:		Netflix
Reviewed by:		mav
Differential Revision:	https://reviews.freebsd.org/D40526
2023-06-19 14:45:43 -06:00
Warner Losh 2e105b61e9 camcontrol: simplify summary logic for defects
We don't need to count the number of lists requested. Instead, use the
more general form of checking to see if any of the non-defect format
bits are set. Also, check summary boolean to control summary reporting
behavior.

Sponsored by:		Netflix
Reviewed by:		mav
Differential Revision:	https://reviews.freebsd.org/D40524
2023-06-19 14:45:43 -06:00
Warner Losh f20d86e171 camcontrol: No need to set CAM_ARG_[PG]LIST in defects
We can or in the the list_format bits directly if we or in the
list_format when we look it up the first time. Free up CAM_ARG_[PG]LIST
from the CAM_ARG_xxx enum.

Sponsored by:		Netflix
Reviewed by:		mav (I made his suggested change)
Differential Revision:	https://reviews.freebsd.org/D40523
2023-06-19 14:45:43 -06:00
Warner Losh 97e24c3868 camcontrol: Simplfiy 12-byte retry logic in defects command
We always start out using the 10-byte version of READ DEFECT DATA, and
then switch to 12-byte when necessary due to errors or data length
requirements. We always need to get the length again when we do this,
and we're always going to be using 12-byte commands from that point
forward. Simplify the logic a bit based on this observation.

Sponsored by:		Netflix
Reviewed by:		mav
Differential Revision:	https://reviews.freebsd.org/D40522
2023-06-19 14:45:43 -06:00
Warner Losh fc78fd9dae camcontrol: Convert int used as booleans to bools
Sponsored by:		Netflix
Reviewed by:		mav
Differential Revision:	https://reviews.freebsd.org/D40521
2023-06-19 14:45:43 -06:00
Warner Losh 8259fc46ac camcontrol: Label the unused command args
Remove CAM_ARG_FORMAT_{BLOCK,BLI,PHYS} since they are not used.  Label
all the unused CAM_ARG_ bits as unused in comments to make them stand
out.

Sponsored by:		Netflix
Reviewed by:		mav
Differential Revision:	https://reviews.freebsd.org/D40520
2023-06-19 14:45:43 -06:00
Mark Johnston eb9fac0edb bhyve: Refactor vmexit_suspend() a bit
Move some of its logic into fbsdrun_deletecpu().  This makes it easier
to split vmexit handlers into a separate file, which in turn makes
landing arm64 support easier.  Also increase the scope of the mutex and
use it to synchronize updates to the vcpu mask.  No functional change
intended.

Reviewed by:	corvink, jhb
MFC after:	2 weeks
Sponsored by:	Innovate UK
Differential Revision:	https://reviews.freebsd.org/D40573
2023-06-19 15:46:32 -04:00
Mark Johnston 15c1f0cc2c bhyve: Register hlt and pause vmexit handlers unconditionally
These exit handlers might not be used if the corresponding VM
capabilities are not set, but there is no harm in putting them into the
handler table regardless.  Doing so simplifies initialization code,
makes it easier to split vmexit handlers into a separate file, and lets
us declare the handler table as const.

Reviewed by:	corvink, jhb
MFC after:	2 weeks
Sponsored by:	Innovate UK
Differential Revision:	https://reviews.freebsd.org/D40572
2023-06-19 15:46:02 -04:00
Mark Johnston 1da1a26436 bhyve: Include vmm.h via the usual path
No functional change intended.

MFC after:	1 week
Sponsored by:	Innovate UK
2023-06-19 15:45:19 -04:00
Mark Johnston 6d1dfc8741 bhyve: Remove some unneeded includes of segments.h
They are not needed and are specific to x86.  No functional change
intended.

MFC after:	1 week
Sponsored by:	Innovate UK
2023-06-19 15:44:44 -04:00
Dimitry Andric dbbaf77801 Apply llvm fix for hanging gcc builds on 32-bit arm
Merge commit 962c306a11d0 from llvm-project (by Florian Hahn):

  [LV] Don't consider pointer as uniform if it is also stored.

  Update isVectorizedMemAccessUse to also check if the pointer is stored.
  This prevents LV to incorrectly consider a pointer as uniform if it is
  used as both pointer and stored by the same StoreInst.

  Fixes #61396.

PR:		271992
Reported by:	John F. Carr <jfc@mit.edu>
MFC after:	3 days
2023-06-19 20:33:33 +02:00
Alexander Leidinger 194e059bb8 service: Add -E option to set environment variables before starting a service.
This allows for quicker testing/debugging of rc scripts and is a pre-req
for automatic service jails.

Differential Revision:	https://reviews.freebsd.org/D40369
Reviewed by:		se
2023-06-19 19:45:54 +02:00
John Baldwin f19ae3633b ifconfig: Pacify a sign comparison warning in regdomain_sort.
Both ic_flags values are unsigned (uint32_t), so cast them to a signed
int to generate a signed result.  Both ic_req values are also
unsigned, but since they are uint16_t, they are implicitly promited to
int before the subtraction.

Reported by:	GCC -Wsign-compare
Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D40610
2023-06-19 10:38:18 -07:00
John Baldwin a3b1138778 ifconfig: Consistently use uint32_t for wireless channel flags.
Reported by:	GCC -Wsign-compare
Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D40609
2023-06-19 10:38:07 -07:00
John Baldwin 08992b2078 ifconfig: Avoid issues with trying to negate unsigned values.
The if_flags and if_cap fields hold a bitmask of flags.  If a flag is
the MSB of the field, then the logic in setifflags and setifcap which
uses a < 0 check does the wrong thing (it tries to clear the flag
rather than setting it).  Also, trying to use -<FOO> doesn't actually
work as the result is a nop.  To fix, stop overloading setifcap and
setifflags and instead add new dedicated action functions clearifcap
and clearifflags for clearing a flag.  The value passed in the
argument to the command is now always the raw flag.

This was reported by a GCC warning after raising WARNS:

sbin/ifconfig/ifconfig.c:2061:33: error: integer overflow in expression '-2147483648' of type 'int' results in '-2147483648' [-Werror=overflow]
 2061 |         DEF_CMD("-txtlsrtlmt",  -IFCAP_TXTLS_RTLMT,     setifcap),
      |                                 ^

Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D40608
2023-06-19 10:37:52 -07:00
Mark Johnston e60316d1ea x86: Add defines for a couple of thermal and PM bits
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2023-06-19 13:32:22 -04:00
Piotr Pawel Stefaniak 14dd001235 sh: also auto-complete built-ins
Reported in a comment in PR 261728.

Reported by:	Oleg
Reviewed by:	jilles (previous version), bapt
Differential Revision:	https://reviews.freebsd.org/D39839
2023-06-19 19:27:20 +02:00
Ed Maste 7a91ccd2fb mpi3mr: fix GCC kernel build
Previously every file that included mpi3mr_app.h but did not use
mpi3mr_mgmt_info reported error: 'mpi3mr_mgmt_info' defined but not
used.

Fixes: 2d1d418e1e ("mpi3mr: 3rd Generation Tri-Mode NVMe/SAS/SATA...")
Reported by:	amd64-gcc12 Cirrus-CI job
Sponsored by:	The FreeBSD Foundation
2023-06-19 12:16:39 -04:00
John Baldwin e6b838363f pcib: Allocate the memory BAR with the MSI-X table.
This is required for pci_alloc_msix() to work and to thus use
MSI-X interrupts for PCI-e hotplug.

Reported by:	cperciva
Reviewed by:	cperciva
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D40581
2023-06-19 09:15:48 -07:00
Ed Maste e54db9a9cc seq: fix check for rounding error/truncation
Based on OpenBSD 30f0fd29ba6c:
> We need to compare the printable version of the last value displayed,
> not the floating point representation.  Otherwise, we may print the
> last value twice.

PR:		271964
Reported by:	Daniel Kolesa
Reviewed by:	yuripv
Obtained from:	OpenBSD
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D40601
2023-06-19 11:02:38 -04:00
Ed Maste e77b2ea427 ifconfig: set boolean to true rather than incrementing
GCC warns about "increment of a boolean expression."

Reported by:	amd64-gcc12 Cirrus-CI run
Sponsored by:	The FreeBSD Foundation
2023-06-19 11:02:38 -04:00
Gordon Bergling 8f79b07564 nameser: Fix a typo in a source code comment
-s /unknwon/unknown/

MFC after:	3 days
2023-06-19 13:49:23 +02:00
Benedict Reuschling 7ad4d94d5b Fix some shell issues by adding quotes and replace backticks with $()
This patch fixes the following issues reported by shellcheck:
- Quote default assignments (SC2223)
- Use $() instead of backticks (SC2006)
- Double quote $@ (SC2068)
- Double quote variables in if-statements and other places (SC2086)

While here, fix a whitespace at one end of line instance in the license
text.

Approved by:	manu
Differential Revision: https://reviews.freebsd.org/D40604
2023-06-19 11:03:06 +00:00
Kajetan Staszkiewicz 7dc3be36b2 pf: Fix usage of pf tags with syncookies
The value stored in pf_mtag->tag comes from "tag" and "match tag"
keywords in pf.conf and must not be abused for storing other
information. A ruleset with enough tags could set or remove the bits
responsible for PF_TAG_SYNCOOKIE_RECREATED.

Move this syncookie status to pf_mtag->flags. Rename this and other
related constants in a way that will prevent such mistakes in the
future. Move PF_REASSEMBLED constant to mbuf.h and rename accordingly
because it's not a flag stored in pf_mtag, but an identifier of a
different m_tag. Change the value of the constant to avoid conflicts
with other m_tags using MTAG_ABI_COMPAT.

Rename the variables in pf_build_tcp() and pf_send_tcp() in to reduce
confusion.

Reviewed by:	kp
Sponsored by:	InnoGames GmbH
Differential Revision:	https://reviews.freebsd.org/D40587
2023-06-19 12:03:55 +02:00
Kristof Provost ba94bf2880 pf: extend use of skip steps for Ethernet rules
Use the already populated PFE_SKIP_DST_ADDR and extend the skip
infrastructure to also skip on IP source/destination addresses.

This should make evaluating the rules slightly faster.

Reported by:	R. Christian McDonald <rcm@rcm.sh>
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D40567
2023-06-19 10:18:30 +02:00
Eugene Grosbein 79a96e294c motd: unbreak for source upgrade
In case of source upgrade path from 12.x proper merge of new /etc
installs /etc/motd.template. Becase of that, the system in left
without symlink /etc/motd -> /var/run/motd but with stale /etc/motd contents.

Fix it creating symlink despite of presence of /etc/motd.template.

MFC after:	1 week
2023-06-19 14:49:35 +07:00
Mihai Burcea c9fdd4f3cc
bhyve: add command line parameter and parsing for migration
This covers warm and live migration.

Reviewed by:		corvink
MFC after:		1 week
Differential Revision:	https://reviews.freebsd.org/D34717
2023-06-19 08:47:35 +02:00
Vitaliy Gusev 381ef27d7b
bhyve: use pci_next() to save/restore pci devices
Current snapshot implementation doesn't support multiple devices with
similar type. For example, two virtio-blk or two CD-ROM-s, etc.

So the following configuration cannot be restored.

bhyve \
	-s 3,virtio-blk,disk.img \
	-s 4,virtio-blk,disk2.img

In some cases it is restored silently, but doesn't work. In some cases
it fails during restore stage.

This commit fixes that issue.

Reviewed by:		corvink, rew
MFC after:		1 week
Sponsored by:		vStack
Differential Revision:	https://reviews.freebsd.org/D40109
2023-06-19 07:57:05 +02:00
Vitaliy Gusev 6f7d2cf8bb
bhyve: add .pe_snapshot method for PCI 'hostbridge'
There is no error when dump doesn't have it, but to be more
consistent this PCI devices should be saved as well.

Reviewed by:		corvink, rew
MFC after:		1 week
Sponsored by:		vStack
Differential Revision:	https://reviews.freebsd.org/D40108
2023-06-19 07:57:04 +02:00
Vitaliy Gusev 14c80457b0
bhyve: add bus, slot and func to device name
Each device needs a unique identifier to store and restore snapshots
properly. Adding the pci bsf information to the device name creates a
unique identifier as a bsf can't be occupied twice.

Reviewed by:		corvink
MFC after:		1 week
Sponsored by:		vStack
Differential Revision:	https://reviews.freebsd.org/D40107
2023-06-19 07:57:04 +02:00
Vitaliy Gusev b10d65a420
bhyve: rename 'user_dev' with 'devices'
Bhyve don't use 'user' specifier for emulated devices. And
using 'user' adds duality.

Reviewed by:		corvink, rew
MFC after:		1 week
Sponsored by:		vStack
Differential Revision:	https://reviews.freebsd.org/D40106
2023-06-19 07:57:01 +02:00
Vitaliy Gusev ee5023f3c2
bhyve: simplify restore of kernel structs
Both devices and kernel struct can use the same 'lookup_dev'
function instead of having duplicated code.

Reviewed by:		corvink, rew
MFC after:		1 week
Sponsored by:		vStack
Differential Revision:	https://reviews.freebsd.org/D40105
2023-06-19 07:51:33 +02:00
Vitaliy Gusev 50aef9f62c
bhyve: rename 'structs' snapshot key with 'kern_structs'
Using key 'structs' is ambiguous. This section contains data
related to the kernel. It should use a more informative naming.

Reviewed by:		corvink, rew
MFC after:		1 week
Sponsored by:		vStack
Differential Revision:	https://reviews.freebsd.org/D40104
2023-06-19 07:50:36 +02:00