Commit graph

2692 commits

Author SHA1 Message Date
Keiichi Watanabe
a939c0c77f vmm_vhost: vhost_user: Simplify send_iovec_all algorithm
BUG=b:204720423
TEST=cargo test --all-features

Change-Id: I554526fb39fb5f2aad14189d4825033290d1d6d4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3268264
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2021-11-10 08:42:15 +00:00
Keiichi Watanabe
a205dc949a vmm_vhost: vhost_user: Remove redundant slice conversion
BUG=b:204720423
TEST=cargo test --all-features

Change-Id: I67c73412a22e52238b0378e5b35dfdb0c72aa68b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3267923
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2021-11-10 08:42:14 +00:00
Keiichi Watanabe
1704332e1c vmm_vhost: Use thiserror and remain::sorted for Error enums
BUG=b:204720423
TEST=cargo test --all-features

Change-Id: Ic54eb2b625d0eb2f77c58356729cd6a68d5047c7
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3267922
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2021-11-10 08:42:14 +00:00
Keiichi Watanabe
d89b31e8d8 vmm_vhost: Enable clippy::{bool_assert_comparison, needless_borrow}
Fix clippy::bool_assert_comparison and clippy::needless_borrow, which
were temporally added at crrev.com/c/3267912.

Most changes are trivial.
`test_should_reconnect` in vhost_user/mod.rs was deleted because the
test doesn't make much sense as a unit test, because it just copies and
pastes the logic of `Error::should_reconnect()`.

BUG=b:205511695, b:204720423
TEST=./tools/clippy
TEST=cargo test --all-features in third_party/vmm_vhost

Change-Id: I664b3aa7df054871d7e127b6dffd0315f9d4c48c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3267918
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2021-11-10 08:42:13 +00:00
Keiichi Watanabe
d7b5f1da0a vmm_vhost: Remove OWNERS file
Remove vmm-vhost's OWNERS file because it became a part of the crosvm
repository now.

BUG=b:205511695
TEST=kokoro

Change-Id: Iba9f64e647d905a4bdd4580b0115bb79085c9a9c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3267921
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2021-11-10 08:42:12 +00:00
Keiichi Watanabe
3a6ec148d6 third_party/vmm_vhost: Add vmm_vhost code into /third_party/
Move rust-vmm/vhost code from chromiumos's third_party directory to
crosvm's one.

Note that we have crrev.com/c/3269863 for license files in Chrome OS
ebuild.

Changes:
* Copied vmm_vhost files at "7c95b4a2 rust-vmm/vhost: switch to upstream
tempfile", whose latest upstream commit is "488b3adc fix warning:
unaligned_references".
* Remove [patch.crates-io] section from its Cargo.toml.
* Add attributes to skip `clippy::bool_assert_comparison` and
`clippy::needless_borrow`, which will be fixed in following CLs.
* Update crosvm's Cargo.toml and tools/chromeos/setup_cargo

BUG=b:205511695
TEST=tools/chromeos/setup_cargo && cargo build

Change-Id: Icee201b39ff1d352df59469a6c8668fc7cb92ab9
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3267912
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2021-11-10 08:42:11 +00:00
Will Deacon
b975546c3f vm-memory: mlock2(MLOCK_ONFAULT) guest memory for protected VMs
By default, the memory of a protected VM is inaccessible to the host
and crosvm. Consequently, attempts to access guest memory are fatal and
must be avoided in order for the guest to run.

Mlock guest pages as they are faulted in for protected VMs, ensuring
that the host doesn't try to age or swap them out as a result of memory
pressure.

Bug: b:204298056
Test: cargo test on x86 and arm64
Cc: Quentin Perret <qperret@google.com>
Cc: Andrew Walbran <qwandor@google.com>
Signed-off-by: Will Deacon <willdeacon@google.com>
Change-Id: I618ec1e8b1136a47a8b3ef563e45bc41d75ab517
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3257689
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2021-11-09 18:59:20 +00:00
Keiichi Watanabe
3230422d59 cargo: Remove *_stub from workspace member
libcras_stub and system_api_stub are empty replacements for libcras and
system_api respectively. so cargo is happy even if they're missing

