The queue size defines the number of available descriptors, that can be
used for exchanging messages between guest and hypervisor. Each
virtio-video command uses at least 1 descriptor (eg. CMD_QUEUE uses 2).
The amount of descriptors in use depends on the number of sessions and
buffers in input and output video queue.
In the worst case scenario the peak number can reach over 672 for 8
simultaneous streams, with 26 + 16 buffers each just for CMD_QUEUE
commands alone.
If the entire queue is overfilled with CMD_QUEUE for OUTPUT queue only,
the driver has no free descriptors for INPUT queue buffers. This leads
to encoder/decoder starvation, hence no OUTPUT buffer can be produced
and no CMD_QUEUE will finish, which leads to dead locking the device.
This patch increases the queue size with consideration of above details
with some headroom to avoid driver's deadlock.
BUG=b:204055006
TEST=App from https://github.com/chromeos/video-decode-encode-demo.git
with 8 simultaneous stream runs without blocking the device.
Change-Id: If51e340dd501b5b261518fba23fc541e3b55af8a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3606869
Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
Reviewed-by: Emilie Roberts <hadrosaur@google.com>
Reviewed-by: Chih-Yu Huang <akahuang@chromium.org>
Commit-Queue: Marcin Wojtas <mwojtas@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Several devices were accepting virtio ring flags that they don't
actually support; remove these, as well as the common base_features
flags that are provided by the generic virtio device infrastructure.
The features removed from device implementations are:
- VIRTIO_F_VERSION_1: set by base_features()
- VIRTIO_RING_F_EVENT_IDX: set by base_features()
- VIRTIO_RING_F_INDIRECT_DESC: unsupported
- VIRTIO_F_NOTIFY_ON_EMPTY: unsupported
- VHOST_F_LOG_ALL: unsupported
- VIRTIO_F_ANY_LAYOUT: unsupported; transitional devices only
BUG=None
TEST=tools/presubmit --all
Change-Id: I9619d9bb784cb47ec85ffa4e25b7a743284d6da6
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3582525
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Previously, the check would only accept exactly the combination of bits
we specify in ready_bits due to the == comparison; the second check for
the failed bit would never be reached. Instead, mask off only the bits
we are interested in checking before comparing them.
BUG=None
TEST=tools/presubmit --all
Change-Id: Ib6cccdb249adeb267282ec0e5b51c0ac6b572490
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3582524
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
This makes the VirtioDevice::device_type() function return type more
descriptive, and it lets us implement fmt::Display for the type instead
of a custom type_to_str() function.
BUG=None
TEST=tools/presubmit --all
Change-Id: Icfc2be37cf31ecab5e73f4b29c2eaaaa417317ab
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3582523
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Abhishek Bhardwaj <abhishekbh@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
This patch split msi emulation from vfio-pci to a seperate file
msi.rs and make it usable for other devices. And we make pcie
bridge use msi instead of msi-x. The reason to use msi is that
msi-x would need extra mmio bar allocation, which does not work
when bridge is hotplugged into the system.
BUG=None
TEST=check msi functionality in both pcie root port and vfio device
Change-Id: Id262e4635d074c2a952807a625c8a0bf0afbf86a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3591961
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Xiong Y Zhang <xiong.y.zhang@intel.corp-partner.google.com>
Restrict the bindgen patterns so that only the declarations from the
appropriate header are included in each binding, and add the
virtio_config binding to get the source of the VIRTIO_F_ and
VIRTIO_CONFIG_ #defines.
BUG=None
TEST=tools/presubmit --all
Change-Id: I216bd8d3540d918ad9bba162db0ae86b76d73f31
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3582522
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
More or less fully document this file to make it a good documentation
example.
BUG=None
TEST=cargo doc
TEST=cargo test -p devices --doc pci_address
Change-Id: I9a02c057135bc684ccc7897a07cb8cfce77dd388
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3630423
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Escape the square brackets in doc comments to resolve the rustdoc
warning.
BUG=None
TEST=tools/cargo-doc
Change-Id: I78f60ef65f57b213da2f0e687ee295b7e046db9e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3630421
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
When multi pcie endpoint devices are connected to one virtual pcie
root port as pcie multi function device, virtual pcie root port couldn't
inject hotplug out interrupt for each removed pcie device. Only one
hotplug out interrupt is needed for all the removed pcie devices.
When the first vfio-pci device send hotplug out vfio command, virtual
pcie root port will inject hotplug out interrrupt. Other vfio-pci device's
hotplug out vfio command just clean virtual pcie root port's structure,
and let virtual pcie root port prepare for the next hotplug in.
BUG=b:185084350
TEST=Check TBT dock's hotplug out function, TBT dock has multi pcie
devices.
Change-Id: I15c2807097c0065d2a78ef269720e57d15eeaf9e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3604291
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
When multi pcie endpoint devices are connected to one virtual pcie
root port as pcie multi function device, virtual pcie root port couldn't
inject hotplug in interrupt for each added pcie device. Only one hotplug
in interrupt is needed for all the added pcie devices.
So this commit adds a hp_interupt field into VfioCommandRequest, only
the last added pcie device sets hp_interrupt to true and requests virtual
pcie root port to inject hotplug in interrupt. Ohter added pcie devices
just create and configure vfio-pci device.
BUG=b:185084350
TEST=Check TBT dock's hotplug in function, TBT dock has multi pcie
devices.
Change-Id: I5a68ec38af9a32de9d4233b48e0aa3681e5a3ba3
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3604290
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Splits out the unix specific code in the vhost-user net device into the
sys module, and adds Windows support.
BUG=b:226233737
TEST=builds
Change-Id: I62690d007700f4ea1f55e1079b18115d6f7e0876
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3621416
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Noah Gold <nkgold@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Usually a TBT dock has one pcie switch and one or more pcie endpoint device
which connect to pcie switch's downstream port, when such TBT dock is hotplug in,
crosvm will find the first pcie endpoint device, passthrough it into guest and
put it under virtual pcie root port in guest, as one pcie root port could
connect one device only, This means only one pcie endpoint device could work
in guest now.
In order to let all the TBT dock's pcie endpoint devices work in guest, virtual
pcie switch is needed. But virtual pcie switch need more development work, as a
short solution, this commit mark all the pcie endpoint devices as multi pci
function device, then all of them could connect to one virtual pcie root port.
This commit do the following three things:
1. Search all the pcie endpoint devices under host pcie root port.
2. Record all the pcie endpoint devices attached to virtual pcie root port,
so that they could be removed in hotplug out.
3. Allocate pci function number to all the pcie endpoint devices.
BUG=b:185084350
TEST=Check TBT dock's function in guest, the TBT dock has multi pcie
endpoint device.
Change-Id: I07df3b556ba1ac8f7a7a3e49f221f0bf6c7ce97b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3604289
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
This commit use the same logic as in initramfs, let hotplug vfio
pci device bind to vfio-pci-pm driver first, if it fails, then
bind to vfio-pci driver.
Without this, there are error message about hotplug vfio pci device's
pm_ops.
BUG=None
TEST=Check hotplug vfio pci device's driver in hypervisor
Change-Id: I8330c7859dff2b8b2db1baa67c16181e2de66ae1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3595227
Reviewed-by: Micah Morton <mortonm@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
A previous commit moved the creation of the executor for the vhost-user
device processes before the minijail jail_and_fork() call, and the file
descriptor of the executor was not marked for preservation when entering
the jail, so running the vhost-user-fs device would result in errors
like this:
[WARNING:cros_async/src/sys/unix/uring_executor.rs:343] Failed to
submit NOP for waking up executor: Failed to enter io uring: 9
This is because the io_uring context file descriptor was no longer
valid, so uring system calls would return 9 (EBADF).
Add AsRawDescriptors implementations to UringExecutor and FdExecutor so
we can preserve the fd across the minijail fork.
Other vhost-user devices were not affected because they don't enter a
jail; the fs device requires this so it can do uid/gid remapping.
BUG=b:231396155
TEST=crosvm device fs --socket /tmp/vhost.sock --tag test --shared-dir /
Fixes: d368c1520a ("devices: vhost-user: fs: remove global executor variable")
Change-Id: I38cf02034bbc28de2582e2ea92bdc13b1d6055d2
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3628292
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Lepton Wu <lepton@chromium.org>
Note that
- the file/symbols within `src/sys/unix/eventfd.rs` have not
changed yet.
- base still exports EventFd to keep common/cros_asyncv2 happy
BUG=b:213153157
TEST=presubmit
Change-Id: Ie0a4308e8501d2e91364b049e6575d656af866cd
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3624568
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
from_safe_descriptor is used by both windows and unix - windows has to
supply size because the way `handle`s are treated. So make size
optional.
BUG=b:213153157
TEST=presubmit
Change-Id: I984b706852f91f5df6b8701df09526f40068f8fe
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3621211
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
Add support for injecting an ACPI sleep button event using the command
line. Upon receiving crosvm sleep command, emulate vPM1 accordingly and
trigger vSCI to the guest if ACPI fixed sleep button event is enabled.
Additionally do not mask the ACPI sleep button event in FADT flags for
the guest anymore. Quoting ACPI specification regarding the sleep button
flag: "If the system does not have a sleep button, this value would be
“1” and no sleep button device would be present".
BUG=b:194391015
TEST=Boot the VM, issue "crosvm sleepbtn /run/vm/vm.<hash>/crosvm.sock",
check guest /sys/firmware/acpi/interrupts/ff_slp_btn counter and if vSCI
was injected. With some additional changes (e.g. acpid on the guest)
suspend guest by issuing sleepbtn command from the host.
Change-Id: Ie50a3a781ba4fbfa04da75186fb5549919a5bd68
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3602867
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Grzegorz Jaszczyk <jaszczyk@google.com>
The constants herein are used on Windows. Normally we'd prefer to get
them from libc, but on Windows, these constants aren't available. For
consistency, cross platform code has been adjusted to use the net_sys
versions of the constants.
BUG=b:213151463
TEST= builds
Change-Id: I9048269483b9553f316aa8690da3ba4acdc8272a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3609236
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Noah Gold <nkgold@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
The vhost-vsock device had some special-case code to handle a file
descriptor as the vhost device rather than a path. However, crosvm
already has base::open_file(), which has special handling for magic
/proc/self/fd/<N> paths and treats them as already-open file descriptors
without requiring a separate command-line option.
This change converts the vhost vsock device to accept only a path
instead of a special path/fd enum, using base::open_file() to support
passing already-open file descriptors via the /proc/self/fd path format.
The existing --vhost-vsock-fd option is kept for compatibility, but it
now just creates a /proc/self/fd path from the passed fd. Existing users
are encouraged to migrate to --vhost-vsock-device.
BUG=b:218223240
TEST=cargo test -p devices vsock::tests::params
Change-Id: Ifad2b7ad0824d4f24d9b12a4af1448557fadcdc1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3564224
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
RutabagaComponents receive an Option<String> with calls to
Rutabaga::create_context(). This is desirable for virglrenderer so that
the guest application name can be used by the host renderer,
particularly to enable application specific GPU driver configs based on
program name matching. It is ignored by other RutabagaComponents for
now.
BUG=b:230678191
TEST=emerge crosvm
TEST=vkcube in VM
Change-Id: Ic08a02040ecc1d2e62795c248a66a88394b268e4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3612467
Commit-Queue: Ryan Neph <ryanneph@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
The early cross platformization work was done prior to finalization of
the styleguide. This CL reorganizes the files to match the intended long
term state.
BUG=b:226233737
TEST=bots
Change-Id: If2058aa69122606071b3fc26fd85bbd31f5977fc
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3597037
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Noah Gold <nkgold@google.com>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
To emulate pending bit for MSI-X, we need to add a new interrupt
delivery path in crosvm. We will make VfioPciWorker share vfio msix
cap with VfioPciDevice, fire interrupt via msix cap when receiving
irq from host device. This makes vfio msix cap shareable.
BUG=None
TEST=./tools/presubmit
Change-Id: I77f5c377a41e7b2bd795e69c1ddcad9a9376f111
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3490238
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Previous vfio's MSI-X emulation lacks per vector masking support. This
patch adds per vector masking for vfio. Now MSI-X vectors are enabled
only if they are currently in use, so host will not allocate extra IRQ
which guest does not use.
BUG=None
TEST=Pass through a nvme disk that uses MSI-X and test its functionality.
Change-Id: If9b3ec907518513d1694b981d94994d8b7e5ea36
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3490237
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
If device does not use all of the MSI vectors, we do not need to
register all for them. This patch pushes the MSI vector registery
to the first time they are enabled.
BUG=None
TEST=./tools/presubmit
Change-Id: I5453e93af4f4f5596d82ad126dc294fa5896846a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3490236
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Use the existing base::open_file function to replace the open-coded
equivalent of file_from_path + File::open fallback.
BUG=None
TEST=tools/presubmit
Change-Id: Ic6190e87056e661be5d552566c466339cefabbfe
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3553764
Reviewed-by: Anton Romanov <romanton@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Device want to get notification when a specific gpe happens, this commit
add register_gpe_notify_dev(gpe_num, dev) interface into PmResource trait,
so that others could register (gpe_num, dev) into acpi, then they
could get notification at specific gpe trigger.
BUG=b:185084350
TEST=Verify TBT pcie hotplug function in ManaTEE, virtual pcie root port
must get gpe notification during this process
Change-Id: I56eb90361a6b96be364d35c4b6a5ec598a50757e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3539566
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Currently, VfioPciDevice always use the same BDF as the device's BDF in
the host OS. However, in certain applications (e.g. Borealis), it is
desired to map the device to a different BDF.
This patch introduces a new parameter to `vfio` so that user could set
the device's BDF to a desired address.
BUG=b:208545409
TEST=Boot Borealis with `--vfio=/path/to/dGPU,guest-address=00:11.0` and
confirmed that the dGPU is at 00:11.0 in the guest OS.
Change-Id: I7ee9e9a7f74e3541e74f89d452f9aad45302eeb4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3535461
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Victor Ding <victording@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Victor Ding <victording@chromium.org>
The vhost-user VMM process is supposed to stop before the device
process, and the device process is supposed to get
`vmm_vhost::Error::ClientExit` when the VMM stops. Add the check in the
existing unit test.
BUG=b:219674197
BUG=b:220639724
TEST=cargo test in /devices/
Change-Id: I1768b9b43855e3b80f1e6e175877317338309e8a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3543005
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Add dedicated tracking for mmio bar mmaps. This allows us to remove the
special case handing that ignores writes of 0 and 0xffffffff to the bar
configuration registers. That handling was actually broken because it
used || instead of &&, which resulted in bars being redundantly
remapped.
BUG=none
TEST=Add logs to set_user_memory_region, boot manatee, and check that
the same regions are mapped.
Change-Id: Ic9905330874a4c05f79dbdaee3b40b4d21a488ff
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3535468
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: David Stevens <stevensd@chromium.org>
Use our new serde_keyvalue crate to annotate the DiskOption structure
and allow us to deserialize it from a key-values string. Add tests to
help ensure parsing won't break in the future.
The existing `root`, `rwroot`, `disk` and `rwdisk` arguments can be
parsed in a compatible manner. In the future it would probably make
sense to merge them all into a single `disk` option since all variants
can now be specified as key-values.
BUG=b:218223240
TEST=crosvm run ... --rwroot /path/to/disk.raw
TEST=cargo test -p devices virtio::block::block::tests::params_from_key_values
Change-Id: I2c8b853b9817aefce0c5f0f5c4d5a1da1f9a45d9
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3473708
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>