Commit graph

19871 commits

Author SHA1 Message Date
Alan Somers a6506dda73 sesutil: fix "fault all" with zoned jbods
Some SAS JBODs support zoning.  This feature allows individual SAS
targets to be accessible by only some initiator ports.  One application
would be connecting two servers to the same JBOD, but they wouldn't be
able to see each other's disks.

A zoned JBOD should also prohibit initiators from accessing SES elements
corresponding to inaccessible SAS targets.  It reports that by setting
the element's status code to 0x8 (No Access Allowed).

The bug is that when doing "sesutil (fault|locate) all ...", sesutil
will attempt a ENCIOC_SETELMSTAT ioctl for every single element, even
the inaccessible ones.  The enclosure will reject the command, the
kernel will return EINVAL, and sesutil will exit.

The solution is to check the element's status, and skip trying to set it
if the status is 0x8.  But if the user actually supplied a ses ID, then
assume that he knows what he's doing and try to set it anyway.

PR:		270093
Sponsored by:	Axcient
Reviewed by:	mav, trasz
Differential Revision: https://reviews.freebsd.org/D39017

(cherry picked from commit 57dc6f5e20)
2023-09-06 14:39:35 -06:00
Jake Freeland 77740df27c syslogd: Add some basic regression tests
Reviewed by:	markj
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D41403

(cherry picked from commit fcace2906d)
2023-08-31 09:55:19 -04:00
Ed Maste fcd0bbbd4a makefs: clean up some leftovers after $FreeBSD$ tag removal
Fixes: 2a63c3be15
(cherry picked from commit 90aad5d3e4)
2023-08-23 11:43:34 -06:00
Warner Losh 636cb7f7b0 Remove $FreeBSD$: one-line xdr pattern
Remove /^\s*%\s*__FBSDID\("\$FreeBSD\$"\);?\s*\n/

Similar commit in main:
(cherry picked from commit 9524e274b5)
2023-08-23 11:43:34 -06:00
Warner Losh a7385d2a90 Remove $FreeBSD$: two-line lua tag
Remove /^--\n--\s*\$FreeBSD\$.*$\n/

Similar commit in main:
(cherry picked from commit 9636a14538)
2023-08-23 11:43:33 -06:00
Warner Losh 350f9ac5b3 Remove $FreeBSD$: one-line bare tag
Remove /^\s*\$FreeBSD\$$\n/

Similar commit in main:
(cherry picked from commit 05248206f7)
2023-08-23 11:43:33 -06:00
Warner Losh 24115b70d6 Remove $FreeBSD$: one-line nroff pattern
Remove /^\.\\"\s*\$FreeBSD\$$\n/

Similar commit in main:
(cherry picked from commit b2c76c41be)
2023-08-23 11:43:32 -06:00
Warner Losh b144e70a33 Remove $FreeBSD$: two-line nroff pattern
Remove /^\.\\"\n\.\\"\s*\$FreeBSD\$$\n/

Similar commit in main:
(cherry picked from commit fa9896e082)
2023-08-23 11:43:31 -06:00
Warner Losh 023fc80ee3 Remove $FreeBSD$: one-line sh pattern
Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/

Similar commit in main:
(cherry picked from commit d0b2dbfa0e)
2023-08-23 11:43:30 -06:00
Warner Losh e63c5c73c1 Remove $FreeBSD$: alt one-line .c pattern
Remove /^\s*__RCSID\("\$FreeBSD\$"\);\n/

Similar commit in main:
(cherry picked from commit c857356409)
2023-08-23 11:43:26 -06:00
Warner Losh 9a298a1247 Remove $FreeBSD$: alt two-line .c pattern
Remove /^\s*__RCSID\("\$FreeBSD\$"\);\n\n/

Similar commit in main:
(cherry picked from commit da5432eda8)
2023-08-23 11:43:26 -06:00
Warner Losh 3d497e17eb Remove $FreeBSD$: one-line .c pattern
Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/

Similar commit in main:
(cherry picked from commit 1d386b48a5)
2023-08-23 11:43:26 -06:00
Warner Losh 8ad303d68c Remove $FreeBSD$: one-line .c comment pattern
Remove /^/[*/]\s*\$FreeBSD\$.*\n/

Similar commit in main:
(cherry picked from commit 2a63c3be15)
2023-08-23 11:43:23 -06:00
Warner Losh 34041aac83 Remove $FreeBSD$: one-line .h pattern
Remove /^\s*\*+\s*\$FreeBSD\$.*$\n/

Similar commit in main:
(cherry picked from commit 42b388439b)
2023-08-23 11:43:22 -06:00
Warner Losh 17da660ad5 Remove $FreeBSD$: two-line .h pattern
Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/

Similar commit in main:
(cherry picked from commit b3e7694832)
2023-08-23 11:43:21 -06:00
Corvin Köhne b02e0f9640
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

(cherry picked from commit 480bef9481)
2023-08-18 09:52:10 +02:00
Corvin Köhne c791a53c80
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

(cherry picked from commit 6632a0a4e3)
2023-08-18 09:52:10 +02:00
Corvin Köhne 50734f2ba3
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

(cherry picked from commit 71fb2dcb00)
2023-08-18 09:32:08 +02:00
Corvin Köhne 04e774846c
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

(cherry picked from commit 1115cdcf7a)
2023-08-18 09:32:08 +02:00
Corvin Köhne b260e413b4
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

(cherry picked from commit 6952b9d25e)
2023-08-18 09:32:07 +02:00
Corvin Köhne 6d037b69ee
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

(cherry picked from commit d9fa7c113d)
2023-08-18 09:32:07 +02:00
Corvin Köhne aa598e677a
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]
e28d6fbfdf/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

(cherry picked from commit 1bd361eea2)
2023-08-18 09:32:07 +02:00
Corvin Köhne 13a371bcdf
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]
e28d6fbfdf/devicemodel/hw/pci/passthrough.c (L655-L657)
[2]
e28d6fbfdf/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

(cherry picked from commit 4a9bf50f40)
2023-08-18 09:32:07 +02:00
Corvin Köhne 3b81aa26ab
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

(cherry picked from commit 90c3a1b662)
2023-08-18 09:32:05 +02:00
Corvin Köhne 6ae7ed9e38
bhyve: import OpRegion definitions
Those definitions are required for the GVT-d emulation to parse the
OpRegion.

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

(cherry picked from commit b67f0d360b)
2023-08-18 09:29:27 +02:00
Corvin Köhne 7ffa1d667f
bhyve: add helper for passthru specific mmio ranges
Intel GPUs have two special memory regions. They are called Graphics
Stolen Memory and OpRegion. bhyve has to emulate both of them. In order
to keep track of those special regions, add generic mmio ranges to the
passthru emulation.

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

(cherry picked from commit 93cf93179c)
2023-08-18 09:29:26 +02:00
Corvin Köhne 194d65b5f8
bhyve: make passthru sel public available
The GVT-d emulation requires access to this selector to read from the
device.

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

(cherry picked from commit 60793cee27)
2023-08-18 09:29:26 +02:00
Corvin Köhne b3f053b4f4
bhyve: allow adding FwCfg items to ACPI tables
A TPM has an event log. Therefore, qemu adds a FwCfg item and adds it to
an ACPI table. We like to use the same OVMF driver as qemu, so we should
do the same. This commit adds the ability to basl to do it.

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

(cherry picked from commit 4e46ab0ebe)
2023-08-18 09:25:06 +02:00
Corvin Köhne b1fffed683
bhyve: add cmdline option for user defined fw_cfg items
Some guest allow to configure themself by fw_cfg. E.g. Fedora CoreOs can
be provisioned by adding a JSON file as fw_cfg item.

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

(cherry picked from commit ca14781c81)

bhyve: error out if fwcfg user file isn't read completely

At the moment, fwcfg reads the file once at startup and passes these
data to the guest. Therefore, we should always read the whole file.
Otherwise we should error out.

Additionally, GCC12 complains that the comparison whether
fwcfg_file->size is lower than 0 is always false due to the limited
range of data type.

Reviewed by:		markj
Fixes:			ca14781c81 ("bhyve: add cmdline option for user defined fw_cfg items")
MFC after:		1 week
Sponsored by:		Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D40076

(cherry picked from commit 26d9f973d8)
2023-08-18 09:24:54 +02:00
Vitaliy Gusev 8caac07ce9
bhyvectl: Add '--get-debug-cpus' command
vmm and libvmmapi already have handlers for that. When adding debug
cpus, they were only used for the debug stub. Over time, they were
reused by other parts like snapshots or idle APs.

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

(cherry picked from commit 65f8467e33)
2023-08-18 09:04:26 +02:00
Vitaliy Gusev 5a07451f79
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

(cherry picked from commit 50aef9f62c)
2023-08-18 09:04:26 +02:00
Vitaliy Gusev 295d69c8b0
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

(cherry picked from commit 6f7d2cf8bb)
2023-08-18 09:04:26 +02:00
Vitaliy Gusev 51e32fe734
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

(cherry picked from commit 14c80457b0)
2023-08-18 09:04:26 +02:00
Vitaliy Gusev 5573404166
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

(cherry picked from commit b10d65a420)
2023-08-18 09:04:25 +02:00
John Baldwin 320ce3c3c5
bhyve: Remove vestigial support for setting max vCPUs.
The kernel part of the hypervisor is not going to support per-VM maxcpu
limits. The topology is only used to control the values returned by
CPUID leaves for which max vCPUs is not relevant.

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

