Commit graph

3295 commits

Author SHA1 Message Date
Dennis Kempin
2b1b78c6ef tools/dev_container: stop old container if new image is available
When the container image is updated, developers may not notice and
continue running a different version. Detect this and restart the
container.

BUG=b:217465164
TEST=./tools/dev_container while changing image_version

Change-Id: Ib1df871c5c6fba9421c436d39ab7065be966f41e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3469050
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-02-18 00:18:57 +00:00
Dennis Kempin
9b7471e51a tools/dev_container: Pythonify
Use the new common.py utilities to make turn this bash script into
python. The behavior should be the same.

BUG=b:218559770
TEST=./tools/presubmit

Change-Id: Id1412c2076089fd21f280959d6cde1f4cb64e163
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3469049
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-02-18 00:18:56 +00:00
Daniel Verkamp
be451c2a8c disk: qcow: pass raw file offset in write_cb
Modify the write callback function to take the offset into the raw
(backing) file as a parameter rather than seeking to the expected
location of the write. This allows removal of the FileReadWriteVolatile
import in qcow, since this was the last use. This also matches the
read_cb, which already passed the backing file offset explicitly.

BUG=b:219595052
TEST=tools/presubmit

Change-Id: I4ac18d4dbe26e8b196eb8a9c056036565eb39501
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3462641
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-02-17 22:04:24 +00:00
Daniel Verkamp
3de62e6468 disk: qcow: rewrite tests using FileReadWriteAtVolatile
The standard Read/Write/Seek impls were only being used in the tests.
Remove them and use the FileReadWriteAtVolatile trait instead. That way,
we are also testing what we actually use in the block device.

BUG=b:219595052
TEST=cargo test -p disk
TEST=tools/presubmit

Change-Id: I21adee0fc057acfb2aed6fbaaed01f92befe895a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3462640
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-02-17 22:04:23 +00:00
Daniel Verkamp
7f400e70fb disk: qcow: remove unused FileReadWriteVolatile impl
Only FileReadWriteAtVolatile is used for disks, so remove the dead code.

BUG=b:219595052
TEST=tools/presubmit

Change-Id: I35280d9218a3f39bdc0e62ca3f30b66d6abb39ae
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3462639
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-02-17 22:04:22 +00:00
Daniel Verkamp
06771581f4 sys_util: remove SeekHole trait
This was only used in the qcow_img utility, so it is dead code now.

BUG=b:219595052
TEST=tools/presubmit

Change-Id: Ie0872df9a02c5a0ccb62b2884db0dfcfeceaa7c7
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3462638
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-02-17 22:04:21 +00:00
Daniel Verkamp
8fb8084032 qcow_utils: remove qcow_img utility and debug fns
This was a utility created to test the qcow disk implementation, but it
is not used anywhere in the running Chrome OS system and has served its
purpose for testing the qcow crate. Removing it will allow further
cleanups and make it easier to convert the qcow and other disk types to
async.

BUG=b:219595052
TEST=cargo build
TEST=cargo test -p disk

Change-Id: I7dddcfdb0685ee8d55fdb13452fa4ebd95bc78db
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3462637
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-02-17 22:04:20 +00:00
Junichi Uekawa
0bb6066ef8 system_allocator: Check io range.
io ports is a 16 bit thing, check that it is actually 16 bits and fix
the parameters.

BUG=None
TEST=read intel SDM, run crosvm test

Change-Id: I50b6d5593b0699317ac2f852836208a46240714b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3470601
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
2022-02-17 22:03:47 +00:00
Dennis Kempin
eb962a6993 create_merge: Add BUG= lines into merge commit message
This will trigger the usual gerrit automation to notify the bugs
about the merge being submitted, which will help identify when
fixes have landed in chromeos.

BUG=b:219743659
TEST=./tools/chromeos/create_merge

