Commit Graph

20047 Commits

Author SHA1 Message Date
Ihor Antonov
e781739084 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
2023-03-02 23:17:02 -06:00
Ihor Antonov
d6c398d882 daemon: add braces to while loop
Reviewed by:	kevans
Pull Request:	https://github.com/freebsd/freebsd-src/pull/672
2023-03-02 23:17:02 -06:00
Ihor Antonov
cd1e6e70d0 daemon: simplify if/else chain
Reviewed by:	kevans
Pull Request:	https://github.com/freebsd/freebsd-src/pull/672
2023-03-02 23:17:02 -06:00
Ihor Antonov
bc43a9a715 daemon: change type of listen_child() to C99 bool
Reviewed by:	kevans
Pull Request:	https://github.com/freebsd/freebsd-src/pull/672
2023-03-02 23:17:02 -06:00
Ihor Antonov
75f61ca920 daemon: flatten and simplify fork() logic
Reviewed by:	kevans
Pull Request:	https://github.com/freebsd/freebsd-src/pull/672
2023-03-02 23:17:02 -06:00
Ihor Antonov
39ea4280e4 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
2023-03-02 23:17:01 -06:00
Ed Maste
398b12691b mergemaster: add deprecation notice to man page
Reviewed by:	bapt, gjb, kevans (all earlier)
Relnotes:	Yes
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D23327
2023-03-02 20:43:34 -05:00
Ed Maste
e27ded83c7 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
2023-03-02 18:58:58 -05:00
Elyes Haouas
de1a17db89 moused: Fix typos
Signed-off-by: Elyes Haouas <ehaouas@noos.fr>
2023-03-02 11:53:44 -05:00
Elyes Haouas
ae90e9a9d6 yp_mkdb: Remove useless return at the end of void function
Signed-off-by: Elyes Haouas <ehaouas@noos.fr>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/656
2023-03-02 08:01:39 -07:00
Elyes Haouas
0715ec7eb4 usbconfig: Remove useless return at the end of void function
Signed-off-by: Elyes Haouas <ehaouas@noos.fr>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/656
2023-03-02 08:01:39 -07:00
Elyes Haouas
0fd15eb335 rrenumd: Remove useless return at the end of void function
Signed-off-by: Elyes Haouas <ehaouas@noos.fr>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/656
2023-03-02 08:01:39 -07:00
Elyes Haouas
fce4b0c51d rpcbind: Remove useless return at the end of void function
Signed-off-by: Elyes Haouas <ehaouas@noos.fr>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/656
2023-03-02 08:01:39 -07:00
Elyes Haouas
c7846853d3 rpc.yppasswdd: Remove useless return at the end of void function
Signed-off-by: Elyes Haouas <ehaouas@noos.fr>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/656
2023-03-02 08:01:39 -07:00
Elyes Haouas
ca2edebb92 pmcstat: Remove useless return at the end of void function
Signed-off-by: Elyes Haouas <ehaouas@noos.fr>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/656
2023-03-02 08:01:39 -07:00
Elyes Haouas
1def31df76 lpr: Remove useless return at the end of void function
Signed-off-by: Elyes Haouas <ehaouas@noos.fr>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/656
2023-03-02 08:01:28 -07:00
Elyes Haouas
a5aa07dd85 extattr: Remove useless return at the end of void function
Signed-off-by: Elyes Haouas <ehaouas@noos.fr>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/656
2023-03-02 07:59:13 -07:00
Elyes Haouas
86cda797bd diskinfo: Remove useless return at the end of void function
Signed-off-by: Elyes Haouas <ehaouas@noos.fr>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/656
2023-03-02 07:59:12 -07:00
Elyes Haouas
b23e15e1c8 dconschat: Remove useless return at the end of void function
Signed-off-by: Elyes Haouas <ehaouas@noos.fr>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/656
2023-03-02 07:59:11 -07:00
Elyes Haouas
beb2af45bd bluetooth/hccontrol: Remove useless return at the end of void function
Signed-off-by: Elyes Haouas <ehaouas@noos.fr>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/656
2023-03-02 07:59:10 -07:00
Ihor Antonov
129ec8f480 daemon: more human-friendly variable names
Reviewed by:	kevans
Pull Request:	https://github.com/freebsd/freebsd-src/pull/669
2023-03-01 21:00:43 -06:00
Ihor Antonov
6f0636728b 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
2023-03-01 21:00:42 -06:00
Ihor Antonov
e70444c622 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
2023-03-01 21:00:42 -06:00
Ihor Antonov
97022e90c3 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
2023-03-01 21:00:42 -06:00
Ihor Antonov
f2f9d31d9f 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
2023-03-01 21:00:42 -06:00
Ihor Antonov
203df05b69 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
2023-03-01 21:00:42 -06:00
Ihor Antonov
259ed21d21 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
2023-03-01 21:00:42 -06:00
Ihor Antonov
91b921c7d4 daemon: fix double init of pid variable
Reviewed by:	kevans
Pull Request:	https://github.com/freebsd/freebsd-src/pull/669
2023-03-01 21:00:42 -06:00
Ihor Antonov
84866cefdf 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
2023-03-01 21:00:41 -06:00
Ihor Antonov
e745dc2287 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
2023-03-01 21:00:41 -06:00
Ihor Antonov
6b4ef4b16a daemon: use braces with 'if' consistently
Reviewed by:	kevans
Pull Request:	https://github.com/freebsd/freebsd-src/pull/669
2023-03-01 21:00:41 -06:00
Ed Maste
ceb5f28ba5 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
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D37703
2023-03-01 20:20:33 -05:00
Elyes Haouas
71a21ad489 bhyve: Remove useless return at the end of void function
Signed-off-by: Elyes Haouas <ehaouas@noos.fr>
2023-03-01 12:04:41 -05:00
Vitaliy Gusev
956171d5bc bhyve: remove redundant variable
Reviewed by:    corvink,markj
Sponsored by:   vStack
Differential Revision: https://reviews.freebsd.org/D38836
2023-03-01 07:45:46 +00:00
Ed Maste
e093c61b2d 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
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
2023-03-01 11:02:54 -05:00
John Grafton
9ab40bc40d 310.accounting: Verify process accounting is active before log rotation.
This corrects a bug in which the daily periodic script '310.accounting'
attempts to rotate logs via /etc/rc.d/accounting by calling
onerotate_logs function. The rotate logs function turns accounting back
on regardless of what acccounting_enable is set to in /etc/rc.conf. This
is due to checkyesno always returning YES since rotate logs is called
with the 'one' prefix.

In effect, accounting will always be turned back on once a day even if
it is disabled and stopped by hand. The fix was simple, just check if
accounting is before rotating logs and if it is, don't attempt the
rotate.

PR: 267464
Reviewed by: imp, hps (lgtm, not approval), Mina Galić
Pull Request: https://github.com/freebsd/freebsd-src/pull/648
Differential Revision: https://reviews.freebsd.org/D37434
2023-02-28 09:59:34 -07:00
Vitaliy Gusev
9ff3e8b7f0
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
2023-02-28 13:37:58 +01:00
Vitaliy Gusev
8104fc31a2
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
2023-02-28 13:37:53 +01:00
Corvin Köhne
34f804e547
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
2023-02-28 13:37:12 +01:00
Corvin Köhne
3ef46195ac
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
2023-02-28 13:37:03 +01:00
Alexander Leidinger
b45f09ac57 periodic: switch lockf to silent operation.
This fixes duplicate mails (one from cron, one from periodic)
when a periodic run is not finished bfore the next one starts.

The man page states that the intended use case is cron, and
the error handling of the lockf invocation handles this case
explicitely, as such no error message for the "interactive"
use was considered.
2023-02-28 09:38:42 +01:00
Vladimir Kotal
9630e237ab report full error string on SSL_connect() failure
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/575
2023-02-27 16:07:30 -07:00
Mina Galić
773c13c686 kldxref: skip .pkgsave files
This should help people transitioning from traditional setups to pkgbase
experience a lot less friction.

We do this by skipping all files containing two dots.

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/661
Differential Revision: https://reviews.freebsd.org/D27959
2023-02-25 10:35:43 -07:00
Mateusz Piotrowski
28111ddf9e powerd.8: Provide a whole path to power_profile for clarity
MFC after:	3 weeks
2023-02-25 17:30:27 +01:00
Kyle Evans
b9c8f4900c config: drop reference to removed System_spec
Fixes the following warning:

yacc: w - the symbol System_spec is undefined
yacc: 3 rules never reduced

Reported by:	otis
Fixes:	6a836ea741 ("config(8): Remove obsolete 'config' directive.")
2023-02-24 13:16:19 -06:00
Dimitry Andric
df2fbbfa71 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
2023-02-24 13:18:05 +01:00
Mark Johnston
8c8574acb8 config: Include errno.h in mkmakefile.cc
Commit da88842029 ("config: error out on malformed env/hint lines")
added a reference to EINVAL.  In some configurations the bootstrap tools
build fails for lack of errno definitions.

Fixes:	da88842029 ("config: error out on malformed env/hint lines")
Reported by:	syzbot+b1a5d112a737d9a2be9b@syzkaller.appspotmail.com
2023-02-23 21:53:06 -05:00
Ed Maste
17a5a29003 efibootmgr: add missing break for 'u' case
Reviewed by:	imp, zlei
Reported by:	Coverity
CID:		1505695
Fixes:		9a79152994 ("efibootmgr: Add --efidev (-u) to dis...")
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D38747
2023-02-23 14:13:18 -05:00
Rick Macklem
fe5c211ba8 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.

MFC after:	3 months
2023-02-22 14:09:15 -08:00
Kyle Evans
c04ad15ca7 config: address a number of Coverity issues
Highlights:
- Various memory leaks
- FILE* leaks
- `tsize` in moveifchanged() is only needed if !changed, and `from_sb`
    is only valid if !changed.
- Simplify trivially true expression
- Sanity check elfdump size output (+ fix variable sizes) (des@)

CID:	1471167, 1006391, 1505333, 1505275, 1505349, 1505306, 1505232
Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D38643
2023-02-16 14:37:06 -06:00
Kyle Evans
da88842029 config: error out on malformed env/hint lines
We need these to be assignments, error out if they're not.

While we're here, tag errout as __printflike so that the compiler will
sanity check the format string + args.

CID:	1505293
Reviewed by:	emaste, imp
Differential Revision:	https://reviews.freebsd.org/D38642
2023-02-16 14:37:05 -06:00
Kyle Evans
b2c5a01722 config: push path() into moveifchanged()
Every caller path()s its arguments anyways, just simplify these and push
path() into moveifchanged().  This fixes a number of memory leaks in the
process since path() allocates memory, which we will now free().

While we're here, make sure we close from_fd/to_fd appropriately.

CID:	1471040, 1471714, 1472045, 1006907, 1006908
Reviewed by:	emaste, imp
Differential Revision:	https://reviews.freebsd.org/D38641
2023-02-16 14:36:42 -06:00
Kyle Evans
f518229d55 config: fix some common issues with path() usage
None of the callers check that the allocation in path() failed, so let's
check in path() and abort instead of failing.

Along those lines, none of the callers seem to acknowledge that the
returned string needs to be free()d -- let's do that as well.  There are
a couple not addressed in this commit that will be addressed in a future
commit by pushing the path() call down into moveifchanged() instead and
freeing it properly there.

CID:	1505271, 1505250, 1505279
Reviewed by:	emaste, imp
2023-02-16 14:36:16 -06:00
Warner Losh
9a79152994 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
2023-02-16 08:54:39 -07:00
Warner Losh
547fb1426c efidp: Remove write only variable
Sponsored by:		Netflix
2023-02-15 16:03:54 -07:00
Stefan Eßer
c2bb66023f kbdcontrol: enable pre-Unicode dead key table compatibility
The definition of pre-Unicode keymap ioctls will be made optional and
dependent on COMPAT_FREEBSD13 in a follow-up commit to 14-CURRENT.

While we generally provide ABI compatibility for older binaries on
a new kernel, but not functionally extended userland programs on an
old kernel, it has been specifically requested to preserve ABI
compatibility for the kbdcontrol program for both these cases.

Passing the kernel configuration option COMPAT_FREEBSD13 to the build
of kbdcontrol will make ioctls visible to the build that are normally
hidden, but required to implement compatibility with kernels that only
support 8 bit characters in dead key maps.

This commit is not to be merged to any previous FreeBSD version and
it shall be reverted as soon as this type of ABI compatibility is no
longer deemed necessary (probably before 14-STABLE is branched).

This commit is a part of review D38465 and split off to allow it to be
reverted using the commit ID.
2023-02-14 13:49:06 +01:00
Stefan Eßer
b4eab621f2 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.

MFC after:	1 month
2023-02-14 13:27:27 +01:00
Corvin Köhne
b11081dca7
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
2023-02-14 08:28:49 +01:00
Corvin Köhne
151d8131a8
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
2023-02-14 08:28:43 +01:00
Corvin Köhne
9b99de77f1
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
2023-02-14 08:28:37 +01:00
Corvin Köhne
fbd045021d
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
2023-02-14 08:28:31 +01:00
Corvin Köhne
682a522d61
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
2023-02-14 08:28:27 +01:00
Corvin Köhne
13a1df5b85
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
2023-02-14 08:28:21 +01:00
Corvin Köhne
1231f047c3
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
2023-02-14 08:28:17 +01:00
Alan Somers
4bd4e4b45e sesutil: don't malloc in a tight loop
Reported by:	mav
MFC after:	1 week
Sponsored by:	Axcient
Reviwed by:	mav
Differential Revision: https://reviews.freebsd.org/D38473
2023-02-13 09:04:05 -07:00
Ihor Antonov
0a402ad2e6 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
2023-02-09 22:36:07 -06:00
Alan Somers
09f29b03dd sesutil: plug memory leaks
MFC after:	1 week
Sponsored by:	Axcient
Reviewed by:	bapt
Differential Revision: https://reviews.freebsd.org/D33955
2023-02-09 14:43:17 -07:00
Kyle Evans
83d7ed8af3 config: drop dependency on libsbuf
Use an std::stringstream instead.  get_word() and get_quoted_word() both
return a buffer that's presumed to not need release, so solve this by
returning a new special configword type that holds a string or eof/eol
state.  This cleans up caller checking for EOF/EOL to make it more
explicit what they're doing, at least in the EOL cases which previously
checked for NULL.

Sponsored by:	Klara, Inc.
Sponsored by:	NetApp, Inc.
Differential Revision:	https://reviews.freebsd.org/D38276
2023-02-08 22:56:10 -06:00
Alexander Kabaev
89a072d11c Makefile.amd64: remove construct that serves no purpose
The variable expansion as written will never match anything but
'amd64/.8' in OBJDIR. The original intention behind the construct
remains unclear, but "as is" it serves no other purpose but to
generate the warning. Remove it altogether.

Fixes: df90aeac24
Reviewed by: imp
Differential Revision:   https://reviews.freebsd.org/D38440
2023-02-08 12:19:39 -07:00
Emmanuel Vadot
cab549c76c pkgbase: Create a FreeBSD-console-tools package
And put in it:
 - kbdcontrol
 - vidcontrol
 - moused
 - kbdmap

Those aren't useful in a jail or for a modern desktop.
While here, split the devd.conf part into some new files.

Reviewed by:	bapt
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D38321
2023-02-08 08:52:40 +01:00
Emmanuel Vadot
431b9b6692 pkgbase: Put sendmail example in the sendmail package
Reviewed by:	bapt
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D38297
2023-02-08 08:50:31 +01:00
Emmanuel Vadot
06a69951fb pkgbase: Put ftp-proxy in the FreeBSD-pf package
It belongs here.
Also this unbloat FreeBSD-utilities a bit and it will not depend
on the FreeBSD-libevent1 package now.

Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D38226
2023-02-08 08:49:43 +01:00
Emmanuel Vadot
4c9c296e63 pkgbase: Create a FreeBSD-netmap package
This unbloat FreeBSD-utilities a bit and not everyone uses
valectl which is the only in-tree consumer of libnetmap

Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D38225
2023-02-08 08:49:28 +01:00
Emmanuel Vadot
751ded1d02 pkgbase: Create a FreeBSD-inetd package
And put inetd and its config file in it.
This unbloat a bit FreeBSD-utilities and some people might not
want inetd always installed.

Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D38229
2023-02-08 08:48:43 +01:00
Emmanuel Vadot
9c1720e59a pkgbase: Create a FreeBSD-smbutils package
And put smb related programs and lib in it.

Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D38228
2023-02-08 08:48:28 +01:00
Kyle Evans
29c5f8bf9a config: drop dependency on libnv
Compile mkmakefile.c as C++ instead and use an std::unordered_map to
accomplish the same goal.