(cherry picked from commit bb17701050)
2023-08-17 15:06:51 +02:00
Bojan Novković 82eece443e
bhyve: fix vCPU single-stepping on VMX
This patch fixes virtual machine single stepping on VMX hosts.

Currently, when using bhyve's gdb stub, each attempt at single-stepping
a vCPU lands in a timer interrupt. The current single-stepping mechanism
uses the Monitor Trap Flag feature to cause VMEXIT after a single
instruction is executed. Unfortunately, the SDM states that MTF causes
VMEXITs for the next instruction that gets executed, which is often not
what the person using the debugger expects. [1]

This patch adds a new VM capability that masks interrupts on a vCPU by
blocking interrupt injection and modifies the gdb stub to use the newly
added capability while single-stepping a vCPU.

[1] Intel SDM 26.5.2 Vol. 3C

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

(cherry picked from commit fefac54359)
2023-08-17 15:06:29 +02:00
Corvin Köhne 3152cbdd16
bhyve: don't panic if e820 finds no available memory
The GVT-d emulation tries to allocate some specific memory. It could
happen that this address doesn't exist. In that case, GVT-d will fall
back to allocate any address. Nevertheless, this only works if the e820
fails with an error instead of exiting on an assertion.

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

(cherry picked from commit 99aeb28b2f)
2023-08-17 14:58:04 +02:00
Marius Strobl aa63608809 base: Remove support for the VTOC8 partitioning scheme
The removal of the sparc64 support in February 2020 obsoleted the
VTOC8 partitioning scheme as no other FreeBSD platform makes use
of it. Moreover, the code is bitrotting as nothing defines e. g.
LOADER_VTOC8_SUPPORT any more and, thus, should go now, too. With
this change, the following commits are reverted as far as VTOC8
is concerned and parts haven't already previously been deleted
along with prior sparc64 removals:
094fcb157d
a7d366e958
ba8d50d08b

The alignment example d9711c28ef
added to the VTOC8 section of gpart.8 is folded into the MBR one.

This should finally conclude the deorbit of sparc64-specific bits.

        We had joy, we had fun
        we ran Unix on a Sun.
        But that source and the song
        of FreeBSD have all gone.

Credits to Michael Bueker for the original "Unix on a Sun" and Rod
McKuen for the "Seasons in the Sun" lyrics.

(cherry picked from commit 4ef1c6f75d)
2023-08-06 19:49:05 +02:00
Jessica Clarke 5f4efa6c9a certctl: Introduce a new -d <distbase> option
This will be used by Makefile.inc1 to fix -DNO_ROOT distributeworld,
which needs to split out DESTDIR from DISTBASE so the METALOG file
includes the base/ prefix.

Reviewed by:	kevans
Obtained from:	CheriBSD
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D35808

(cherry picked from commit 232cf6be4b)
2023-08-01 21:42:50 +01:00
John Baldwin 9fe302d781 bhyve: Fully reset the fwctl state machine if the guest requests a reset.
If a guest tries to reset the fwctl device while a pending request was
in flight, the fwctl state machine can be left in an incomplete state.
Specifically, rinfo is not cleared.

Normally the state machine for fwctl alternates between REQ (receiving
request) and RESP (sending response) and ignores port writes while in
RESP or port reads while in REQ.  Once a guest completes the writes to
the port to send a request, the state machine transitions to RESP and
ignores future writes.

However, if a guest writes a full request and then resets the fwctl
device, the state would transition to REQ without draining the pending
response or discarding the received request.  Instead, additional
port writes after the reset were treated as new payload bytes, but
were appended to the previously-received request and could overflow
the fget_str buffer.

To fix, fully reset the fwctl state machine if the guest requests a
reset.

admbugs:	998
Approved by:	so
Reviewed by:	markj
Reported by:	Omri Ben Bassat <t-benbassato@microsoft.com>
Security:	FreeBSD-SA-23:07.bhyve
Security:	CVE-2023-3494

(cherry picked from commit bed3ae1d78)
2023-08-01 15:48:53 -04:00
Mark Johnston a53a2971ac bhyve: Stop calling pci_lintr_request() in the NVMe device model
The device model effectively assumes that MSI-X is enabled (it never
asserts the legacy interrupt), so any guest which relies on being able
to use the legacy PCI interrupt will fail.

The WIP arm64 port does not implement legacy PCI interrupts, but NVMe
emulation is potentially useful there.  Simply remove the call.

Reviewed by:	corvink, chuck, jhb
Tested by:	chuck
MFC after:	1 month
Sponsored by:	Innovate UK
Differential Revision:	https://reviews.freebsd.org/D40731

(cherry picked from commit 13013d266e)
2023-08-01 09:56:16 -04:00
Warner Losh 6d30916e9b spdx: The BSD-3-Clause-FreeBSD identifier never was, drop -FreeBSD
There never was a BSD-3-Clause-FreeBSD SPDX identifier. Replace it
with BSD-3-Clause.

Discussed with:		pfg
MFC After:		3 days
Sponsored by:		Netflix

(cherry picked from commit eb8f887758)
2023-07-25 09:18:00 -06:00
Warner Losh 58f593fbb8 spdx: Simplify BSD-2-Clause AND BSD-2-Clause
After removing the -FreeBSD and -NetBSD, we're left with a nuber of
BSD-2-Clause AND BSD-2-Clause, so tidy that up.

Discussed with:		pfg
MFC After:		3 days
Sponsored by:		Netflix

(cherry picked from commit eebd9d5366)
2023-07-25 09:17:00 -06:00
Warner Losh f73b4bf27c spdx: The BSD-2-Clause-NetBSD identifier is obsolete, drop -NetBSD
The SPDX folks have obsoleted the BSD-2-Clause-NetBSD identifier. Catch
up to that fact and revert to their recommended match of BSD-2-Clause.

Discussed with:		pfg
MFC After:		3 days
Sponsored by:		Netflix

(cherry picked from commit b61a573019)
2023-07-25 09:15:32 -06:00
Warner Losh caa41f6417 spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD
The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch
up to that fact and revert to their recommended match of BSD-2-Clause.

Discussed with:		pfg
MFC After:		3 days
Sponsored by:		Netflix

(cherry picked from commit 4d846d260e)
2023-07-25 09:13:49 -06:00
Mark Johnston a710a3f13d bhyve: Deduplicate some code in modify_bar_registration()
No functional change intended.

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

(cherry picked from commit 0dea4f064d)
2023-07-18 09:36:25 -04:00
Mitchell Horne c6741d6aa7 pmcstat(8): Drop .Ud
This utility has existed for a long time and should not be advertised as
"currently under development".

While here, fix the one other warning from igor about using a newline
for a new sentence.

MFC after:	3 days
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit a5b3e56330)
2023-07-17 13:48:58 -03:00
Juraj Lutter 9000459d3b 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

(cherry picked from commit e5d7100c09)
2023-07-06 09:56:35 +02:00
Mark Johnston b16a120b3b bhyve: Rename a pci_cfgrw() parameter
pci_cfgrw() may be called via a write to the extended config space,
which is memory-mapped.  In this case, the name "eax" is misleading.
Give it a more generic name.  No functional change intended.

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

(cherry picked from commit f4841d8af0)
2023-07-05 09:06:59 -04:00
Mark Johnston 861fae6089 bhyve: Include vmm.h via the usual path
No functional change intended.

MFC after:	1 week
Sponsored by:	Innovate UK

(cherry picked from commit 1da1a26436)
2023-06-26 15:52:08 -04:00
Mark Johnston d934517627 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

(cherry picked from commit 6d1dfc8741)
2023-06-26 15:52:08 -04:00
Poul-Henning Kamp c6d3829c09 freebsd-update: Mention 13.2-RELEASE in usage.
(cherry picked from commit e0e5bf4d62)
2023-06-21 08:52:32 -04:00
Dag-Erling Smørgrav 9feaa109e4 local-unbound-setup: Disable the libc subscriber.
This is the correct way to prevent resolvconf from updating resolv.conf.

Reviewed by:	cy
Differential Revision:	https://reviews.freebsd.org/D39262

(cherry picked from commit 9b20ab1e1e)
2023-06-14 14:40:39 +02:00
Rick Macklem 4eee1fcdfc nfsuserd: Improve failure message when running in a jail
If a jail is not correctly configured to run nfsd(8)
in the jail, nfsuserd(8) cannot run.
This patch improves the failure message for this case.

(cherry picked from commit a94018e200)
2023-06-11 18:23:37 -07:00
Rick Macklem 4deff63c5d gssd: Improve failure message when running in a jail
If a jail is not correctly configured to run nfsd(8)
in the jail, gssd(8) cannot run.
This patch improves the failure message for this case.

(cherry picked from commit 697727110b)
2023-06-11 13:07:55 -07:00
Mitchell Horne e6246bd85a pmcstat: augment an error message
It also applies to the -t argument.

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

(cherry picked from commit bf66159342)
2023-06-09 15:14:59 -03:00
Mitchell Horne e456727fcc pmccontrol: drop Pentium 4 special case
This is dead code; we no longer support Pentium hardware in libpmc or
hwpmc.

MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 8bd4459560)
2023-06-09 15:14:58 -03:00
Cy Schubert 5d3fa3d71c ntp: import ntp-4.2.8p17
Fixes two small bugs including one regression.