Change-Id: I6365f3c5596a94a6990caf1e1733e8040e5e8fff
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3469495
Reviewed-by: Noah Gold <nkgold@google.com>
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-02-17 19:11:03 +00:00
Alexandre Courbot
05bd01793d devices: vvu: proxy: handle VIRTIO_MSI_NO_VECTOR
The driver can send VIRTIO_MSI_NO_VECTOR as a MSI notification vector in
order to indicate this vector should not be used. We are not using this
currently but the spec mentions it.

BUG=b:194136484
TEST=VVU-enabled console device works properly.

Change-Id: I7023926b4acc8c46c193af6a4c3fb5b6d2383096
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3467299
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-02-17 12:42:20 +00:00
Alexandre Courbot
777348bbae devices: vvu: proxy: do not mandate a MSI vector for each queue
Currently the proxy code aborts if the sibling did not set a MSI vector
for each of the 16 potentially supported queues. This prevents devices
that use less queues than that (like console, which uses 2) to even
start.

Fix this by putting the MSI vector into an option, and returning an
error at runtime if an unset interrupt is ever signaled.

BUG=b:194136484
BUG=b:213531730
TEST=VVU-enabled console device can start.

Change-Id: I985870c23365ff97fc97553206d6b1a2bfdf8b06
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3467298
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-02-17 12:33:42 +00:00
Alexandre Courbot
27b4506000 devices: vvu: proxy: use same type for sending and receiving doorbell indices
`process_doorbell_message` receives a usize, so make sure that
`write_bar_doorbell` sends an index of the same type. The
current code is only working on 64-bit machines where both types have
the same size by accident.

BUG=b:194136484
TEST=VVU-enabled console device works properly.

Change-Id: Idf01d4846edcf9bcc5c2d6c36dbc739c81f363e6
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3467296
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-02-17 11:55:10 +00:00
Andrew Walbran
cdea9aef39 Allow sandbox pivot root directory to be given on command-line.
This will be useful on Android, which doesn't have /var/empty.

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

Change-Id: I3ae013bc29940b223607ca10788c571883acd7ca
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3468676
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Andrew Walbran <qwandor@google.com>
2022-02-17 11:29:59 +00:00
Alexandre Courbot
516e536a11 devices: vvu: proxy: divide doorbell write offset by multiplier
As specified by the VVU spec, the adress of a doorbell within a BAR is

    cap.offset doorbell_idx * doorbell_off_multiplier

The `cap.offset` is properly accounted for, but not the multiplier,
resulting in a invalid doorbell being notified if the write offset is
bigger than 0.

BUG=b:194136484
BUG=b:213531730
TEST=VVU-enabled console device works properly.

Change-Id: I96a2b67d905d2453017cdd230b2dda21345d236a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3467295
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-02-17 11:14:28 +00:00
Dennis Kempin
278849cbe1 test_runner: More flexible timeouts
Tests can now be marked as large to increase the timeout from it's
original 60s to 120s.
The test runner is also updated to detect if the test is running in
an emulated environment, and doubles the timeout for those.

BUG=b:218681921
TEST=./tools/presubmit --all

Change-Id: I95fc238dcd23a5035826f422752eaf0ca215706c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3469496
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Anton Romanov <romanton@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-02-16 22:54:17 +00:00
Daniel Verkamp
310d4b3593 aarch64: generalize FDT PCI node parameters
Rather than hard-coding knowledge of the low and high MMIO regions and
configuration space access region in the fdt creation code, we can move
this to the aarch64 VM setup code that has more visibility into memory
layout and allocators.

This will enable future refactoring to collapse the multiple MMIO
regions into a single allocator.

BUG=b:188011323
TEST=Boot Crostini on trogdor

Change-Id: I2709b831d94b467b772cd37465e3431072c7a49d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3457884
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-02-16 21:44:56 +00:00
Alexandre Courbot
488af9c977 devices: vhost-user: vsock: remove global executor variable
This variable can be passed as part of the backend structure.

BUG=None
TEST=cargo build

Change-Id: Ic279af17e67ffe31baae5db5cb2b3c5a511b0c13
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3451758
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-02-16 12:10:53 +00:00
Alexandre Courbot
2e7d926f90 devices: vhost-user: wl: remove global executor variable
This variable can be passed as part of the backend structure.