BUG=none
TEST=cargo build with CL:3267568

Change-Id: I20ba2ca77a241e354a45816605282d06d26f895f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3267907
Auto-Submit: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2021-11-08 18:02:32 +00:00
Junichi Uekawa
7225ebc077 crosvm: Sprinkle notes on API search.
It's not obvious it's possible to search API docs, it's one of the
things I would use the most often if it's reachable.

BUG=None
TEST=read it.

Change-Id: I29df6ae4df3eb667f17e22d0afc00aee80912187
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3267906
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2021-11-08 07:21:20 +00:00
David Staessens
85fa9ce5f1 Revert "virtio: video: reject resources with more than one entry"
This reverts commit 4ceec18783.

Reason for revert: This breaks all ARCVM HW encoding

BUG=b:205488531
TEST=arc.VideoEncodeAccel.h264_192p_i420_vm

Original change's description:
> virtio: video: reject resources with more than one entry
>
> The crosvm video device cannot currently work with resources that have
> more than one memory/object entry. Enforce this rule at the command
> level.
>
> BUG=b:161774071
> BUG=b:169295147
> TEST=Android Youtube plays properly on Hatch.
>
> Cq-Depend: chromium:3247491
> Cq-Depend: chromium:3247492
> Change-Id: Ibfe2e420b4a77062cca940c5e97e7053aa4b76a7
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3026345
> Tested-by: kokoro <noreply+kokoro@google.com>
> Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
> Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>

Bug: b:161774071
Bug: b:169295147
Change-Id: Ib24bd8098b37d696b74bc942cdb7c81719d1b8b6
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3267727
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: David Staessens <dstaessens@chromium.org>
2021-11-08 03:57:27 +00:00
Daniel Verkamp
6b29858a34 linux.rs: replace Error enum with anyhow
Use the anyhow crate to provide ad-hoc errors with context. This removes
the large, manually-updated enum, which we never use programmatically
anyway (error messages are printed in human-readable form and otherwise
not matched against).

BUG=b:190433480
TEST=cargo build
TEST=./test_all

Change-Id: Ia7b90b33774d4031054b346d650861d3105044ee
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3105436
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2021-11-05 23:06:09 +00:00
Xiong Zhang
2d8e1b09a5 Devices: Return bar reallocation info at bar written
Previous commit "devices: Add/Remove device mmio at config memory enable
/disable", it has an assumption that when driver update bar's location,
driver should disable bar's memory/io at first.

But some driver reallocate bar's address even with memory/io enabled,
this commit monitor bar's config write, if address is modified, it
return this  modification.

BUG=b:174705596
TEST=boot a vm, monitor resource reallocation and check function.

Change-Id: I9aa883192f5e2fec344d3e86c818c7a29287f49a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3184726
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-11-05 19:35:10 +00:00
Xiong Zhang
479efab2f5 devices: Don't return bar info if memory/io is disabled
get_bar_configuration() returnis bar's info, this ignores memory/io enable
bit. Usually driver disable memory/io first, then wrtie 0xFFFFFFFF to
probe bar's existence and size, finally write real address and enable
memory/io.

if get_bar_configuration is called after mmio/io disabled, current
it may return invalid info. In order to filter these invalid info,
this commit checks memory/io enable bit, only return info at memory/io
enabled.

BUG=b:174705996
TEST=carto test -p devices

Change-Id: Ib8bf1a7f7f959025117f319f8f6c5a9e5efea2e2
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3252779
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-11-05 19:35:09 +00:00
Christian Blichmann
7a976d3a8a virtio-fs: Apply syscall!() macro to syscall invocations
TESTED=./tools/presubmit --quick

Change-Id: I5238731b9785f315d0869ed85984cf87ed36ad73
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3259940
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Commit-Queue: Christian Blichmann <cblichmann@google.com>
2021-11-05 09:22:30 +00:00
Christian Blichmann
6addda2203 Add override for container tool in dev_container script
This change allows to override the command line tool that is used to
start the dev container in the `tools/dev_container` script. The
Makefile for creating the dev container uses the `DOCKER` env var to
implement this, so this is used here as well.