Merge commit 'ab1f1aa8333369a83ff284848fc3fc2e52d5f29f'

(cherry picked from commit e6bfd18d21)

ntp: Fix build

Two files used to obtain time from reference clocks did not include
ntp_types.h resulting in an undefined NONEMPTY_TRANSLATION_UNIT.

Fixes:		e6bfd18d21

(cherry picked from commit 82aa1470c9)
2023-06-09 06:35:55 -07:00
Chuck Silvers 89bd147dbf ffs: restore backward compatibility of newfs and makefs with older binaries
The previous change to CGSIZE had the unintended side-effect of allowing
newfs and makefs to create file systems that would fail validation when
examined by older commands and kernels, by allowing newfs/makefs to pack
slightly more blocks into a CG than those older binaries think is valid.
Fix this by having newfs/makefs artificially restrict the number of blocks
in a CG to the slightly smaller value that those older binaries will accept.
The validation code will continue to accept the slightly larger value
that the current newfs/makefs (before this change) could create.

Fixes:		0a6e34e950
Reviewed by:	mckusick
MFC after:	3 days
Sponsored by:	Netflix

(cherry picked from commit d464a7698d)
2023-06-04 04:00:22 -07:00
Cy Schubert b916516fdd ntp: Update version string
Chase a466cc5537, updating the version string in the local config.h.

Reported by:	 Trond Endrestol <Trond.Endrestol@ximalas.info>
Fixes:		a466cc5537

(cherry picked from commit 4d78061377)
2023-06-01 15:18:21 -07:00
Cy Schubert 91ae4636fb ntp: import ntp-4.2.8p16
Security:       NtpBUg3767, NtpBug3808, NtpBug3807 (CVE-2023-26555)

(cherry picked from commit a466cc5537)
2023-06-01 08:06:46 -07:00
Kirk McKusick 4a3834e31f Fix size differences between architectures of the UFS/FFS CGSIZE macro value.
Reported-by:  Tijl Coosemans
Tested-by:    Tijl Coosemans and Peter Holm
Sponsored-by: The FreeBSD Foundation

(cherry picked from commit 0a6e34e950)
2023-05-26 14:25:50 -07:00
Rick Macklem 8d92ebe2fa nfsd.c: Log a more meaningful failure message
For the cases where the nfsd(8) daemon is already running or
has failed to start within a prison due to an incorrect prison
configuration, the failure message logged is:
  Can't read stable storage file: operation not permitted

This patch replaces the above with more meaningful messages.
It depends on commit 10dff9da97 to differentiate between the
above two cases, however even without this commit, the messages
should be an improvement.

(cherry picked from commit fe5c211ba8)
2023-05-23 19:15:01 -07:00
Rick Macklem e11c3ae65e mountd.8: Update for mountd running in jails
Mountd can now be run in an appropriately
configured vnet jail.

This man page update adds some information
for this case.

This is a content change.

(cherry picked from commit 9432e798fc)
2023-05-22 11:31:50 -07:00
Rick Macklem 12d9715002 nfsd.8: Update for nfsd running in jails
Nfsd can now be run in an appropriately
configured vnet jail.

This man page update adds some information
for this case.

This is a content change.

(cherry picked from commit a1254dcaa8)
2023-05-22 11:29:25 -07:00
Rick Macklem e608f0713d jail.8: Update the allow.nfsd section
This patch updates the information for "allow.nfsd"
and adds configuration information.

This is a content change.

(cherry picked from commit c0f94fee0b)
2023-05-22 11:27:45 -07:00
Rick Macklem ffcdd031d7 jail.8: Update the man page for allow.nfsd
Commit bba7a2e896 added "allow.nfsd" to optionally allow
mountd/nfsd to be run inside a vnet prison when the kernel
is built with "options VNET_NFSD".

This patch updates the man page for this change.

This is a content change.

(cherry picked from commit d4b4f3b9c3)
2023-05-22 11:26:03 -07:00
Baptiste Daroussin 4399248d87 pkg(7): now that we do use libmd, use it completly
Use SHA256_Fd and SHA256_Data instead of home made equivalent.
wrap those functions into hash.c to avoid header collition between
openssl and libmd

Suggested by:	kevans

(cherry picked from commit e5dd5bfa55)
2023-05-19 10:16:51 +02:00
Baptiste Daroussin 7bc2192380 pkg(7): use libmd for sha256 instead of openssl
OpenSSL 3.0 has deprecated the sha256 api, let's use libmd which has the
same API instead.

In order to avoid the collision in definitions (sha256.h cannot be
included in the same file as a file where openssl headers has been
included) let's move the sha256 related code in its own file

PR:		270023
Reported by:	ngie

(cherry picked from commit b2654064c2)
2023-05-19 10:16:51 +02:00
pbuff 732f13ad32 pw: The pw_checkname function has added ';' checking.
The pw_checkname function forgot to include a ';'
when checking usernames, causing shell commands
to be executed when a username with a ';' is deleted.

PR:		271427
MFC After:	3 days

(cherry picked from commit e0155c6989)
2023-05-19 10:10:09 +02:00
Michael Osipov e31fbe0dff periodic: Use locale-agnostic (ISO 8601) timestamp format
Instead of reyling on locale-sensitive output which can be mangled when e-mailed
use consistently ISO 8601 format which contains the same information as '-T'.

PR:		271240
MFC After:	3 days

(cherry picked from commit d2b4753f06)
2023-05-19 10:10:08 +02:00
Baptiste Daroussin c1150a6379 pw: do not call system()
Calling system makes pw(8) spawn a shell, which can then be abused.

MFC After:	3 days

(cherry picked from commit ef7d0eb948)
2023-05-19 10:08:15 +02:00
Colin Percival 866e5c6b3c freebsd-update: Fix merging already-updated files
When performing an "upgrade" (moving between FreeBSD releases, as
opposed to "update" which merely applies security/errata updates
to the installed release) FreeBSD Update:

1. Generates a list of "files needing to be merged", namely those
files which don't match the version installed in the "old" release
and have paths matching the MergeChanges configuration directive
(by default, /boot/device.hints and everything under /etc/).

and later on,

2. Compares the currently-installed files to the versions in the
"new" release, removing index entries for files which "don't need
to be updated because they're not changing".

Unfortunately if a file falls into both of these categories -- that
is to say, if a file in /etc/ is the same as the version in the new
release and not the same as the version in the old release -- the
resulting "merge" step saw that the file was no longer listed as
being part of the new release, resulting in the file being deleted.

For the first 18 years of FreeBSD Update's existence, this never
happened, since $FreeBSD$ tags resulted in "new release" files
always being different from any files systems would already have
installed.

This commit fixes this behaviour by only placing a file into the
"files needing to be merged" list if it does not match the version
in the old release *or* the version in the new release.

Reported by:	des
Reviewed by:	delphij (earlier version), des, emaste
MFC after:	7 days
X-EN-Candidate:	yes
Differential Revision:	https://reviews.freebsd.org/D39973

(cherry picked from commit c55b7e5226)
2023-05-16 14:34:10 -07:00
Mina Galic 3f39a2a839 ntpd: Support IPv6-only hosts
0.pool.* returns only IPv4 addresses.
2.pool.* returns both, IPv6 and IPv4 addresses.

conservatively extend our IPv4 only pool configuration by adding a
second pool, which also returns IPv6 addresses.

PR:			270536
Reported by:		Lapo Luchini <lapo@lapo.it>
Pull Request:		https://github.com/freebsd/freebsd-src/pull/731
Differential Revision:	https://reviews.freebsd.org/D39954

(cherry picked from commit fff1551c03)
2023-05-08 10:33:24 -07:00
Corvin Köhne 03d8264dca
bhyve: pass E820 table to guest
E820 table will be used to report valid RAM ranges and reserve special
memory areas like graphics memory for GPU passthrough.

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

(cherry picked from commit 16f23f7543)
2023-05-08 10:21:32 +02:00
Corvin Köhne f1b5ce0d1d
bhyve: add E820 dump function
For debugging purposes it is helpful to dump the E820 table.

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

(cherry picked from commit a8a8e9af57)
2023-05-08 10:21:32 +02:00
Corvin Köhne 0f8a17795d
bhyve: add allocation function to E820
This function makes it easy to allocate new E820 entries. It will be
used to allocate graphics memory for Intel integrated graphic devices.

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

(cherry picked from commit 5597f56487)
2023-05-08 10:21:31 +02:00
Corvin Köhne 951ca31bf6
bhyve: add common memory holes to E820 table
The VGA and the ROM memory ranges can't be used as system memory. For
that reason, remove them from the E820 table.

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

(cherry picked from commit 059af92a30)
2023-05-08 10:21:31 +02:00
Corvin Köhne 694f2c9d35
bhyve: add basic E820 implementation
There are some use cases where bhyve has to prepare some special memory
regions. E.g. GPU passthrough for Intel integrated graphic devices needs
to reserve some memory for the graphic device. So, bhyve has to inform
the guest about those memory regions. This information can be passed by
the qemu fwcfg interface. As qemu creates an E820 table, we can reuse
the existing fwcfg item "etc/e820".

This commit is the first one of a series. It only adds a basic
implementation for the creation of the E820 table. Some subsequent
commits will add more items to the E820 table and register it as fwcfg
item.

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