BUG=None
TEST=cargo build

Change-Id: I085761711fe3d214217541e91bb23f00eafc67c5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3451757
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-02-16 12:01:41 +00:00
Alexandre Courbot
b0ba179eb1 devices: vhost-user: gpu: remove global executor variable
This variable can be passed as part of the backend structure.

BUG=None
TEST=cargo build

Change-Id: Ic41c9dbcea780e0251743bc63d7935969fa4550b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3451756
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-02-16 10:31:34 +00:00
Alexandre Courbot
d368c1520a devices: vhost-user: fs: remove global executor variable
This variable can be passed as part of the backend structure.

BUG=None
TEST=cargo build

Change-Id: Ic2f5987110acb54bd5486bd63924d052bded17cc
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3451755
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-02-16 09:56:48 +00:00
Alexandre Courbot
95d104fdd9 devices: vhost-user: cras_snd: remove global executor variable
This variable can be passed as part of the backend structure.

BUG=None
TEST=cargo build

Change-Id: Id8f905cc87de261a1a547da66fb93dafc1b7686d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3451754
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-02-16 08:36:03 +00:00
Alexandre Courbot
405608118a devices: vhost-user: console: remove global executor variable
This variable can be passed as part of the backend structure.

BUG=None
TEST=cargo build

Change-Id: Ib849a1479c8559b9482b0a96e97e3452a9519cd8
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3450028
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Morg <morg@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-02-16 06:50:38 +00:00
Alexandre Courbot
8068fd74fc devices: vhost-user: block: remove global executor variable
This variable can be passed as part of the backend structure.

BUG=None
TEST=cargo build

Change-Id: I3c1f6e04417ea2e6c8b2d4d662829cf24b353fdf
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3450027
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-02-16 04:54:54 +00:00
Junichi Uekawa
120318d6e6 resources: remove unneeded export of AddressAllocator
Nobody relies on this.

BUG=None
TEST=build

Change-Id: I79e34103079a0e9660a0ff79db4a154125f04bfc
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3450016
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
2022-02-16 03:23:55 +00:00
Junichi Uekawa
b451dc78f1 devices: fix some test example values for allocator
Some tests had unrealistic values, fix them in case I want to add some
validation in the future.

BUG=None
TEST=None

Change-Id: I126c83b4ac91442f87aae8be9e84565a7a3d98a2
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3446980
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
2022-02-16 02:32:52 +00:00
Dennis Kempin
27ecaad405 Pythonify clippy/fmt scripts and add common.py
We are replacing most of our bash tools with python versions so we
can support cross-platform development.

To facilitate writing shell-like scripts in Python, this CL adds
a common.py file to share common utilities. It curretly contains
tools to simplify shell-like command execution and argument parsing.

BUG=b:218559770
TEST=./tools/clippy && ./tools/fmt && ./tools/impl/common.py

Change-Id: I7f8b3523394973ed5c741b926fdc41e52133189f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3461240
Reviewed-by: Maciek Swiech <drmasquatch@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-02-15 22:01:58 +00:00
Vikram Auradkar
7c9b08aae9 Prepare vmm_vhost to be milti-platform 2/2
The patch prepares backend.rs and connection.rs to be platform
independent by
- depending on base instead on sys_util
- using base::Event over sys_util::EventFd
- replacing RawFd usage with RawDescriptor and derivatives

To keep the noise low, the patch
- aliases structs/traits (Event as EventFd)
- does not rename variables (say from fd to rd).

Note: With this patch the crate/files are not completely platform
independent.

Test: Built, clippy and fmt
Bug: b:213151429
Change-Id: Ib57528ef1a951c3d083cf345c878ec1417b7ce3e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3460428
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
2022-02-15 20:56:20 +00:00
Woody Chow
9415d71eb4 virtio_pci_device: Move device activation code to activate()
Increase readability by reducing nesting and function length.
Also, remove Option from VirtioPciDevice.mem as it cannot be
None.

