Commit Graph

414 Commits

Author SHA1 Message Date
Peter Grehan
26e6e3e65d Use correct PCI device id for virtio-rng.
This prevented the device from attaching with a
Windows guest (most other guests use the device type
for matching)

PR:	212711
Submitted by:	jbeich
MFC after:	3 days
2017-01-08 20:58:58 +00:00
Peter Grehan
6e616e4f4b Make sure the 'Always-one' bit is always set to one,
in the first byte of the 3-byte mouse data report.
Plan9/9front requires this.

Switch over to using #defines for the data report bits.

Verified no regression on Win10/Fedora-live.

Reported and tested by: Trent Thompson (trentnthompson at gmail com)
MFC after:	1 week
2017-01-08 20:29:35 +00:00
Andriy Gapon
9aaefb2c53 bhyve: stability and performance improvement for dbgport
The TCP server implementation in dbgport does not track clients, so it
may try to write to a disconected socket resulting in SIGPIPE.
Avoid that by setting SO_NOSIGPIPE socket option.

Because dbgport emulates an I/O port to guest, the communication is done
byte by byte.  Reduce latency of the TCP/IP transfers by using
TCP_NODELAY option.  In my tests that change improves performance of
kgdb commands with lots of output (e.g. info threads) by two orders of
magnitude.

A general note.  Since we have a uart emulation in bhyve, that can be
used for the console and gdb access to guests.  So, bvmconsole and bvmdebug
could be de-orbited now.  But there are many existing deployments that
still dependend on those.

Discussed with:	julian, jhb
MFC after:	2 weeks
Sponsored by:	Panzura
2016-11-29 13:11:00 +00:00
Jakub Wojciech Klama
d286418ee6 virtio_console: handle short writes to an Unix domain socket gracefully.
writev() can do a short write.  Retrying it results in a very convoluted
and complex code, so we iterate over iovec and do regular stream_write()
instead.

Approved by:	trasz
Sponsored by:	iXsystems, Inc.
2016-11-24 22:16:18 +00:00
Jakub Wojciech Klama
962094d52a Allow opening virtio-console ports from the host side before guest
enumerates them.

Approved by:	trasz
Sponsored by:	iXsystems, Inc.
2016-11-24 21:53:42 +00:00
Bryan Drewery
28323add09 Fix improper use of "its".
Sponsored by:	Dell EMC Isilon
2016-11-08 23:59:41 +00:00
Gleb Smirnoff
42854d99e8 Fix unchecked array reference in the VGA device emulation code.
Submitted by:   Ilja Van Sprundel <ivansprundel@ioactive.com>
Patch by:	tychon
Security:       SA-16:32
2016-10-25 17:13:58 +00:00
Baptiste Daroussin
a146e36c02 accept4 actually expect SOCK_NONBLOCK and not O_NONBLOCK
Reported by:	jhb
Pointyhat to:	bapt
2016-10-25 15:20:06 +00:00
Maxim Konovalov
d609986008 Typo fixed: arbitraty -> arbitrary.
PR:		213559
Submitted by:	olgeni
2016-10-17 09:40:18 +00:00
Baptiste Daroussin
734bfbc5b0 Use accept4 with O_NONBLOCK rather than accept + fcntl 2016-10-01 11:43:37 +00:00
Ed Schouten
ecc288634a Fix misuse of the basename() and dirname() functions.
These functions are allowed to overwrite their input. Pull a copy of the
input parameter and call dirname() and basename() on that instead. Do
ensure that we reload the pathname value between calls.
2016-09-21 13:02:43 +00:00
Jakub Wojciech Klama
13ee8dde04 Add virtio-console support to bhyve.
Adds virtio-console device support to bhyve, allowing to create
bidirectional character streams between host and guest.

Syntax:
-s <slotnum>,virtio-console,port1=/path/to/port1.sock,anotherport=...

Maximum of 16 ports per device can be created. Every port is named
and corresponds to an Unix domain socket created by bhyve. bhyve
accepts at most one connection per port at a time.

Limitations:
- due to lack of destructors of in bhyve, sockets on the filesystem
  must be cleaned up manually after bhyve exits
- there's no way to use "console port" feature, nor the console port
  resize as of now
- emergency write is advertised, but no-op as of now