(cherry picked from commit 9180daa1e3)
2023-05-08 10:21:30 +02:00
Corvin Köhne a02d136df0
bhyve: make use of qemus acpi table loader
Add all acpi tables to qemus acpi table loader. This passes the acpi
tables by fwcfg to the guest.

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

(cherry picked from commit 7959d80d99)
2023-05-08 10:21:30 +02:00
Corvin Köhne d71c3dd112
bhyve: add helper struct for qemus acpi table loader
The hypervisor is aware of all system properties. For the guest bios
it's hard and complex to detect all system properties. For that reason,
it would be better if the hypervisor creates acpi tables instead of the
guest. Therefore, the hypervisor has to send the acpi tables to the
guest. At the moment, bhyve just copies the acpi tables into the guest
memory. This approach has some restrictions. You have to keep sure that
the guest doesn't overwrite them accidentally. Additionally, the size of
acpi tables is limited.

Providing a plain copy of all acpi tables by fwcfg isn't possible. Acpi
tables have to point to each other. So, if the guest copies the acpi
tables into memory by it's own, it has to patch the tables. Due to
different layouts for different acpi tables, there's no generic way to
do that.  For that reason, qemu created a table loader interface. It
contains commands for the guest for loading specific blobs into guest
memory and patching those blobs.

This commit adds a qemu_loader class which handles the creation of qemu
loader commands. At the moment, the WRITE_POINTER command isn't
implement. It won't be required by bhyve's acpi table generation yet.

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

(cherry picked from commit f565b4d630)
2023-05-08 10:21:29 +02:00
John Baldwin f894317873 bhyve: Don't return -ENOMEM from qemu_fwcfg_add_file.
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D39212

(cherry picked from commit 7bf44831ca)
2023-05-02 17:07:05 -07:00
John Baldwin 2c63333240 bhyve: Accept a variable-length string name for qemu_fwcfg_add_file.
It is illegal (UB?) to pass a shorter array to a function argument
that takes a fixed-length array.  Do a runtime check for names that
are too long via strlen() instead.

Reviewed by:	markj
Reported by:	GCC -Wstringop-overread
Differential Revision:	https://reviews.freebsd.org/D39211

(cherry picked from commit 61482760a0)
2023-05-02 17:06:52 -07:00
John Baldwin 0218596e92 acpica: Quiet a -Wdangling-pointer warning in AcpiUtInitStackPtrTrace.
This function intentionally saves a pointer to an on-stack variable in
a global as a dubious way of reading the stack pointer.

Reviewed by:	imp, emaste
Differential Revision:	https://reviews.freebsd.org/D37535

(cherry picked from commit f4432625ed)
2023-05-02 17:05:54 -07:00
John Baldwin 50367e285d pw: Don't return a pointer to an on-stack buffer from grp_set_passwd.
Make 'line' static to move it to .bss instead as that pattern is used
elsewhere in pw(8) (e.g. the static buffer in pw_pwcrypt).

Reported by:	GCC -Wdangling-pointer
Reviewed by:	imp, emaste
Differential Revision:	https://reviews.freebsd.org/D37534

(cherry picked from commit 1055bedbed)
2023-05-02 17:05:05 -07:00
John Baldwin 0345952b9e fwcontrol: Disable -Wzero-length-bounds warnings.
firewire.h includes zero length arrays in unions that trigger this
warning.

Reviewed by:	imp, emaste
Differential Revision:	https://reviews.freebsd.org/D37538

(cherry picked from commit aa9ce62be5)
2023-05-02 17:04:46 -07:00
Vitaliy Gusev b8cca0cdc0
bhyve: remove redundant variable
Reviewed by:    corvink,markj
Sponsored by:   vStack
Differential Revision: https://reviews.freebsd.org/D38836
2023-04-28 14:01:23 +02:00
Corvin Köhne 82622189fe
bhyve: add QEMU_FWCFG_INDEX_MAX_CPUS item
Requested-by:		coreboot
Reviewed by:		<If someone else reviewed your modification.>
MFC after:		1 week
Sponsored by:		Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D39315

(cherry picked from commit 305edaa479)
2023-04-28 09:28:34 +02:00
Corvin Köhne 0ad27bd40b
bhyve: add hook for PCI header of passthru devices
Most register of the PCI header are either constant values or require
emulation anyway. The command and status register are the only exception which
require hardware access. So, we're adding an emulation handler for all
other register.

As this emulation handler will be reused by some future features like
GPU passthrough, we directly export it.

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

(cherry picked from commit b6e67875a3)
2023-04-28 09:28:34 +02:00
Corvin Köhne 847adbb116
bhyve: define array to protect passthru regs
GPU passthrough requires a special handling of some PCI config register.
Therefore, we need a flexible approach for implementing it. Adding an
array of handler meets this condition.

Start by using the default handler for all accesses to the PCI config
space. In upcoming commits, we can start to split the default handler
into several handler for each register that requires emulation.

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

(cherry picked from commit 931bb7bf1c)
2023-04-28 09:28:34 +02:00
Corvin Köhne 9c8a0c311a
bhyve: save softc of ACPI devices
This will be useful for writing device specific ACPI tables or DSDT
methods.

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

(cherry picked from commit 158adced65)
2023-04-28 09:28:34 +02:00
Corvin Köhne 1c7053169d
bhyve: allow device specific DSDT entries
This feature will be used by future commits to implement a device
specific method (_DSM) for TPM devices.

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

(cherry picked from commit e976464a50)
2023-04-28 09:28:34 +02:00
Corvin Köhne fbf9519ab9
bhyve: check for errors when writing device specific DSDT entries
At the moment, this function can't fail. This behaviour will change in
the future. In preparation to that, convert the return type to int in
order to be able to check for errors.

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

(cherry picked from commit ab34ea4711)
2023-04-28 09:28:33 +02:00
Corvin Köhne 76f744cf2d
bhyve: allow building device specific ACPI tables
Some ACPI devices require a device specific acpi table. E.g. a TPM2
device requires a TPM2 table. Use the acpi_device_emul struct to define
such a device specific table.

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

(cherry picked from commit 0926566f6f)
2023-04-28 09:28:33 +02:00
Corvin Köhne 3f7acfe073
bhyve: introduce acpi_device_emul struct
It'll be easier to add new properties to the ACPI device emulation if we
have a struct which holds all device specific properties. In some future
commits the acpi_device_emul struct will be expanded to include some
device specific functions to build ACPI tables.

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

(cherry picked from commit acd0088c44)
2023-04-28 09:28:32 +02:00
Corvin Köhne d4cae9c5e6
bhyve: add config option to modify LPC IDs
The Intel GOP driver checks the LPC IDs to detect the platform it's
running on. The GOP driver only works on the platforms it's written for.
Maybe other Intel driver have the same behaviour. For that reason, we
should use the LPC IDs of the FreeBSD host for GPU passthrough to work
properly.

We don't know if setting different LPC IDs have any side effect.
Therefore, don't use the host LPC IDs by default on Intel system. Give
the user the opportunity to modify the LPC IDs.

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

(cherry picked from commit f4ceaff56d)

bhyve: fix spelling mistake of pcireg option

The option is spelled "pcireg" not "pcir".

MFC after:		1 week
Fixes:			f4ceaff56d
Sponsored by:		Beckhoff Automation GmbH & Co. KG

(cherry picked from commit c98d13fbf9)

bhyve: scan PCI device functions to find host LPC

At least on some AMD devices the host LPC bridge could be located as
seperate function of another PCI device.

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

(cherry picked from commit d3e03d235e)

bhyve: do not exit if LPC finds no host selector

The host selector is only required when the user likes to use the same
LPC device IDs as the physical LPC device. This is an uncommon use case.
For that reason, it makes no sense to exit when we don't find the host
selector.

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

(cherry picked from commit 0d29d750b9)
2023-04-28 09:28:13 +02:00
Ed Maste 0001406ae2 makefs: set cd9660 Rock Ridge timestamps for . and ..
DOT and DOTDOT entries have special handling, and previously only Rock
Ridge PX (POSIX attributes) entries were attached.  Add TF (timestamp)
entries as well.

PR:		203531
Reported by:	Thomas Schmitt <scdbackup@gmx.net>
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D39662

(cherry picked from commit dd9059b3e9)
2023-04-27 12:45:37 -04:00
Ed Maste d74a8305b0 makefs: call brelse from bread
This matches NetBSD and rationalizes makefs with the kernel API.

This reverts commit 370e009188.

Reviewed by:	mckusick
Sponsored by:	The FreeBSD Foundation
Obtained from:	NetBSD 0a62dad69f62, 0c4125e1a19f, cb6a5a3575fd
Differential Revision:	https://reviews.freebsd.org/D39070

(cherry picked from commit e5551216d8)
2023-04-27 12:45:37 -04:00
Ed Maste 775defbe0c makefs: use unsigned and %u for rock_ridge_move_count
For diff reduction against NetBSD's makefs.  Based on NetBSD git mirror
commit 00991aee8248.

With this change our makefs cd9660 support should be in sync up to
NetBSD commit bdae6c9dc792 ("makefs(8): Nix trailing whitespace.").

Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 10854bf517)
2023-04-21 17:19:48 -04:00
Ed Maste 6dda38e5ca makefs: remove unused variable
Reported by:	Clang
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 79ead08497)
2023-04-21 17:19:48 -04:00
Ed Maste 5fbe15bc21 makefs: remove unused cd9660 options
Makefs defined "follow-symlinks" and "help" options, but they did
nothing.  Remove them.

