History log of /freebsd-current/usr.sbin/bhyve/pci_fbuf.c
Revision Date Author Comments
# 0600b575 29-Dec-2023 Robert Wing <rew@FreeBSD.org>

bhyve: verify that user provided fbuf values fall within limits

The upper limits for height/width are already checked, this commit
enforces the lower limit as well.

The behavior is also changed such that, the framebuffer fails to
initialize if the provided values don't parse cleanly.

Reviewed by: corvink, jhb
Differential Revision: https://reviews.freebsd.org/D42692


# 4d65a7c6 24-Nov-2023 Warner Losh <imp@FreeBSD.org>

usr.sbin: Automated cleanup of cdefs and other formatting

Apply the following automated changes to try to eliminate
no-longer-needed sys/cdefs.h includes as well as now-empty
blank lines in a row.

Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/
Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/
Remove /\n+#if.*\n#endif.*\n+/
Remove /^#if.*\n#endif.*\n/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/

Sponsored by: Netflix


# fb51ddb2 20-Nov-2023 Robert Wing <rew@FreeBSD.org>

bhyve: increase fbuf display resolution limit

This enables connecting to the VNC server at a higher resolution.

Reviewed by: corvink, markj
Differential Revision: https://reviews.freebsd.org/D42620


# 61429b49 03-Oct-2023 Mark Johnston <markj@FreeBSD.org>

bhyve: Conditionally compile framebuffer-related code

The arm64 port does not implement VGA, so move the device model sources.
Compile framebuffer code only on amd64 for now, but do not move the
sources, as we ought to be able to add support later.

No functional change intended.

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


# 1d386b48 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

Remove $FreeBSD$: one-line .c pattern

Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/


# b3e76948 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

Remove $FreeBSD$: two-line .h pattern

Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/


# 4d846d26 10-May-2023 Warner Losh <imp@FreeBSD.org>

spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD

The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch
up to that fact and revert to their recommended match of BSD-2-Clause.

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


# 71a21ad4 22-Feb-2023 Elyes Haouas <ehaouas@noos.fr>

bhyve: Remove useless return at the end of void function

Signed-off-by: Elyes Haouas <ehaouas@noos.fr>


# 6a284cac 19-Jan-2023 John Baldwin <jhb@FreeBSD.org>

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


# 78c2cd83 09-Dec-2022 John Baldwin <jhb@FreeBSD.org>

bhyve: Remove unused vcpu argument from PCI read/write methods.

Reviewed by: corvink, markj
Differential Revision: https://reviews.freebsd.org/D37652


# 84633b9d 23-Oct-2022 Mark Johnston <markj@FreeBSD.org>

bhyve: Put the prototype for vga_render() in a header

No functional change intended.

MFC after: 1 week


# 98d920d9 08-Oct-2022 Mark Johnston <markj@FreeBSD.org>

bhyve: Annotate unused function parameters

MFC after: 1 week


# 37045dfa 16-Aug-2022 Mark Johnston <markj@FreeBSD.org>

bhyve: Mark variables and functions as static where appropriate

Mark them const as well when it makes sense to do so. No functional
change intended.

MFC after: 1 week
Sponsored by: The FreeBSD Foundation


# c2fa905c 26-Dec-2021 Toomas Soome <tsoome@FreeBSD.org>

bhyve: clean up trailing whitespaces

Clean up trailing whitespaces. No functional changes.

Reviewed by: jhb
Differential Revision: https://reviews.freebsd.org/D33681


# 5085153a 18-Nov-2021 Corvin Köhne <CorvinK@beckhoff.com>

bhyve: do not explicitly map fbuf framebuffer

Allocating a BAR will call baraddr which maps the framebuffer. No need
to allocate it explicitly on init.

Reviewed by: grehan
Sponsored by: Beckhoff Autmation GmbH & Co. KG
Differential Revision: https://reviews.freebsd.org/D32596


# f8a6ec2d 18-Mar-2021 D Scott Phillips <scottph@FreeBSD.org>

bhyve: support relocating fbuf and passthru data BARs

We want to allow the UEFI firmware to enumerate and assign
addresses to PCI devices so we can boot from NVMe[1]. Address
assignment of PCI BARs is properly handled by the PCI emulation
code in general, but a few specific cases need additional support.
fbuf and passthru map additional objects into the guest physical
address space and so need to handle address updates. Here we add a
callback to emulated PCI devices to inform them of a BAR
configuration change. fbuf and passthru then watch for these BAR
changes and relocate the frame buffer memory segment and passthru
device mmio area respectively.

We also add new VM_MUNMAP_MEMSEG and VM_UNMAP_PPTDEV_MMIO ioctls
to vmm(4) to facilitate the unmapping needed for addres updates.

[1]: https://github.com/freebsd/uefi-edk2/pull/9/

Originally by: scottph
MFC After: 1 week
Sponsored by: Intel Corporation
Reviewed by: grehan
Approved by: philip (mentor)
Differential Revision: https://reviews.freebsd.org/D24066


