Commit Graph

741 Commits

Author SHA1 Message Date
John Baldwin
c6efcb1281 bhyve: Support setting the disk serial number for VirtIO block devices.
Reviewed by:	allanjude
Obtained from:	illumos
Differential Revision:	https://reviews.freebsd.org/D31983
2021-09-17 09:55:48 -07:00
Ka Ho Ng
e31cc1d526 bhyve: Fix pci device node key in bhyve_config.5
PCI device node key in the manual page is wrong. It should be
pci.bus.slot.function.

MFC after:	3 days
2021-09-13 04:35:03 +08:00
Elliott Mitchell
e76c0e4f45 bhyve: Nuke double-semicolons
A distinct number of double-semicolons ended up in bhyve. Take a pass at
getting rid of many of these harmless typos.

MFC after:	3 days
2021-08-30 15:31:04 +08:00
Mark Johnston
71fbc6faed bhyve: Fix vq_getchain() error handling bugs in various device models
Reviewed by:	grehan, khng
Approved by:	so
Security:	CVE-2021-29631
Security:	FreeBSD-SA-21:13.bhyve
2021-08-24 14:29:13 -04:00
Mariusz Zaborski
3a92927bb6 bhyve: change a default address from ANY to localhost
Discussed with:     grehan, jhb
2021-08-21 19:43:17 +02:00
Mariusz Zaborski
2cdff9918e byhve: add option to specify IP address for gdb
Allow user to specify the IP address available for gdb debugger.

Reviewed by:	jhb, grehan, rgrimes, bcr (man pages)
Differential Revision:	https://reviews.freebsd.org/D29607
2021-08-21 19:43:17 +02:00
Mark Johnston
42375556e5 bhyve: Use pci(4) to access I/O port BARs
This removes the dependency on /dev/io.

PR:		251046
Reviewed by:	jhb
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D31308
2021-08-14 10:59:04 -04:00
Ka Ho Ng
3676512b60 bhyve: Use fspacectl(2) for BOP_DELETE on regular file images
bhyve can also make use of fspacectl(2) to implement BOP_DELETE with
hole-punching. Since it is not desirable to do zero-filling for large
DEALLOCATE/UNMAP range, candelete is not set if pathconf(2) indicates
that the underlying file system does not support native
VOP_DEALLOCATE(9).

Sponsored by:	The FreeBSD Foundation
Reviewed by:	grehan
Differential Revision:	https://reviews.freebsd.org/D28880
2021-08-07 17:10:30 +08:00
Bjoern A. Zeeb
56be282bc9 bhyve: net_backends, automatically IFF_UP tap devices
If you want communications with the outside world and tell bhyve to
create an interfaces then it should be usable as well.
Rather than relying on the sysctl net.link.tap.up_on_open automatically
try to IFF_UP the opened tap device.

MFC after:	10 days
Reviewed by:	markj, grehan
Differential Revision: https://reviews.freebsd.org/D31342
2021-08-01 20:50:53 +00:00
Chuck Tuffli
91064841d7 bhyve: Fix NVMe iovec construction for large IOs
The UEFI driver included with Rocky Linux 8.4 uncovered an existing bug
in the NVMe emulation's construction of iovec's.

By default, NVMe data transfer operations use a scatter-gather list in
which all entries point to a fixed size memory region. For example, if
the Memory Page Size is 4KiB, a 2MiB IO requires 512 entries. Lists
themselves are also fixed size (default is 512 entries).

Because the list size is fixed, the last entry is special. If the IO
requires more than 512 entries, the last entry in the list contains the
address of the next list of entries. But if the IO requires exactly 512
entries, the last entry points to data.

The NVMe emulation missed this logic and unconditionally treated the
last entry as a pointer to the next list. Fix is to check if the
remaining data is greater than the page size before using the last entry
as a pointer to the next list.

PR:		256422
Reported by:	dave@syix.com
Tested by:	jason@tubnor.net
MFC after:	5 days
Relnotes:	yes
Reviewed by:	imp, grehan
Differential Revision:	https://reviews.freebsd.org/D30897
2021-06-27 15:14:52 -07:00
Chuck Tuffli
a11ca79cd9 bhyve: fix NVMe MDTS comment
Removes an obsolete comment and adds parenthesis around the macro while
in the area. No functional change.
2021-06-25 08:02:28 -07:00
Chuck Tuffli
3a4ab18377 bhyve: Fix cli regression with NVMe ram
The configuration management refactoring inadvertently removed support
for a RAM-backed NVMe Namespace (i.e. -s X,nvme,ram=16384). This adds it
back.

