Commit graph

2057 commits

Author SHA1 Message Date
Chirantan Ekbote
6676bdadb2 Fixup Cargo.toml for cros_async and io_uring
Add magic comments so that we can have separate ebuilds for the io_uring
and cros_async crates.

BUG=none
TEST=`FEATURES=test emerge-$BOARD cros_async`

Change-Id: I8e4befc90d44b4b021864f4358c8f9b3ec5a87d5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2794162
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2021-04-01 03:32:58 +00:00
Tomasz Jeznach
3ce74765c2 crosvm-direct: p-t support for port and memory I/O.
Option to passthrough port and memory mapped IO and
enable direct host device access for the guest.

BUG=b:179801783
TEST=boot and validate access with iotools.

Change-Id: I93fcc93fecccab49fd9c08b5406bcc3533128147
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2733578
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Tomasz Jeznach <tjeznach@chromium.org>
2021-04-01 03:02:44 +00:00
Zach Reizner
48e1e52928 base: add tube module
Tube is the replacement for MsgSocket and related types and traits.

TEST=run_tests
BUG=b:176847362

Change-Id: I290279a714eb04c5cc6f2aef15ba7c61c708ab08
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2726980
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Zach Reizner <zachr@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-04-01 01:59:29 +00:00
Woody Chow
5890b7084c devices: Add vhost-user fs vmm
Option: --vhost-user-fs "$SOCKET_PATH:$TAG"

BUG=b:181190800
TEST=Interoperability test with virtiofsd-rs
TEST=Run pjdfstest in the shared dir added by --vhost-user-fs
TEST=Mount 2 different virtio-fs devices at the same time
TEST=Boot from a virtio-fs device directly with
     "root=/dev/root rootfstype=virtiofs"

Change-Id: Id4bbcccc89d7d0d84fd5f5603c3af5576f02522f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2690735
Tested-by: kokoro <noreply+kokoro@google.com>
Tested-by: Woody Chow <woodychow@google.com>
Commit-Queue: Woody Chow <woodychow@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2021-03-31 05:00:50 +00:00
Chirantan Ekbote
0f4195a833 fs: Set SECBIT_NO_SETUID_FIXUP for all worker threads
Doing this in the init() function means that this bit only gets set for
the worker thread that handles the init message. Instead do this in
Worker::run so that it gets set for all worker threads.

BUG=none
TEST=vm.Virtiofs

Change-Id: I9b2dc309e3cc2d26a6250cbe8c3bd7409dbb2e5a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2794161
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
2021-03-31 02:42:59 +00:00
Tomasz Jeznach
417ee187da crosvm-direct: interrupt passthrough kernel interface.
Kernel interface to the host interrupt passthrough driver.
User space part of the interrupt handler registers eventfd
objects for trigger notifications and interrupt resample
requests.

BUG=b:173824544
TEST=None

Change-Id: I1b8f443655e7232e668c7d3bea78fbebf150e169
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2733580
Tested-by: Tomasz Jeznach <tjeznach@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Tomasz Jeznach <tjeznach@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-03-31 02:12:55 +00:00
Daniel Verkamp
dd0ee59eee devices: virtio: block: port GET_ID to async block
Support for the VIRTIO_BLK_T_GET_ID operation was added to the non-async
block device while the async block device was under development and not
yet merged.  Add support for GET_ID to async block to fix the feature
gap.

BUG=chromium:901139
TEST=Launch crosvm with async disk with id
TEST=cat /sys/block/vda/serial
TEST=cargo test -p devices

Change-Id: I329359b9c4dc459ebcf5846ac5307f56192ce02e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2792681
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-03-30 19:21:50 +00:00
Gurchetan Singh
64182afb63 devices: gpu: complete investigation of udmabuf driver
Hello everyone ..!  After 2.5 years of "on the side" inquiries,
I have finally completed my investigations [1] of the udmabuf!!

udmabuf is a kernel driver that turns memfd pages into dmabufs.

The original hope was it would reduce texture upload costs for
virgl, which it did for larger textures [2].  But no measurable
improvements where seen with real games.  In addition, a more
advanced "gfx-streaming" model has since come into the horizon[3][4],
which is more performant, conformant, secure and simpler than
virgl. As such, building more on virgl does not seem to be best
option, but that's another story for another day.

