Commit graph

1384 commits

Author SHA1 Message Date
Dmitry Torokhov
a4a3b1dd6c devices: irq_event: implement as_raw_descriptors() and use them
This implements AsRawDescriptors trait for IrqEdgeEvent and
IrqLevelEvent and updates the users.

BUG=None
TEST=./tools/presubmit

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

BUG=None
TEST=./tools/presubmit

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

BUG=None
TEST=./tools/presubmit

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

BUG=None
TEST=./tools/presubmit

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

BUG=None
TEST=./tools/presubmit

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

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

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

BUG=b:226233737

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

BUG=None
TEST=./tools/presubmit

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

BUG=None
TEST=./tools/presubmit

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

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

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

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

BUG=None
TEST=./tools/presubmit

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

BUG=None
TEST=./tools/presubmit

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

BUG=None
TEST=./tools/presubmit

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

BUG=None
TEST=./tools/presubmit

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

BUG=None
TEST=./tools/presubmit

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

BUG=None
TEST=./tools/presubmit

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

BUG=None
TEST=./tools/presubmit

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

BUG=None
TEST=./tools/presubmit

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

BUG=None
TEST=./tools/presubmit

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

BUG=None
TEST=CQ

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

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

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

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

BUG=None
TEST=tools/presubmit

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

BUG=None
TEST=cargo test -p devices pci_address

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

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

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

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

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

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

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

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

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

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

Test: presubmit
Bug: b:213149278

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

BUG=None
TEST=serial console input works.

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

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

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

BUG=b:194137301
TEST=cargo build

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

BUG=None
TEST=cargo build

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

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

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

BUG=b:194137301
TEST=cargo build

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Change-Id: I81c6fae7b89f1e1a445b8076bd9451a8aa9f0255
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3490239
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-03-31 00:49:29 +00:00
Tinghao Zhang
acfc8083f0 devices: vfio_pci: make vfio msix cap shareable
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>
2022-03-31 00:49:28 +00:00
Tinghao Zhang
35d66b9817 devices: vfio_pci: enable MSI-X per vector masking
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>
2022-03-31 00:49:27 +00:00
Tinghao Zhang
95932f07b5 devices: pci: msix: lazy MSI vector allocation
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>
2022-03-31 00:49:26 +00:00
Daniel Verkamp
cbddc592dd devices: serial: replace file_from_path with open_file
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>
2022-03-28 19:37:56 +00:00
Vikram Auradkar
3a29174a7b Upstream windows serial device
Bug: b:213149155
Test: cargo test and presubmit
Upstream-Crate: devices
Change-Id: I1420fee814271dae9502878963872449dae8218e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3527444
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
2022-03-24 23:45:10 +00:00
Xiong Zhang
1b6e011dab ACPI: Add register gpe notify event interface
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>
2022-03-24 23:41:05 +00:00
Victor Ding
3f7495983a vfio: Support user-set address for VFIO PCI devices
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>
2022-03-24 07:24:53 +00:00
Keiichi Watanabe
52a0f3b1e8 devices: vhost-user: Add a test case for ClientExit
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>
2022-03-24 05:09:02 +00:00
David Stevens
6cda440730 vfio_pci: improve mmaped mmio bar tracking
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>
2022-03-24 01:47:51 +00:00
Alexandre Courbot
2c29fa8a0f devices: block: parse options using serde_keyvalue crate
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>
2022-03-24 01:33:23 +00:00
Alexandre Courbot
da20cf1d78 devices: serial: parse options using serde_keyvalue crate
Use our new serde_keyvalue crate to annotate the SerialParameters
structure and allow us to create it from a key-values string. Add tests
to help ensure parsing doesn't break in the future.

The existing arguments can be parsed identically by this new code, so
replace the old serial options.

BUG=b:218223240
TEST=cargo test -p devices serial_device::tests::params_from_key_values
TEST=cargo test parse_serial

Change-Id: I4898a45399b69b87a44f80d3a214daf081b06173
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3439670
Reviewed-by: Anton Romanov <romanton@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-03-24 01:33:22 +00:00