Commit Graph

20194 Commits

Author SHA1 Message Date
Alfonso Gregory
a2cc93ec7f Mark usage function as __dead2 in programs where it does not return
In most cases, usage does not return, so mark them as __dead2. For the
cases where they do return, they have not been marked __dead2.

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/735
2023-07-07 10:45:18 -06:00
Alfonso Gregory
a9cce232a6 Mark usage function as __dead2 in programs where it does not return
In most cases, usage does not return, so mark them as __dead2. For the
cases where they do return, they have not been marked __dead2.

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/735
2023-07-07 10:45:18 -06:00
Alfonso Gregory
72e1ea2f13 Mark usage function as __dead2 in programs where it does not return
In most cases, usage does not return, so mark them as __dead2. For the
cases where they do return, they have not been marked __dead2.

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/735
2023-07-07 10:45:18 -06:00
Emmanuel Vadot
c81495a621 fwget: Fix quoting
This kind of quoting doesn't work, no idea why shellcheck wanted this.
If there is a "safer" way to "fix" this feel free to do it just test
that it's working after.

Reported by:	Kenneth Raplee <kenrap@kennethraplee.com>
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Fixes:	7ad4d94d5b ("Fix some shell issues by adding quotes and replace backticks with $()")
2023-07-07 09:19:41 +02:00
Vadim Goncharov
a81b559dad Fix saving STRUCTURED-DATA in RFC 5424 log format
When saving log files in RFC 5424 format presence of STRUCTURED-DATA
in message caused line to not appear in log file at all, because
a variable forgotten to initialize. This could be tested by (slightly
modified) example from RFC:

    echo '<165>1 2003-10-11T22:14:15.003Z mymachine.example.com su 12345 ID47 [exampleSDID@32473 iut="3" eventSource="Application" eventID="1011"][id@2 test="tast"] BOM"su root" failed for lonvick on /dev/pts/8" ' | nc -w1 -Uu /var/run/log

While here, update stale information in comment to logmsg() that RFC 5424
log format was not supported.

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/717
2023-07-06 23:15:10 -06:00
Warner Losh
761ab48d6a kbdcontrol: Remove compat code for 4.x -> 5.x transition
I think we're safely past that now...