Where does that leave udmabuf, then?!?  The investigation was
able to turn up two possible use cases:

1) Intel integrated + dGPU PCI-passthrough resource sharing

When the dGPU is passthroughed into the guest, the dGPU's memory
is not available to the host.  Ideally, for zero-copy, we would
like to get the render target out of the guest somehow and then
send to the display.  Many approaches have been proposed, such
as Vivek Kasireddy's Vdmabuf driver [5].  The current thinking
is virtgpu guest blobs can be exported, and then imported into
the dGPU -- Vivek is looking into this approach right now ..!!

Sommelier or virtgpu KMS can then share the guest blob with the
host.  It's a quite complex use case and requires changes to guest
Mesa GBM to get (such as metadata query) to get the right modifier.
Indeed, some would even say you need a virtgpu context type optimized
for sharing across domain boundaries.  minigbm already supports this
for Android upstream's Virtual Graphics Interface (VGI) initiative.

2) Guest VRAM dedicated heap created udmabufs

This use case, proposed by automative virtualization expert Dmitry
Sepp [6], is primarily for automotive hypervisors (such COQOS).
It's typically not easy for such hypervisors to get zero-copy via
BLOB_MEM_HOST3D, and these hypervisors have had their homebrew
versions of udmabuf for many years.  It's important to upstream the
workarounds that are currently done for such hypervisors.  To increase
security and isolation, a guest dedicated heap is preferred over guest
system memory. We might even need dedicated queues, who knows.

crosvm seems like the most likely upstream target due to it's world
class blob support and open-source nature.  As such, this CL adds basic
udmabuf capabilites so these use cases can be developed further via
crosvm.

[1] https://www.youtube.com/watch?v=lp6z3s1Gig0
[2] crrev.com/c/1325515
[3] goto.google.com/address-space-graphics
[4] https://drive.google.com/file/d/19K_6M8QUeOn-x7HVYvoNfnuC6G5vkR8f/view
[5] https://lists.freedesktop.org/archives/dri-devel/2021-February/296177.html
[6] https://gitlab.freedesktop.org/virgl/virglrenderer/-/issues/159

BUG=chromium:892806, b:173630595
TEST=Create a bunch of udmabufs from the guest, with the subsequent
patches

Change-Id: Ia8083c0aa065f303f660ec6875ff5fb76f5d7b4f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2786290
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-03-30 16:42:03 +00:00
Gurchetan Singh
1e9e331799 guest_memory: make do_in_region(..) callback take memfd offset
Useful for the udmabuf use case.  The current offset used
by the callback is relative to the mapping, not the absolute
memfd offset.

BUG=chromium:892806, b:173630595
TEST=cargo test -p vm_memory

Change-Id: I57d02d016888a2d974f1f9e359375cb0941dc949
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2786289
Tested-by: kokoro <noreply+kokoro@google.com>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-03-30 16:42:02 +00:00
Gurchetan Singh
db17478125 crosvm: Keep memfd alive when creating new process
This is only needed by udmabuf driver, so key it on yet another
feature flag (called "udmabuf").

BUG=chromium:892806, b:173630595
TEST=cargo test

Change-Id: I434a5d1a35d009af0924440df4f72cc7cc9df0e9
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2786288
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2021-03-30 16:42:01 +00:00
Gurchetan Singh
b66d6f62dc crosvm: sandbox changes for udmabuf
Allow:
   - UDMABUF_CREATE_LIST -- needed to create udmabuf
   - DMA_BUF_IOCTL_SYNC -- to flush the udmabuf.
     virtio-wl already allows this everywhere so
     this should be fine.

Also add the path to minijail.

BUG=chromium:892806, b:173630595
TEST=no sandbox violations

Change-Id: I70ace6ef0349c4b133615eb41f9f56ccd7121e4b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2786287
Tested-by: kokoro <noreply+kokoro@google.com>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-03-30 16:42:00 +00:00
Gurchetan Singh
dda58b774f pci_configuration: bump up CAPABILITY_MAX_OFFSET to byte max
dverkamp@ suggested that crrev.com/c/1157440 contained a
mis-reading of the relevant Wikipedia article.