Rationale: Googlers are advised to not install Docker
(go/dont-install-docker) and to use Podman instead.

If the `DOCKER` variable is unset, the script will try to use
Docker first and podman.

Change-Id: I33bc8e4af632fa982406e838e762572407ccdc22
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3259939
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Christian Blichmann <cblichmann@google.com>
2021-11-05 08:40:43 +00:00
David Staessens
528fcabc5d virtio: video: Allow config changes if encoding hasn't started yet.
When initializing the device for encoding the underlying encoder
session is immediately brought up, as this is required to determine
parameters such as the desired output buffer size. This causes further
configuration changes to be refused, even when the device isn't
encoding anything yet. This CL makes changes to allow configuration
changes by recreating the encoder sessions as long as no buffers have
been queued.

BUG=b:203608233
TEST=tast run DUT arc.VideoEncodeAccel.h264_192p_i420_vm

Change-Id: I7e9d8b41ea2497b5d86aaca7db7ed13af056f11d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3252185
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: David Staessens <dstaessens@chromium.org>
2021-11-05 00:32:33 +00:00
Colin Downs-Razouk
11bed5eef7 devices: re-add set_access_id to bus
We need the access id for some future changes that will be posted soon
for a userspace irqchip.

Each vcpu will have a clone of the Bus itself, not the Arc<Bus>, so that
they can each have their own access id.

This also adds a call to set_access_id to run_vcpu.

BUG=b:160610704
TEST=ran local presubmit, and ran test image

Change-Id: I4afb0ef9c234f25150ce2f89d6fb228ad5b88745
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3261627
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Colin Downs-Razouk <colindr@google.com>
2021-11-04 17:55:18 +00:00
Alexandre Courbot
7f02059afc virtio: video: build backends separately from the codec device
The current way for building a codec device is to call the corresponding
constructor method of the backend we want to use. However doing this
forces us to pass the resource bridge to these constructors, introducing
dependencies from the backend to parts of the code that are not used
otherwise.

Switch the construction method to one constructor per backend, which
only takes the arguments relevant to the backend, and one device
constructor that takes the backend to use as parameter.

BUG=b:161774071
BUG=b:169295147
TEST=Android Youtube plays properly on Hatch.

Change-Id: I493f421e982a1d2ba8292a69bae575afeee17e4c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3026349
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2021-11-04 14:01:22 +00:00
Alexandre Courbot
8230abf39a virtio: video: compile out decoder or encoder if corresponding feature not selected
We have two separate features for video decoder and encoder, but
selecting any of them results in all the video code being included. Add
some #[cfg] statements to compile out the unneeded code if only one of
the features is selected.

BUG=b:161774071
TEST=`cargo build` passes without warning
TEST=`cargo build --features "video-decoder"` passes without warning
TEST=`cargo build --features "video-encoder"` passes without warning
TEST=`cargo build --features "video-decoder,video-encoder"` passes without warning

Change-Id: I3e5f2173695ee9dd5e8d26ace14374d426e570a6
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3026347
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2021-11-04 14:01:20 +00:00
Alexandre Courbot
66ed8cfb41 virtio: video: make backends accept GuestResources as inputs
Make the backends accept our generic resource types as inputs instead of
expecting virtio objects. This makes the backends able to deal with any
kind of resource, the counterpart being that they must now check what
kind of resource they received. The VDA can only deal with virtio
objects and will reject other kinds of resources.

On top of making backends not limited to virtio objects, this is also
safer than passing FDs because it becomes clear when we are transferring
ownership of a resource, and when we need to clone them. Also since
resources carry information about their layout, the number of arguments
we need to pass to the backends is reduced.

BUG=b:161774071
BUG=b:169295147
TEST=arc.VideoDecodeAccel.h264_vm passes on hatch
TEST=arc.VideoEncodeAccel.h264_360p_i420_vm passes on hatch
TEST=GtsExoPlayerTestCases com.google.android.exoplayer.gts.DashTest
passes on hatch