Approved by:	trasz
MFC after:	1 month
Relnotes:	yes
Sponsored by:	iXsystems, Inc.
Differential Revision:	D7185
2016-09-17 13:48:01 +00:00
Bryan Drewery
776d5e11e9 DIRDEPS_BUILD: Update dependencies.
Sponsored by:	EMC / Isilon Storage Division
2016-08-31 19:30:46 +00:00
Marcelo Araujo
9287c0323d Invert calloc(3) argument order.
Reviewed by:	grehan, mav
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D7613
2016-08-30 12:40:12 +00:00
Peter Grehan
5a347e3bc3 - 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
2016-07-27 00:03:29 +00:00
Peter Grehan
34b1e8a155 Catch another case where an XHCI interrupt was being
injected without state being set up.

This fixes a core dump when dropping to the UEFI prompt
with graphics enabled and moving the mouse around.

Discussed with:	Leon Dang
MFC after:	3 days
2016-07-26 23:40:25 +00:00
Peter Grehan
d73abd4b09 Disallow interrupt requests on disabled endpoints.
Submitted by:	Leon Dang
MFC after:	3 days
2016-07-17 20:34:46 +00:00
Alexander Motin
6d6fccace2 Fix NCQ TRIM emulation.
When this code was written, there was no guests using it to test.
2016-07-17 14:13:47 +00:00
Alexander Motin
9c4dd8bdf0 Revert unwanted change leaked into r302932. 2016-07-16 09:44:31 +00:00
Alexander Motin
ee7230f4f7 Increase I82545_MAX_TXSEGS from 20 to 64 and add checks for it.
There seems no hard limit on number of segments per packet in the chip,
and 20 appeared insufficient.  Hope 64 will be enough, but if not -- add
check to report that and drop the packet instead of corrupting stack.
2016-07-16 09:08:33 +00:00
Alexander Motin
1b4496d043 Make PCI interupts allocation static when using bootrom (UEFI).
This makes factual interrupt routing match one shipped with UEFI firmware.
With old firmware this make legacy interrupts work reliable for functions 0
of PCI slots 3-6.  Updated UEFI image fixes problem completely.
2016-07-14 17:16:10 +00:00
Alexander Motin
e95b7573d7 Make unknown register reads predictable.
Reported by:	Coverity
CID:		1357525
2016-07-12 17:38:18 +00:00
Alexander Motin
a88b19f9e2 Add missing breaks in I/O BAR read/write.
This could be important if any guest actually used those registers.

Reported by:	Coverity
CID:		1357519, 1357520
2016-07-12 17:30:37 +00:00
Peter Grehan
5dab2ac7af Implement right shift/ctl, and convert the VNC/xorg scancode
of 0xff03 into right-alt.

Reported by:	lme@
MFC after:	1 week
2016-07-11 06:31:15 +00:00
Alexander Motin
9e749f25da Add emulation for Intel e1000 (e82545) network adapter.
The code was successfully tested with FreeBSD, Linux, Solaris and Windows
guests.  This interface is predictably slower (about 2x) then virtio-net,
but it is very helpful for guests not supporting virtio-net by default.

Thanks to Jeremiah Lott and Peter Grehan for doing original heavy lifting.
2016-07-09 20:41:59 +00:00
Alexander Motin
3dd7961093 Add emulation for multiple (up to 16) MSI vectors for AHCI.
It was useless before, but may improve performance now if multiple devices
are configured and guest supports this feature.

Sponsored by:	iXsystems, Inc.
2016-07-08 21:30:18 +00:00
Alexander Motin
098f5155d1 Allow AHCI controller to support up to 32 arbitrary devices.
While old syntax is still supported, new syntax looks like this:

-s 3,ahci,hd:/dev/zvol/XXX,hd:/dev/zvol/YYY,cd:/storage/ZZZ.iso

Sponsored by:	iXsystems, Inc.
2016-07-08 21:25:37 +00:00
Enji Cooper
7e12dfe5ef Fix CTASSERT issue in a more clean way
- Replace all CTASSERT macro instances with static_assert's.
- Remove the WRAPPED_CTASSERT macro; it's now an unnecessary obfuscation.
- Localize all static_assert's to the structures being tested.
- Sort some headers per-style(9).

Approved by: re (hrs)
Differential Revision: https://reviews.freebsd.org/D7130
MFC after: 1 week
X-MFC with: r302364
Reviewed by: ed, grehan (maintainer)
Submitted by: ed
Sponsored by: EMC / Isilon Storage Division
2016-07-06 16:02:15 +00:00
Enji Cooper
eef0d63731 Fix gcc warning
Remove -Wunused-but-set-variable (`mopt`).