BUG=chromium:892806, b:173630595
TEST=boot VM with capabilities list of size 207

Change-Id: I4afbe2058b5439bc502be59b8063a4db0fc5a12b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2792041
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2021-03-30 16:41:59 +00:00
Dennis Kempin
758503bcb5 io_uring: Disable multi_thread_submit_and_complete
This CL reverts previous attempts at reducing the flakiness of the test
and disables it completely.

BUG=b:183722981
TEST=./test_all

Change-Id: I36527d6404c67ff9e73792676a52f064d2f48d14
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2787246
Reviewed-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-03-30 00:05:34 +00:00
Allen Webb
44c728c123 sys_util: Add functionality to signals.
This refactors register_signal_handler to take a callback with the
correct parameter (c_int).

It adds functionality for clearing signal handlers, checking if a signal
handler is defined, and waiting for a signal. As part of this work a
helper function was added to create libc::timespec structs from
std::time::Duration, and get the max Duration that can be represented by
libc::timespec.

BUG=None
TEST=cargo test

Cq-Depend: chromium:2782855, chromium:2782856
Change-Id: Id531d9aaeeeb65f0f6f9b64bed4aba024a2328cb
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2783043
Tested-by: Allen Webb <allenwebb@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Allen Webb <allenwebb@google.com>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2021-03-29 20:54:20 +00:00
Zach Reizner
de0c63dbcd implement Serialize and Deserialize for base and sys_util types
These types make up parts of larger messages that implemented
MsgOnSocket.

BUG=b:176847362
TEST=run_tests

Change-Id: I1f99e08f494d646ad0566eb556e2c28726d1d217
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2733207
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Zach Reizner <zachr@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-03-29 19:39:52 +00:00
Zach Reizner
daceeb59c6 sys_util: add tool for raw descriptor reflection
This CL enables serde based serialize and deserialize types to interact
with a side-channel stash of descriptors. The idea is that many types
could implement Serialize and Deserialize, but they have descriptors
buried in them, such as a File or kernel object. Although these can be
serialized literally, usually the transciever of the serialized value
needs explicit access to the descriptors to send them over, such as with
Unix domain sockets.

TEST=cargo test -p base
BUG=b:176847362

Cq-Depend: chromium:2757675
Change-Id: I3273889f8d43cca761a54c531a981b7ab1ad3c03
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2576633
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Zach Reizner <zachr@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-03-29 19:39:51 +00:00
Zach Reizner
ec3c32825d fuzz: update Cargo.lock from the addition of the fuzz crate
Probably should have been done in the change that added the fuzz crate
to the workspace to prevent the Cargo.lock changes from ending up in
unrelated commits.

BUG=None
TEST=cargo check

Change-Id: I20d42e5b53f24a73c3c351a5dc38eb2a24e8c4eb
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2785600
Tested-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Auto-Submit: Zach Reizner <zachr@chromium.org>
Commit-Queue: Zach Reizner <zachr@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-03-29 19:39:50 +00:00
Keiichi Watanabe
6068658584 devices: virtio: Add vhost-user-net master device
Add vhost-user virtio-net master device. Ctrl queue will be supported in a separate CL.

BUG=b:179755448
TEST=curl/ping worked with cloud-hypervisor's backend

Change-Id: Ibda3d93457be9841748b649e492d0fd11969fd4f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2717904
Tested-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2021-03-25 08:26:18 +00:00
Keiichi Watanabe
f3a37f4953 devices: virtio: Add vhost-user-block master device
This adds a vhost-user device block, which will be enabled by `--vhost-user-blk
<socket path>` option.
This device runs with vhost-user block device backend programs such as:
* DPDK's vhost_blk sample application [1] with a patch [2],
* cloud-hypervisor's backend [3], and
* crosvm backend prototype [4]

[1] https://doc.dpdk.org/guides/sample_app_ug/vhost_blk.html
[2] https://mails.dpdk.org/archives/dev/2021-March/202586.html
[3] https://github.com/cloud-hypervisor/cloud-hypervisor/tree/master/vhost_user_block
[4] https://github.com/keiichiw/crosvm/tree/topic/vhost_user_blk

BUG=b:179471380
TEST=mount ext4 disk with DPDK/cloud-hypervisor/crosvm backend