# 621b5090 26-Jun-2019 John Baldwin <jhb@FreeBSD.org>

Refactor configuration management in bhyve.

Replace the existing ad-hoc configuration via various global variables
with a small database of key-value pairs. The database supports
heirarchical keys using a MIB-like syntax to name the path to a given
key. Values are always stored as strings. The API used to manage
configuation values does include wrappers to handling boolean values.
Other values use non-string types require parsing by consumers.

The configuration values are stored in a tree using nvlists. Leaf
nodes hold string values. Configuration values are permitted to
reference other configuration values using '%(name)'. This permits
constructing template configurations.

All existing command line arguments now set configuration values. For
devices, the "-s" option parses its option argument to generate a list
of key-value pairs for the given device.

A new '-o' command line option permits setting an individual
configuration variable. The key name is always given as a full path
of dot-separated components.

A new '-k' command line option parses a simple configuration file.
This configuration file holds a flat list of 'key=value' lines where
the 'key' is the full path of a configuration variable. Lines
starting with a '#' are comments.

In general, bhyve starts by parsing command line options in sequence
and applying those settings to configuration values. Once this is
complete, bhyve then begins initializing its state based on the
configuration values. This means that subsequent configuration
options or files may override or supplement previously given settings.

A special 'config.dump' configuration value can be set to true to help
debug configuration issues. When this value is set, bhyve will print
out the configuration variables as a flat list of 'key=value' lines.

Most command line argments map to a single configuration variable,
e.g. '-w' sets the 'x86.strictmsr' value to false. A few command
line arguments have less obvious effects:

- Multiple '-p' options append their values (as a comma-seperated
list) to "vcpu.N.cpuset" values (where N is a decimal vcpu number).

- For '-s' options, a pci.<bus>.<slot>.<function> node is created.
The first argument to '-s' (the device type) is used as the value of
a "device" variable. Additional comma-separated arguments are then
parsed into 'key=value' pairs and used to set additional variables
under the device node. A PCI device emulation driver can provide
its own hook to override the parsing of the additonal '-s' arguments
after the device type.

After the configuration phase as completed, the init_pci hook
then walks the "pci.<bus>.<slot>.<func>" nodes. It uses the
"device" value to find the device model to use. The device
model's init routine is passed a reference to its nvlist node
in the configuration tree which it can query for specific
variables.

The result is that a lot of the string parsing is removed from
the device models and centralized. In addition, adding a new
variable just requires teaching the model to look for the new
variable.

- For '-l' options, a similar model is used where the string is
parsed into values that are later read during initialization.
One key note here is that the serial ports use the commonly
used lowercase names from existing documentation and examples
(e.g. "lpc.com1") instead of the uppercase names previously
used internally in bhyve.

Reviewed by: grehan
MFC after: 3 months
Differential Revision: https://reviews.freebsd.org/D26035


# 483d953a 04-May-2020 John Baldwin <jhb@FreeBSD.org>

Initial support for bhyve save and restore.

Save and restore (also known as suspend and resume) permits a snapshot
to be taken of a guest's state that can later be resumed. In the
current implementation, bhyve(8) creates a UNIX domain socket that is
used by bhyvectl(8) to send a request to save a snapshot (and
optionally exit after the snapshot has been taken). A snapshot
currently consists of two files: the first holds a copy of guest RAM,
and the second file holds other guest state such as vCPU register
values and device model state.

To resume a guest, bhyve(8) must be started with a matching pair of
command line arguments to instantiate the same set of device models as
well as a pointer to the saved snapshot.

While the current implementation is useful for several uses cases, it
has a few limitations. The file format for saving the guest state is
tied to the ABI of internal bhyve structures and is not
self-describing (in that it does not communicate the set of device
models present in the system). In addition, the state saved for some
device models closely matches the internal data structures which might
prove a challenge for compatibility of snapshot files across a range
of bhyve versions. The file format also does not currently support
versioning of individual chunks of state. As a result, the current
file format is not a fixed binary format and future revisions to save
and restore will break binary compatiblity of snapshot files. The
goal is to move to a more flexible format that adds versioning,
etc. and at that point to commit to providing a reasonable level of
compatibility. As a result, the current implementation is not enabled
by default. It can be enabled via the WITH_BHYVE_SNAPSHOT=yes option
for userland builds, and the kernel option BHYVE_SHAPSHOT.

Submitted by: Mihai Tiganus, Flavius Anton, Darius Mihai
Submitted by: Elena Mihailescu, Mihai Carabas, Sergiu Weisz
Relnotes: yes
Sponsored by: University Politehnica of Bucharest
Sponsored by: Matthew Grooms (student scholarships)
Sponsored by: iXsystems
Differential Revision: https://reviews.freebsd.org/D19495


# cbd7ddcf 17-Mar-2020 Rebecca Cran <bcran@FreeBSD.org>

Bhyve: DPRINTF already includes newline, so don't add another

Reviewed by: jhb, vmaffione, emaste
Differential Revision: https://reviews.freebsd.org/D24099