Approved by: re (gjb)
Differential Revision: https://reviews.freebsd.org/D7119
MFC after: 1 week
X-MFC with: r302332
Reported by: Jenkins
Reviewed by: grehan (maintainer)
Sponsored by: EMC / Isilon Storage Division
2016-07-06 05:17:56 +00:00
Enji Cooper
77334a7eb9 Fix gcc build errors with SSE 4.2 detection and gcc warnings
- Remove -Wunused-but-set-variable's (`len`, etc).
- Replace clang-specific tests in sse42_supported(..) with generic,
  FreeBSD-supported CPU feature tests, using macros and functions
  from machine/cpufunc.h and machine/specialreg.h . The previous method
  for determining SSE4.2 availability was only compatible with clang.
- Sort #includes per style(9).

Approved by: re (gjb)
Differential Revision: https://reviews.freebsd.org/D7119
MFC after: 1 week
X-MFC with: r302332
Reported by: Jenkins
Reviewed by: grehan (maintainer)
Sponsored by: EMC / Isilon Storage Division
2016-07-06 05:17:07 +00:00
Enji Cooper
73a709081c Fix gcc warnings
Remove unused function (`fifo_available`)

Approved by: re (gjb)
Differential Revision: https://reviews.freebsd.org/D7119
MFC after: 1 week
X-MFC with: r302332
Reported by: Jenkins
Reviewed by: grehan (maintainer)
Sponsored by: EMC / Isilon Storage Division
2016-07-06 05:11:39 +00:00
Enji Cooper
db17ba9691 Fix gcc warnings
- Put parentheses around bitwise OR'ed values in the `FIELD_COPY(..)` and
  `FIELD_REPLACE(..)` macros to mute warning from gcc 4.2.1.
- Remove -Wunused-but-set-variable's (`setup_addr`, `status_addr`).

Approved by: re (gjb)
Differential Revision: https://reviews.freebsd.org/D7119
MFC after: 1 week
X-MFC with: r302332
Reported by: Jenkins
Reviewed by: grehan (maintainer)
Sponsored by: EMC / Isilon Storage Division
2016-07-06 05:09:13 +00:00
Enji Cooper
98e21e80d2 Fix gcc warnings
Remove -Wunused-but-set-variable (`error`). Cast calls with
`(void)` to note that the return value is explicitly ignored.

Approved by: re (gjb)
Differential Revision: https://reviews.freebsd.org/D7119
MFC after: 1 week
Reported by: Jenkins
Reviewed by: grehan (maintainer)
Sponsored by: EMC / Isilon Storage Division
2016-07-06 05:05:03 +00:00
Enji Cooper
edb603345b Fix gcc warnings
Add `WRAPPED_CTASSERT` macro by annotating CTASSERTs with __unused
to deal with -Wunused-local-typedefs warnings from gcc 4.8+.
All other compilers (clang, etc) use CTASSERT as-is. A more generic
solution for this issue will be proposed after ^/stable/11 is forked.

Consolidate all CTASSERTs under one block instead of inlining them in
functions.

Approved by: re (gjb)
Differential Revision: https://reviews.freebsd.org/D7119
MFC after: 1 week
Reported by: Jenkins
Reviewed by: grehan (maintainer)
Sponsored by: EMC / Isilon Storage Division
2016-07-06 05:02:59 +00:00
Enji Cooper
f94fd843f4 Fix gcc warnings
Put cfl/prdt under AHCI_DEBUG #defines as they are only used in
those cases.

Approved by: re (gjb)
Differential Revision: https://reviews.freebsd.org/D7119
MFC after: 1 week
Reported by: Jenkins
Reviewed by: grehan (maintainer)
Sponsored by: EMC / Isilon Storage Division
2016-07-06 04:58:42 +00:00
Enji Cooper
9c9eaf63e3 Fix gcc warnings
- Remove -Wunused-but-set-variable (newcpu)
- Always return VMEXIT_CONTINUE as the code always set retval to that value.

Approved by: re (gjb)
Differential Revision: https://reviews.freebsd.org/D7119
MFC after: 1 week
Reported by: Jenkins
Reviewed by: grehan (maintainer)
Sponsored by: EMC / Isilon Storage Division
2016-07-06 04:56:45 +00:00
Peter Grehan
2cf9911fc1 Import bhyve_graphics into CURRENT. Thanks to all who tested
this on the branch.