Change-Id: I09dd81bac13a46fa908a4107a376fa7d59fb9759
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2983096
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2021-11-04 14:01:17 +00:00
Alexandre Courbot
cf16363c4c virtio: video: introduce basis for proper resource management
Currently the video device only accepts virtio objects (as file
descriptors) for resources, and file descriptors are hard-coded a bit
all over the place to represent buffers and frames. This causes two issues:

1) Multiple buffers cannot currently be used to represent frames, i.e. 1
   frame is exactly one virtio object,
2) Resources that are not virtio objects, like guest memory, cannot
   be used at the moment.

This patch introduces more flexibility in the way resources are handled:
first, all the resource-related code, including their resolution using
the resource bridge, is consolidated into a new resource module. Then,
the command module does not arbitrarily decide that all resources are
virtio objects, and leaves that decision to the queues. Finally,
resources now have their enum type that can unfold into any of the
resource types we will support (currently only virtio objects). This
forces consumers of resources to check their type before using them.

Semantically, very little should change. The only noticeable side-effect
should be that we now call the resource bridge only once per input
buffer instead of once per decoder operation.

BUG=b:161774071
BUG=b:169295147
TEST=arc.VideoDecodeAccel.h264_vm passes on hatch
TEST=arc.VideoEncodeAccel.h264_360p_i420_vm passes on hatch

Change-Id: I93b203117b5c96e91d4f1b8007e95ec5c501ea5f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2983095
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2021-11-04 14:01:16 +00:00
Alexandre Courbot
4ceec18783 virtio: video: reject resources with more than one entry
The crosvm video device cannot currently work with resources that have
more than one memory/object entry. Enforce this rule at the command
level.

BUG=b:161774071
BUG=b:169295147
TEST=Android Youtube plays properly on Hatch.

Cq-Depend: chromium:3247491
Cq-Depend: chromium:3247492
Change-Id: Ibfe2e420b4a77062cca940c5e97e7053aa4b76a7
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3026345
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2021-11-04 14:01:16 +00:00
David Stevens
5ebe30d0e5 wl: add support for host fences
Add support for guest fences backed by host sync_files. Rather than
adding a new fence type, fences are implemented as vfds that only
support hup. The host simply waits on the sync_file and sends the guest
a hup when the fence is signaled.

BUG=b:169908659
TEST=Revert ag/15543199, resize ArcCameraFpsTest

Change-Id: I8c79ec9f418b1d71150b5a19f500c5ac7a6c9b02
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3199298
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: David Stevens <stevensd@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-11-04 01:24:37 +00:00
Xiong Zhang
e9020b1c83 devices: Add/Remove deviece mmio at config memory enable/disable
When device memory/io is disabled, its mmio/io range should be
removed from mmio_bus/io_bus.

When device memory/io is enabled, its mmio/io range should be
added into mmio_bus/io_bus.

BUG=b:174705596
TEST=Boot a vm, monitor device mmio/io enable/disable, then check
vm function.

Change-Id: Ic77565b9828599d574329bea76146cff597a94fe
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3252778
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-11-03 20:14:02 +00:00
Daniel Verkamp
ff31bcfb48 devices: bus: add BusDevice function to get ranges
When device's bar are reallocated, all the old resource ranges should be
deleted, the new resouce ranges shoud be added, this commit add the
interface to get device mmmio/io old/new ranges.

BUG=b:174705596
TEST=Boot a vm, monitor device bar reallocation and check function

Change-Id: I1000607d9f766ff8b445bf92f17969b094f3b2ae
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2718280
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2021-11-03 20:14:01 +00:00
Xiong Zhang
d982b8d9a3 devices: Introduce remove() for bus
When device's bar is reallocated, the old ranges will be deleted,
this commit add remove() function to delete one old range from
bus->devices.

BUG=b:174705596
TEST=Boot a vm, monitor Bar Reallocation then check function

Change-Id: Id0600ae1d7a3d04c7f05a90abcc8807b7f1020c3
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3184725
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-11-03 20:14:00 +00:00
Dennis Kempin
ccb9014afb Deprecate old dev tooling scripts
All of the developer tooling has moved to ./tools to make them
easier to discover.

BUG=None
TEST=None