BUG=b:215307964
TEST=cargo test

Change-Id: I66d57d5205a59a507433d71de71ca58a98cfeb6c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3460790
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Woody Chow <woodychow@google.com>
2022-02-15 08:12:35 +00:00
Abhishek Bhardwaj
c39d402d84 crosvm: vvu: proxy: Add main process tube to keep_rds
This change adds the main process tube to the list of fds that need to
be kept open after the proxy device process forks.

BUG=b:194136484
TEST=Run device VM without --disable-sandbox.

Change-Id: I41be8ef68cf5925b2f677944998cf2ae1c20fdb8
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3435165
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Abhishek Bhardwaj <abhishekbh@chromium.org>
2022-02-15 06:41:02 +00:00
Abhishek Bhardwaj
4e3693fd2a crosvm: vvu: proxy: Add num_interrupts method to the VirtioDevice trait
This change adds a new num_interrupts API to the Virtio device trait.
This is because for the proxy device the number of interrupts is
different from the number of its own queues. It also includes the queues
of the device being proxied i.e. block, net, etc..

BUG=b:194136484
TEST=Run "head /dev/vdb;mount /dev/vdb /mnt;echo "1" >> /mnt/1.txt" in
the sibling VM.

Change-Id: I0c3b3a85772c1364660d5570ad86bbaecfb0faf5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3309202
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Abhishek Bhardwaj <abhishekbh@chromium.org>
2022-02-15 06:29:59 +00:00
Abhishek Bhardwaj
2d9300370c crosvm: vvu: proxy: Implement Doorbell logic
This change implements the Doorbell bar logic for the VVU proxy device.
This includes writing to the call event corresponding to vring specified
by the doorbell write.

BUG=b:194136484
TEST=Test with sibling VM with Vhost master connecting to a device VM.

Change-Id: I1e97c171ca8336151facd19ebe8107b092db8d42
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3301861
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Abhishek Bhardwaj <abhishekbh@chromium.org>
2022-02-15 06:19:05 +00:00
Abhishek Bhardwaj
13d8745ce8 crosvm: vvu: proxy: Add set_mem_table size check
This change adds another metadata size check to the set_mem_table
function.

BUG=b:194136484
TEST=Test with sibling VM with Vhost master connecting to a device VM.

Change-Id: I561af017a35b2fa7ac81b9bcb1af9c6fcf63ba1f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3462647
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Abhishek Bhardwaj <abhishekbh@chromium.org>
2022-02-15 05:54:55 +00:00
Abhishek Bhardwaj
b6a624edbf crosvm: vvu: proxy: Implement SET_VRING_KICK and SET_VRING_CALL
This change implements the SET_VRING_KICK and SET_VRING_CALL VVU
message. This involves storing both the call and kick events in the
proxy device. Furthermore, this change monitors the kick event and
injects the corresponding interrupt into the guest.

BUG=b:194136484
TEST=Test with sibling VM with Vhost master connecting to a device VM.

Change-Id: I8b400a01c1e82ff7d4fbdbc8a6d7926fef3511dd
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3301860
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Abhishek Bhardwaj <abhishekbh@chromium.org>
2022-02-15 05:41:52 +00:00
Junichi Uekawa
d2d66bc0a4 system_allocator: allow more than one region to be in the pool
Allows crosvm-direct to have 0-0xfff regions to be mapped.

limitations: Only the first regions gets reflected in the
pool_base/pool_size.

BUG=b:188011323
BUG=b:184815519
TEST=build

Change-Id: I9da3cb2b8d5611068f9323d6ebf62f44162838b4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3450017
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
2022-02-15 00:46:48 +00:00
Vikram Auradkar
15cc292b7e Prepare vmm_vhost to be milti-platform 1/2
The patch prepares backend.rs and connection.rs to be platform
independent by
- depending on base instead on sys_util
- using base::Event over sys_util::EventFd
- replacing RawFd usage with RawDescriptor and derivatives