Reviewed by:	imp
Sponsored by:	Klara, Inc.
Sponsored by:	NetApp, Inc.
Differential Revision:	https://reviews.freebsd.org/D38275
2023-02-08 00:09:19 -06:00
Kyle Evans
2ffdc21324 config: make changes to allow some parts to build as C++
Highlights:
- Avoid keywords (this, not) as variable names
- Move yyparse into config.h with other declarations
- All declarations in config.h are assumed guilty until proven innocent
- Some const-correctness
- Casting malloc/calloc returns

Note that we're not building any C++ here yet, this will be introduced
in other commits to replace some of the lib dependencies.  Reducing the
number of FreeBSD-specific dependencies we have reduces some friction
for building our bootstrap tools independently in other environments.

Reviewed by:	imp
Sponsored by:	Klara, Inc.
Sponsored by:	NetApp, Inc.
Differential Revision:	https://reviews.freebsd.org/D38274
2023-02-08 00:09:10 -06:00
Tijl Coosemans
8932f7ce17 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
2023-02-07 11:13:33 +01:00
Stefan Eßer
b92f8e5c0d 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
2023-02-06 23:56:44 +01:00
Marius van Witzenburg
17720d0bd0 Strip trailing slashes from DESTDIR
Solves duplicate slashes in paths

Scanning //usr/share/certs/trusted for certificates...
Scanning //usr/local/share/certs for certificates...

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/595
2023-02-04 12:11:02 -07:00
Elvin Aslanov
cfd6acbb55 jail: Correct jail_max_af_ips sysctl name
The sysctl is named "security.jail.jail_max_af_ips" with the jail_
prefix in the final part.

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/605
2023-02-04 11:46:46 -07:00
Warner Losh
f051d72314 hyperv: Build and install where supported
Remove the hard-coded dependency on HYPERV being only x86. Instead, 100%
rely on MK_HYPERV. It's always right (since it's marked BROKEN (so set
to "no") on architectures we don't support).

Sponsored by:		Netflix
Reviewed by:		bz
Differential Revision:	https://reviews.freebsd.org/D38306
2023-02-01 10:21:57 -07:00
Xin LI
4bbf45cf56 etcupdate: Chase test case after pwd_mkdb(8) no longer copies comments.
MFC after:	3 days
2023-01-29 20:40:58 -08:00
John Baldwin
cf57f20edc bhyve: Fix a buffer overread in the PCI hda device model.
The sc->codecs array contains HDA_CODEC_MAX (15) entries.  The
guest-supplied cad field in the verb provided to hda_send_command is a
4-bit field that was used as an index into sc->codecs without any
bounds checking.  The highest value (15) would overflow the array.

Other uses of sc->codecs in the device model used sc->codecs_no to
determine which array indices have been initialized, so use a similar
check to reject requests for uninitialized or invalid cad indices in
hda_send_command.

PR:		264582
Reported by:	Robert Morris <rtm@lcs.mit.edu>
Reviewed by:	corvink, markj, emaste
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D38128
2023-01-20 09:58:38 -08:00
John Baldwin
bfe8e339eb bhyve: Fix a global buffer overread in the PCI hda device model.
hda_write did not validate the relative register offset before using
it as an index into the hda_set_reg_table array to lookup a function
pointer to execute after updating the register's value.

PR:		264435
Reported by:	Robert Morris <rtm@lcs.mit.edu>
Reviewed by:	corvink, markj, emaste
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D38127
2023-01-20 09:57:45 -08:00
John Baldwin
6a284cacb1 bhyve: Remove vmctx argument from PCI device model methods.
Most of these arguments were unused.  Device models which do need
access to the vmctx in one of these methods can obtain it from the
pi_vmctx member of the pci_devinst argument instead.

Reviewed by:	corvink, markj
Differential Revision:	https://reviews.freebsd.org/D38096
2023-01-19 10:30:18 -08:00
John Baldwin
b36b14beda bhyve: Avoid triggering false -Wfree-nonheap-object warnings.
XHCI port and slot numbers are 1-based rather than 0-based.  To handle
this, bhyve was subtracting one item from the pointers saved in the
softc so that index 1 accessed index 0 of the allocated array.

However, this is UB and confused GCC 12.  The compiler noticed that
the calls to free() were using an offset and emitted a warning.
Rather than storing UB pointers in the softc, push the decrement
operation into the existing macros that wrap accesses to the relevant
arrays.

Reviewed by:	corvink, markj
Differential Revision:	https://reviews.freebsd.org/D36829
2023-01-19 10:21:50 -08:00
Gordon Bergling
72e709040f nfs: Fix a common typo in source code comments
- s/ingore/ignore/

MFC after:	3 days
2023-01-19 14:26:06 +01:00
Gordon Bergling
afc55510b1 mountd(8): Fix a typo in a source code comment
- s/ingore/ignore/

MFC after:	3 days
2023-01-19 14:23:51 +01:00
Gordon Bergling
74d2a3c16d cxgbetool(8): Fix common typos in sysctl descriptions
- s/addres/address/

MFC after:	5 days
2023-01-19 14:22:00 +01:00
Gordon Bergling
7a184a41c6 bsnmpget.1: Fix a typo in the man page
- s/ingore/ignore/

MFC after:	3 days
2023-01-19 14:18:52 +01:00
Juraj Lutter
1d577bedba 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
MFC after:      1 month
X-MFC with:     1838dec318
2023-01-18 08:50:07 +01:00
Ceri Davies
d9499d3f47 bsdconfig: correct name of the wpa_supplicant config file
Approved by:	maintainer timeout (dteske)
Differential Revision:	https://reviews.freebsd.org/D37750
2023-01-16 18:56:45 +00:00
Danilo G. Baio
591e291179 bsdconfig, bsdinstall: Refresh mirrors list
The mirrors list is in sync with the Handbook / Mirrors section [1],
which was refreshed a few months ago. Mirrors removed were not
responding or had duplicated addresses (aliases) with another mirror.

1 - https://docs.freebsd.org/en/books/handbook/mirrors/

Reviewed by:	philip (clusteradm)
Approved by:	philip
MFC after:	1 week
Differential Revision: https://reviews.freebsd.org/D38014
2023-01-16 13:48:06 -03:00
Mark Johnston
5c2b216a1c mixer: Fix default_unit switching with mixers that have no devices
Apparently it's possible for a mixer to have no devices:

$ mixer -f /dev/mixer2
pcm2:mixer: <USB audio> at ? kld snd_uaudio (rec)
$

If this is the default sound device, an attempt to change the default
unit using mixer -d fails with a segfault because mod_dunit is called
with a NULL device pointer, which is dereferenced to get the parent
mixer.

ctl_dunit seems to be a dummy, i.e., we don't actually need it and can
simply pass the mixer to mod_dunit() directly.  This patch removes that
structure and associated indirection to fix the crash.

Reviewed by:	christos, hselasky
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D38060
2023-01-16 08:02:54 -05:00
Cy Schubert
06b93ef8cd 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
MFC after:	1 month
X-MFC with:	1838dec318
2023-01-14 23:06:40 -08:00
Cy Schubert
1838dec318 unbound: Vendor import 1.17.1
Release notes at
    https://www.nlnetlabs.nl/news/2023/Jan/12/unbound-1.17.1-released/.

MFC after:      1 month

Merge commit '7699e1386a16236002b26107ffd2dcbde375e197' into main
2023-01-14 21:39:31 -08:00
Brooks Davis
6e011d1503 makefs: don't needlessly require directories to exist
If a type=dir entry exists and all contents are directories, files
added with contents=, or symlinks with link= attributes then it doesn't
need to exist.  Just let openat fail in that case.  It's conceivable
this will make debugging some cases weird, but it's sufficent to handle
the way we add /root/.ssh in CheriBSD VM images.

This is a recommit of 794154149f with
bugfixes.

Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D38029
2023-01-12 19:16:14 +00:00
Brooks Davis
5e5baba880 Revert "makefs: don't needlessly require directories to exist"
I pushed prematurely and this version is broken.