Cq-Depend: chromium:2717529, chromium:2719985
Change-Id: I5a1e3cb3b7fdb00655564db981a2d686f71388c9
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2646790
Tested-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2021-03-25 08:26:17 +00:00
Chirantan Ekbote
53ef751fb3 seccomp: 9p: Allow fchown and fchmod
Needed by upcoming implementation changes.

BUG=chromium:1082345,chromium:920262,chromium:912599
TEST=`emerge-$BOARD crosvm`

Change-Id: Id366cd9d0bb3af24e2445fdf897d6ef45ae88115
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2784163
Auto-Submit: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Stephen Barber <smbarber@chromium.org>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
2021-03-24 18:59:02 +00:00
Chirantan Ekbote
fa4bf10955 Add fuzz to crosvm's workspace
I don't really remember why the fuzz crate needed to be a separate
workspace and doing it that way seems to break our fuzzer builds so just
move it into crosvm's workspace.

BUG=none
TEST=USE="asan fuzzer" emerge-amd64-generic crosvm

Cq-Depend: chromium:2777911
Change-Id: Ibb0e2de14189683ee5af501392594230996accc3
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2772678
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: Chirantan Ekbote <chirantan@chromium.org>
2021-03-24 06:23:34 +00:00
Noah Gold
0ffcc07a81 [linux_input_sys/data_model]: signed input_event
Previously we restricted the virtio_input_event/input_event's value
field to u32. In actuality, this field is an i32 in the kernel, and the
negative values are used for relative mice (among other things). This CL
switches the value field to be signed.

BUG=None
TEST=builds (also tested on another branch)

Change-Id: Ia2c43e1a8ee21aa618d97b308369ab49c194cab4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2770724
Auto-Submit: Noah Gold <nkgold@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-03-23 18:49:33 +00:00
Noah Gold
803749bcb1 cros_async: add missing dev-deps.
These didn't get moved in the original move of cros_async::sync. This CL
adds them.

BUG=None
TEST=builds

Change-Id: I08204a9aedd960e0e8e7befc930076df065b74ee
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2776214
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Commit-Queue: Noah Gold <nkgold@google.com>
2021-03-23 01:02:24 +00:00
Gurchetan Singh
6e8f33aa0a rutabaga_gfx: convert to SafeDescriptor
To be truly OS-agnostic, we need an OS-agnostic Rust wrapper over
the OS-specific handle type.  SafeDescriptor seems to be the best
option, and I hope it on crates.io in the future.

This converts virtio_gpu/rutabaga to use the SafeDescriptor handle
when practical.  minigbm still uses File in some places, since it
needs to SeekFrom(..), but minigbm is a Linux only thing anyways.

BUG=b:173630595
TEST=boot VM in 2D/3D mode

Change-Id: I18d735844d479f52d82d7976bf9b4e383b2e2252
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2779492
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Zach Reizner <zachr@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Michael Hoyle <mikehoyle@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2021-03-23 00:44:10 +00:00
Dennis Kempin
1736adac0d io_uring: Really fix flaky test
It's still flaky, removing another check. That should take care of it.
Unfortunately it does not reproduce frequently when running locally.

BUG=None
TEST=./test_all

Change-Id: Ie60fef676f860f5ff36f7b0b57ce8582f03fe669
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2774938
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2021-03-22 21:55:09 +00:00
Zach Reizner
d09392e37e uprev rust-toolchain and fix clippy warnings
Some judgement calls were made about unnecessary wrapping. Usually they
would get resolved by removing the wrapping or returning a convenient
error, but the ones that returned results for consistency with other
functions were added to the allow list.

The error handling in the usb code had a lot of unit error types which
is now a clippy lint. This was resolved by either removing the result
entirely or returning a convenient error.

The field_reassign_with_default lint is faulty and was added to the list
of supressions. This affected virtio-wayland code.

BUG=b:179277332
TEST=cargo clippy with rustc 1.50+

Change-Id: Ie812cdeaf7c42f4f2b47b1dc87f05a7c87a60f8f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2757510
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Auto-Submit: Zach Reizner <zachr@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2021-03-22 21:41:07 +00:00
Manoj Gupta
d4d0b5ccf3 crosvm: add more time syscalls to policies
glibc 2.32 is using clock_gettime/64 on some arm boards
when gettimeofday is used. In addition, support 64-bit
variants of the time syscalls for use with glibc 2.32.