To keep the noise low, the patch
- aliases structs/traits (Event as EventFd)
- does not rename variables (say from fd to rd).

Note: With this patch the crate/files are not completely platform
independent.

Test: Built, clippy and fmt
Bug: b:213151429

Change-Id: Id93d4a70db627578e6577017f8ca4d69f892d69a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3460427
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
2022-02-14 19:43:17 +00:00
Keiichi Watanabe
9051c150d9 devices: vhost-user: net: Support VVU
BUG=b:213531892
TEST=todo

Change-Id: I0737b85f19295e05e1c0ed073205de0bd2e7e70b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3354273
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2022-02-14 07:13:47 +00:00
Chirantan Ekbote
6d97fd0bd7 devices: vhost-user: vsock: Support VVU
Support running the vsock device backend over vvu instead of a unix
doman socket.

BUG=b:213530766
TEST=Use nc-vsock to transfer data between device vm <-> sibling vm

Change-Id: I065ebf8d0bc306fe707d843cfabc2bf600b2e8f4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3369506
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2022-02-14 07:13:46 +00:00
Daniel Verkamp
f04ba1a14b aarch64: limit PCI IRQ allocator to number of SPIs
The previous limit was incorrect, as we are using SPI (Shared Peripheral
Interrupt) type interrupt sources for PCI devices, but the limit was
based on the total number of SPI + PPI interrupts.

This fixes interrupt delivery when many PCI devices are used on arm
platforms.

BUG=b:218757314
TEST=Run crosvm with 32+ block devices on trogdor

Change-Id: Ie89bc5b7115117d8acaca30ff758b9342940b450
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3453119
Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-02-12 00:07:05 +00:00
Daniel Verkamp
7a06e688f7 aarch64: enlarge low MMIO allocator region
The previous size was only 1 MiB, which can be exhausted when enough
virtio-pci devices or other users of low MMIO are added. Increase it to
32 MiB to allow the addition of more devices, and while we are at it,
change the base of the low MMIO region to a more nicely aligned offset.

BUG=b:218757314
TEST=Run crosvm with 28 block devices on trogdor

Change-Id: Iea30d02f5c529be133b0fcb3666bf2ca72d5a90c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3453117
Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-02-12 00:07:04 +00:00
Daniel Verkamp
cb3749e632 devices: xhci: allow statx syscall on x86_64
Recent builds (starting R100.14501.0.0) crash when attaching a USB
device to the Linux VM due to calling the statx syscall, which was
missing from the seccomp policy. stat was already allowed, so add statx
as well to prevent the crash.