Reported by:	andy@omniosce.org
Reviewed by:	jhb, andy@omniosce.org
Fixes:		621b509048
MFC after:	1 week
Differential Revision: https://reviews.freebsd.org/D30717
2021-06-16 14:19:01 -07:00
Robert Crowston
efec757b20 bhyve: enhance debug info for memory range clash
Explain what the two clashing regions are.

Reivewed by:		grehan, jhb
Differential Revision:	https://reviews.freebsd.org/D29696
Pull Request:		https://github.com/freebsd/freebsd-src/pull/463
2021-06-13 16:41:45 -06:00
John Baldwin
2349cda44f bhyve vtblk: Inform guests of disk resize events.
Register a resize callback with the blockif interface.  When the
callback fires, update the size of the disk and notify the guest via a
configuration change interrupt.

Reviewed by:	grehan, markj
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D30506
2021-06-11 18:00:25 -07:00
John Baldwin
c06676bee3 bhyve: Split out a lower-level helper for VirtIO interrupts.
This allows device models to assert VirtIO interrupts for reasons
other than publishing changes to a VirtIO ring such as configuration
changes.

Reviewed by:	grehan, markj
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D30505
2021-06-11 18:00:25 -07:00
John Baldwin
8794846a91 bhyve: Add support for handling disk resize events to block_if.
Allow clients of blockif to register a resize callback handler.  When
a callback is registered, register an EVFILT_VNODE kevent watching the
backing store for a change in the file's attributes.  If the size has
changed when the kevent fires, invoke the clients' callback.

Currently resize detection is limited to backing stores that support
EVFILT_VNODE kevents such as regular files.

Reviewed by:	grehan, markj
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D30504
2021-06-11 18:00:24 -07:00
John Baldwin
67d60dcce6 bhyve: Add support for EVFILT_VNODE mevents.
This allows registering an event to watch for changes to a file's
attributes.  This is a bit imperfect as it would be nice to have a way
to determine if an fd can use EVFILT_VNODE successfully.  mevent's
current structure does not permit that and a failure to register a
single kevent impacts several other kevents.

Reviewed by:	grehan, markj
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D30503
2021-06-11 18:00:24 -07:00
John Baldwin
e8424e2947 bhyve: Register new kevents synchronously.
Change mevent_add*() to synchronously add the new kevent.  This
permits reporting event registration failures to the caller and avoids
failing the registration of other, unrelated events queued up in the
same batch.

Reviewed by:	grehan, markj
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D30502
2021-06-11 18:00:24 -07:00
Corvin Köhne
054accac71 Add a virtio-input device emulation.
This will be used to inject keyboard/mouse input events into a guest.
The command line syntax is:
   -s <slot>,virtio-input,/dev/input/eventX

Reviewed by:	jhb (bhyve), grehan
Obtained from:	Corvin Köhne <C.Koehne@beckhoff.com>
MFC after:	3 weeks
Relnotes:	yes
Differential Revision:	https://reviews.freebsd.org/D30020
2021-06-08 19:05:09 +10:00
Robert Wing
fdbc86cf79 bhyve/snapshot: split up mutex/cond initialization from socket creation
Move initialization of the mutex/condition variables required by the
save/restore feature to their own function.

The unix domain socket that facilitates communication between bhyvectl
and bhyve doesn't rely on these variables in order to be functional.

Reviewed by:    markj
Differential Revision:  https://reviews.freebsd.org/D30281
2021-05-21 11:23:06 -08:00
Robert Wing
d4870e3a72 bhyve/snapshot: provide a way to send other messages/data to bhyve
This is a step towards sending messages (other than suspend/checkpoint)
from bhyvectl to bhyve.

Introduce a new struct, ipc_message - this struct stores the type of
message and a union containing message specific structures for the type
of message being sent.