This reverts commit 794154149f.
2023-01-12 18:21:27 +00:00
Brooks Davis
794154149f makefs: don't needlessly require directories to exist
If a type=dir entry exists and all contents are directories, files
added with contents=, or symlinks with link= attributes then it doesn't
need to exist.  Just let openat fail in that case.  It's conceivable
this will make debugging some cases weird, but it's sufficent to handle
the way we add /root/.ssh in CheriBSD VM images.

Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D38029
2023-01-12 18:19:14 +00:00
Brooks Davis
b78d5b4241 makefs: handle mtree link= for ZFS
When a link target is specified use it rather than attempting to read
a potentially non-existant file.

Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D38028
2023-01-12 18:18:45 +00:00
Brooks Davis
aac389a347 makefs: handle mtree contents= in zfs
When a source path is provided use it rather than constructing one.

Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D38027
2023-01-12 18:18:24 +00:00
Rick Macklem
24f42edcdd Revert "gssd: Fix handling of the gssname=<name> NFS mount option"
This reverts commit c33509d49a.

It turns out that the long 27 second delay I saw in the
gss_acquire_cred() call was caused by a (mis)configured
DNS.  Although I did not specify "dns" in /etc/nsswitch.conf,
I did have a /etc/resolv.conf file on the system (left
there by wpa_supplicant).  As such, with no route, it was
somehow trying to contact the DNS server, although there was none.

Once I got rid of the /etc/resolv.conf file, it worked
as expected.

Since there is now a large 5 minute timeout on the
kernel to gssd(8) upcalls, the gssd(8) daemon will not
get terminated when this delay occurs and the only affect
is a 30 second delay during the mount.

Discussed with:	bjk
2023-01-11 18:23:17 -08:00
Gordon Bergling
40bb52c89b iwmbtfw(8): Fix a typo in a kernel message
- s/succesful/successful/

MFC after:	5 days
2023-01-11 12:22:18 +01:00
Dag-Erling Smørgrav
394cf6719a tzcode: Move configuration into separate header.
MFC after:	1 week
Sponsored by:	Klara, Inc.
2023-01-11 11:39:12 +01:00
Dag-Erling Smørgrav
bc42155199 Bring our tzcode up to date.
* Replay 2010[acflm] which had been merged but not recorded.
* Merge 2010n.
* Reorganize (unsplit) the code to match the upstream layout.
* Merge 2022[cdefg].

MFC after:      1 week
Sponsored by:   Klara, Inc.
2023-01-10 16:14:27 +01:00
Rick Macklem
c33509d49a gssd: Fix handling of the gssname=<name> NFS mount option
If an NFS mount using "sec=krb5[ip],gssname=<name>" is
done, the gssd daemon fails.  There is a long delay
(several seconds) in the gss_acquire_cred() call and then
it returns success, but the credentials returned are
junk.

I have no idea how long this has been broken, due to some
change in the Heimdal gssapi library call, but I suspect
it has been quite some time.

Anyhow, it turns out that replacing the "desired_name"
argument with GSS_C_NO_NAME fixes the problem.
Replacing the argument should not be a problem, since the
TGT for the host based initiator credential in the default
keytab file should be the only TGT in the gssd'd credential
cache (which is not the one for uid 0).

I will try and determine if FreeBSD13 and/or FreeBSD12
needs this same fix and will MFC if they need the fix.

This problem only affected Kerberized NFS mounts when the
"gssname" mount option was used.  Other Kerberized NFS
mount cases already used GSS_C_NO_NAME and work ok.
A workaround if you do not have this patch is to do a
"kinit -k host/FQDN" as root on the machine, followed by
the Kerberized NFS mount without the "gssname" mount
option.

MFC after:	1 month
2023-01-07 13:49:25 -08:00
Andre Albsmeier
0deb25bd9d 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
MFC after:	1 month
2023-01-04 22:18:09 -08:00
David E. O'Brien
f3c043bb5f newsyslog.conf: Minor formatting fix 2022-12-28 16:26:51 -08:00
David E. O'Brien
bb6266f279 newsyslog.conf: Sort paths 2022-12-28 16:23:41 -08:00
Mateusz Guzik
65308195e8 bsdinstall: s/to small/too small/
Reported by:	Sulev-Madis Silber <ketas@si.pri.ee>
2022-12-22 17:57:08 +00:00
Rick Macklem
ab3c59a107 rpc.tlsservd: Check for a tls syscall failure.
Although the tls syscall to set up the upcall should
not normally fail, the daemon should check for such
a failure.  This patch adds a check for that failure.

MFC after:	1 week
2022-12-22 09:10:27 -08:00
Rick Macklem
3fe0cb6695 rpc.tlsclntd: Check for a tls syscall failure.
Although the tls syscall to set up the upcall should
not normally fail, the daemon should check for such
a failure.  This patch adds a check for that failure.

MFC after:	1 week
2022-12-21 15:12:06 -08:00
John Baldwin
e53fcff184 bhyve: Simplify spinup_ap_realmode slightly.
There is no reason to modify the passed in rip variable.

Reviewed by:	corvink, markj
Differential Revision:	https://reviews.freebsd.org/D37647
2022-12-21 10:33:34 -08:00
John Baldwin
7224a96a55 bhyve: Tidy vCPU pthread startup.
Set the thread affinity in fbsdrun_start_thread next to where the
thread name is set.  This keeps all the pthread initialization
operations at the start of a thread in one place.

Reviewed by:	corvink, markj
Differential Revision:	https://reviews.freebsd.org/D37646
2022-12-21 10:33:18 -08:00
John Baldwin
8487443792 bhyve: Don't access vcpumap[vcpu] directly in parse_cpuset().
Reviewed by:	corvink, markj
Differential Revision:	https://reviews.freebsd.org/D37645
2022-12-21 10:33:04 -08:00
John Baldwin
a20c00c60e bhyve: Allocate struct vm_exit on the stack in vm_loop.
The global vmexit[] array is no longer needed to smuggle the rip
value from fbsdrun_addcpu() to vm_loop().

Reviewed by:	corvink, markj
Differential Revision:	https://reviews.freebsd.org/D37644
2022-12-21 10:32:45 -08:00
John Baldwin
ceb0d0b0f1 bhyve: Remove some no-op code for setting RIP.
fbsdrun_addcpu() read the current vCPU's RIP register from the kernel
via vm_get_register() to pass along through some layers to vm_loop()
which then set the register via vm_set_register().  However, this is
just always setting the value back to itself.

Reviewed by:	corvink
Differential Revision:	https://reviews.freebsd.org/D37643
2022-12-21 10:32:24 -08:00
John Baldwin
461663ddba bhyve: Simplify setting vCPU capabilities.
- Enable VM_CAP_IPI_EXIT in fbsdrun_set_capabilities along with other
  capabilities enabled on all vCPUs.

- Don't call fbsdrun_set_capabilities a second time on the BSP in
  spinup_vcpu.

- To preserve previous behavior, don't unconditionally enable
  unrestricted guest mode on the BSP (this unbreaks single-vCPU guests
  on Nehalem systems, though supporting such setups is of dubious
  value).  Other places that enbale UG on the BSP are careful to check
  the result of the operation and fail if it is not available.

- Don't set any capabilities in spinup_ap().  These are now all
  redundant with earlier settings from spinup_vcpu().

- While here, axe a stale comment from fbsdrun_addcpu().  This
  function is now always called from the main thread for all vCPUs.

Reviewed by:	corvink, markj
Differential Revision:	https://reviews.freebsd.org/D37642
2022-12-21 10:31:16 -08:00
John Baldwin
e7d5d2d187 bhyve: Remove unused return value from spinup_ap.
Reviewed by:	corvink, markj
Differential Revision:	https://reviews.freebsd.org/D37641
2022-12-21 10:31:02 -08:00
John Baldwin
007d9ca5dd bhyve: Remove handler for VM_EXITCODE_SPINUP_AP.
Since commit 0bda8d3e9f, bhyve always enables VM_EXITCODE_IPI exits
instead, so this handler is no longer used.

Reviewed by:	corvink, markj
Differential Revision:	https://reviews.freebsd.org/D37640
2022-12-21 10:30:45 -08:00
Rick Macklem
d4b4f3b9c3 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.

