Commit graph

1395 commits

Author SHA1 Message Date
Daniel Verkamp
f35f636cc5 Rust 1.60 clippy fixes
BUG=None
TEST=tools/presubmit # with rust-toolchain updated to 1.60.0

Change-Id: I5772e8b0593f8d92003e93aeb2145e87610abe2e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3577332
Reviewed-by: Anton Romanov <romanton@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-04-11 20:40:36 +00:00
Daniel Verkamp
fa0ffe7e81 base: accept AsRawDescriptor in PollContext/EpollContext/mmap
This lets us remove the wrap_descriptor() calls.

A few other places around the tree need to be updated to use Descriptor
instead of RawFd to match the new API.

BUG=None
TEST=tools/presubmit

Change-Id: Ie290f082b50bcf6ae8f77ce6a8b7615fad1be480
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3572770
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-04-11 20:27:06 +00:00
Peter Fang
63c3a69e21 devices: vfio_pci: implement coordinated PM using PCI config accesses
Perform coordinated PM in the hypervisor for vfio-pci devices using
several sysfs interfaces added to the hypervisor kernel.

The interfaces used and the PCI header hacks are identical to the ones
previously added to pcie.

This is only a temporary solution. A proper communication channel should
be implemented in the future.

BUG=b:189182339
TEST=boot manatee and verify the sysfs interfaces are used correctly in
     the hypervisor

Change-Id: I8022ed17e4bf898065b5ebcf8fe09f5c8e3c3fa4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3578021
Reviewed-by: Dmytro Maluka <dmy@semihalf.com>
Reviewed-by: Tomasz Nowicki <tnowicki@google.com>
Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dmitry Torokhov <dtor@chromium.org>
2022-04-11 19:09:27 +00:00
Peter Fang
87f947a4ff pcie: implement coordinated PM using PCI config accesses
Perform coordinated PM in the hypervisor using several sysfs interfaces
added to the hypervisor kernel.

- /sys/bus/pci/devices/X/power/coordinated
  Writing "enter" to this file will cause the device to enter PCI
  coordinated PM
  Writing "exit" to this file will cause the device to exit PCI
  coordinated PM

- /sys/bus/pci/devices/X/power/op_call
  A write to this file will cause the device to perform a PCI PM
  operation

- /sys/bus/pci/devices/X/power_state
  A read from this file returns a snapshot of the device's current power
  state, including PCI_D3cold

The guest makes use of these interfaces through a couple of
quick-and-dirty hacks in the PCI header in the guest.

- Byte writes to the "Revision ID" register are interpreted as PM op
  calls
- Reads from the "BIST" register are interpreted as device PCI power
  state

The PCI spec defines the "Revision ID" register as read-only. The "BIST"
register is mostly considered legacy and its use has not been observed
in recent Chromebooks.

The rest of the PCI config accesses remain the same.

This is only a temporary solution. A proper communication channel should
be implemented in the future.

BUG=b:189182339
TEST=boot manatee and verify the sysfs interfaces are used correctly in
     the hypervisor

Change-Id: I7570728257300435d0fc77076d1e3f6bea6af5e3
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3455125
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dmytro Maluka <dmy@semihalf.com>
Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
Commit-Queue: Dmitry Torokhov <dtor@chromium.org>
2022-04-11 17:54:51 +00:00
David Stevens
4257919fa7 devices: vvu: poll when opening vvu device
Launching a VVU device requires access to /dev/vfio/$vfio_group. The
permissions on those files can't be set by upstart, since the files
don't exist until a vvu device process binds its vvu pci device to
vfio-pci. Instead, the permissions are set via udev rules.
Unfortunately, there is no good way to wait for udev to modify the
permissions, so the device process just needs to poll until it is
successfully able to open its device.

BUG=b:222424090
TEST=vmc start termina