Change-Id: I4daf6a0ca08c94a0c35ce8bc52f9d86e4cb15de9
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3251781
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2021-11-02 22:23:03 +00:00
Daniel Verkamp
57e4f542a2 Reland "Devices: Allocate non pci bar mmio at top of HighMmio"
Original reason for revert: Causes crosvm to not start on AMD based devices b/204222491
Fixed by clamping the maximum physical address to 64 TiB, which is the
largest physical address supported by x86-64 Linux with only 4-level
page tables enabled.

In addition, the high MMIO region size calculation has been split into a
separate function, get_high_mmio_size(), and an off-by-one error in the
size calculation was fixed.

Original change's description:
> Devices: Allocate non pci bar mmio at top of HighMmio
>
> Some devices like virtio-pmem, intel host bridge need private mmio, these private
> mmio isn't exposed to Vm through pci bar, and crosvm use mmio allocation interface
> to allocate them, so guest OS pci bus driver couldn't detect them, and once guest
> OS reallocate pci mmio, these private mmmio could be assigned to pci device bar.
> then resource conflict happens.
>
> This patch allocates these non pci bar mmio at the top of HighMmio, since HighMmio
> is large enough and OS allocates pci mmio from low to high. So these non pci bar
> mmio won't conflict with pci bar.
>
> BUG=b:199442120
> BUG=b:185084350
> TEST=crosvm run --pmem-device xxxx
>
> Change-Id: I615d7901d595dd46ba6362f88b71d96baa9c4c8f
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3184549
> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
> Tested-by: kokoro <noreply+kokoro@google.com>
> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>

This is a reland of https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3184549

BUG=b:199442120
BUG=b:185084350
TEST=Crostini starts on grunt (AMD device)
TEST=crosvm run --pmem-device rootfs -p 'root=/dev/pmem0' kernel

Change-Id: I7c93f7132dbfbc3f38ecbfa0504b59214a1eb6bf
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3251788
Reviewed-by: Xiong  Zhang <xiong.y.zhang@intel.corp-partner.google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-11-02 22:08:54 +00:00
Gurchetan Singh
3059851cd0 rutabaga_gfx: export rutabaga
This change adds FFI bindings to the Rutabaga Virtual Graphics
Interface (VGI).

BUG=b:173630595
TEST= compile
      cp rutabaga_gfx_ffi.so + rutabaga_gfx.so to sysroot
      ./rutabaga_test

Change-Id: Iba99b0ace9f1ad90b6c42d9075038dd9f05b9367
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3230331
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2021-11-02 15:53:02 +00:00
Junichi Uekawa
b933598310 crosvm: Add python3-pip dependency.
This is required for the following step.

Updated installation steps so that it is possible to follow the steps
and build.

BUG=chromium:1265286
TEST=./install-deps inside docker container running ubuntu.

Change-Id: Icd6b1c9c3c74c790aba2fd41050ebd2f3470e946
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3255185
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
2021-11-01 23:58:39 +00:00
Keiichi Watanabe
e538834fe1 ci: kokoro: Run mdbook command
BUG=none
TEST=kokoro

Change-Id: I61f80da1c6d82979201aa1b3c11b60d9da6ba705
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3255195
Auto-Submit: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2021-11-01 19:26:51 +00:00
Keiichi Watanabe
1d0ef4d7a3 mdbook: Fix broken links detected by mdbook-linkcheck
Run mdbook-linkcheck locally and fix detected errors.
Note that we avoid running mdbook-linkcheck in CI, as its installation
takes ~1min.

BUG=none
TEST=run GitHub Action

Change-Id: I2bbd5f30486573454dc9ece86353296eca55be70
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3255194
Auto-Submit: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2021-11-01 19:07:01 +00:00
Keiichi Watanabe
73b68faf7f CONTRIBUTING: Add more instruction on use of mdbook command
BUG=none
TEST=check rendered results

Change-Id: I10532c45317f5189bd867850f36e7ae93b4abcc4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3252187
Auto-Submit: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2021-11-01 15:32:26 +00:00
Marc Zyngier
17b1e02fb6 aarch64: Provide the maximum supported IPA size as the machine type
The value 0 passed to KVM_CREATE_VM has a special meaning for KVM/arm64.
It indicates that the VM is configured with a 40bit IPA space.
However, not all HW support such an IPA space, and the KVM_CREATE_VM
call fails on these systems.