Reviewed by:	jamie, bcr (manpages)
MFC after:	4 months
Differential Revision:	https://reviews.freebsd.org/D37665
2022-12-17 13:54:33 -08:00
Mark Johnston
a9e7a44c24 makefs: Add some validation of ZFS pool names
Reported by:	imp
2022-12-16 10:30:58 -05:00
Mike Karels
38d2b4db78 daily 440.status-mailq: avoid error from dma with submit queue
dma(8) supports mailq, but not mailq -Ac to print the submission
queue.  Don't try to print that queue from the daily script if
mailq -Ac returns an error.

Reviewed by:	bapt
Differential Revision:	https://reviews.freebsd.org/D37713
2022-12-16 09:13:31 -06:00
Mike Karels
c934f2a574 daily 150.clean-hoststat: suppress error when using dma
dma(8) does not have hoststat or purgestat, so this script produces
an error from the daily script.  We could disable this script, but
that would mean yet another change to switch back to sendmail.  Check
for purgestat in mailer.conf before attempting either hoststat or
purgestat.

Reviewed by:	pstef, bapt
Differential Revision:	https://reviews.freebsd.org/D37712
2022-12-16 09:13:07 -06:00
Jamie Gritton
e8d7ae918a jail: fix a NULL pointer derefence in parsing ip6.addr settings.
This is the counterpart to bd24e861b4, which did the same for ip4.
PR:		268377
Reported by:	ahkithaama at proton.me
2022-12-14 16:47:55 -08:00
John Baldwin
08b05de1e2 bhyve: Remove the unused vcpu argument from all of the I/O port handlers.
Reviewed by:	corvink, markj
Differential Revision:	https://reviews.freebsd.org/D37653
2022-12-09 10:35:44 -08:00
John Baldwin
78c2cd83ec bhyve: Remove unused vcpu argument from PCI read/write methods.
Reviewed by:	corvink, markj
Differential Revision:	https://reviews.freebsd.org/D37652
2022-12-09 10:35:28 -08:00
John Baldwin
0857e5555d bhyve: Pass a vCPU ID of 0 to vm_setup_pptdev_msi*.
These ioctls are not vCPU-specific and the ioctl now ignores the vCPU
ID.  0 is used instead of -1 to provide limited forwards
compatibility.

Reviewed by:	corvink, markj
Differential Revision:	https://reviews.freebsd.org/D37651
2022-12-09 10:31:17 -08:00
John Baldwin
34781da505 bhyve: Remove unused argument from pci_nvme_handle_doorbell.
Reviewed by:	corvink, chuck, markj
Differential Revision:	https://reviews.freebsd.org/D37650
2022-12-09 10:27:36 -08:00
Doug Rabson
5eeb4f737f imgact_binmisc: Optionally pre-open the interpreter vnode
This allows the use of chroot and/or jail environments which depend on
interpreters registed with imgact_binmisc to use emulator binaries from
the host to emulate programs inside the chroot.

Reviewed by:	imp
MFC after:	2 weeks
Differential Revision: https://reviews.freebsd.org/D37432
2022-12-08 14:32:03 +00:00
Michael Tuexen
cef3c4e0ba ppp: improve MSS clamping
ppp supports MSS clamping for TCP/IPv4. This patch
* improves MSS clamping for TCP/IPv4 by using the MSS as specified
  in RFC 6691.
* adds support for MSS clamping for TCP/IPv6.

Reported by:		Timo Voelker
Reviewed by:		thj
MFC after:		1 week
Differential Revision:	https://reviews.freebsd.org/D37624
2022-12-08 09:48:29 +01:00
Corvin Köhne
b972e7cbb4
bhyve: build SPCR ACPI table
OVMF ships some static ACPI tables. This worked in the past but won't
work in the future when we support devices like tpms. They require a TPM
ACPI table. So, we have to dynamically create ACPI tables depending on
the bhyve configuration.

Bhyve has much more information about the system than OVMF. Therefore,
it's easier for bhyve to build up some ACPI tables. For that reason, it
would be much better to use the ACPI tables provided by bhyve instead of
building some tables by OVMF.

At the moment, OVMF always creates a SPCR table. Maybe someone depends
on it. So, we have to build it by bhyve too before we can patch OVMF to
install the tables provided by bhyve.

Reviewed by:		markj
MFC after:		1 week
Sponsored by:		Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D37591
2022-12-06 12:58:27 +01:00
Robert Wing
5a023bd2a5 bhyveload: open guest boot disk image O_RDWR
When a boot environment has been booted via the bootonce feature,
userboot clears the bootonce value from an nvlist but fails to write the
updated nvlist back to disk.

The failure occurs because bhyveload opens the guest boot disk image
O_RDONLY, fix this by opening it O_RDWR.

Reviewed by:	imp, markj, jhb
Differential Revision:	https://reviews.freebsd.org/D37274
2022-12-05 08:22:45 -09:00
John Baldwin
aa9ce62be5 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
2022-12-04 16:30:20 -08:00
John Baldwin
f4432625ed 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
2022-12-04 16:28:59 -08:00
John Baldwin
1055bedbed 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
2022-12-04 16:28:22 -08:00
Alexander Motin
7467a69536 CTL: Allow userland supply tags via ioctl frontend.
Before this ioctl frontend always replaced tags with sequential ones.
It was done for ctladm, that can not keep track of global tag list.
But in case of virtio-scsi in bhyve we can pass provided tags as-is.
It should be on virtio-scsi initiator to provide us valid tags.  It
should allow proper task management, error reporting, etc.  In case
of several virtio-scsi devices, they should use different CTL ports
or initiator IDs to avoid conflicts, but this is expected by design.

PR:	267539
2022-12-03 12:05:05 -05:00
Alexander Motin
fcdcfa2189 Missed chunk of 0acc026dda. 2022-12-03 11:26:22 -05:00
Alexander Motin
0acc026dda CTL: Increase maximum SCSI tag size from 32 to 64 bits.
SAM-5 specification states maximum size of command identifier (tag),
defined by specific transports, should not be larger than 64 bits.
While most of supported transports use 32 bits or less, it was
reported that virtio-scsi uses 64 bits.  Truncation to 32 bits in
bhyve code caused false tag conflict errors reported and possibly
other issues.

This changes CTL ABI and HA protocol, so CTL_HA_VERSION is bumped.

While we make HA protocol incompatible, increase default maximum
number of ports in CTL from 256 to 1024, matching number of LUNs.
There are many reports from people who need many iSCSI targets with
only one LUN each.  Increased memory consumption should be less of
a problem these days.

PR:	267539
2022-12-03 10:23:29 -05:00
Alexander Motin
b81ac5cdc3 bhyve virtio-scsi: Fix residual reporting.
CTL does not really use residual field and it always returned zero.
Use ext_data_filled instead.

MFC after:	2 weeks
2022-12-03 10:08:20 -05:00
Gleb Smirnoff
657729a89d Retire trpt(8).
trpt(8) was utility to pull TCP debugging data from the kernel
originating back from 4.2BSD.  It is not used nowadays by TCP
developers.  We have more powerful debugging facilities, e.g.
the Dtrace probing, the TCP black box logging and siftr.

Discussed with: rscheff, tuexen, rrs, jtl and others
2022-12-02 14:10:55 -08:00
Jessica Clarke
bad602850e bsdinstall: Fix local_unbound option default on revisit
The variable used for the checklist's default value needs to correspond
to the rc.conf variable as that's what's being parsed to determine them.
In the case of local_unbound it's missing the _enable suffix and thus
always defaults to off on revisit.

Fixes:	58eb9abb31 ("Add a line to the post-installation configuration dialog to enable the local_unbound service.")
2022-11-29 03:33:47 +00:00
Jessica Clarke
91985bc5ad bsdinstall: Fix issues parsing rc.conf.services on revisit
There are a few issues here, some of which are hiding others. The first
is that we don't use double quotes around the command substitution so
every word in the conf file is treated as a separate argument to eval,
resulting in spaces being used in place of newlines and thus comments in
the file commenting out the rest of the file, not just to the end of
their line. In particular, we insert one comment just before the dumpdev
entry (the final one in the file) and so we never see dumpdev as set,
and thus set a default value of on for the menu.

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