Change-Id: Id8668c66ff7ddaa7bb43061979ead51d12cde8f2
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3574422
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: David Stevens <stevensd@chromium.org>
2022-04-11 04:56:18 +00:00
Daniel Verkamp
aebda741ff devices: pci: convert PciAddress::from_string into FromStr impl
Implement the standard FromStr trait, since it has the same prototype as
our existing from_string function.

BUG=None
TEST=cargo test -p devices pci_address

Change-Id: I41bb77638891bfcc39f9fb555b3463f2f92c029f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3576956
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-04-08 19:42:39 +00:00
David Stevens
e123e39433 devices: vvu: use CrOS memory size for BAR size
The size of the BAR limits the size of sibing VMs that can be used with
the vvu proxy device. Since concierge creates VMs with memory size a
little bit smaller than the amount of physical memory it sees, use the
CrOS guest's memory size for the vvu proxy device bar size. Since what
consumes memory is the mapping of sibling memory into the CrOS guest
(not the BAR itself), it's not necessary to strictly limit BAR size.

BUG=None
TEST=vmc start termina

Change-Id: I899e3f126b7ab32665aeabc05f51d3b121dec808
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3574423
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: David Stevens <stevensd@chromium.org>
2022-04-08 12:30:44 +00:00
Woody Chow
91296bdee0 devices: vvu: virtio-iommu support in virtio-vhost-user
Make vvu use devices use VFIO to manage their virt queues. This
alleviates the need to use noiommu mode. However, it is still necessary
to use `vfio_iommu_type1.allow_unsafe_interrupts=1`.

BUG=b:202151642,b:215310597
TEST=launch sibling with vvu + virtio-iommu

Cq-Depend: chromium:3565728, chromium:3565260
Change-Id: If418524598c40a37d41c0ffaa1dcc0f8ee11fcb3
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3501052
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: David Stevens <stevensd@chromium.org>
2022-04-08 01:39:22 +00:00
Long Cheng
3491bdfc56 Revert "Apply usb configuration even configuration is not changed."
This reverts commit 7ea795dc56.

Reason for revert: This cl cause some Android devices in debug mode fail to connect to crostini 

Original change's description:
> Apply usb configuration even configuration is not changed.
>
> Apply usb configuration even when configuration is not changed. When
> Android sets usb configuration, it expects the device connection gets reset.
> This change will pass CTS verifer  USB devices tests which try to
> observe device connection and reconnection after set unchanged usb
> configuration.
>
> BUG=b:123374026
> TEST= Run cts verifer USB device tests in ARCVM.
> TEST=lsusb in crostini. device shows.
>
> Change-Id: I5856d1173a3ea1a65c6fa205cb9facd407706a6c
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3413815
> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
> Auto-Submit: Long Cheng <lgcheng@google.com>
> Tested-by: kokoro <noreply+kokoro@google.com>
> Commit-Queue: Long Cheng <lgcheng@google.com>

Bug: b:123374026
Change-Id: Ie5a91a3af5083f2174a329add53763ccc4d1e82b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3575287
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Long Cheng <lgcheng@google.com>
2022-04-07 20:21:44 +00:00
Dmytro Maluka
0ac97979b6 direct_irq: Add support for host wakeup capable IRQs
Add userspace counterpart to host kernel change CL:3571844 to support
physical wakeup of the machine from suspend via forwarded interrupts
from wakeup-capable devices owned by CrOS (touchpad, keyboard etc).

Add --direct-wake-irq param for marking forwarded IRQs as wakeup
capable.

BUG=b:227735609
TEST=put DUT in s2idle and wakeup by keyboard and LID open

Change-Id: I28fe26a06ca88920e55caf1121c5774711db2160
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3572121
Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Tomasz Nowicki <tnowicki@google.com>
2022-04-07 10:40:41 +00:00
Alexandre Courbot
93aefc512c devices: block: merge device and vhost-user handle_queue functions into one
Both the regular asynchronous block device and the vhost-user one had
their own handle_queue() method which are almost identical ; they can be
merged into one function if we tune the arguments of the original to
make those of the vhost-user version, and implement SignalableInterrupt
for interrupts behind a Rc<RefCell<>>, similarly to what is already done
for Arc<Mutex<>>.