Obtained from:	OpenBSD a8f1645688c2
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit c753f49f70)
2023-04-21 17:18:24 -04:00
Michael Tuexen d7339c4267 trpt: fix several bugs and add deprecation notice
This patch fixes several bugs releated to trpt including
* the computation of the TCP payload bytes, in particular when
  TCP options are present or IPv4 is used.
* the logging of incoming and outgoing packets.
* the logging of timers, in particular add support for logging of
  the delayed ack timer.
Also add a deprecation note, since support for this utility has been
removed from the main branch. Therefore, this is a direct commit to
stable/13.

Reviewed by:		cc, glebius, rrs
Sponsored by:		Netflix, Inc.
Differential Revision:	https://reviews.freebsd.org/D39436
2023-04-21 00:09:40 +02:00
Ed Maste 72ef847c17 makefs: use %s and __func__ in printf messages
For diff reduction against NetBSD.

Obtained from:	NetBSD 0c4125e1a19f
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit af7624ed31)
2023-04-14 08:10:38 -04:00
Ed Maste 496478c1dc makefs: set the validation entry system type
Obtained from:	NetBSD c3cb4dcc9c43
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 22db5e5d03)
2023-04-14 08:10:38 -04:00
Ed Maste c821bafd9c makefs: use size_t or ssize_t where appropriate
Obtained from:	NetBSD af7bc97830ac

(cherry picked from commit 1d1ffa2efd)
2023-04-14 08:10:38 -04:00
Ed Maste 066d6824fc makefs: simplify filename conversion handling
Obtained from:	OpenBSD 4095a2e01d18
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit c02e6ca7c2)
2023-04-14 08:10:38 -04:00
Ed Maste 511e83ab14 makefs: remove some unused cd9660 types and defines
Obtained from:	OpenBSD
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit d73acb32d3)
2023-04-14 08:10:38 -04:00
Ed Maste 1a38a53924 makefs: avoid uninitialized memory in root directory date
Move date setting into cd9660_populate_iso_dir_record so there is no
path that leaves it unset.

PR:		203531
Reported by:	Thomas Schmitt <scdbackup@gmx.net>
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D39258

(cherry picked from commit 7bc4ccf3ae)
2023-04-14 08:10:37 -04:00
Ed Maste 6787081641 makefs: remove CD9660MAXPATH #define
It was used only in constructing the host path that contains file
content, which is not related to anything CD9660-specific.  PATH_MAX is
the appropriate limit.  See OpenBSD commit 299d8950f319.

Obtained from:	OpenBSD
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 2f11df6337)
2023-04-14 08:10:37 -04:00
Ed Maste ac8ec8c7cc makefs: improve some cd9660 error messages
Obtained from:	OpenBSD
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit c6ed8694ac)
2023-04-14 08:10:37 -04:00
Ed Maste 4311c5b3db makefs: #define Apple Partition bits
NetBSD defines these in sys/bootblock.h, which we don't have.  Add local
defintions in cd9660_eltorito.c (as OpenBSD did) to reduce diffs between
the three makefs implementations.

Obtained from:	OpenBSD
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit f0bef3d20e)
2023-04-14 08:10:37 -04:00
Ed Maste 8c22a34e9a makefs: correct "filname" typo
Obtained from:	NetBSD cd9660.c r1.58

(cherry picked from commit efe6a1574e)
2023-04-14 08:10:37 -04:00
Ed Maste 3dff748720 makefs: Whitespace cleanup to sync with NetBSD
(cherry picked from commit 52c68e1625)
2023-04-14 08:10:37 -04:00
Ed Maste 57f6ba0e38 makefs: remove vestigial '?' cases from top-level getopt(3) loop
getopt(3) returns '?' when it encounters a flag not present in the in
the optstring or if a flag is missing its option argument.  We can
handle this case with the "default" failure case with no loss of
legibility.

Obtained from:	OpenBSD makefs.c 1.22

(cherry picked from commit cc4adc4c4e)
2023-04-14 08:10:36 -04:00
Ed Maste 5f31bbc5fa makefs: do not pass mode to open() call lacking O_CREAT
Obtained from:	OpenBSD ffs.c 1.35

(cherry picked from commit 45e405603b)
2023-04-14 08:10:36 -04:00
Ed Maste a025a94c50 makefs: spelling
Obtained from:	OpenBSD msdosfs_fat.c 1.7

(cherry picked from commit 1fb7d2cf99)
2023-04-14 08:10:36 -04:00
Christos Margiolis 18eb15bd8a makefs(8): do not print comma after the last super-block
Reviewed by:	markj, emaste
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D39430

(cherry picked from commit f21faa67ab)
2023-04-12 10:18:37 -04:00
Corvin Köhne b0efaef285
bhyve: add QEMU_FWCFG_INDEX_NB_CPUS item
Requested-by:		OVMF (qemu)
Reviewed by:		markj
MFC after:		1 week
Sponsored by:		Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D39316

(cherry picked from commit e46be58cca)

bhyve: add missing include to qemu_fwcfg.c

Fixes:			e46be58cca ("bhyve: add QEMU_FWCFG_INDEX_NB_CPUS item")
MFC after:		1 week
Sponsored by:		Beckhoff Automation GmbH & Co. KG

(cherry picked from commit 76fa62b523)
2023-04-11 09:29:54 +02:00
Stefan Eßer 1412836cbd kbdcontrol.c: make pre-Unicode compatibility conditional
Support for the full range of Unicode character codes has been added
to the main keymap back in 2009, with compatibility shims added in
2011 (to support an older kbdcontrol command on a new kernel during
an upgrade from FreeBSD-8 to FreeBSD-9).

Unicode support for accented characters that are reached via dead key
combinations has been added just recently, again with compatibility
shims to allow all combinations of old/new kernel and old/new
kbdcontrol command to load and display the keymaps including the dead
key table. (But full Unicode in the dead key table requires both a new
kernel and kbdcontrol command.)

This commit makes the compatibility shims depend on the respective
compatibility ioctls (OGIO_KEYMAP, OPIO_KEYMAP, OGIO_DEADKEYMAP, and
OPIO_DEADKEYMAP) being defined in sys/kbio.h. This is true for all of
them in 13-STABLE, none in 12-STABLE (as of now), and will become
optional due to a follow-up commit to sys/kbio.h in -CURRENT.

This commit is the only part of review D38465 that should be merged
back to 12-STABLE and 13-STABLE.

(cherry picked from commit b4eab621f2)
2023-04-10 23:31:24 +02:00
Ed Maste 3a52cc4445 makefs: emit NM records for all directory entries
We previously attempted to emit Rock Ridge NM records only when the name
represented by the Rock Ridge extensions would actually differ. We would
omit the record for an all-upper-case directory name, however Linux (and
perhaps other operating systems) map names with no NM record to
lowercase.

This affected only directories, as file names have an implicit ";1"
version number appended and thus always differ.  To solve, just emit NM
records for all entries other than DOT and DOTDOT .

We could continue to omit the NM record for directories that would avoid
mapping (for example, one named 1234.567) but this does not seem worth
the complexity.

PR:		203531
Reported by:	Thomas Schmitt <scdbackup@gmx.net
Reviewed by:	kevans
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D39258

(cherry picked from commit 978013a094)
2023-04-10 09:37:40 -04:00
Ed Maste b957461353 makefs: correct El Torito bood record
The boot catalog pointer is a DWord, but we previously populated it via
cd9660_bothendian_dword which overwrote four unused bytes following it.
See El Torito 1.0 (1995) Figure 7 for details.

PR:		203531, 203646
Reported by:	Coverity Scan
Reported by:	Thomas Schmitt <scdbackup@gmx.net>
Reviewed by:	kevans
CID:		977470
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D39231

(cherry picked from commit 9f2a525360)
2023-04-10 09:37:40 -04:00
Ed Maste 62f8e14192 makefs: correct iso9660 Rock Ridge NM values
These are not actually used by makefs (yet), but ought to match the
spec.

See RRIP 4.1.4 Description of the "NM" System Use Entry for details.

PR:		203531
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit c3ec19359e)
2023-04-10 09:37:40 -04:00
Ed Maste a79601b07a makefs: correct iso9660 Rock Ridge TF timestamps
The bit definitions for the TF_* timestamp bits (TF_MODIFY, etc.) were
incorrect, and timestamps were written in the wrong order.

See RRIP 4.1.6 Description of the "TF" System Use Entry for details.

PR:		203531
Reported by:	Thomas Schmitt <scdbackup@gmx.net>
Reviewed by:	jrtc27, kevans
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D39221

(cherry picked from commit c65c969bd5)
2023-04-10 09:37:40 -04:00
Kyle Evans 535fc5f75e daemon: reformat longopts
Use a single tab instead of eight spaces, these aren't line
continuations.

(cherry picked from commit b84aaf143c)
2023-04-09 17:49:52 -05:00
Ihor Antonov 81f89a76e8 daemon: decouple init logic from main loop
main() func contained both initialization and main loop logic.
This made certain operations like restarting problematic and
required dirty hacks in form of goto jumps.

This commit moves the main loop logic into daemon_eventloop(),
cleans up main, and makes restart logic clear: daemon_mainloop()
is run in a loop with a restart condition checked at the end.

Reviewed by:	kevans

(cherry picked from commit 4c41f4a0d6)
2023-04-09 17:49:52 -05:00
Ihor Antonov 7ad1bebb0f daemon: move signal setup into a function
No functional change intended.