Reviewed by:    grehan
Differential Revision: https://reviews.freebsd.org/D30221
2021-05-12 17:20:15 -08:00
Mark Johnston
02e7a6514e bhyve: Set SO_REUSEADDR on the gdb stub socket
Reviewed by:	jhb
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D30037
2021-05-03 13:24:30 -04:00
Ryan Moeller
89c3c32647 bhyve: Gracefully handle virtio-scsi with no conf
Fixes segfault with the command `bhyve -s 0,virtio-scsi`, which is used
by some third party software to probe bhyve for virtio-scsi support.

Reviewed by:	jhb
MFC after:	1 day
Sponsored by:	iXsystems, Inc.
Differential Revision:	https://reviews.freebsd.org/D29926
2021-04-22 12:06:08 -04:00
Michael Reifenberger
b563ff5d4f Append Keyboard Layout specified option for using VNC.
Part one: supporting QEMU Extended Keyboard Event Message

PR:             246121
Submitted by:   koinec@yahoo.co.jp
Differential Revision: https://reviews.freebsd.org/D29430
2021-04-21 12:40:44 +02:00
John Baldwin
e15bf05e0a bhyve: Be explicit that setting config.dump will not start a VM.
Suggested by:	rpokala
Reviewed by:	bcr (manpages)
Differential Revision:	https://reviews.freebsd.org/D29738
2021-04-20 13:34:07 -07:00
Mateusz Piotrowski
8d9fefe643 bhyve.8: Fix mandoc -Tlint issues
While here, keep network backends section consistent with other
sections.

MFC after:	2 weeks
2021-04-19 02:16:14 +02:00
Mateusz Piotrowski
061f37d280 bhyve: Document the format for HD audio backends
- This change is done for consistency with other backend definitions.

MFC after:	2 weeks
2021-04-19 02:16:14 +02:00
Mateusz Piotrowski
d5fcc4b606 bhyve.8: Improve AHCI backends documentation
- Document the backend format.

MFC after:	2 weeks
2021-04-19 02:16:13 +02:00
Mateusz Piotrowski
6eff58acc7 bhyve.8: Improve documentation of NVME backend
- Document the configuration format.
- Document two additional configuration options: eui64 and dsm.

MFC after:	2 weeks
2021-04-19 02:16:13 +02:00
Mateusz Piotrowski
8b97e97548 bhyve.8: Improve framebuffer backends description
- Use appropriate mdoc macros
- Document that tcp= is a synonym to rfb= (tcp is used in the examples,
  but never mentioned)
- Clarify the IP address specification

MFC after:	2 weeks
2021-04-19 02:16:13 +02:00
Mateusz Piotrowski
3f4c771f64 bhyve.8: Clean up virtio console device backends description
MFC after:	2 weeks
2021-04-19 02:16:13 +02:00
Mateusz Piotrowski
2fda01a1b7 bhyve.8: Clean up TTY, boot ROM, and pass-through descriptions
MFC after:	2 weeks
2021-04-19 02:16:12 +02:00
Mateusz Piotrowski
2d00b57022 bhyve.8: Clean up 9P device backends section
MFC after:	2 weeks
2021-04-19 02:16:12 +02:00
Mateusz Piotrowski
7c5829c942 bhyve.8: Clean up SCSI device backends section
MFC after:	2 weeks
2021-04-19 02:16:12 +02:00
Mateusz Piotrowski
5232a35f1e bhyve.8: Clean up block storage device backends description
MFC after:	2 weeks
2021-04-19 02:16:12 +02:00
Mateusz Piotrowski
7fb2272981 bhyve.8: Clean up network backends section
- Reformat the format lists, use appropriate mdoc macros for
  readability.
- Add a missing Oxford comma.

MFC after:	2 weeks
2021-04-18 23:33:24 +02:00
Mateusz Piotrowski
7014cb2393 bhyve.8: Improve emulation description of the -s flag
- Set width of the list to the longest key word for readability.
- Separate descriptions of amd_hostbridge and hostbridge emulations.
  Also, wordsmith their descriptions for consistency with other entries.
- Use Cm instead of Li for command modifiers.
- Do not stylize AMD with Li, there's no need to do it.
- Mention COM3 and COM4 in the definition of lpc.
- Fix a typo in the definition of ahci-hd ("hard drive" instead of
  "hard-drive").

MFC after:	2 weeks
2021-04-18 23:33:23 +02:00
Mateusz Piotrowski
234d8c470b bhyve.8: Clean up the slot description of -s
Also, remove the macros of the nested list which contained slot,
emulation and conf. This decreases the indention of the -s description.
It was necessary to clean up the slot description.