BUG=b:228385297
TEST=block device works with both regular VM and using virtio-vhost-user.

Change-Id: I657bd8331275d3c3827b2f799562bcd8a272d07b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3565302
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-04-07 01:53:38 +00:00
Dmitry Torokhov
a4a3b1dd6c devices: irq_event: implement as_raw_descriptors() and use them
This implements AsRawDescriptors trait for IrqEdgeEvent and
IrqLevelEvent and updates the users.

BUG=None
TEST=./tools/presubmit

Change-Id: I879531e98396f1eb8e99db73cb00d7b3330101a9
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3552317
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dmitry Torokhov <dtor@chromium.org>
2022-04-07 01:41:56 +00:00
Dmitry Torokhov
7997f0c28f devices: vfio_platform: add specialized assign_{edge|level}_platform_irq()
The new specialized functions take IrqEdgeEvent and IrqLevelEvent
arguments, so that callers can use them directly.

BUG=None
TEST=./tools/presubmit

Change-Id: I2e5c5d92a6c292f31ad6cfb8652f0c46f0a7a958
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3548067
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dmitry Torokhov <dtor@chromium.org>
2022-04-07 01:41:53 +00:00
Dmitry Torokhov
f021a62130 devices: irqchip: add specialized register_{edge|level}_irq_event()
The new specialized functions take IrqEdgeEvent and IrqLevelEvent
arguments, so that callers can use them directly.

BUG=None
TEST=./tools/presubmit

Change-Id: I2c1272e31f6b20eb22743b003bd23b9c1105cda6
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3548066
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dmitry Torokhov <dtor@chromium.org>
2022-04-07 01:41:52 +00:00
Dmitry Torokhov
c11a18b713 devices: vfio_platform: change assign_platfrom_irq() to accept events refs
This is in preparation for callers to use IrqEdgeEvent and IrqLevelEvent
and follows general principle in crosvm that if entity needs to hold on
to an event, the entity is responsible for cloning it.

BUG=None
TEST=./tools/presubmit

Change-Id: I9da9a5156108355449b290a2a848257816370fb2
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3548064
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dmitry Torokhov <dtor@chromium.org>
2022-04-07 01:41:51 +00:00
Dmitry Torokhov
99067756fb devices: vfio_platform: make assign_platform_irq() return errors
This allows to make the code more concise and gives callers a chance
to act upon errors.

BUG=None
TEST=./tools/presubmit

Change-Id: Ibd9d53270bc21f90fcb44c673d2c7f3763a44c3b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3548063
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dmitry Torokhov <dtor@chromium.org>
2022-04-07 01:41:50 +00:00
Noah Gold
44306221c1 devices: Upstream Windows vhost-user net device.
Splits the vhost-user device into unix & Windows components, and
upstreams the Windows side. Note that we can't build devices on Windows
yet in crosvm because we have to upstream a fair bit more first
(net_util, cros_async, the vmm side of the vhost-user device).

Since net_util isn't upstreamed yet, we've made some very minor changes
to keep things consistent & building on Linux.

TEST=unix is tested by bots upstream & downstream; windows is tested by
bots downstream only.

BUG=b:226233737

Change-Id: Ie3f9818ff93c9e0085a5434055f9dc71c6f6851c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3549854
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Noah Gold <nkgold@google.com>
2022-04-07 01:19:21 +00:00
Dmitry Torokhov
7b7a20620f devices: direct_irq: switch to using IrqEdgeEvent and IrqLevelEvent
With users of IRQ code switching to dedicated objects to represent IRQ
signalling, let's introduce DirectIrq::new_edge() and
DirectIrq::new_level() methods accepting appropriate event types.

BUG=None
TEST=./tools/presubmit