The change is likely due to the upgrade of the Rust toolchain in the
Chrome OS SDK (https://crrev.com/c/3439725), which landed in this build.

This was already allowed on arm/aarch64, so no other changes are
required.

BUG=b:218565401
TEST=Attach USB device to crosvm on hatch

Change-Id: Ia3a383429a839c68b44040f4b99c990a1f1f8e9d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3448188
Reviewed-by: Long Cheng <lgcheng@google.com>
Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-02-11 19:40:28 +00:00
Dennis Kempin
5f46e21c02 Remove rutabaga_gfx_ffi from workspace
The crate requires special compilation flags that conflict with the
workspace flags.

We may want to consider moving it to common/ so the test runner can
compile it in a separate workspace.

This brings us one step closer to be able to run
`cargo build --workspace` with no excludes.

BUG=b:206689789
TEST=./tools/presubmit

Change-Id: Ice747ced00f81db0a8e05ff2bc43d4d0e323e456
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3453050
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-02-11 15:58:56 +00:00
Lepton Wu
6ac3f7332d gpu: Allow F_GET_SEALS arg in fcntl
This is used in upcoming virglrenderer change:
https://gitlab.freedesktop.org/virgl/virglrenderer/-/merge_requests/688

BUG=None
TEST=manual - push updated policy to device and no crash.

Change-Id: Ic95d2cedcc13542b6ee3864b5a39ed2bce794c3a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3453118
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Lepton Wu <lepton@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Lepton Wu <lepton@chromium.org>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
2022-02-11 06:08:38 +00:00
Alexandre Courbot
4da0e52ba5 Cargo.toml: add "chromeos" and "lto" build profiles
Add a "chromeos" profile that mimics the flags used when compiling for
Chrome OS. This is useful to determine how much the crosvm binary will
inflate due to a given CL.

Also add an "lto" profile enabling LTO on top of the "chromeos" profile,
so we can easily see how much space we save by enabling LTO.

BUG=b:218473401
BUG=b:218566754
TEST=cargo build --profile chromeos
TEST=cargo build --profile lto

Change-Id: I2fd743b6c980b847af1f3db593a55b683cbb8d57
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3450026
Reviewed-by: Anton Romanov <romanton@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-02-11 05:34:19 +00:00
Dennis Kempin
12ae5e8bc8 Update ./tools/presubmit defaults and add --all mode
The new default should be quick, aarch64 tests barely take longer
than clippy/fmt and gives good enough coverage for most things.

The --all mode will add all other builds run by kokoro, including
armhf and a --no-default-features build.

BUG=b:203152778
TEST=./tools/presubmit (--quick, --all)

Change-Id: Ie778f397e9d65d9ca79bcb55acf0e74394bb04af
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3447293
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-02-10 22:04:18 +00:00
Dennis Kempin
4d0436e74e Add DO_NOT_RUN_ON_FOREIGN_KERNEL option
While we can run armhf binaries on aarch64 or use user-space emulation
to run aarch64 tests on the x86 host, some tests will fail in that
scenario as they will interact with kernel APIs directly (e.g. kvm).

This will make it easier to distinguish 'do not run on armhf because
we haven't fixed the tests' from 'this test is not supported on
a foreign arch kernel and that is expected'.

It also enables a quicker method of running aarch64 tests with
user-space emulation.

BUG=b:218374759
TEST=./tools/dev_container ./tools/run_tests --target=host
--arch=aarch64

Change-Id: I81871e11d3b02ee1ed3bac88bada28fbba8a3f31
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3447292
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-02-10 22:04:18 +00:00
Keiichi Watanabe
ee58ebff65 devices: vvu: Disable time-consuming tests on non-native environment
BUG=none
TEST=kokoro

Change-Id: Id1de70e3037c03d0d204793b0015992a8ff15cb9
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3451760
Auto-Submit: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-02-10 16:30:50 +00:00
Kaiyi Li
74abb9de04 rutabaga_gfx: use as to perform type conversion
On Windows os_handle is of type void*, can't use Into::into to cast to
i64. Use as i64 instead.

Test: launch_cvd
Change-Id: I7fe44dbadf5214ff9bfd81482f5b598091a8f692
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3448217
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Kaiyi Li <kaiyili@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Kaiyi Li <kaiyili@google.com>
2022-02-10 16:30:04 +00:00
Keiichi Watanabe
c8d819dda8 devices: vhost-user: block: Support VVU
crosvm device block --vfio 0000:00:07.0 --file disk.img

BUG=b:213532031
TEST=Run vvu on QEMU

Change-Id: Idf288c0d6ec9e6784772f3147e4a25607bd434f1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3245356
Reviewed-by: Chirantan Ekbote
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Auto-Submit: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2022-02-10 11:22:14 +00:00
Keiichi Watanabe
6f9c40feee devices: vhost-user: Extend DeviceHandler to support VVU
BUG=b:194137301
TEST=cargo test in devices

Change-Id: I1b5a53eec0114f35421512f374f7cec693520fd7
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3149876
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Auto-Submit: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2022-02-10 11:22:13 +00:00
Andrew Walbran
a24a752708 Disable RNG device for protected VMs.
They can't trust the host to provide entropy, so there's no point
providing it.

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

Change-Id: I5355e846191d34e10c0c5c3cf0b2afaa3c779313
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3450875
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Andrew Walbran <qwandor@google.com>
2022-02-10 10:04:55 +00:00