In order to maximize compatibility, we can ask KVM for the maximum
supported IPA size, and use that as an input to KVM_CREATE_VM, at
which point the kernel will instantiate a VM with that IPA size.

This enables crosvm on exotic hardware such as the Apple-M1.

TEST=tools/run_tests

Change-Id: I7ea39ac6e5de6a1389c0c30cdfeb7c970c411589
Signed-off-by: Marc Zyngier <mzyngier@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3124677
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2021-11-01 14:24:27 +00:00
Andrew Walbran
d80eabc803 Use constants for third_party code locations rather than hard-coding.
The constants already existed but weren't being used consistently. This
will make the Android downstream patches to change the paths a little
simpler.

BUG=b:204072128
TEST=tools/run_tests

Change-Id: If9b81ef9ca0a7c52f0d9fe7cf836841027a2c92d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3253369
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Andrew Walbran <qwandor@google.com>
Auto-Submit: Andrew Walbran <qwandor@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2021-11-01 13:26:18 +00:00
Dennis Kempin
8f5978fda2 crosvm: Do not use .cargo/config.toml
Building crates in common/ will try to access the file, but won't
be allowed to read it with CROS_WORKON_SUBTREE set.

BUG=b:195126527
TEST=./tools/run_tests --target=vm:aarch64

Change-Id: Ic455ca6c3102dd363daf70468e5d89003d10bb4c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3254042
Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
Reviewed-by: Abhishek Bhardwaj <abhishekbh@chromium.org>
Tested-by: Dennis Kempin <denniskempin@google.com>
2021-10-30 00:16:33 +00:00
Dennis Kempin
8a1c50d5cd Refactoring: Move various general purpose crates to common/
This change contains the results of running

./tools/contib/cargo_refactor.py

This will break the next uprev, and needs to be synchronizized
with the corresponding ebuild changes in https://crrev.com/c/3248925

BUG=b:195126527
TEST=./tools/run_tests

Change-Id: Ied15a1841887bb8f59fba65b912b81acf69beb73
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3248129
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-10-29 22:31:43 +00:00
Keiichi Watanabe
cb14f61ce7 mdbook: Explain how to build a binary for beginner
Add a section to explain how to build crosvm binary for beginners who
may not have used cargo.
Also, ran mdformat on the file.

BUG=none
TEST=check

Change-Id: I902157cd471652b829d73bb27fc52e04db64d6d5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3252186
Auto-Submit: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2021-10-29 16:43:56 +00:00
Keiichi Watanabe
99020040f9 github: Don't use 80-char rule in pull_request_template
Unlike usual markdowns, GitHub comments don't ignore line breaks. So we
should avoid breaking lines at the middle of paragraph.

BUG=none
TEST=none

Change-Id: I1dfc933c8cfba91d7a7b1e411b2cd4193a3487c5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3251825
Auto-Submit: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2021-10-29 16:19:21 +00:00
Keiichi Watanabe
80801406ce github: Use install-deps script
We now install newer meson via pip instead of apt-get.

BUG=none
TEST=run GitHub action on my personal account

Change-Id: Icbe55bf06e84253cd26e676647bca17408ab9d9b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3251824
Auto-Submit: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2021-10-29 16:19:21 +00:00
Keiichi Watanabe
787e5c3dcc CONTRIBUTING: Add a guide for contributing to the book
BUG=b:199687531
TEST=check rendered result

Change-Id: I1fcb4bb2853658866a599394d54d344d4ebc2e50
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3250154
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2021-10-29 03:21:07 +00:00
Keiichi Watanabe
24d6f7a8a3 github: Add yaml for mistaken-pull-closer app
ref. https://opensource.google/docs/github/disable-features/#close

BUG=none
TEST=none

Change-Id: I850718d059737c14f546d9fad438db14bfe3955d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3250156
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2021-10-29 03:21:06 +00:00
Keiichi Watanabe
04eff872d8 navbar: Update navbar contents
BUG=none
TEST=see Gitiles view at Gerrit