Change-Id: I18d9373c8cf5ed9db7c33227ca8b67e0a9136f6c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3548062
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dmitry Torokhov <dtor@chromium.org>
2022-04-06 23:46:08 +00:00
Dmitry Torokhov
d77eab2921 devices: acpi: convert to using IrqLevelEvent
Now that we have enough infrastructure in place, we can convert
ACPIPMResource to use IrqLevelEvent for both the host (direct) and guest
SCI handling, which makes the code cleaner.

BUG=None
TEST=./tools/presubmit

Change-Id: Ia3c522a9b143b852bf9c34f62a975b670530a82f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3548065
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dmitry Torokhov <dtor@chromium.org>
2022-04-06 23:21:19 +00:00
Daniel Verkamp
c30abefc07 vfio_sys: regenerate bindings
BUG=b:218388029
TEST=tools/presubmit --quick

Change-Id: Ia1dc0daeb8d642ca94336c671639691930a246f2
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3339852
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-04-06 19:20:35 +00:00
Daniel Verkamp
ac0b33ad9f net_sys: regenerate bindgen bindings
This replaces the bindgen-based bindings with Rust libc crate types and
constants where possible, so our custom bindings are significantly
reduced.

BUG=b:218388029
TEST=tools/presubmit --quick

Change-Id: I7f20ecf5ccd651456f9a23ce7964fdbd0e8064ef
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3339851
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-04-06 19:20:34 +00:00
Dmitry Torokhov
dd21595173 devices: pci: change assign_irq() to accept IrqLevelEvent
This continues conversion from a pair of Event objects to single
IrqLevelEvent.

BUG=None
TEST=./tools/presubmit

Change-Id: Iec7e94f4c40cc29fa612cc3ae364cc6f8b0d0177
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3548061
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dmitry Torokhov <dtor@chromium.org>
2022-04-06 18:54:49 +00:00
Dmitry Torokhov
be3bbc0f37 devices: pl030: convert to using IrqEdgeEvent
This converts pl030 code to use IrqEdgeEvent.

BUG=None
TEST=./tools/presubmit

Change-Id: Ibc216d1989d90880176e70821f3d98ccc41302f0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3572999
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dmitry Torokhov <dtor@chromium.org>
2022-04-06 18:54:48 +00:00
Dmitry Torokhov
ccb9e902d0 devices: ac97: convert to using IrqLevelEvent
This converts AC97 code to use IrqLevelEvent.

BUG=None
TEST=./tools/presubmit

Change-Id: If388b724db808891a5bcb5ad040a7dfc4a4dff9b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3548060
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dmitry Torokhov <dtor@chromium.org>
2022-04-06 18:54:47 +00:00
Dmitry Torokhov
e1196921a7 devices: xhci: convert to using IrqLevelEvent
This converts XHCI code to use IrqLevelEvent.

BUG=None
TEST=./tools/presubmit

Change-Id: I503ab76e162c4175c0be62a6d9ddf8da18f8617b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3548059
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dmitry Torokhov <dtor@chromium.org>
2022-04-06 18:54:46 +00:00
Dmitry Torokhov
3d159f8e50 devices: pcie: convert to using IrqLevelEvent
This converts PciBridge to use IrqLevelEvent.

BUG=None
TEST=./tools/presubmit

Change-Id: I01b8da5a6bc843a1b065c0e19e026aa5ddaff71e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3548058
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dmitry Torokhov <dtor@chromium.org>
2022-04-06 18:54:45 +00:00
Dmitry Torokhov
f6f5789f51 devices: vfio_pci: convert to using IrqLevelEvent
This converts VfioPciDevice to use IrqLevelEvent.

BUG=None
TEST=./tools/presubmit

Change-Id: Idc3dd32ec92936e771f0d418aa4c0dfb6eb9d3ab
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3548057
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dmitry Torokhov <dtor@chromium.org>
2022-04-06 18:54:43 +00:00
Dmitry Torokhov
7e17b32eaa devices: virtio: pci device: convert to using IrqLevelEvent
This converts VirtioPciDevice to use IrqLevelEvent.

BUG=None
TEST=./tools/presubmit