BUG=chromium:1190305
TEST=crostini tests pass

Change-Id: I070eee92817d3f959ea385ff2c3adca610e0a574
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2776211
Commit-Queue: Manoj Gupta <manojgupta@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Manoj Gupta <manojgupta@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Auto-Submit: Manoj Gupta <manojgupta@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-03-20 13:40:00 +00:00
Dennis Kempin
3f63661afc Run integration_tests by calling crosvm binary
Instead of instanciating crosvm directly, we can start the binary as
a sub-process.
This includes parsing of crosvm options in the tests, and makes the
test cases closer to real-world usage.

To make make this possible, we need to make sure that the crosvm binary
is uploaded to the VM before running the test, which is done by the
sync_so script, which is baked into the builder container.
We prevent future container re-builds for just maintaining the script,
I have removed them from the container, and call the scripts from the
local source directly.

The test runner is also updated to ensure all package binaries are
built (currently only tests are built).

BUG=b:182841358
TEST=./test_all passes

Change-Id: I7dfd21abcb2b90fe125eb43f85572fbf645b888a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2744280
Tested-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-03-19 20:35:53 +00:00
Chuanxiao Dong
e2d00176e5 VFIO: set user memory region with page size aligned size
For some PCI device, its MMIO bar size may not be page size aligned.
When setting user memory region for such bar with not aligned size, KVM
will report failure back and failed to map that bar. As current crosvm
can continue run with this failure, the performance will be hurt as each
time when guest is accessing this bar, it will trap to hypervisor.

To resolve this, extend the size to be page size aligned when setting
user memory region in KVM and do DMA map. This should be safe to extend
because the mmap actually rounds up the mmap size to be page aligned.

BUG=None
TEST=boot vm with a passthrough device whose bar has unaligned size

Change-Id: Ic816984ec503edf7f12da4893b78d996ebf93976
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2717448
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dylan Reid <dgreid@chromium.org>
2021-03-19 18:51:32 +00:00
Dennis Kempin
dbd3bbcbbd crosvm: Remove owners wildcard
Adding a few people who frequently +2 changes across different teams
and timezones.

People on this list will also be able to set V+1, which is otherwise
going to be managed by Kokoro.

BUG=b:183147853
TEST=None

Change-Id: I11f20e58eaeeab9f219dc603e27ffdfe1dcbf2cb
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2773703
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2021-03-19 01:57:41 +00:00
Manoj Gupta
4029491dfe block_device.policy: Add arm time64 variants
Add time64 variants for crosvm.

BUG=chromium:1188714
TEST=no more crashes when installing Linux

Change-Id: I5bacb0436b6002aef059dd619ac0cc80995315aa
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2774389
Tested-by: Manoj Gupta <manojgupta@chromium.org>
Auto-Submit: Manoj Gupta <manojgupta@chromium.org>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Manoj Gupta <manojgupta@chromium.org>
2021-03-19 01:40:03 +00:00
Dennis Kempin
ae447c4bc7 io_uring: Fix flaky test
The test has been failing every ~10 test runs. The removed check
can be racy since we cannot wait for all threads to complete.

BUG=None
TEST=./test_all passes consistently

Change-Id: I231ae0734bc1a0d0c0fc991448f6ebf63b11fc56
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2768678
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2021-03-18 22:12:59 +00:00
Keiichi Watanabe
d56a2f432d Fix formatting
Ran `cargo fmt`.

BUG=none
TEST=cargo fmt

Change-Id: I9b069c6b30724148be5d3e059e0a447615abeac9
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2772679
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Dylan Reid <dgreid@chromium.org>
Tested-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Auto-Submit: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2021-03-18 22:12:57 +00:00
Tomasz Jeznach
eb1114ced7 crosvm-direct: support for variable IOAPIC irqs.
More recent Intel IO-APICs can support more than 24 interrupt
lines. This change enables variable size of IO-APIC lines for
user level IO-APIC emulation code (split-irqchip).

Reported version and supported IO-APIC registes matching ICH10
implementation of IO-APIC device.