The final issue is that our case-insensitive YES/NO (and now AUTO)
replacements have no word boundaries around them so match the middle of
words too. As it happens this doesn't matter in practice at the moment,
but it could in future; currently the only effect is that it rewrites
moused_nondefault_enable to moused_offndefault_enable, but since this
variable is never read, only written based on moused(_enable) this is
harmless, but we should fix it in case a service comes along in future
that does get affected by it.
2022-11-29 03:33:47 +00:00
Jessica Clarke
1843da3edb bsdinstall: Fix ntpd_sync_on_start service option
This installer option is currently totally useless, as it ends up
creating an ntpd_sync_on_start_enable="YES" entry in rc.conf, not an
ntpd_sync_on_start="YES" entry, as is the correct name. This can also be
noticed by revisiting the services menu, which parses the previously
written rc.conf.services file to set variables governing the default
menu entry values so that selecting OK regenerates the same file, as the
menu entry will use the correct variable name and thus think the entry
was not selected last time, defaulting back to off and losing the
setting.

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

Fixes:	c153a35bfd ("bsdinstall: replace ntpdate by ntpd_sync_on_start")
2022-11-29 03:33:47 +00:00
John Baldwin
bc92880072 bhyve: Avoid passing a possible garbage pointer to free().
All of the error paths in pci_vtcon_sock_add free the sock pointer.
However, sock is not initialized until part way through the function.
An early error would pass stack garbage to free().

Reviewed by:	corvink, markj
Differential Revision:	https://reviews.freebsd.org/D37491
2022-11-28 17:10:30 -08:00
John Baldwin
32b21dd271 bhyve: Appease warning about a potentially unaligned pointer.
When initializing the device model for a PCI pass through device that
uses MSI-X, bhyve reads the MSI-X capability from the real device to
save a copy in the emulated PCI config space.  It also saves a copy in
a local struct msixcap on the stack.  Since struct msixcap is packed,
GCC complains that casting a pointer to the struct to a uint32_t
pointer may result in an unaligned pointer.

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

Reviewed by:	corvink, bz, markj
Differential Revision:	https://reviews.freebsd.org/D37490
2022-11-28 17:10:07 -08:00
John Baldwin
15cebe3d63 bhyve: Fix sign compare warnings in the NVMe device model.
Reviewed by:	corvink
Differential Revision:	https://reviews.freebsd.org/D37489
2022-11-28 17:09:44 -08:00
John Baldwin
5d805962ca bhyve: Avoid unlikely truncation of the blockif ident strings.
The ident string for NVMe and VirtIO block deivces do not contain the
bus, and the various fields can potentially use up to three characters
when printed as unsigned values (full range of uint8_t) even if not
likely in practice.

Reviewed by:	corvink, chuck
Differential Revision:	https://reviews.freebsd.org/D37488
2022-11-28 17:09:15 -08:00
John Baldwin
47d6116239 bhyve: Clear lid to 0 for internal device errors for NVMe AENs.
Reported by:	GCC
Reviewed by:	corvink, chuck, imp, markj
Differential Revision:	https://reviews.freebsd.org/D37487
2022-11-28 17:08:57 -08:00
John Baldwin
1d9e8a9e60 bhyve: Don't leak uninitialized bits in NVMe completion statuses.
In some cases, some bits in the 16-bit status word were never
initialized.

Reported by:	GCC
Reviewed by:	corvink, chuck, markj
Differential Revision:	https://reviews.freebsd.org/D37486
2022-11-28 17:08:36 -08:00
John Baldwin
e7cd5ffff8 bhyve: Fix sign compare warnings in the e1000 device model.
Adding a bare constant to a uint16_t promotes to a signed int which
triggers these warnings.  Changing the constant to be explicitly
unsigned instead promotes the expression to unsigned int.

Reviewed by:	corvink, markj
Differential Revision:	https://reviews.freebsd.org/D37485
2022-11-28 17:08:09 -08:00
John Baldwin
0acf696151 bhyve basl: Use GCC pragmas.
These work with both clang and GCC.

Reviewed by:	corvink, markj
Differential Revision:	https://reviews.freebsd.org/D37484
2022-11-28 17:07:39 -08:00
Eugene Grosbein
1cbe5012cf pw(8): fix combination of modes -N and -w random
The command "pw usermod nobody -Nw random" (or useradd)
generates random password and prints it in encrypted form
but skips choosen random string that makes not much sense
and contradicts the manual page pw.8

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

MFC after:	2 weeks
2022-11-28 21:22:39 +07:00
John Baldwin
abb9a940bb makefs: Ignore some sign comparison warnings from GCC.
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D37470
2022-11-23 10:38:29 -08:00
John Baldwin
82ac811efa makefs zfs: Disable -Wunused-function for GCC as well.
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D37469
2022-11-23 10:35:30 -08:00
John Baldwin
9821e24441 makefs zfs: Use signed values for both results of ?:.
Reported by:	GCC -Wsign-compare
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D37468
2022-11-23 10:35:14 -08:00
Corvin Köhne
67654ffd44
bhyve: use dynamic ACPI table offsets
Now that all ACPI tables are build by basl, basl can dynamically
calculate the offset for each table.

Reviewed by:		jhb, markj (older version)
Approved by:		manu (mentor)
MFC after:		2 weeks
Sponsored by:		Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D37002
2022-11-21 09:28:01 +01:00
Corvin Köhne
03e7111fa6
bhyve: build RSDP table by basl
Building the RSDP table by basl will allow it to be loaded by qemu's
ACPI table loader in the future.

Reviewed by:		jhb, markj (older version)
Approved by:		manu (mentor)
MFC after:		2 weeks
Sponsored by:		Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D37001
2022-11-21 09:28:00 +01:00
Corvin Köhne
f3dcdf8be4
bhyve: build RSDT table by basl
Building the RSDT table by basl will allow it to be loaded by qemu's
ACPI table loader in the future.

Reviewed by:		jhb, markj (older version)
Approved by:		manu (mentor)
MFC after:		2 weeks
Sponsored by:		Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D37000
2022-11-21 09:27:59 +01:00
Corvin Köhne
4a60470f05
bhyve: build XSDT table by basl
Building the XSDT table by basl will allow it to be loaded by qemu's
ACPI table loader in the future.

Reviewed by:		jhb, markj (older version)
Approved by:		manu (mentor)
MFC after:		2 weeks
Sponsored by:		Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D36999
2022-11-21 09:27:58 +01:00
Corvin Köhne
6a75de903b
bhyve: build FADT table by basl
Building the FADT table by basl will allow it to be loaded by qemu's
ACPI table loader in the future.

Reviewed by:		jhb, markj (older version)
Approved by:		manu (mentor)
MFC after:		2 weeks
Sponsored by:		Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D36998
2022-11-21 09:27:57 +01:00
Corvin Köhne
897fe59adf
bhyve: build MADT table by basl
Building the MADT table by basl will allow it to be loaded by qemu's
ACPI table loader in the future.

Reviewed by:		jhb, markj (older version)
Approved by:		manu (mentor)
MFC after:		2 weeks
Sponsored by:		Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D36997
2022-11-21 09:27:56 +01:00
Corvin Köhne
d61d712299
bhyve: build HPET table by basl
Building the HPET table by basl will allow it to be loaded by qemu's
ACPI table loader in the future.

Reviewed by:		jhb, markj (older version)
Approved by:		manu (mentor)
MFC after:		2 weeks
Sponsored by:		Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D36996
2022-11-21 09:27:55 +01:00
Corvin Köhne
60277ad75e
bhyve: add helper to fill a ACPI_GENERIC_ADDRESS
Reviewed by:		jhb
Approved by:		manu (mentor)
MFC after:		2 weeks
Sponsored by:		Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D37407
2022-11-21 09:27:54 +01:00
Corvin Köhne
2c2bd15532
bhyve: build MCFG table by basl
Building the MCFG table by basl will allow it to be loaded by qemu's
ACPI table loader in the future.

Reviewed by:		jhb, markj (older version)
Approved by:		manu (mentor)
MFC after:		2 weeks
Sponsored by:		Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D36995
2022-11-21 09:27:53 +01:00
Corvin Köhne
8897b562ab
bhyve: add helper to append a basl table without a header
The common style for build an ACPI table will be:

1. basl_table_create
2. basl_table_append_header
3. setup an ACPI_TABLE_* struct
4. basl_table_append_bytes (without header)

Add a helper for the last step.