Change-Id: Ifcc72c1dd9e1fb1f116ab78f3639363dfb0136b3
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3548056
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dmitry Torokhov <dtor@chromium.org>
2022-04-06 18:54:42 +00:00
Dmitry Torokhov
7a8ce70bae devices: virtio: convert Interrupt to use IrqLevelEvent
Instead of using a separate pair of events in Interrupt structure
convert it to use IrqLevelEvent.

BUG=None
TEST=./tools/presubmit

Change-Id: Ibf0fa69b96de4686fc58a1a431c3a983b7ed4de1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3546575
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dmitry Torokhov <dtor@chromium.org>
2022-04-06 18:54:41 +00:00
Dmitry Torokhov
bcc5368cc1 devices: goldfish battery: convert to using IrqLevelEvent
Use IrqLevelEvent instead of 2 separate event for interrupt handling.

BUG=None
TEST=./tools/presubmit

Change-Id: I56e57044b665565cf1b42831e8ac2240e41bd102
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3536894
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dmitry Torokhov <dtor@chromium.org>
2022-04-06 18:54:40 +00:00
Dmitry Torokhov
16f37e0f65 devices: introduce IrqLevelEvent and IrqEdgeEvent
Instead of passing primary trigger and resample events separately when
implementing devices using level-triggered interrupts, let's create
a dedicated IrqLevelEvent, and its counterpart, IrqEdgeEvent.

BUG=None
TEST=CQ

Change-Id: Id51dd805cf8994368fa12a6df0475e433b6f03fb
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3536893
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dmitry Torokhov <dtor@chromium.org>
2022-04-06 18:54:38 +00:00
Steven Moreland
070407809e Print error when netlink socket not created.
The panic here didn't show what error might be encountered
(EPERM, for instance).

Bug: 228077254
Test: check log on error
Change-Id: I56f34f87430a68266af85ba1d0abb2aeb2c05407
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3569267
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Andrew Walbran <qwandor@google.com>
Commit-Queue: Steven Moreland <smoreland@google.com>
2022-04-06 17:33:09 +00:00
Alexandre Courbot
c7cd0e0114 Move libvda to media/libvda
As we are going to introduce more media-related crates, reserve the
"media" folder as a placeholder for them, starting with the existing
libvda.

BUG=b:169295147
BUG=b:214478588
TEST=cargo build --features "video-decoder,video-encoder,libvda"

Change-Id: I1b2ec65cbba8b735db3d19845c504546fa1c64ca
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3565623
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-04-06 01:19:07 +00:00
Daniel Verkamp
e584f835a8 devices: vvu: refactor to use PciAddress
This removes some duplicated PCI address string parsing code in PciSlot.

BUG=None
TEST=tools/presubmit

Change-Id: Ib38f8ef397d3fbed50806c96d46b85fc8257f1e9
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3534505
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-04-05 19:55:01 +00:00
Daniel Verkamp
971a49e946 devices: pci: add domain to PciAddress fmt output
This was accidentally omitted in the original change. Add some basic
tests to make sure it doesn't regress.

BUG=None
TEST=cargo test -p devices pci_address

Change-Id: Iaedf2357ae02d6203e8296e9765f5ce3bf5bdc84
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3534507
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-04-05 19:55:00 +00:00
Daniel Verkamp
67e64f7810 devices: virtio: block: report 1 segment max on Windows
As part of the Windows porting effort, the virtio-block device was
changed to only report the VIRTIO_BLK_F_SEG_MAX feature on Linux, since
the maximum number of segments is based on the maximum number of iovec
entries supported by the system as reported by iov_max, which isn't
available on Windows.

Instead, we can support the VIRTIO_BLK_F_SEG_MAX feature everywhere, but
report that only one segment is supported on Windows. This results in
the same effective behavior for the Linux virtio-blk guest driver, which
assumes one segment if the feature is not supported, but it lets us
remove some platform-specific differences in the device and test code.