BUG=b:181795297
TEST=boot and allocate irq from upper range.

Change-Id: I56480befb39c4c268266f04e4a93105402248772
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2733579
Tested-by: Tomasz Jeznach <tjeznach@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Tomasz Jeznach <tjeznach@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-03-18 22:02:54 +00:00
Daniel Norman
5e23df7939 Adds a new input device for switches, with socket flag --switches.
Bug: 181664980
Test: Launch cuttlefish with crosvm, observe switches /dev/input
      device with `getevent -lp`.
Test: cargo test
Change-Id: I209b93421bcfcc4ab26efc8981fcd2d680717d59
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2765762
Reviewed-by: Zach Reizner <zachr@chromium.org>
Auto-Submit: Daniel Norman <danielnorman@google.com>
Commit-Queue: Daniel Norman <danielnorman@google.com>
Tested-by: Daniel Norman <danielnorman@google.com>
2021-03-18 04:28:54 +00:00
Chirantan Ekbote
8e80902ce3 cros_async: Fix circular reference memory leak
PollSource keeps a strong reference to the FdExecutor, which can lead to
a memory leak via a circular reference if the caller spawns a future
that owns a PollSource and then detaches it.  Avoid this by using weak
references instead.

With this change, we now only use weak references internally.  The only
way to increase the strong reference count is by cloning the FdExecutor.

BUG=none
TEST=unit tests

Change-Id: Ic58ff475a31c6fca831c3ced73b26b87ceeda028
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2760378
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-03-17 19:24:07 +00:00
Chirantan Ekbote
12d17e90b8 cros_async: Delete RunnableQueue::set_waker
Previously each executor had to call RunnableQueue::set_waker at the
beginning of every loop before it started executing futures, which was a
bit tedious.  This call was needed so that the RunnableQueue would wake
up the executor if a new future was scheduled.

Instead move responsibility for waking the executor when a future is
scheduled back to the executor.  This lets us get rid of the set_waker
method and is arguably a better separation of responsibilities.

BUG=none
TEST=unit tests

Change-Id: Ica46437f78c822d87096eaa215954d118c6578f2
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2760377
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-03-17 19:24:06 +00:00
Keiichi Watanabe
5dc0f60d44 kokoro: Add rust-vmm/vhost in manifest.xml
BUG=b:181227406
TEST=ci/kokoro/simulate_all

Change-Id: I65065963daa9e96457ed9a64f01e34ad93bd8667
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2762488
Tested-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2021-03-17 19:12:08 +00:00
Dennis Kempin
ebc0520d0b Enable integration_tests on Kokoro for X86
Increases the communication timeout to 10 secs since we are running
twice nested KVMs, and things get a bit slower.

BUG=b:181675114
TEST=./test_all

Change-Id: Ifa3ea05952cd8a4f7fbe4fefb12143098243c21a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2752341
Tested-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-03-17 00:04:27 +00:00
Daniel Verkamp
6485f8115d arch: fdt: minor documentation cleanups
Wrap the link to the FDT spec in <> so it becomes a clickable link in
the doc output.

Also fix a parenthesized abbreviation of Devicetree Blob to be DTB
rather than FDT.

BUG=None
TEST=cargo doc

Change-Id: Ie607acb6388820e7dfdb436bdad34ff077289666
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2763204
Reviewed-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-03-16 23:47:37 +00:00
Daniel Verkamp
2cce1a271b devices: virtio: video: mark non-Rust code block
Indicate that the code block with instructions for running bindgen is
not Rust code to avoid this warning:

  warning: could not parse code block as Rust code

BUG=None
TEST=cargo doc --all-features

Change-Id: I38a9d49487dc1da8e41d3fca5dfa1b8bc8ae5e84
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2762064
Reviewed-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-03-16 23:24:45 +00:00
Daniel Verkamp
89e64c0d2e src: escape non-link [] in rustdoc
Fix a broken_intra_doc_links warning:

  warning: unresolved link to `ARGUMENTS`
  the module `argument` contains no item named `ARGUMENTS`

BUG=None
TEST=cargo doc --all-features

