Commit graph

1412 commits

Author SHA1 Message Date
Tina Zhang
c834b038c2 devices: virtio: iommu: get iova_max_addr according to ranges' info
Previously the iova_max_addr was got according to the cpu physical
address size. Since the cpu physical address is no more than the maximum
iova size provided by hardware iommu, the iova space size can work for
any passthrough devices. But it may not utilize the whole iova space, as
the iova size isn't got from the underlying hardware iommu.

This patch introduces a way to get iova_max_addr according to the iommu
ranges' info, therefore the iova_max_addr can be precisely calculated.

BUG=b:185084350
TEST=Boot a crosvm guest with vIOMMU enabled

Change-Id: I4ed37bf158208d61663a4bf474549df4fce3adf5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3580373
Reviewed-by: David Stevens <stevensd@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: David Stevens <stevensd@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-04-28 04:43:11 +00:00
Tina Zhang
349247860c devices: virtio: iommu: assign a sensible default value to page_size_mask
Assign a sensible default value to page_size_mask and reject the empty
page_size_mask case.

BUG=b:185084350
TEST=Boot a crosvm guest with vIOMMU enabled

Change-Id: Id711c9ff25265f707618a58eb212fd5ca16383e8
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3580372
Reviewed-by: David Stevens <stevensd@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: David Stevens <stevensd@chromium.org>
2022-04-28 04:43:10 +00:00
Richard
8b62a101cf vhost-user handler: Upstream Windows handler.rs device implementation
Also update vsock handler enum usage

Bug: b:228081882
Test: built and presubmits
Change-Id: I7c771a84632c1acb819ecb7eb93b7351468ffa8a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3600919
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Richard Zhang <rizhang@google.com>
2022-04-28 00:55:47 +00:00
Alexandre Courbot
8452002639 devices: vhost-user: handler: use the same run loop for all handler types
The VVU runner had to use a dedicated run loop as the event signaling
availability of vhost-user commands required being explicitly read to go
low. Fix this by decreasing the event counter when reading buffers on
the VvuDevice. On top of allowing the handler event to behave as
expected (i.e. being readable iif there is input pending), this is also
safer as one buffer write does not necessarily correspond to exactly one
vhost-user command, as the previous code assumed.

As it turns out, this also produces a run loop that is generic enough to
be reused with the vhost-user VVU device, reducing some more technical
debt along the way.

BUG=b:229554679
TEST=vhost-user console device works.
TEST=vvu console device works and does not receive spurious events from
the vhost-user request handler.
TEST=vhost-user vsock device works (tested with socat on both ends).
TEST=VVU vsock device works (tested with socat on both ends).

Change-Id: I54e53087bf9e3447d0ab4a8a0ae26079a439f97c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3585202
Reviewed-by: Richard Zhang <rizhang@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2022-04-27 00:07:57 +00:00
David Stevens
1af4dcd7fd devices: virtio: iommu: reset on detach
Add support to virtio-iommu for detaching virtio device endpoints from
their domains. Passthrough devices do not support detaching due to VFIO
limitations.

BUG=b:230065032
TEST=start VVU block backend, connect and kill sibling, restart backend

Change-Id: Ie54fa5f4ecc732d41061eaaca36ed616a112124b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3600173
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: David Stevens <stevensd@chromium.org>
2022-04-26 09:30:21 +00:00
Alexandre Courbot
f82754c78c virtio: console: inline write_output function
These two lines are called from one place and do not justify having a
dedicated function.

BUG=b:228912920
TEST=cargo build

Change-Id: Ia57b8f74bb6fa9c7b78e7caa56ea3f7c3ce259db
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3600163
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-04-23 03:51:53 +00:00
Richard
6601d6cf36 vhost-user handler: Upstream Windows handler.rs vmm implementation
System specific code refactored into "sys" module

Bug: b:228081882
Test: built and presubmits
Change-Id: Id9caacb23cc7fcd8ca8640ce7292562809f0f71e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3601236
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Richard Zhang <rizhang@google.com>
2022-04-22 18:27:10 +00:00
Pierre-Clément Tosi
5edab50b7c virtio: Add default VirtioDevice::supports_iommu()
Introduce a way for virtio devices to broadcast their need for a
virtio-iommu without relying on parsing their feature bits, as
VIRTIO_F_ACCESS_PLATFORM may be set for other reasons than needing an
IOMMU.

Bridge the gap between PciDevice::supports_iommu() and that new method
in VirtioPciDevice.

Use the new method to enable virtio-iommu support in VirtioVHostUser.

BUG=b:223546213
BUG=b:226644087
TEST=tools/dev_container tools/run_tests --target=vm:aarch64

Change-Id: I5c20def2b96ee971f3d56776095635a984feccfe
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3571561
Reviewed-by: Andrew Walbran <qwandor@google.com>
Reviewed-by: David Stevens <stevensd@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2022-04-22 10:07:35 +00:00
Noah Gold
486fa03648 net_util: refactor unix for cross platforming.
BUG=b:213151463