BUG=b:213149164
TEST=cargo test -p devices block

Change-Id: Id3160b01ee32a2694d40ef6f3d3a286cdb043ea8
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3564230
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-04-05 18:18:22 +00:00
Daniel Verkamp
bc712f12dc devices: virtio: block: add missing copyright headers
BUG=None
TEST=None

Change-Id: Ic4be21c0a2eed2f149a9eee8e6ac2f83c0cf9eb2
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3564229
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-04-05 18:18:21 +00:00
Lingfeng Yang
3c2d5cefa2 gfxstream: support async fence cb
This adds the asynchronous interrupts in crosvm-gpu for gfxstream.
This will allow gfxstream to alternate between the main signalling
method (ASG [1]) and the more traditional interrupts when it
makes sense performance-wise.

gfxstream also requires new write fence callbacks that take into
account the ring_idx and ctx_id where the fence is on.

[1] goto.google.com/address-space-graphics

BUG=b:192614792
TEST=Tested locally with Vulkan cereal

Change-Id: I010d9ebfc71594b393fee062b984a4c6d69404d8
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3027489
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2022-04-05 16:34:56 +00:00
Vikram Auradkar
0953c58edb upstream a few file from dev/pci
The files include
- coiommu.rs
- msix.rs
- pci_configuration.rs
- pci_root.rs
- pci_bridge.rs
- pvpanic.rs
- stub.rs

Rest of the changes in the patch are supporting changes to build
and test.

Test: presubmit
Bug: b:213149278

Change-Id: Ic8fbcda4ad95370689b232c1656e782ee33425e1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3541336
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
2022-04-04 21:49:33 +00:00
Alexandre Courbot
dba517d0ef devices: console: simplify handle_input()
Instead of handling special conditions by setting a variable and
breaking from the loop into the error handling code, just return the
right error code directly.

BUG=None
TEST=serial console input works.

Change-Id: I02c9b8fd4bc64e4e0f16308d65cd05ace41c5756
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3565299
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-04-03 12:45:54 +00:00
Alexandre Courbot
566f42655e devices: vhost-user: console: remove unneeded VIRTIO_F_VERSION_1 feature
base_features() already sets VIRTIO_F_VERSION_1 - no need to repeat it here.

BUG=None
TEST=vhost-user serial device is working.

Change-Id: I9e9c1277629e6f4c928daf69c586f7eec63a74ed
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3565301
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-04-03 12:45:24 +00:00
Alexandre Courbot
0ff5b53914 devices: vvu: remove Arc<Mutex<>> for VvuDevice
The VvuDevice is now the sole owner of the passed VvuPciDevice. Remove
the Arc<Mutex<>> surrounding it as it has become unnecessary.

BUG=b:194137301
TEST=cargo build

Change-Id: I130a9b8da6b68524aeee784614b690bfc2ac27ad
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3565622
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-04-03 12:45:09 +00:00
Alexandre Courbot
33d1b09adf devices: vhost-user: vsock: use HandlerType
The vhost-user vsock device still uses an Option to record whether we
are using VVU or not. Our request handler has a proper type to record
that information, so use it instead. Doing so also allows us to drop a
reference to the VvuPciDevice.

BUG=None
TEST=cargo build

Change-Id: Id952d179758db679f2cd9f739b56d3acda941f69
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3565621
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-04-03 12:45:08 +00:00
Alexandre Courbot
1cb82fdb35 devices: vvu: handler: only pass needed data to HandlerType
When using VVU, the DeviceRequestHandler only needs a reference to the
VFIO device, the PCI caps, and the notification events. There is no need
to share a reference to the whole VvuPciDevice, and releasing that
reference will actually allow us to remove it as well as the
VvuPciDevice mutex in a future CL.

BUG=b:194137301
TEST=VVU block device works.

Change-Id: I077c053af8ddefa4b0d624fe6775b5072e843686
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3565620
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-04-03 12:45:07 +00:00
Alexandre Courbot
89f97d8178 devices: vvu: remove config from VvuPciDevice
This field is not used beyond the constructor and was only stored so it
can be referred by the init() method. Get rid of it by slightly
reorganizing the code.