Change-Id: I678aa5dd9ede33879b2725e5a53411cad38d8a65
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2762063
Reviewed-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-03-16 23:24:43 +00:00
Noah Gold
2494889d28 Move libchromeos::sync to cros_async::sync.
To allow for porting to non POSIX platforms, we've brought the
libchromeos::sync module into cros_async (which was the only
consumer).

BUG=b:180978556
TEST=builds

Change-Id: I97256b1dc37124cebc693c035e63d2c5b29e94b1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2757280
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Noah Gold <nkgold@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2021-03-16 18:12:03 +00:00
Manoj Gupta
19ad688208 add getdents64 to policies
glibc 2.32 is using getdents64 syscall instead of getdents.
So add getdents64 to policies that already have getdents.

BUG=chromium:1171287
TEST=CQ

Change-Id: Icbe1da7cbf669432c8160779a9cbfdeb04db57c0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2760299
Tested-by: Manoj Gupta <manojgupta@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Auto-Submit: Manoj Gupta <manojgupta@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Commit-Queue: Manoj Gupta <manojgupta@chromium.org>
2021-03-16 05:25:16 +00:00
Jorge E. Moreira
6a88a5d986 Allow VioS backend in android OS too
Change-Id: I3eaa744054e83a3f6b91227a0c8030a6cb2d049b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2757270
Reviewed-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Jorge Moreira Broche <jemoreira@google.com>
2021-03-16 02:05:47 +00:00
Daniel Verkamp
cef22bc39f run_tests: enable rutabaga_gfx and vm_memory tests
Add the privileged requirement so that these tests run in a VM and can
successfully call memfd_create().

BUG=b:181672913
BUG=b:181675101
TEST=./test_all

Change-Id: Ic0eadade4e625e50e73682771a9c6fbb92468af2
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2754487
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2021-03-16 00:52:23 +00:00
Chih-Yu Huang
44f1ffd5de video: do not clear output resource when getting QueueClear command
When the V4L2 output queue is streamoff, crosvm gets QueueClear
command. All the V4L2 output buffers are dropped, but VDA doesn't drop
output buffers at this point. We should only clear the enqueued
resource ids, and not clear the whole output resources.

BUG=b:181541291
TEST=android.media.cts.AdaptivePlaybackTest
TEST=com.google.android.exoplayer.gts.DashTest

Change-Id: I343b809e80d5bc56679b76baa5593aebb4558a74
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2756068
Tested-by: Chih-Yu Huang <akahuang@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Chih-Yu Huang <akahuang@chromium.org>
2021-03-15 09:49:26 +00:00
Dennis Kempin
84b2d93c70 Fix io_uring tests for running on Kokoro
Some of the multi-threaded tests had race conditions that show up when
running inside the Kokoro Test VMs.

To wake up and complete all running threads, no-ops are inserted into
the uring. However, each thread can grab a list of results. On the
test VMs, all no-ops are read by one thread, leaving the others running,
blocking the test from completing.

Since this is just a test.. let's just leave the threads hanging and
let the OS take care of them.

BUG=b:181673923
TEST=./test_all

Change-Id: I504b6db9cf934e2454d27c1155667b4b0f7fbc77
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2750783
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2021-03-12 23:36:14 +00:00
Dennis Kempin
dcf540be92 Add SEPARATE_WORKSPACE requirement for run_tests
The io_uring and fuzz crate cannot be tested in the same workspace
via `cargo test -p io_uring -p fuzz`.
This change allows test_runner.py to run tests independently by
cd'ing into the crates directory and running cargo test in there.

BUG=b:181672910
BUG=b:181673923
TEST=Tests for the above mentioned crates can be enabled and run, but
test failures prevent them from being enabled so far.

Change-Id: Ia03868d53e508549fe2f071da399b982359a8834
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2749772
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2021-03-12 23:36:13 +00:00
Dennis Kempin
f217c0fb46 integration_tests: Add prebuilts for aarch64
Updates the guest_under_test Makefile / upload script to build
for aarch64 as well.

BUG=b:176748319
TEST=Unfortunately KVM is not fully functional in our arch64 VM, so I have
not been able to test the prebuilt yet.

Change-Id: I554da6a620b26ffa1db34baa13d529f0b1de1616
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2676994
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2021-03-12 22:50:30 +00:00