Change-Id: I6af5b8f3b65ac5e43d769011843874f9fcee7782
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3250153
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2021-10-29 01:56:24 +00:00
Keiichi Watanabe
daa5b7b27d github: Add pull request template to tell we use Gerrit
BUG=none
TEST=none

Change-Id: I003f0084b8b057d669ec0c6160f4d8fed2871919
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3250152
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2021-10-29 01:56:24 +00:00
Keiichi Watanabe
105a94aaaf README: Use PNG logo image
Use PNG instead of SVG as Gitiles doesn't render SVG well.
In order to make ImageMagick's conversion work well, fill-opacity and
stroke-opacity are explicitly specified in the SVG.

Also, the PNG image will be put at the bottom of README so people can
read contents at first glance without scrolling over the logo.

BUG=none
TEST=check gitiles view on Gerrit
TEST=mdbook build

Change-Id: I2203be1258265400be3caf2ad8d8a1e8cacc5aab
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3250151
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2021-10-29 01:56:23 +00:00
Dennis Kempin
6e3350a956 Add base crate to cargo_refactor
We are adding an ebuild file for this crate in a future
CL: https://crrev.com/c/3251800

BUG=b:195126527
TEST=Run the script

Change-Id: If58c28075d5f3a3d2ad2b8c55714d1f8cdb968ab
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3251784
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2021-10-28 21:04:59 +00:00
Jorge E. Moreira
e40fb21c0d Allow sched_yield in all devices' seccomp policy
The sched_yield system call is somehow called by the code the rust
compiler generates and not directly by the author's implementation. That
along with the fact that it won't get called on every run makes it very
easy to miss when adding a new device (that happened with virtio-snd).
Since that call is quite harmless (it could be argued minijail shouldn't
even block it in the first place) it makes sense to allow it for all
devices.

BUG=b/201306350

Change-Id: I9895da6c8060ae83053474ed9e4472ea2cd8d3e3
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3248126
Auto-Submit: Jorge Moreira Broche <jemoreira@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Jorge Moreira Broche <jemoreira@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-10-28 19:10:45 +00:00
Keiichi Watanabe
31ef2d0b76 mdbook: Add links to source code at top page
BUG=none
TEST=none

Change-Id: Ife7f1d7c8d5885f72e9b489e62735e8b236c1750
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3245056
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-10-28 10:44:45 +00:00
Dennis Kempin
70c66baed0 Revert "Devices: Allocate non pci bar mmio at top of HighMmio"
This reverts commit 9557588786.

Reason for revert: Causes crosvm to not start on AMD based devices b/204222491

Original change's description:
> Devices: Allocate non pci bar mmio at top of HighMmio
>
> Some devices like virtio-pmem, intel host bridge need private mmio, these private
> mmio isn't exposed to Vm through pci bar, and crosvm use mmio allocation interface
> to allocate them, so guest OS pci bus driver couldn't detect them, and once guest
> OS reallocate pci mmio, these private mmmio could be assigned to pci device bar.
> then resource conflict happens.
>
> This patch allocates these non pci bar mmio at the top of HighMmio, since HighMmio
> is large enough and OS allocates pci mmio from low to high. So these non pci bar
> mmio won't conflict with pci bar.
>
> BUG=b:199442120
> BUG=b:185084350
> TEST=crosvm run --pmem-device xxxx
>
> Change-Id: I615d7901d595dd46ba6362f88b71d96baa9c4c8f
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3184549
> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
> Tested-by: kokoro <noreply+kokoro@google.com>
> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>

Bug: b:199442120
Bug: b:185084350
Change-Id: Ida1369bf0b70782633b1073ceef50e1bab108f55
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3248906
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2021-10-27 23:22:53 +00:00
Dennis Kempin
783791441d Refactor script: Move non-workspace crates to common/
This CL contains just a refactoring script, a follow-up contains
the result of running it. This is easier to review than 100s of
search/replace.

I think it makes sense to leave this script around for future
reference if we need to shuffle things around again.

BUG=b:195126527
TEST=None

Change-Id: Ic8cc69946b8e6908877e4fbde44230d40a1ea566
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3232967
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-10-27 22:51:25 +00:00