Reviewed by:		jhb, markj
Approved by:		manu (mentor)
MFC after:		2 weeks
Sponsored by:		Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D37406
2022-11-21 09:27:51 +01:00
Corvin Köhne
7263419f38
bhyve: make basl_table_add_* functions public
The code will be more readable if we use struct definitions from ACPI-CA
to build ACPI tables. We can fill out the struct and append it to the
basl_table by using basl_table_append_bytes. After that, we have to
declare which checksums, length and pointers should be patched by basl.
That's done by the add_* functions.

Reviewed by:		jhb, markj
Approved by:		manu (mentor)
MFC after:		2 weeks
Sponsored by:		Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D37405
2022-11-21 09:27:50 +01:00
Corvin Köhne
bdbb1da75a
bhyve: build FACS table by basl
Building the FACS table by basl will allow it to be loaded by qemu's
ACPI table loader in the future.

Reviewed by:		jhb, markj (older version)
Approved by:		manu (mentor)
MFC after:		2 weeks
Sponsored by:		Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D36994
2022-11-21 09:27:48 +01:00
Mark Johnston
71ebd11738 bhyve: Enable the default compiler warnings
Disable -Wcast-align for now since we have many instances of that
warning (I fixed some but not most of them) and platforms on which bhyve
runs don't particularly care about unaligned accesses.

Reviewed by:	corvink
Differential Revision:	https://reviews.freebsd.org/D37296
2022-11-18 14:12:51 -05:00
Mark Johnston
0705b7f4e6 bhyve: Avoid using a packed struct for xhci port registers
I believe the __packed annotation is there only because
pci_xhci_portregs_read() is treating the register set as an array of
uint32_t.  clang warns about taking the address of portregs->portsc
because it is a packed member and thus might not have expected
alignment.

Fix the problem by simply selecting the field to read with a switch
statement.  This mimics pci_xhci_portregs_write().  While here, switch
to using some symbolic constants.

There is a small semantic change here in that pci_xhci_portregs_read()
would silently truncate unaligned offsets.  For consistency with
pci_xhci_portregs_write(), which does not do that, return all ones for
unaligned reads instead.

MFC after:	2 weeks
Reviewed by:	corvink, jhb
Differential Revision:	https://reviews.freebsd.org/D37408
2022-11-18 14:11:48 -05:00
Mark Johnston
c127c61efa bhyve: Let BASL compile with raised warnings
- Make basl_dump() as unused.
- Avoid arithmetic on a void pointer.
- Avoid a signed/unsigned comparison with
  BASL_TABLE_CHECKSUM_LEN_FULL_TABLE.
- Ignore warnings about unused parameters from stuff pulled in by
  acpi.h.  In particular, any prototype wrapped by
  ACPI_DBG_DEPENDENT_RETURN_VOID() will raise such parameters unless
  ACPI_DEBUG_OUTPUT is defined.

Reviewed by:	corvink, jhb
Differential Revision:	https://reviews.freebsd.org/D37397
2022-11-18 14:11:48 -05:00
Mark Johnston
bd634fc733 bhyve: Address an unused parameter warning in the smbios code
The compiler was warning that the "size" parameter to
smbios_generic_initializer() was unused.  This parameter is apparently
used to populate the "maximum structure size" field in the SMBIOS entry
point, but we were always setting it to zero.

Implement it instead in the main loop of the smbios table builder.

MFC after:	2 weeks
Reviewed by:	corvink, jhb
Differential Revision:	https://reviews.freebsd.org/D37294
2022-11-18 14:11:48 -05:00
Mark Johnston
1a8e52391b bhyve: Disable thread safety analysis
The warnings that arise are bogus and have to be muted with
__no_lock_analysis in most cases.  As a step towards enabling the
default warning level for bhyve, just disable them.

Reviewed by:	corvink, jhb
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D37295
2022-11-18 14:11:48 -05:00
John Baldwin
2b4fe856f4 bhyve: Remove unused vm and vcpu arguments from vm_copy routines.
The arguments identifying the VM and vCPU are only needed for
vm_copy_setup.

Reviewed by:	corvink, markj
Differential Revision:	https://reviews.freebsd.org/D37158
2022-11-18 10:25:36 -08:00
Corvin Köhne
b922cf4fe3
bhyve: build DSDT table by basl
Building the DSDT table by basl will allow it to be loaded by qemu's
ACPI table loader.

Building the DSDT is complex and basl doesn't support it yet. For that
reason, it's still compiled by iasl. It's just a bit restructured.
Upcoming commits will restructure the builds of all other ACPI tables in
a similar way. So, this commit is done for consistency reasons. We're
starting with DSDT because it doesn't point to any other tables and it's
the last one in our current build list.

Reviewed by:		jhb, markj (older version)
Approved by:		manu (mentor)
MFC after:		2 weeks
Sponsored by:		Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D36993
2022-11-16 12:43:41 +01:00
Corvin Köhne
2fb0f352b9
bhyve: add basl support for common table header
Most ACPI tables are using the same header. Make it easy to create this
header by creating a function for it.

Reviewed by:		jhb, markj (older version)
Approved by:		manu (mentor)
MFC after:		2 weeks
Sponsored by:		Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D36992
2022-11-16 12:42:19 +01:00
John Baldwin
fd104a6ebc bhyve: Use XHCI_PORTREG_PTR in one place that open-coded it.
Reviewed by:	corvink, markj
Differential Revision:	https://reviews.freebsd.org/D36888
2022-11-15 19:19:35 -08:00
Rick Macklem
e471259313 rpc.tlsservd.8: Update man page for new -N/--numdaemons option
Commit 1e588a9ceb added a new command line option -N/numdaemons
that specifies how many daemons to run. This allows a server
to be configured with more than one rpc.tlsservd daemon, which
may be necessary to handle a reboot for an NFS server with
many NFS-over-TLS client mounts.

This patch updates the man page for this commit.

This is a content change.

Reviewed by:	karels, pauamma (man pages)
Differential Revision:	https://reviews.freebsd.org/D37382
2022-11-15 13:30:41 -08:00
Corvin Köhne
49b947c01d
bhyve: add basl support for pointers
Some ACPI tables like XSDT contain pointers to other ACPI tables. When
an ACPI table is loaded by qemu's loader, the address in the guest
memory is unknown. For that reason, the qemu loader supports patching
those pointers. Basl keeps track of all pointers and causes the qemu
loader to patch all pointers.

The qemu ACPI table loader is unsupport yet. However, in a future commit
bhyve will use dynamic ACPI table offsets based on the size and
alignment requirements of each ACPI table. Therefore, tracking ACPI
table pointer is required too.

Reviewed by:		jhb
Approved by:		manu (mentor)
MFC after:		2 weeks
Sponsored by:		Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D36991
2022-11-15 08:27:11 +01:00
Corvin Köhne
2957847031
bhyve: add basl support for checksums
The qemu ACPI table loader patches the ACPI tables. After patching them,
checksums aren't correct any more. It has to calculate a new checksum
for the ACPI table. For that reason, basl has to keep track of checksums
and has to cause the qemu loader to create new checksums for the tables.

The qemu ACPI table loader isn't supported yet. However, the address of
all tables is unknown as long as bhyve hasn't finished ACPI table
creation. So, the checksum of tables which include pointer to other
tables are unknown too. This requires tracking of checksums too.

Reviewed by:		jhb
Approved by:		manu (mentor)
MFC after:		2 weeks
Sponsored by:		Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D36990
2022-11-15 08:27:10 +01:00
Corvin Köhne
3a766cd0f1
bhyve: add basl support for length fields
ACPI tables have different layouts. So, there's no common position for
the length field. When tables are build by basl, the length is unknown
at the beginning. It has to be set after building the table.

Reviewed by:		jhb
Approved by:		manu (mentor)
MFC after:		2 weeks
Sponsored by:		Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D36989
2022-11-15 08:27:09 +01:00
Corvin Köhne
995374a655
bhyve: add basl support for generic addresses
In upcoming commits, bhyve will build some ACPI tables by it's own.
Therefore, it should be capable of appending GENERIC_ADDRESS structs to
ACPI tables.

Reviewed by:		jhb, markj
Approved by:		manu (mentor)
MFC after:		2 weeks
Sponsored by:		Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D36988
2022-11-15 08:27:08 +01:00
Corvin Köhne
e22f5ce2bf
bhyve: add basl support for int values
In upcoming commits, bhyve will build some ACPI tables by it's own.
Therefore, it should be capable of appending int values to ACPI tables.