Reviewed by:	kevans

(cherry picked from commit 9ee1faeeba)
2023-04-09 17:49:52 -05:00
Kyle Evans 2a69943c7b daemon: kill off some stray blank lines
Overlooked in review; mea culpa.

Reported by:	jrtc27

(cherry picked from commit 6b49a630f4)
2023-04-09 17:49:51 -05:00
Ihor Antonov 980ad64271 daemon: remove unnecessary memset in daemon_state_init()
(cherry picked from commit 8117ea0a41)
2023-04-09 17:49:51 -05:00
Ihor Antonov edc3bffde2 daemon: repace goto exit with daemon_terminate()
Start breaking down big main()
Remove goto exit label and replace it with a function that does cleanup.

Comment re-worded by kevans@.

(cherry picked from commit cf6356fd47)
2023-04-09 17:49:51 -05:00
Ihor Antonov 7362081fad daemon: move variables into struct daemon_state
The fact that most of the daemon's state is stored on the stack
of the main() makes it hard to split the logic smaller chunks.
Which in turn leads to huge main func that does a a lot of things.
struct log_params existed because some variables need to be passed
into other functions together.

This change renames struct log_params into daemon_state
and moves the rest of the variables into it. This is a necessary
preparation step for further refactroing.

Reviewed by: imp

(cherry picked from commit 298a392ec3)
2023-04-09 17:49:51 -05:00
Mateusz Guzik bda1244f01 sendmail: silence K&R warns
Sponsored by:	Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 95a2b4d172)
2023-04-09 16:56:45 +02:00
Corvin Köhne e6bb702fce
bhyve: return EEXIST when adding a fwcfg item twice
Reviewed by:		rew
MFC after:		1 week
Sponsored by:		Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D39338

(cherry picked from commit e37edc91b6)
2023-04-06 08:06:23 +02:00
Corvin Köhne 2a33e252a7
bhyve: remove unnecessary const qualifier in acpi_device.h
Those const qualifier declare that the function doesn't change the
values internally. It makes no sense to add them in the header file.

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

(cherry picked from commit 4046899086)
2023-04-06 08:06:23 +02:00
Corvin Köhne ab64356b1c
bhyve: make use of helper to read PCI IDs from bhyve config
For compatibilty reasons, the old config values are still supported.

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

(cherry picked from commit b72e06b13e)
2023-04-05 12:00:39 +02:00
Corvin Köhne ee3a7907bb
bhyve: add helper to read PCI IDs from bhyve config
Changing the PCI IDs is valuable in some situations. The Intel GOP
driver requires that some PCI IDs of the LPC bridge are aligned with the
physical values of the host LPC bridge. Another use case are oracles
virtio driver. They require different subvendor ID than the default one.
For that reason, create a helper which makes it easy to read PCI IDs
from bhyve config. Additionally, this helper ensures that all emulation
devices are using the same config keys.

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

(cherry picked from commit ffaed739a8)
2023-04-05 12:00:39 +02:00
Gordon Bergling f7174106ef rarpd(8): Fix a typo in a source code comment
- s/combinataion/combination/

Obtained from:	NetBSD