Sponsored by:		Netflix
2023-07-06 23:10:18 -06:00
Michael
971bac5ace kbd: consolidate kb interfaces (phase one)
Refactor to eliminate duplicated rate and delay tables, with minor style
tweaks for changed lines.  Remove an obsolete comment about needing to
convert from microseconds to ticks (that's done elsewhere). Remove
traiing whitespace in kbdcontrol.c.

Except for the new warning, no change in behavior

Sponsored by: 		DSS GmbH
Reviewed by:		imp [minor style tweaks as well]
Pull Request:		https://github.com/freebsd/pull/683
Differential Revision: 	https://reviews.freebsd.org/D38818
2023-07-06 23:10:18 -06:00
Mateusz Guzik
65e55a0a2a flowctl: low-effort fix to make it compilable with neither inet nor inet6 2023-07-05 10:03:10 +00:00
Mateusz Guzik
fda83023cd jls: low-effort fix to make it compilable with neither inet nor inet6 2023-07-05 10:03:07 +00:00
Mark Johnston
f4841d8af0 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
2023-06-28 16:29:49 -04:00
Mark Johnston
13013d266e 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
2023-06-28 16:29:49 -04:00
John Baldwin
a80e5bdff5 camdd: Remove some dead code but also make -E functional.
- Pass down the top-level arglist from main down to camdd_rw and use
  it in place of the hardcoded CAMDD_ARG_ERR_RECOVER when calling
  camdd_probe_pass.  This now disables error recovery by default
  unless -E is specified.

- Use the return value of parse_btl to determine if an explicit LUN
  was specified.

- Remove most CAMDD_ARG_* flags that are only set and never checked.
  CAMDD_ARG_VERBOSE remains, but could perhaps be removed (and possibly
  -v should be removed as well since it is currently a no-op).

Reported by:	clang -Wunused-but-set-variable (arglist in main)
Differential Revision:	https://reviews.freebsd.org/D40666
2023-06-28 11:12:50 -07:00
John Baldwin
2309909919 bsdinstall: Handle errors from geom_gettree.
geom_gettree probably never fails, and if it does there isn't much of
a fallback other than aborting partitioning.  However, a few places
were checking the return value and not doing anything with it
triggering a unused-but-set-variable warning.  Checking the errors
resolves the warning.

While here, check for errors in other places that weren't checking for
them at all, remove a spurious double call (the second call overwrote
the mesh structure leaking all the pointers from the first), and close
a few resource leaks on error paths.

Reviewed by:	imp, emaste
Differential Revision:	https://reviews.freebsd.org/D40779
2023-06-28 11:11:00 -07:00
Benedict Reuschling
7776cec946 Add quotes around variables and replace backticks with $()
The quotes are added to prevent word splits and globbing. Some
whitespaces were also removed after variables.

Approved by:	imp
Differential Revision: https://reviews.freebsd.org/D40726
2023-06-28 16:48:39 +00:00
John Baldwin
eca9714e4b libbsnmptools: Fully comment out set but unused count variable.
These functions all end with 'return (2/* count */);'.

Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D40670
2023-06-27 10:19:32 -07:00
John Baldwin
f66a8328c3 bsdinstall: Replace correct, but fragile, string builder with open_memstream.
The old one triggered a false positive -Warray-bounds from GCC (the
compiler assumed len was always 0), but it was also fragile with
manually computed lengths paired with strcat vs using a string
builder.

Differential Revision:	https://reviews.freebsd.org/D40658
2023-06-27 10:19:32 -07:00
Warner Losh
ccfc9600ce Replace BSD-2-Clause-FreeBSD with BSD-2-Clause
Sponsored by:		Netflix
2023-06-22 20:51:22 -06:00
Corvin Köhne
1e8d0c6cf6
Revert "bhyve: add command line parameter and parsing for migration"
Unfortunately, this feature didn't receive much feedback in the past.
However, after committing this, some people came up and complain that
this feature requires some more discussion before upstreaming it.
Additionally, it wasn't a good idea to start this new feature by adding
a new command line parameter as it fixes the user interface.

This reverts commit c9fdd4f3cc.
2023-06-21 08:55:34 +02:00
John Baldwin
4a0b57b0b4 fifolog: Trim some dead code and unused variables.
The gmt_ptr and gmt variables are not used, so the call to gmtime can
be removed entirely.  In addition, there isn't a need to call
localtime twice.

Reported by:	GCC -Wunused-but-set-variable
Reviewed by:	phk, emaste
Differential Revision:	https://reviews.freebsd.org/D40656
2023-06-20 14:03:35 -07:00
John Baldwin
3456659866 jail: Mute -Wunused-but-set-variable for yynerrs.
This is in the generated parser when using %pure-parser.

y.tab.c:382:14: error: variable 'yynerrs' set but not used [-Werror,-Wunused-but-set-variable]
    int      yynerrs;
             ^

Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D40671
2023-06-20 12:38:20 -07:00
John Baldwin
f13a7fabfe iasl: Disable -Wunused-but-set-variable for a couple of files.
Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D40669
2023-06-20 12:36:43 -07:00
John Baldwin
e65868ddd4 acpidump: Remove set but unused variable.
ACPICA's table dumper doesn't try to dump this subtable's contents
either.

Reported by:	GCC
Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D40657
2023-06-20 12:33:37 -07:00
John Baldwin
52642de03b camdd: Remove set but unused variables.
Reported by:	GCC
Reviewed by:	ken
Differential Revision:	https://reviews.freebsd.org/D40655
2023-06-20 12:32:57 -07:00
John Baldwin
afb001df81 bsnmpd snmp_bridge: Remove set but unused variable. 2023-06-20 09:29:00 -07:00
John Baldwin
80badfcb70 iostat: Remove set but unused variable. 2023-06-20 09:29:00 -07:00
John Baldwin
def653cd6c ac: Remove set but not used variable.
Reported by:	clang
2023-06-20 09:29:00 -07:00
John Baldwin
8457b7f426 ypldap: Remove set but unused variables.
Some of these were reported by GCC, others reported by clang.
2023-06-20 09:29:00 -07:00
John Baldwin
c196442842 nscd: Remove set but unused variables.
Reported by:	GCC
2023-06-20 09:28:59 -07:00
John Baldwin
9d7c4486e2 bluetooth: Remove set but unused variable.
Reported by:	GCC
2023-06-20 09:28:59 -07:00
John Baldwin
5f0bd29180 bluetooth/ath3kfw: Propagate return value from ath3k_load_fwfile.
The caller ignores the return value so this is a no-op, but
ath3k_init_ar3012 returns the return values of its internal functions,
so this is more consistent.

Fix some misleading indentation while here.

Reported by:	GCC -Wunused-but-set-variable (1)
2023-06-20 09:28:59 -07:00
John Baldwin
98f7dec508 mptable: Remove set but unused variable.
Reported by:	GCC
2023-06-20 09:28:59 -07:00
John Baldwin
96f286866d rpc.lockd: Remove set but unused variables.
Reported by:	GCC
2023-06-20 09:28:59 -07:00
Corvin Köhne
35c8063ab1
bhyve: dos2unix
tpm_intf.h was incorrectly committed with dos line endings.

Fixes:			0917f925b4 ("bhyve: add basic CRB interface for TPM devices")
MFC after:		1 week
Sponsored by:		Beckhoff Automation GmbH & Co. KG
2023-06-20 11:52:43 +02:00
Corvin Köhne
0daf5f02cf
bhyve/tpm: create crb thread for sending tpm commands
Commands send to a tpm are very slow. They can take up to several
seconds for completion. For that reason, create a thread which issues
the commands to the tpm device.

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

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

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

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

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

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

Reviewed by:		jhb, markj
MFC after:		1 week
Sponsored by:		Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D39284
2023-06-20 10:51:54 +02:00
Mark Johnston
eb9fac0edb bhyve: Refactor vmexit_suspend() a bit
Move some of its logic into fbsdrun_deletecpu().  This makes it easier
to split vmexit handlers into a separate file, which in turn makes
landing arm64 support easier.  Also increase the scope of the mutex and
use it to synchronize updates to the vcpu mask.  No functional change
intended.

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

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

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

MFC after:	1 week
Sponsored by:	Innovate UK
2023-06-19 15:44:44 -04:00
Alexander Leidinger
194e059bb8 service: Add -E option to set environment variables before starting a service.
This allows for quicker testing/debugging of rc scripts and is a pre-req
for automatic service jails.

Differential Revision:	https://reviews.freebsd.org/D40369
Reviewed by:		se
2023-06-19 19:45:54 +02:00
Benedict Reuschling
7ad4d94d5b Fix some shell issues by adding quotes and replace backticks with $()
This patch fixes the following issues reported by shellcheck:
- Quote default assignments (SC2223)
- Use $() instead of backticks (SC2006)
- Double quote $@ (SC2068)
- Double quote variables in if-statements and other places (SC2086)

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

Approved by:	manu
Differential Revision: https://reviews.freebsd.org/D40604
2023-06-19 11:03:06 +00:00
Mihai Burcea
c9fdd4f3cc
bhyve: add command line parameter and parsing for migration
This covers warm and live migration.

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

So the following configuration cannot be restored.

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

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

This commit fixes that issue.

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

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

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

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

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