# 332eff95 08-Jan-2020 Vincenzo Maffione <vmaffione@FreeBSD.org>

bhyve: add wrapper for debug printf statements

Add printf() wrapper to use CR/CRLF terminators depending on whether
stdio is mapped to a tty open in raw mode.
Try to use the wrapper everywhere.
For now we leave the custom DPRINTF/WPRINTF defined by device
models, but we may remove them in the future.

Reviewed by: grehan, jhb
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D22657


# bf51e078 11-Jul-2019 Sean Chittenden <seanc@FreeBSD.org>

usr.sbin/bhyve: commit miss from r349918

Submitted by: markj
Approved by: markj
Differential Revision: https://reviews.freebsd.org/D20918


# bab8915c 11-Jul-2019 Sean Chittenden <seanc@FreeBSD.org>

usr.sbin/bhyve: free leaked memory during option parsing

Also update to use strsep(3) instead of strtok(3).

Most of this commit inadvertently ended up in r349914.

Coverity CID: 1357337
Approved by: markj
PR: 233038
Differential Revision: https://reviews.freebsd.org/D20918


# 2a1950b9 11-Jul-2019 Sean Chittenden <seanc@FreeBSD.org>

usr.sbin/bhyve: free resources if there is an initialization error in rfb

Coverity CID: 1357335
Approved by: markj, jhb
Differential Revision: https://reviews.freebsd.org/D20919


# 2c386b11 06-Nov-2018 Marcelo Araujo <araujo@FreeBSD.org>

Revert my bogus attempt to silence coverity on r340045, it created
more bad side effects than good.

PR: 233038
Submitted by: We Maag <jwmaag@gmail.com>


# 250c472a 02-Nov-2018 Marcelo Araujo <araujo@FreeBSD.org>

Fix resource leak when using strdup(3).

Reported by: Coverity
CID: 1357337
Sponsored by: iXsystems Inc.


# 8883128b 24-Oct-2018 Bjoern A. Zeeb <bz@FreeBSD.org>

Allow the bhyve VNC server to listen on IPv6 for incoming connections.

Alternatively to IPv4 address:port this will allow to listen on IPv6
link-local (incl. scope), a specific address, or ::. Addresses have
to be given in RFC2732 format so that [::]:port parsing will work.

This patch also starts to introduce WITH_INET/INET6_SUPPORT to bhyve.

PR: 232018
Submitted by: Dave Rush (northwoodlogic.free gmail.com) (original)
Reviewed by: Dave Rush (updated verison)
MFC after: 3 days


# fb72b618 22-Oct-2018 Bjoern A. Zeeb <bz@FreeBSD.org>

In bhyve's fbuf emulation improve the overall "usage" message and
for the vga option, rather than printing the entire option string,
only print vga (as we do for everything else).

MFC after: 3 days


# ce80faa4 12-Jun-2018 Marcelo Araujo <araujo@FreeBSD.org>

Add SPDX tags to bhyve(8).

Discussed with: rgrimes, pfg and mav.
Obtained from: TrueOS
MFC after: 4 weeks.
Sponsored by: iXsystems Inc.


# f4d34383 01-Jun-2017 Marcelo Araujo <araujo@FreeBSD.org>

Add VNC Authentication support based on RFC6143 section 7.2.2.

Submitted by: Fabian Freyer <fabian.freyer@physik.tu-berlin.de>
Reworked by: myself
Reviewed by: grehan, rgrimes and jilles
MFC after: 1 week.
Relnotes: Yes.
Sponsored by: iXsystems, Inc.
Differential Revision: https://reviews.freebsd.org/D10818


# bc5d44ec 27-Apr-2017 Gleb Smirnoff <glebius@FreeBSD.org>

- For security reasons by default listen on localhost address,
not on wildcard. [1]
- Move the default port assignment from pci_fbuf.c to rfb.c,
to avoid polluting pci_fbuf.c with network things.

Suggested by: grehan


# 3909a600 27-Apr-2017 Gleb Smirnoff <glebius@FreeBSD.org>

When no "rfb" configuration specified bind to the default VNC
port instead of binding to a random one.


# 60bfcbd6 27-Apr-2017 Gleb Smirnoff <glebius@FreeBSD.org>

Make comments match the code. No functional change.


# 5a347e3b 26-Jul-2016 Peter Grehan <grehan@FreeBSD.org>

- Change the fbuf "vga" parameter to "vga=on|io|off".
"io" is the default, and allows VGA i/o registers to be
accessed. This is required by Win7/2k8 graphics guests that
use a combination of BIOS int10 and UEFI.
"off" disables all VGA i/o and mem accesses.
"on" is not yet hooked up, but will enable full VGA rendering.

OpenBSD/UEFI >= 5.9 graphics guests can be booted using "vga=off"

- Allow "rfb" to be used instead of "tcp" for the fbuf VNC
description. "tcp" will be removed at a future point and is
kept as an alias.

Discussed with: Leon Dang
MFC after: 3 days