(cherry picked from commit 107597fbd4)
2023-03-30 08:30:52 +02:00
Mark Johnston 3b6598f874 bhyve: Sleep briefly in the VMEXIT_DEBUG handler
As of commit 0bda8d3e9f ("vmm: permit some IPIs to be handled by
userspace") and commit 9cc9abf409 ("bhyve: create all vcpus on
startup"), we have a misbehaviour where AP vCPU threads spin until they
receive a SIPI.  In particular, since they are "suspended", they simply
call the VMEXIT_DEBUG handler in a loop, but the handler is a no-op by
default.

This is tricky to fix since the gdb stub isn't aware of whether a given
vCPU is supposed to be running.  For 13.2's sake, introduce a simple
workaround wherein the VMEXIT_DEBUG handler sleeps for a short period.
This ensures that host CPU usage remains sane when VMs are starting
without penalizing users of VMEXIT_DEBUG too much.

Reviewed by:	corvink, jhb
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D39174

(cherry picked from commit ef0ac973db)
2023-03-27 08:50:12 -04:00
Corvin Köhne d468d5dd19
bhyve: add cmdline option to enable qemu's fwcfg
Let the user decide if he wants to use bhyve's fwctl or qemu's fwcfg. He
can set the interface by adding a fwcfg option to bootrom:

-l bootrom,<path/to/rom>,fwcfg=bhyve
-l bootrom,<path/to/rom>,fwcfg=qemu

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

(cherry picked from commit d85147f3d6)
2023-03-27 08:32:59 +02:00
Corvin Köhne 35bdc8b79e
bhyve: add helper for adding fwcfg files
Fwcfg items without a fixed index are reported by the file_dir. They
have an index of 0x20 and above. This helper simplifies the addition of
such fwcfg items. It selects a new free index, assigns it to the fwcfg
items and creates an proper entry in the file_dir.

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

(cherry picked from commit 6f9ebb3d0f)
2023-03-27 08:32:59 +02:00
John Baldwin f31f677c1d makefs: Ignore some sign comparison warnings from GCC.
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D37470

(cherry picked from commit abb9a940bb)
2023-03-22 08:22:07 -07:00
Ed Maste a16159aa2e makefs: do not call brelse if bread returns an error
If bread returns an error there is no bp to brelse.  One of these
changes was taken from NetBSD commit 0a62dad69f62 ("This works well
enough to populate..."), the rest were found by looking for the same
pattern.

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

(cherry picked from commit bc33c99234)
2023-03-21 11:58:40 -04:00
Ihor Antonov 799d67ec40 daemon: set supervise_enabled during argument processing
Now when supervsion mode has it's own variable there is really no
reason to set it separately from the rest of the variables. Move
initialization of supervise_enabled var to the argument processing
switch loop, where it belongs.

Reviewed by:	kevans
Pull Request:	https://github.com/freebsd/freebsd-src/pull/672

(cherry picked from commit f907027b49)
2023-03-17 16:01:03 -05:00
Ihor Antonov ec3a7d2828 daemon: decouple restart variable
The 'restart' variable was responsible for enablement of restart
behavior and for restart delay. While it may seem convenient it
leads to cluttering the exit/restart logic

Reviewed by:	kevans
Pull Request:	https://github.com/freebsd/freebsd-src/pull/672

(cherry picked from commit e781739084)
2023-03-17 16:01:03 -05:00
Ihor Antonov 3f0b048a24 daemon: add braces to while loop
Reviewed by:	kevans
Pull Request:	https://github.com/freebsd/freebsd-src/pull/672

(cherry picked from commit d6c398d882)
2023-03-17 16:01:03 -05:00
Ihor Antonov bc9d2ee0a7 daemon: simplify if/else chain
Reviewed by:	kevans
Pull Request:	https://github.com/freebsd/freebsd-src/pull/672

(cherry picked from commit cd1e6e70d0)
2023-03-17 16:01:02 -05:00
Ihor Antonov bb2e206cae daemon: change type of listen_child() to C99 bool
Reviewed by:	kevans
Pull Request:	https://github.com/freebsd/freebsd-src/pull/672

(cherry picked from commit bc43a9a715)
2023-03-17 16:01:02 -05:00
Ihor Antonov 204306b053 daemon: flatten and simplify fork() logic
Reviewed by:	kevans
Pull Request:	https://github.com/freebsd/freebsd-src/pull/672

(cherry picked from commit 75f61ca920)
2023-03-17 16:01:02 -05:00
Ihor Antonov 05578dd521 daemon: style changes
This is not a functional change.
- Clean up whitespace (spaces where there should be tabs)
- Break up lines that are longer than 80

Reviewed by:	kevans
Pull Request:	https://github.com/freebsd/freebsd-src/pull/672

(cherry picked from commit 39ea4280e4)
2023-03-17 16:01:02 -05:00
Ihor Antonov 8eb1e5dd77 daemon: more human-friendly variable names
Reviewed by:	kevans
Pull Request:	https://github.com/freebsd/freebsd-src/pull/669

(cherry picked from commit 129ec8f480)
2023-03-17 16:01:02 -05:00
Ihor Antonov d8b8a0316e daemon: move syslog facility and syslog tag into log_params
Since struct log_params already contains logging-related
varaiables, including syslog-related, move remaining
syslog-related variables into struct log_params as well

Reviewed by:	kevans
Pull Request:	https://github.com/freebsd/freebsd-src/pull/669

(cherry picked from commit 6f0636728b)
2023-03-17 16:01:02 -05:00
Ihor Antonov b71a65870f daemon: deduplicate log_params varaibles
While we're here, sort log_params by size.

Reviewed by:	kevans
Pull Request:	https://github.com/freebsd/freebsd-src/pull/669

(cherry picked from commit e70444c622)
2023-03-17 16:01:02 -05:00
Ihor Antonov 5e46ebc5d0 daemon: make log_reopen variable a bool
Following style(9) and C99 recommendation use bool instead of
int for boolean operations.

Reviewed by:	kevans
Pull Request:	https://github.com/freebsd/freebsd-src/pull/669

(cherry picked from commit 97022e90c3)
2023-03-17 16:01:02 -05:00
Ihor Antonov d394c80f49 daemon: make dosyslog variable a bool and give it a better name
Following style(9) and C99 recommendation use bool instead of
int for boolean operations. Also give the variable a more descriptive
name that follows boolean naming convention.

Reviewed by:	kevans
Pull Request:	https://github.com/freebsd/freebsd-src/pull/669

(cherry picked from commit f2f9d31d9f)
2023-03-17 16:01:01 -05:00
Ihor Antonov 6f71a68456 daemon: add supervision_enabled var
explicitly name a bunch of boolean checks that enable
supervison mode and improve comments

Reviewed by:	kevans
Pull Request:	https://github.com/freebsd/freebsd-src/pull/669

(cherry picked from commit 203df05b69)
2023-03-17 16:01:01 -05:00
Ihor Antonov 52f302f136 daemon: initialize struct sigaction at declaration site
This improves readability by uncluttering the code

Reviewed by:	kevans
Pull Request:	https://github.com/freebsd/freebsd-src/pull/669

(cherry picked from commit 259ed21d21)
2023-03-17 16:01:01 -05:00
Ihor Antonov 93871c6cff daemon: fix double init of pid variable
Reviewed by:	kevans
Pull Request:	https://github.com/freebsd/freebsd-src/pull/669

(cherry picked from commit 91b921c7d4)
2023-03-17 16:01:01 -05:00
Ihor Antonov cc123f0dba daemon: initialize mask_orig with sigemptyset()
consolidation of variable declarations and initializations in previous
commit allowed me to detect that one of the signal masks is not properly
initialized with sigemptyset (as man 3 sigsetops demands)

Reviewed by:	kevans
Pull Request:	https://github.com/freebsd/freebsd-src/pull/669

(cherry picked from commit 84866cefdf)
2023-03-17 16:01:01 -05:00
Ihor Antonov d24c97ebfb daemon: consolidate variable declarations and initializaions
- improve readability by breaking apart single-line multi-variable declarations
- initialize simple variables at declaration site
- move other top-level variable initializations closer declarations
  to avoid potential UB and unclutter the use-site.

Reviewed by:	kevans
Pull Request:	https://github.com/freebsd/freebsd-src/pull/669

(cherry picked from commit e745dc2287)
2023-03-17 16:01:01 -05:00
Ihor Antonov 488cf4bb6f daemon: use braces with 'if' consistently
Reviewed by:	kevans
Pull Request:	https://github.com/freebsd/freebsd-src/pull/669

(cherry picked from commit 6b4ef4b16a)
2023-03-17 16:01:01 -05:00
Ihor Antonov 282e4cf32d daemon: add long_opts
Long options improve readability of scripts, makes code comprehension
easier.  This patch adds long options while preserving the existing CLI
interface.

Also --help/-h option is added.

Reviewed by:	allanjude, pauamma (both earlier versions), kevans
Differential Revision:	https://reviews.freebsd.org/D38244

(cherry picked from commit 0a402ad2e6)
2023-03-17 16:01:01 -05:00
Vitaliy Gusev 4e10f8056b
bhyvectl: don't permit using --suspend and --checkpoint at same time
When using the --suspend and --checkpoint parameter, bhyvectl will
produce two checkpoint images and the exits. This is slightly ambiguous.
So, permit only one of theses parameters at the same time.

Reviewed by:		corvink, markj
MFC after:		1 week
Sponsored by:		vStack
Differential Revision:	https://reviews.freebsd.org/D38887

(cherry picked from commit 062f2818c1)
2023-03-17 11:26:35 +01:00
Vitaliy Gusev c8ec366fd7
bhyve: init checkput before caph_enter
init_checkpoint_thread binds to a socket. Bhyve isn't allowed to do that
after caph_enter.

Reviewed by:		corvink, markj
MFC after:		1 week
Sponsored by:		vStack
Differential Revision:	https://reviews.freebsd.org/D38857

(cherry picked from commit 9a9a248964)
2023-03-17 11:26:35 +01:00
Vitaliy Gusev 6efb053bea
bhyve: exit with EX_OSERR if init checkpoint or restore time failed
Reviewed by:		corvink, markj
MFC after:		1 week
Sponsored by:		vStack
Differential Revision:	https://reviews.freebsd.org/D38872

(cherry picked from commit d213429e42)
2023-03-17 11:26:35 +01:00
Vitaliy Gusev 2193f12bf8
bhyve: add cap limits for ipc socket
Reviewed by:		corvink, markj
MFC after:		1 week
Sponsored by:		vStack
Differential Revision:	https://reviews.freebsd.org/D38856

(cherry picked from commit 577ddca908)
2023-03-17 11:26:35 +01:00
Vitaliy Gusev c8b5f34731
bhyve: don't flush readonly device at blockif_pause
Reviewed by:		corvink, markj
MFC after:		1 week
Sponsored by:		vStack
Differential Revision:	https://reviews.freebsd.org/D38855

(cherry picked from commit 5c0a031259)
2023-03-17 11:26:34 +01:00
Vitaliy Gusev f63fd20a9a
bhyvectl: don't leak nvlist in send_message
Reviewed by:		corvink, markj
MFC after:		1 week
Sponsored by:		vStack
Differential Revision:	https://reviews.freebsd.org/D38900

(cherry picked from commit 942525ab47)
2023-03-17 11:26:34 +01:00
Vitaliy Gusev d2da92306a
bhyvectl: correct socket_fd closing in send_message
Reviewed by:		corvink, markj
MFC after:		1 week
Sponsored by:		vStack
Differential Revision:	https://reviews.freebsd.org/D38889

(cherry picked from commit b64ba24264)
2023-03-17 11:26:33 +01:00
Vitaliy Gusev 38b37099bb
bhyvectl: do not return garbage from send_message
err is used uninitialized in some cases.

Reviewed by:		corvink, markj
MFC after:		1 week
Sponsored by:		vStack
Differential Revision:	https://reviews.freebsd.org/D38886

(cherry picked from commit 89fe7b98fe)
2023-03-17 11:26:33 +01:00
Vitaliy Gusev f6a333f855
bhyve: fix resume for vms with guest_ncpus > 1
This error occurs because vm->vcpu[1] has not been allocated yet when
vm_snapshot_vm() is called.

To fix this, move spinup_vcpu() before restore code.

Reviewed by:		corvink, markj
MFC after:		2 weeks
Sponsored by:		vStack
Differential Revision:	https://reviews.freebsd.org/D38477

(cherry picked from commit 9ff3e8b7f0)
2023-03-17 11:26:33 +01:00
Vitaliy Gusev 38acc80a5b
bhyve: fix restore of kernel structs
vmx_snapshot() and svm_snapshot() do not save any data and error occurs at
resume:

Restoring kernel structs...
vm_restore_kern_struct: Kernel struct size was 0 for: vmx
Failed to restore kernel structs.

Reviewed by:		corvink, markj
Fixes:			39ec056e6d ("vmm: Rework snapshotting of CPU-specific per-vCPU data.")
MFC after:		2 weeks
Sponsored by:		vStack
Differential Revision:	https://reviews.freebsd.org/D38476

(cherry picked from commit 8104fc31a2)
2023-03-17 11:26:33 +01:00
Corvin Köhne 0229691960
bhyve: add common fwcfg items
Qemu defines some common fwcfg items. We don't need to support all of
them. Only a subset needs to be present for fwcfg to work properly.

- signature
  The signature is used by the guest to check if qemu's fwcfg is
  available or not.
- id
  The id is used by the guest to check which features are supported by
  the fwcfg implementation of the hypervisor.
- file_dir
  The file dir reports all fwcfg items which don't have a fixed index.
  These are mostly user defined fwcfg items.

Reviewed by:		<If someone else reviewed your modification.>
MFC after:		1 week
Sponsored by:		Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D38335

(cherry picked from commit 34f804e547)
2023-03-17 11:26:32 +01:00
Corvin Köhne 1adfb2e834
bhyve: add helper to add fwcfg items
This helper makes it easier to add multiple fwcfg items. You can pass an
index and some data to the helper. The helper adds these information to
the fwcfg emulation so that the guest reads the given data on the
specified index.

Reviewed by:		<If someone else reviewed your modification.>
MFC after:		1 week
Sponsored by:		Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D38334

(cherry picked from commit 3ef46195ac)
2023-03-17 11:26:32 +01:00
Alan Somers bd66219c6d sesutil: don't malloc in a tight loop
Reported by:	mav
Sponsored by:	Axcient
Reviwed by:	mav
Differential Revision: https://reviews.freebsd.org/D38473

(cherry picked from commit 4bd4e4b45e)
2023-03-15 16:35:49 -06:00
Warner Losh aa1e6a4f4c makefs: make msdos creation go fast
Add missing brelse(bp). Without it the cache grows and we have a n^2
lookup.  I'm not entirely sure why we read the block before we write it
back out, since the only side effect of that is to allocate memory,
clear the memory, read it in from disk, throw it away with the contents
of the file being written out. We likely should just do a getblk() here
instead, but even with all that, this takes the time it takes to create
a 150MB msdos fs image down from 5 minutes to 30 seconds.

Old: 317.663u 0.685s 5:18.34 100.0%	198+360k 0+19io 1009pf+0w
New: 7.330u 23.841s 0:31.17 100.0%	198+360k 0+250522io 4pf+0w

See code review for how we got this. tl;dr: netbsd move brelse
into bwrite and we picked up msdos code after that, but not the
move. That change should be picked up later.

Sponsored by:		Netflix
Reviewed by:		emaste
MFC After:		1 day (13.2 is coming fast)
Differential Revision:	https://reviews.freebsd.org/D39025

(cherry picked from commit 370e009188)
2023-03-14 09:47:46 -06:00
Mark Johnston 25766cfd83 bhyvectl: Address compiler warnings and bump WARNS
Avoid unaligned accesses in cpu_vendor_intel() and address a few other
nits.  No functional change intended.

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

(cherry picked from commit 3f5d875a27)
2023-03-13 11:53:16 -04:00
Mark Johnston cc7b54d6ec bhyveload: Address compiler warnings and bump WARNS
Mostly sprinkle __unused.  Also duplicate strings passed to addenv() so
that constant string literals can be passed.  No functional change
intended.

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

(cherry picked from commit ad43dd69ce)
2023-03-13 11:53:16 -04:00
Ed Maste b562307b70 freebsd-update: use grep -E instead of egrep
GNU egrep emits a warning that it is obsolescent and suggests grep -E
instead.  Switch to grep -E in case we end up invoking GNU (e)grep (and
for consistency with other invocations in this file).

Reported by:	Steffen Nurpmeso
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit e27ded83c7)
2023-03-05 19:30:57 -05:00
Ed Maste ab53efd142 mergemaster: add deprecation notice to man page
PR:		252417
Reviewed by:	bapt, gjb, kevans (all earlier)
Relnotes:	Yes
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D23327

(cherry picked from commit 398b12691b)
2023-03-05 19:30:57 -05:00
Ed Maste 24fe8a5183 freebsd-update: avoid effects of user's environment on grep
A user had GREP_OPTIONS containing --color=always, which broke grep use
in freebsd-update.  Unset this environment variable.

PR:		255990
Reviewed by:	kevans
Approved by:	re (cperciva, expedited MFC)
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit e093c61b2d)
2023-03-02 13:30:54 -05:00
Ed Maste c7e3703352 freebsd-update: re-edit files if merge conflict markers remain
freebsd-update will open ${EDITOR} if conflicts occur while merging
updates to config files.  Inform the user if they've left conflict
markers behind, and go back to editing the file.