Original commit message:
  Initial bhyve native graphics support.

  This adds emulations for a raw framebuffer device, PS2 keyboard/mouse,
  XHCI USB controller and a USB tablet.

  A simple VNC server is provided for keyboard/mouse input, and graphics
  output.

  A VGA emulation is included, but is currently disconnected until an
  additional bhyve change to block out VGA memory is committed.

  Credits:
   - raw framebuffer, VNC server, XHCI controller, USB bus/device emulation
      and UEFI f/w support by Leon Dang
   - VGA, console/g, initial VNC server  by tychon@
   - PS2 keyboard/mouse jointly done by tychon@ and Leon Dang
   - hypervisor framebuffer mem support by neel@

  Tested by: Michael Dexter, in a number of revisions of this code.

  With the appropriate UEFI image, FreeBSD, Windows and Linux guests can
  installed and run in graphics mode using the UEFI/GOP framebuffer.

Approved by:	re (gjb)
2016-07-04 03:19:06 +00:00
Roman Bogorodskiy
6ee52c658c bhyve: improve memory size documentation
A couple of minor memory size option related nits:

 - use common name 'memsize' (instead of 'max-size' or just 'size')
 - bhyve: update usage with memsize unit suffix, drop legacy "MB"
   unit
 - bhyveload: update usage with memsize unit suffix
 - bhyve(8): document default size
 - bhyveload(8): use memsize formatting like it's done
   in bhyve(8)

Reviewed by:            wblock, grehan
Approved by:            re (kib), wblock, grehan
Differential Revision:  https://reviews.freebsd.org/D6952
2016-06-26 14:44:01 +00:00
Baptiste Daroussin
86bdfe1565 Improve error message when failing to open a backing file
When bhyve cannot open a backing file, it now says explicitly which file
could not be opened

Note that the change has only be maed in block_if.c and not in
pci_virtio_block.c as the error will always be catched by the first

PR:		202321 (different patch)
Reviewed by:	grehan
MFC after:	3 day
Sponsored by:	Gandi.net
Differential Revision:	https://reviews.freebsd.org/D6576
2016-05-27 11:46:54 +00:00
Pedro F. Giffuni
9f3dba686c bhyve: consider the bogus case of a negative bar idx.
This is a followup to r297472 to squelch Coverity.

CID:	1194319
2016-05-13 14:59:02 +00:00
Pedro F. Giffuni
40dbeed32b bhyve: replace uninitialized variable "offset".
Use io->io_req.br_offset instead.

Suggested by:	grehan
CID:		1288937
2016-05-13 14:38:04 +00:00
Marcelo Araujo
59c895f143 Use MIN()/MAX() macros from sys/param.h.
Reviewed by:	grehan
Differential Revision:	https://reviews.freebsd.org/D6054
2016-04-22 06:25:32 +00:00
Peter Grehan
e37bf586eb Don't use SYSDIR to avoid conflicts with existing usage.
Also, use SRCTOP to locate the top of the source tree
instead of a relative path.

PR:	208856
2016-04-20 17:05:32 +00:00
Roman Bogorodskiy
c2202d41f9 Update the bhyve(8) man page:
- Document powering off by sending SIGTERM signal
 - Document exit codes

Reviewed by:		wblock, neel
Approved by:		wblock
Differential Revision:	D5982
2016-04-20 06:29:03 +00:00
John Baldwin
cff92ffd4d Always emit an error message on passthru configuration errors.
Previously, many errors (such as the PCI device not being attached
to the ppt(4) driver) resulted in bhyve silently exiting without
starting the virtual machine.  Now any errors encountered when
configuring a virtual slot for a PCI passthru device should be noted
on stderr.

Reviewed by:	neel
Differential Revision:	https://reviews.freebsd.org/D5990
2016-04-19 20:43:05 +00:00
Glen Barber
0edd2576c0 MFH
Sponsored by:	The FreeBSD Foundation
2016-04-16 02:32:12 +00:00
John Baldwin
5c40acf8b5 Handle PBA that shares a page with MSI-X table for passthrough devices.
If the PBA shares a page with the MSI-X table, map the shared page via
/dev/mem and emulate accesses to the portion of the PBA in the shared
page by accessing the mapped page.

Reviewed by:	grehan
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D5919
2016-04-13 18:39:33 +00:00
Glen Barber
876d357fa7 MFH
Sponsored by:	The FreeBSD Foundation
2016-04-11 15:24:59 +00:00
Peter Grehan
5ccf6ce169 Allow the location of the kernel source tree to be overridden.
This makes it easier for the bhyve executable to be built
out of the tree.
2016-04-10 05:58:19 +00:00
Glen Barber
2263fb580e MFH
Sponsored by:	The FreeBSD Foundation
2016-04-06 01:44:21 +00:00