Reviewed by:		jhb, markj (older version)
Approved by:		manu (mentor)
MFC after:		2 weeks
Sponsored by:		Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D36987
2022-11-15 08:27:07 +01:00
Corvin Köhne
22a2e94f38
bhyve: use basl to load ACPI tables
Load the blobs compiled by iasl into a basl_table. The basl_table is a
temporary buffer which copies the ACPI tables into guest memory for us.
This allows us in the future to pass the blobs over the qemu fwcfg
interface to the guest.

Reviewed by:		jhb, markj
Approved by:		manu (mentor)
MFC after:		2 weeks
Sponsored by:		Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D36986
2022-11-15 08:27:06 +01:00
Corvin Köhne
ac3c2b3e38
bhyve: add table dump functions for basl
Developing an ACPI table compiler isn't quite easy. It's helpful if you
can take a look at the ACPI tables created by the compiler.

The dump functions can either dump a ACPI table which was copied into
guest memory or a ACPI table provided for qemu's ACPI table loader.

Reviewed by:		jhb, markj
Approved by:		manu (mentor)
MFC after:		2 weeks
Sponsored by:		Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D36985
2022-11-15 08:27:04 +01:00
Corvin Köhne
21bbc28426
bhyve: add basic basl implementation
Basl is the bhyve ASL compiler. At the moment, it's just a small wrapper
to call iasl, the Intel ASL compiler. As bhyve will gain support for
qemu's ACPI table loader in the future, it has to create ACPI tables on
it's own. Therefore, it makes sense to create a new file which keeps the
code for basl.

This first implementation of basl supports creating an ACPI table by
appending raw bytes to it. It's also capable of loading all tables into
guest memory.

Reviewed by:		jhb, markj (older version)
Approved by:		manu (mentor)
MFC after:		2 weeks
Sponsored by:		Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D36984
2022-11-15 08:27:01 +01:00
Corvin Köhne
eff8d03477
bhyve/kdblayout: add some missing keys to german layout
The '/' and '§' keys are missing in the german keyboard layout.

Reviewed by:		markj
Approved by:		manu (mentor)
MFC after:		1 week
Sponsored by:		Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D37386
2022-11-15 07:48:27 +01:00
Wanpeng Qian
10846c53c4
bhyve: nvme controller obey async event setting when reporting critical temperature
Async event report is controlled by async event configuration feature
setting. When reporting a critical temperature warning, check the async
event configuration.

Approved by:		manu (mentor)
MFC after:		1 week
Differential Revision:	https://reviews.freebsd.org/D37355
2022-11-15 07:48:26 +01:00
Wanpeng Qian
05a21658eb
bhyve: return FEATURE_NOT_CHANGEABLE for unimplemented feature of NVMe controller
Set Feature is a feature specified function. Currently only some
features have the set procedure. For features that are not handled by
the controller, we should return a FEATURE_NOT_CHANGEABLE error message.

Approved by:		manu (mentor)
MFC after:		1 week
Differential Revision:	https://reviews.freebsd.org/D32802
2022-11-15 07:48:25 +01:00
Wanpeng Qian
8ab99dbea1
bhyve: abort and return FEATURE_NOT_SAVEABLE while set feature with a save flag for NVMe controller.
Currently bhyve's NVMe controller cannot save feature values cross
reboot. It should return a FEATURE_NOT_SAVEABLE error when the command
specifies a save flag.

Quote from NVMe specification, page 205:

https://nvmexpress.org/wp-content/uploads/NVM-Express-1_4-2019.06.10-Ratified.pdf

If the Feature Identifier specified in the Set Features command is not
saveable by the controller and the controller receives a Set Features
command with the Save bit set to one, then the command shall be aborted
with a status of Feature Identifier Not Saveable.

Reviewed by:		chuck (older version)
Approved by:		manu (mentor)
MFC after:		1 week
Differential Revision:	https://reviews.freebsd.org/D32767
2022-11-15 07:48:24 +01:00
Mark Johnston
c4c368fb3e bhyve: Simplify control flow in the xhci device model
We only need to call pci_xhci_xfer_complete() when handling a transfer
to the control endpoint, so move that code into the epid == 1 block and
eliminate a goto.  Also remove an unneeded reinitialization of
setup_trb.

No functional change intended.

MFC after:	1 week
Reviewed by:	corvink, jhb
Differential Revision:	https://reviews.freebsd.org/D37287
2022-11-14 15:08:45 -05:00
Mark Johnston
84b0b7ea4c bhyve: Fix a typo in a comment
Reported by:	Mikaël Urankar <mikael.urankar@mailo.fr>
Fixes:	719e307f80 ("bhyve: Cast away const when fetching a config nvlist")
2022-11-14 09:01:00 -05:00
Gordon Bergling
30a6c8a3a8 vipw.8: Add a FILES section
Mention passwd related files in the FILES section
of vipw(8).

Obtained from:	OpenBSD
MFC after:	3 days
2022-11-12 12:56:29 +01:00
Mark Johnston
719e307f80 bhyve: Cast away const when fetching a config nvlist
Silence a warning from the compiler about "const" being discarded.  The
warning is correct: nvlist values are supposed to be immutable.
However, fixing this properly will require some contortions on behalf of
consumers who look up a subtree of the config and modify it.  Per a
discussion on freebsd-virtualization@, the solution will probably be to
outright replace the use of nvlists for VM configuration, but until that
happens let's document the problem and silence the warning.

No functional change intended.

MFC after:	2 weeks
Reviewed by:	corvink, jhb
Differential Revision:	https://reviews.freebsd.org/D37293
2022-11-11 10:02:42 -05:00
Mark Johnston
8b1adff8bc bhyve: Drop volatile qualifiers from snapshot code
They accomplish nothing since the qualifier is casted away in calls to
memcpy() and copyin()/copyout().  No functional change intended.

MFC after:	2 weeks
Reviewed by:	corvink, jhb
Differential Revision:	https://reviews.freebsd.org/D37292
2022-11-11 10:02:26 -05:00
Mark Johnston
593200c23b bhyve: Drop volatile qualifiers from virtio rings
The qualifiers are there presumably because these rings are mapped into
the guest, but they do not appear to be required for correctness, and
bhyve generally doesn't qualify accesses to guest memory this way.
Moreover, the qualifiers are discarded by snapshot code, causing clang
to emit warnings.  Just stop using volatile here.

MFC after:	2 weeks
Reviewed by:	corvink, jhb
Differential Revision:	https://reviews.freebsd.org/D37291
2022-11-11 10:02:10 -05:00
Mark Johnston
691e23e6c5 bhyve: Drop volatile qualifiers from xhci hw struct fields
This fixes a warning raised by the removal of the volatile qualifier
from &trb->qwTrb0 in the following snippet:

	xfer_block = usb_data_xfer_append(xfer,
	     (void *)(trbflags & XHCI_TRB_3_IDT_BIT ?
		 &trb->qwTrb0 : XHCI_GADDR(sc, trb->qwTrb0)),
	     trb->dwTrb2 & 0x1FFFF, (void *)addr, ccs);

The use of volatile appears to be inherited from the kernel driver's
definitions of the same structures.  It makes some sense, since USB TRBs
and related structures live in guest memory, but bhyve device models
generally don't volatile-qualify accesses to guest memory and I can't
see how they are required for correctness here.  Moreover, XHCI_GADDR
does not return volatile pointers so we're already being inconsistent.
Just drop the qualifiers to address the warning.

MFC after:	2 weeks
Reviewed by:	corvink, jhb
Differential Revision:	https://reviews.freebsd.org/D37290
2022-11-11 10:01:52 -05:00
Mark Johnston
0ced97acb0 bhyve: Define an accessor for net backend private data
Use it to silence warnings about potential unaligned accesses.  No
functional change intended.

MFC after:	1 week
Reviewed by:	corvink, jhb
Differential Revision:	https://reviews.freebsd.org/D37289
2022-11-11 10:01:40 -05:00
Mark Johnston
f64f343809 bhyve: Address warnings about potential unaligned accesses in fwctl.c
This silences some warning about potential unaligned accesses.  No
functional change intended.

MFC after:	1 week
Reviewed by:	corvink, jhb
Differential Revision:	https://reviews.freebsd.org/D37288
2022-11-11 10:01:27 -05:00