PR:		185546
PR:		229689
Reviewed by:	delphij
Approved by:	re (cperciva, expedited MFC)
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D37703

(cherry picked from commit ceb5f28ba5)
2023-03-02 13:29:57 -05:00
Corvin Köhne 3c12bcba78
bhyve: add emulation for qemu's fwcfg data port
The data port returns the data of the fwcfg item.

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

(cherry picked from commit b11081dca7)
2023-02-28 11:04:37 +01:00
Corvin Köhne bd8366500e
bhyve: add emulation for the qemu fwcfg selector port
The selector port is used to select the desired fwcfg item.

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

(cherry picked from commit 151d8131a8)
2023-02-28 11:04:36 +01:00
Corvin Köhne 0232125972
bhyve: add basic qemu fwcfg implementation
qemu's fwcfg and bhyve's fwctl are both used to configure ovmf. qemu's
fwcfg is much more powerfull than bhyve's fwctl. For that reason, add
support for qemu's fwcfg.

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

(cherry picked from commit 9b99de77f1)
2023-02-28 11:04:35 +01:00
Corvin Köhne 2c1cbd0836
bhyve: maintain a list of acpi devices
The list is used to generate the dsdt entry for every acpi device.

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

(cherry picked from commit fbd045021d)
2023-02-28 11:04:34 +01:00
Corvin Köhne 6726130d68
bhyve: add helper func to write a dsdt entry
The guest will check the dsdt to detect acpi devices. Therefore, add a
helper function to create such a dsdt entry for an acpi device.

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

(cherry picked from commit 682a522d61)
2023-02-28 11:04:34 +01:00
Corvin Köhne eb8931d77c
bhyve: add helper func to add acpi resources
These helper function can be used to assign acpi resources to an
acpi_device.

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

(cherry picked from commit 13a1df5b85)
2023-02-28 11:04:33 +01:00
Corvin Köhne b5d47fa9a5
bhyve: add helper struct for acpi device handling
To simplify the handling of different acpi devices like qemu fwcfg or a
tpm, add a helper struct. It will handle the reporting of acpi
resources.

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

(cherry picked from commit 1231f047c3)
2023-02-28 11:04:26 +01:00
Dimitry Andric 0196b09444 Update leap-seconds to latest leap-seconds.3676924800 (expires 2023-12-28)
Obtained from:	ftp://ftp.boulder.nist.gov/pub/time/leap-seconds.3676924800
MFC after:	3 days

(cherry picked from commit df2fbbfa71)
2023-02-27 10:21:16 +01:00
Warner Losh 8ab17c6dd1 efibootmgr: Add --efidev (-u) to discover UEFI's device path to a dev or file
"efibootmgr --efidev unix-path" will return the UEFI device-path to the
file or device specified by unix-path. It's useful for debugging, but
may also be useful for scripting.

Sponsored by:		Netflix
Reviewed by:		corvink, manu
Differential Revision:	https://reviews.freebsd.org/D38617

(cherry picked from commit 9a79152994)
2023-02-18 17:46:57 -07:00
Alan Somers c16a901eac sesutil: plug memory leaks
Sponsored by:	Axcient
Reviewed by:	bapt
Differential Revision: https://reviews.freebsd.org/D33955

(cherry picked from commit 09f29b03dd)
2023-02-15 17:32:00 -07:00
Juraj Lutter e0c3f2a1e2 unbound: Fix config file path
Commit 1838dec318 changed the
config file path to /usr/local/etc/unbound/unbound.conf which
is wrong for unbound in base.

Reported by:	Ihor Antonov <ihor_AT_antonovs_family>
Reviewed by:	zlei
Approved by:	zlei
Differential Revision: https://reviews.freebsd.org/D38106

Fixes:          1838dec318

(cherry picked from commit 1d577bedba)
2023-02-14 10:32:39 -08:00
Cy Schubert 9f9f2a1270 unbound: Fix config.h
FreeBSD src does not support HAVE_DECL_EVSIGNAL_ASSIGN. While reviewing
the new config.h after regenerating it, this definition was not removed.

Updating config.h is a manual process of configuring the port and
copying/merging the generated config.h into src. This definition was
missed and not removed (#undef'd).

Fixes:		1838dec318

(cherry picked from commit 06b93ef8cd)
2023-02-14 10:32:39 -08:00
Cy Schubert 26ba9518ff unbound: Vendor import 1.17.1
Release notes at
    https://www.nlnetlabs.nl/news/2023/Jan/12/unbound-1.17.1-released/.

Merge commit '7699e1386a16236002b26107ffd2dcbde375e197' into main

(cherry picked from commit 1838dec318)
2023-02-14 10:32:39 -08:00
Tijl Coosemans 412d15f726 local-unbound-setup: Use default root certificates
Don't force /etc/ssl/cert.pem.  It does not exist by default, only if
security/ca_root_nss is installed.  Just use the default OpenSSL search
locations which are /etc/ssl/cert.pem and /etc/ssl/certs/.

The tls-system-cert option was added in Unbound 1.16.0.

Reviewed by:	zlei
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D38243

(cherry picked from commit 8932f7ce17)
2023-02-13 11:52:20 +01:00
Stefan Eßer 6693d527a4 usr.sbin/kbdcontrol.c: Add backwards compatibility functions
This commit allows a kbdcontrol binary built with a version of kbio.h
that supports Unicode characters in dead key maps to load and display
keymaps including the dead key tables on a kernel built with a
previous version of kbio.h (that only supported 8 bit characters in
the dead key map).

This commit is meant as a temporary compatibility shim that will be
reverted when it can be assumed that all relevant systems have been
upgraded to a kernel that uses the updated kbio.h.

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

(cherry picked from commit b92f8e5c0d)
2023-02-09 22:36:09 +01:00
Xin LI d07eb716f3 etcupdate: Chase test case after pwd_mkdb(8) no longer copies comments.
(cherry picked from commit 4bbf45cf56)
2023-02-03 16:26:24 -08:00
Andre Albsmeier 3e95573311 pwd_mkdb(8): Don't copy comments from /etc/master.passwd to /etc/passwd.
The intention of /etc/passwd was to support legacy applications that are
not yet converted to use modern API like getpwent(3). Comments are not
defined in the legacy format, so copying them could break these
applications. Plus, it could leak sensitive information (e.g. encrypted
form of password of an user that was commented out instead of deleted
or disabled).

PR:		bin/144652
(cherry picked from commit 0deb25bd9d)
2023-02-03 16:25:54 -08:00
Emmanuel Vadot ee4bb682f1 pkgbase: Put devmatch in its own package
devmatch is useful on standalone machine but not on jails.
Put devinfo(8) and libdevinfo there too.

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

(cherry picked from commit e7a5a60ed5)
2023-02-02 10:32:56 +01:00
Emmanuel Vadot 01db7f820e pkgbase: Put ufs related tools and lib in their own package
It's not really useful in a jail or in a mdroot or even if a users
wants to do a full zfs machine.

Reviewed by:	mckusick
Differential Revision:	https://reviews.freebsd.org/D36227

(cherry picked from commit a7ffc94849)
2023-02-02 10:32:55 +01:00
Emmanuel Vadot 33fea630f2 pkgbase: Put accounting utilities in the acct package
(cherry picked from commit 0c6b2a9179)
2023-02-02 10:32:54 +01:00