MFC after:	2 weeks
2021-04-18 23:33:23 +02:00
Mateusz Piotrowski
449f0e48e9 bhyve.8: Clean-up synopsis of -s
- Document "-s help" separately for readability.
- Use appropriate mdoc macros.

MFC after:	2 weeks
2021-04-18 23:33:23 +02:00
Mateusz Piotrowski
3357e9482f bhyve.8: Fix indention in the signals table
MFC after:	2 weeks
2021-04-18 22:09:39 +02:00
Mateusz Piotrowski
b24eea8c7a bhyve.8: Clean up description of -r
There is no need to wrap those flags in Op macros.

MFC after:	2 weeks
2021-04-18 22:09:37 +02:00
Mateusz Piotrowski
90df54374f bhyve.8: Fix the synopsis of -p
Use appropriate mdoc macros.

MFC after:	2 weeks
2021-04-18 22:09:36 +02:00
Mateusz Piotrowski
7e0cb3df68 bhyve.8: Improve the description of the -m flag
- Stylize the synopsis with proper mdoc macros
- Do some wordsmithing on the description for consistency.

MFC after:	2 weeks
2021-04-18 22:09:34 +02:00
Mateusz Piotrowski
4c08b978b2 bhyve.8: Improve the description and synopsis of -l
- Describe "-l help" separately for readability.
- List all the supported comX devices explicitly
- Use Cm instead of Ar for command modifiers (i.e., literal values a
  user can specify as an argument to the command).
- Explain where to get more information about the possible values of the
  conf argument.

MFC after:	2 weeks
2021-04-18 22:09:33 +02:00
Mateusz Piotrowski
ccb1c87a6a bhyve.8: Sort the options in the OPTIONS section
No content change intended. Just moving the option descriptions around
to follow the order suggested by style(9).

MFC after:	2 weeks
2021-04-18 22:09:24 +02:00
Mateusz Piotrowski
b6a572d03f bhyve: Improve the option description in the usage message
- Sort options as suggested by style(9)
- Capitalize some words like CPU and HLT
- Add a missing description for the -G flag

MFC after:	2 weeks
2021-04-18 20:22:13 +02:00
Mateusz Piotrowski
03c3e5e40d bhyve: Fix synopsis in the usage message
In particular:
- Sort short options to align with style(9)
- Add two missing flags: -G and -r
- Drop unnecessary angle brackets for consistency
- Rename the "vm" argument to vmname for consistency with the manual
  page

MFC after:	2 weeks
2021-04-18 20:22:13 +02:00
Mateusz Piotrowski
bfe40b692d bhyve.8: Make synopsis more readable
There is no need to squeeze all the possible options into one synopsis
entry. Let "-l help" and "-s help" be listed separately.

While here, keep -s and its arguments on the same line.

MFC after:	2 weeks
2021-04-18 20:22:13 +02:00
Corvin Köhne
17d214c2ca bhyve: implement rdmsr for MSR_IA32_FEATURE_CONTROL
Without the -w option, Windows guests crash on boot. This is caused by a rdmsr
of MSR_IA32_FEATURE_CONTROL. Windows checks this MSR to determine enabled VMX
features. This MSR isn't emulated in bhyve, so a #GP exception is injected
which causes Windows to crash.

Fix by returning a rdmsr of MSR_IA32_FEATURE_CONTROL with Lock Bit set and
VMX disabled to informWindows that VMX isn't available.

Reviewed by:	jhb, grehan (bhyve)
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D29665
2021-04-15 13:49:19 +10:00
John Baldwin
eacc27affe bhyve: Move the gdb_active check to gdb_cpu_suspend().
The check needs to be in the public routine (gdb_cpu_suspend()), not
in the internal routine called from various places
(_gdb_cpu_suspend()).  All the other callers of _gdb_cpu_suspend()
already check gdb_active, and this breaks the use of snapshots when
the debug server is not enabled since gdb_cpu_suspend() tries to lock
an uninitialized mutex.

Reported by:	Darius Mihai, Elena Mihailescu
Reviewed by:	elenamihailescu22_gmail.com
Fixes:		621b509048
Differential Revision:	https://reviews.freebsd.org/D29538
2021-04-12 11:43:34 -07:00