BUG=b:194137301
TEST=cargo build

Change-Id: I4532a40ef1998ca20fdece9f0f016a36331c2e73
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3565618
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-04-03 12:45:04 +00:00
Ryan Neph
a999284da2 rutabaga_gfx: remove fence polling and enable async callback
Now that rutabaga users can provide a callback for fence
completion, fences no longer need to be polled on the main thread.

Optional polling still occurs for Rutabaga Components that still
rely on it for other purposes (e.g. virglrenderer for GL query
checking).

Also, use a BTreeMap rather a HashMap since we only expect a dozen
or so entries at most.  In such cases, a BTreeMap is faster.

* v1 (lfrb@collabora.com): remove all polling + add async_cb
* v2 (ryanneph@google.com): re-introduce optional polling to fix
      virglrenderer that relies on it for GL query checking.
* v3 (ryanneph@google.com): replace timer-based polling with
      eventfd-based poll() signaling for components that want to
      use it.

BUG=b:175527587
TEST=glxgears and vkcube in a crosvm guest VM.

Cq-Depend: chromium:3555854, chromium:3563893
Change-Id: I8e0181317e954cd15e2b8dc04c9b1329b0a6e182
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2860746
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Ryan Neph <ryanneph@google.com>
2022-04-01 15:45:58 +00:00
Daniel Verkamp
29950ef5a6 devices: make virtio tpm backend pluggable
Split the creation of the software TPM emulator from the virtio-tpm
device so that other backends can be used with virtio-tpm.

BUG=b:227283268
TEST=cargo build --features=tpm

Change-Id: Ic1ebd2ebd49615201892afbf86cd5be68f6fde8c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3213271
Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-03-31 23:03:16 +00:00
Richard
66eb01adec virtio-block: Upstream window's block device
This CL mainly splits up Window's and Unix code into their own files.

seg_max is now a part of windows, but will always be set to 0
now. seg_max
in virtio_blk_config was being set to 0 on windows anyways.`

Bug: b:213149164
Test: cargo test and presubmit
Change-Id: Icdd481dd8e05c90ac8c1f29773d51312b64d3b2b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3553760
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Richard Zhang <rizhang@google.com>
2022-03-31 17:28:21 +00:00
Alexandre Courbot
c6ad83fbd4 devices: vsock: allow to parse options using serde_keyvalue crate
Use our new serde_keyvalue crate to annotate the
VhostVsockDeviceParameter config structure and allow us to create a
vsock device configuration from a key-values string. Add tests to make
sure parsing happens as expected.

Currently the vsock device is configured using the `--cid`,
`--vhost-vsock-fd` and `--vhost-vsock-device` command-line options.
While this CL introduces a way to set the vsock device up with a single
option (an ability we will eventually use), we retain the existing ones
for compatibility reasons.

BUG=b:218223240
TEST=cargo test -p devices vsock::tests::params
TEST=crosvm run with --cid parameter and check that virtio socket device
is present in the output of `lspci`.

Change-Id: Id58beee57f2ada3d2c0d353a430b038bb6c7eef3
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3473709
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-03-31 01:12:51 +00:00
Tinghao Zhang
5a792cb933 devices: vfio_pci: refactor pending bit emulation for MSI-X
When a vfio MSI-X vector got masked by guest, host vfio will release
the corresponding irqfd. Thus host device cannot trigger interrupt
via this fd and we then cannot set the pending bit. What we do instead
is to not release the irqfd but switch the registered kvm irqfd into
a new crosvm irqfd. So that when host device do trigger an interrupt,
crsovm will know about it and set the pending bit accordingly.

BUG=None
TEST=Pass through a nvme disk and tested its functionality.

Change-Id: I81c6fae7b89f1e1a445b8076bd9451a8aa9f0255
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3490239
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-03-31 00:49:29 +00:00