TEST=bots

Change-Id: I67d43171df084392175261de98c8dc0404a933d6
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3598233
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Noah Gold <nkgold@google.com>
2022-04-22 01:37:58 +00:00
Noah Gold
78ef113617 cros_async: make AsyncTimer use base::Timer
TimerFd is the sys_util era Unix-specific timer, which doesn't support Windows.
This CL moves us to base::Timer, which is the cross platform equivalent.

Thanks to acourbot@ for suggesting the splits in this series.

BUG=b:213147081
TEST=see final CL in series.

Change-Id: I41c8ad88da77c48397ed466ff11aecd703c470a8
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3583612
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Noah Gold <nkgold@google.com>
2022-04-19 05:37:41 +00:00
Noah Gold
084aa95af1 cros_async: make AsyncEvent use base::Event
EventFd is the original sys_util era Unix-specific Event. We need to use
base::Event, which is the cross platform event that works on Windows.

Thanks to acourbot@ for suggesting the splits in this series.

BUG=b:213147081
TEST=see final CL in series.

Change-Id: I174313cb544c5fc3768810365a42e6eaac1ca91a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3583611
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Noah Gold <nkgold@google.com>
2022-04-19 05:37:40 +00:00
Risan
ab11843e86 fs: Support setting project inheritance flag
This CL allows passthrough to set project inheritance flag through
cryptohome since setting project inheritance flag cannot be done in
user namespace.

BUG=b:226908517
TEST=atest android.appsecurity.cts.StorageHostTest

Change-Id: Icdde5164e2e6f8655fff28748f6bc18449ad36c3
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3585215
Reviewed-by: Ryo Hashimoto <hashimoto@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Risan <risan@chromium.org>
2022-04-19 00:18:41 +00:00
Shao-Chuan Lee
105d68747b Revert "rutabaga_gfx: remove fence polling and enable async callback"
This reverts commit a999284da2.

This also introduces two extra `use` statements to fix the corresponding
errors in the LUCI build, which did not occur in local builds.

Reason for revert: caused deadlock in virglrenderer

Original change's description:
> 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>

BUG=b:175527587,b:228782431,b:228521246
TEST=arc.Notification.vm on kukui-arc-r
TEST=dEQP-VK.wsi.android.swapchain.create#image_usage on dedede/kukui-arc-r

Change-Id: I616e3f283a60fe6a260f796cddce67c548b5e304
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3584076
Reviewed-by: Kazuhiro Inaba <kinaba@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Ryan Neph <ryanneph@google.com>
2022-04-13 17:46:41 +00:00
Shao-Chuan Lee
a1fac454ed Revert "gfxstream: support async fence cb"
This reverts commit 3c2d5cefa2.

Reason for revert: depends on crrev.com/c/2860746

Original change's description:
> 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>

BUG=b:192614792,b:228782431,b:228521246
TEST=arc.Notification.vm on kukui-arc-r
TEST=dEQP-VK.wsi.android.swapchain.create#image_usage on
dedede/kukui-arc-r

Change-Id: I4d2c43320880e38e8396cee3b96ce8c32addf39b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3584075
Reviewed-by: Kazuhiro Inaba <kinaba@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Commit-Queue: Ryan Neph <ryanneph@google.com>
2022-04-13 17:46:40 +00:00
Keiichi Watanabe
c59db48131 devices: vvu: Unbind driver first regardless of driver type
When a VVU driver starts, the current implementation tries to unbind
virtio-pci driver unconditionally, but this can fail when no driver is
bounded or another driver is bounded.

Instead of assuming virtio-pci driver is bounded, we should unbind the
bounded driver regardless of its type by writing to
"/sys/bus/pci/devices/${ADDR}/driver/unbind", which is a symlink to the
unbind file of the currently bounded driver.

This change will allow the vvu driver to open a vvu device after a previous
driver exists. (Note that our vvu device hasn't supported
reinitialization yet.)

BUG=b:216407443
TEST=run vvu on workstation

Change-Id: Ib6c3ac1cd51a8018573596eef9fe0fd759450c07
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3581833
Reviewed-by: David Stevens <stevensd@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Abhishek Bhardwaj <abhishekbh@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2022-04-13 02:27:28 +00:00
Alexandre Courbot
b32bcc4edc devices: vvu: handler: do not run executor within async method
run_vvu() was running the request handling loop on the executor passed
as argument, even though it is an async function that is being run on
the very same executor.

BUG=b:194137301
TEST=VVU console device is working.

Change-Id: I8c79f9285329c07b3411b2d4121c94d0e5c88a49
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3578142
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-04-12 02:11:37 +00:00
Daniel Verkamp
f620437e8b virtio_sys: regenerate bindings
BUG=b:218388029
TEST=tools/presubmit --quick

Change-Id: I381dbc4d97e3a0a99dedd4416a347388daf4ccf8
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3339853
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-04-11 21:14:01 +00:00
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