Commit graph

3679 commits

Author SHA1 Message Date
Keiichi Watanabe
0f6e096bbf devices: vvu-proxy: Introduce enum representing connection status
BUG=b:232273004, b🅱️216407443
TEST=cargo build

Change-Id: Ic3fecab7d3c04cdd09f5c77b849c1fac7ee43f7b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3640875
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Abhishek Bhardwaj <abhishekbh@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2022-05-17 06:06:40 +00:00
Junichi Uekawa
8a2188ae51 crosvm: Sort VmComponents and RunnableLinuxVm.
BUG=None
TEST=build

Change-Id: I64ebd32a24e28fdc7417b53a19c1ec94c833674d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3649385
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
2022-05-16 23:49:22 +00:00
Vikram Auradkar
b448c016d8 crosvm: move unix specific host_ip and seccomp related args
BUG=b:227659915
TEST=presubmit

Change-Id: I1387f4a23098213e03cd694d76c625835608f821
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3647896
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
2022-05-16 23:30:54 +00:00
Vikram Auradkar
ec482840b9 crosvm: Better error message
Prints only compiled-in options

BUG=b:227659915
TEST=presubmit

Change-Id: If58013fc0d0387237da0c4ab0677efcd317a6fed
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3649737
Commit-Queue: Vikram Auradkar <auradkar@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-05-16 23:30:53 +00:00
Vikram Auradkar
9c2fe689b7 crosvm: move more unix specific code out of main
Also introduces helper function is_gpu_backend_deprecated.

BUG=b:227659915
TEST=presubmit

Change-Id: Ieee6e7fa747b5c2ef80b825487ae4f191e0550f1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3647895
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
2022-05-16 23:30:52 +00:00
Richard
df8201cfc6 vhost_user: Refactored mod.rs files to match style guide and to include
Windows imports

BUG=b:213149291
TEST=built and presubmits

Change-Id: I04c113accf23c82f1119835ae3570b3149694390
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3646780
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Richard Zhang <rizhang@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
2022-05-16 14:24:44 +00:00
Junichi Uekawa
8958e11283 crosvm: Sort struct Config default initializers.
BUG=None
TEST=build

Change-Id: Id1d86ac775bd32375cd03456aba7a14e9cc4c00e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3644537
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-16 11:03:34 +00:00
Junichi Uekawa
90f281c1ff crosvm: Use /dev/zero instead of /dev/mem
/dev/mem doesn't exist inside the dev_container and test failed because
/dev/mem is not there. We don't actually care about what file it is here
although it is typically /dev/mem, so use /dev/zero instead.

BUG=None
TEST=DOCKER=podman ./tools/dev_container cargo build --features=direct

Change-Id: Ic07ed6c3bf222c24eea1387028afbeb52e5c8563
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3643357
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-05-14 12:21:02 +00:00
Vikram Auradkar
cc3fcb8e9d crosvm: carve-out unix specific parts of parse_ac97_options
BUG=b:227659915
TEST=presubmit

Change-Id: Ie0ee9e751f36d8572270dcb68e9972ac0107dae0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3647894
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-05-14 00:31:56 +00:00
Vikram Auradkar
4281630b12 crosvm: carve-out unix specific parts of start_device
BUG=b:227659915
TEST=presubmit

Change-Id: I96f5e8ccaa30888f77e78c3b8a1ebf8b0947b70e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3646032
Reviewed-by: Noah Gold <nkgold@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
2022-05-14 00:31:55 +00:00
Alistair Delva
e3cae7275b crosvm: drop a few useless legacy I/O ports
Remove a few ioports that did nothing, but were specifically wired up to
stubs so they would not generate debug prints.

Port 0xed will only be used by Linux if io_delay=alternate is set on the
cmdline, which was only required for some quirky PC hardware.

Ports 0xf0 ("busy latch reset") and 0xf1 ("coprocessor reset") were only
required by some i386 PC clones without native FPU support.

Dropping this code simplifies the removal of the no_legacy cfg which
will be done by a future change.

BUG=b:223443221
TEST=crosvm run kernel
TEST=crosvm run --bios u-boot.rom --disk kernel

Change-Id: I7b71bd6799759ac3d35be4eb9e157d4eedd9f0c5
Signed-off-by: Alistair Delva <adelva@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3510981
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-05-13 21:25:06 +00:00
Vikram Auradkar
5b3cfb9143 crosvm: carve-out unix specific set and get arguments
BUG=b:227659915
TEST=presubmit

Change-Id: I1e7080c6cb19ffe34c052524933711b12d750b2f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3643041
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
2022-05-13 20:11:25 +00:00
Sahitya Tummala
a6945f4a49 aarch64: Add support for loading kernel image formatted as ELF
This is done similar to x86 platform to check if a kernel image have
ELF signature first and if it doesn't, then it is passed to the Image
loader as a fallback.

BUG=b:232360323

Change-Id: I27b362952bd7f2678d1c7646b1b1c052c3518fca
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3646449
Commit-Queue: Steven Moreland <smoreland@google.com>
Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-13 18:48:12 +00:00
Ryan Neph
646de85eee gfxstream: fix fence_handler not stored in fencing cookie
While we support both the old and new fence handling methods of
b:175527587, we need two copies of the RutabagaFenceHandler (one for
each method).

BUG=b:228051513,b:175527587
TEST=emerge crosvm
TEST=tested by gfxstream team

Change-Id: I516cf135819aebb5128e41b8a9d585e17680c6a9
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3646777
Commit-Queue: Ryan Neph <ryanneph@google.com>
Auto-Submit: Ryan Neph <ryanneph@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Kaiyi Li <kaiyili@google.com>
2022-05-13 18:37:56 +00:00
Richard
eb0cf09769 devices: vhost_user: Split up system specific code in fs device
The fs device doesn't have Windows specific code. This CL just splits up
system specific code in order be consistent with the formats of other
devices.

BUG=b:229902431
TEST=built and presubmits

Change-Id: I6a1a7c68d89536d8d5f6a1d45c4727739bdca6a8
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3642341
Reviewed-by: Noah Gold <nkgold@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Richard Zhang <rizhang@google.com>
2022-05-13 16:07:33 +00:00
Vaibhav Nagarnaik
bb30f23ce0 hypervisor: Upstream traits changes for Vm
Add to the `trait Vm` 2 new methods that allow more control for
hypervisors when dealing with memory (un)mapping. This is intended for
dealing with expanding and releasing memory from `virtio-balloon`.

For windows based hypervisors, balloon expansion triggers OS interaction
with reclaiming memory pages, which is automatically managed in KVM.
Similarly, a balloon deflation will cause OS interaction for releasing
memory back to the OS.

Update the error return for `remove_mapping` when `madvise` call fails.

BUG=b:213150327
TEST=compiled.

Change-Id: I6ac04d27ac06ea97825f4d22e36543b5dde5b032
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3640424
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Vaibhav Nagarnaik <vnagarnaik@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-05-13 00:30:09 +00:00
Xiong Zhang
1b27aef288 x86_64: Add parameter to speicify pcie cfg mmio base and size
Previous pcie cfg mmio is predefined as constand to avoid conflict with pci mmio,
this has two issues:
a. The size of pcie cfg mmio is limited to 64MB, so the max pci bus number is 64.
This isn't ennough for vfio-pci device, as such device's bus number is same as
host bus number, it may be above 64.
b. In manatee, CrOS may be required to have the same pcie cfg mmio base and size
as host.

So this commit add a parameter and let user could specify pcie cfg mmio base and
size. Then the guest memory layout will be adjusted to avoid conflict between
guest ram and pci low mmio.

BUG=b:197877871
TEST=run crosvm with --pcie-ecam=xxxx,xxxx, check vm's memory layout and pcie
ECAM function

Change-Id: I22cf7e2b3f01ab3f48dff9f5246cb1c24faa9703
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3305948
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-05-13 00:19:52 +00:00
Daniel Verkamp
f0e09415a5 rutabaga_gfx: silence unused_mut warning for non-virgl builds
When the virgl_renderer and gfxstream features are not enabled (e.g. in
a default `cargo build`), the use_timer_based_fence_polling variable is
never written, so the compiler warns about an unused `mut`. Add an allow
to silence this warning (we could use cfg checks to optionally add the
mut, but that would be much more complex for no real gain).

BUG=None
TEST=cargo build # no warnings

Change-Id: I176185328322d9d65cadce602ed09d43ef9eb4e4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3646451
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-05-12 22:19:43 +00:00
Daniel Verkamp
96e50eb795 base: return SmallVec directly from platform wait impls
On Windows, this changes the EventContext::wait() return type from Vec
to SmallVec; this removes an extra conversion step, since the only
caller, WaitContext::wait(), constructed a SmallVec from the return
value anyway.

On Linux, this lets us get rid of the PollEventsOwned structure, since
the SmallVec contains the events and does not need to point back at a
separate type for storage.

BUG=b:213153157
TEST=tools/dev_container tools/presubmit --all

Change-Id: I7857a306ad71be020af309d4186d9e3e651fcc05
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3633110
Reviewed-by: Noah Gold <nkgold@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-05-12 20:37:30 +00:00
Richard
65b3c0fe97 devices: Upstream Windows vhost-user block vmm code
Main update is separating unix and windows to have their own `Block::new` constructor. Also made a `get_all_features` platform agnostic constructor helper since it can be shared on both platforms.

BUG=b:227364312
TEST=built and presubmits

Change-Id: Ie5073389c7e6961fa397bd07275cafb3d571d66d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3578375
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Richard Zhang <rizhang@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
2022-05-12 18:28:18 +00:00
Richard
0e5ee848ea devices: Upstream Windows vhost-user block device
The biggest change is adding a platform agnostic constructor helper method
`BlockBackend::new_from_async_disk`. `BlockBackend::new` is moved to the
sys module since it's only used by Linux and Windows will have a
`BlockBackend::new_from_files` constructor.

Next step will be to upstream Windows vhost-user block vmm.

BUG=b:227364312
TEST=built and presubmits

Change-Id: I80a6e219f7139c17abb5a00d3ba3e89a9a994030
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3576953
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Richard Zhang <rizhang@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2022-05-12 18:15:29 +00:00
Shao-Chuan Lee
c3c170f780 Revert "base: Add CloseNotifier support to Linux"
This reverts commit b10fa49a6f.

Reason for revert: made ARCVM unresponsive during CTS tests

Original change's description:
> base: Add CloseNotifier support to Linux
>
> This is necessary for its cross-platform usage in metrics.
>
> BUG=b:213152497
> TEST=build
>
> Change-Id: I6618777679349d1f6298f79e1f93fe4e9a3ecf7a
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3622798
> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
> Tested-by: kokoro <noreply+kokoro@google.com>
> Commit-Queue: Michael Hoyle <mikehoyle@google.com>

BUG=b:213152497,b:232316549
TEST=CtsAccessibilityServiceTestCases

Change-Id: If27d2ad016878896a261d6d80c4ea3e252ddd08e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3641219
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Michael Hoyle <mikehoyle@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Auto-Submit: Shao-Chuan Lee <shaochuan@chromium.org>
2022-05-12 16:31:52 +00:00
Shao-Chuan Lee
55a5c8d8f9 Revert "metrics: Add metrics crate."
This reverts commit 4c2017c757.

Reason for revert: dependency crrev.com/c/3622798 caused regression

Original change's description:
> metrics: Add metrics crate.
>
> This crate is effectively a collection of stubs in this repo,
> but will allow a downstream repo to implement those stubs.
>
> BUG=b:213152497
> FIXED=b:213152497
> TEST=build + kokoro
>
> Change-Id: I3c544644ec3d7917f9ebb2e8621042c35b556db8
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3622799
> Reviewed-by: Noah Gold <nkgold@google.com>
> Commit-Queue: Michael Hoyle <mikehoyle@google.com>
> Tested-by: kokoro <noreply+kokoro@google.com>

BUG=b:213152497,b:232316549
TEST=CtsAccessibilityServiceTestCases

Change-Id: Idd636d7d34e68977fffc1f6c0a89924eb7be5d54
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3641218
Auto-Submit: Shao-Chuan Lee <shaochuan@chromium.org>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Michael Hoyle <mikehoyle@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-05-12 16:31:51 +00:00
Zhao Liu
34d958f581 crosvm: Add MSR handler after setting CPU affinity
For MSR handlers with "from running CPU" configuration, they will open
and store the MSR file descriptior immediately while their creation.

So move their creation after crosvm sets CPU affinity for each vCPU
thread can avoid storing redundant MSR file fds.

BUG=b:225375705
TEST=Set `--userspace-msr=0x1a2,type=r,action=pass,from=cpu0`

Change-Id: Iaa7bf804595ef45eec150e826be87c86ffeeef24
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3641478
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
2022-05-12 04:54:11 +00:00
Xiong Zhang
f6173ca7bb x86_64: Change guest memroy layout from constant to variables
When pcie cfg mmio and pci low mmio address could be specified by user,
guest memory layout will be changed to avoid conflict between guest ram,
and pci mmio below 4G. So this commit changes them from constant to
variables, the default value is prefined constand value, but it could
be changed later.

BUG=b:197877871
TEST=tools/presubmit

Change-Id: I5ad1f9d6a050d83ea16a53b926d1fadfac1ed75d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3305947
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
2022-05-12 01:17:36 +00:00
Xiong Zhang
efb69c3c0a x86_64: Move PCIE config mmio into pci low mmio
By default PCIE config mmio is above pci low mmio, and they are adjacent.
When user could specify pcie config mmio address and size, the specified
address range will be highly overlap with pci low mmio or guest memory,
then it will split pci low mmio or guest memory. Finally three memory
regions exist in the below 4G space: guest ram, pci low mmio and
pcie config mmio.

In order to simplify memory space management, this commit move pcie
config mmio into pci low mmio, and pcie config mmio is reserved from
pci low mmio at the beginning. In this way, only guest ram and pci
low mmio exist in below 4G space.

BUG=None
TEST=boot a vm and check memory layout below 4G.

Change-Id: I0b253b7bf7fb0287a27a88b34ee28b0a0bd2d172
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3578016
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-12 01:17:35 +00:00
Xiong Zhang
3be45af929 linux: Reserve direct mmio in mmio allocator
Direct mmio range couldn't be assigned to any device, so this commit
exclude them from mmio allocator before build_vm().

BUG=None
TEST=tools/presubimt and boot manatee

Change-Id: I71414de1d44545e2c490ce75f5ced5545752858f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3605163
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-05-12 01:17:34 +00:00
Xiong Zhang
496bcbe8bf resource: Add reserve_mmio() function
Some mmio should be reserved from mmio allocator such as direct mmio and pcie config mmio,
and the space of mmio allocator is determined by arch and mmio-address-range parameter
which are in different model, it is hard to exclude the reserved mmio at mmio allocator
creation.

So this commit add a reserve_mmio() function, so that different model could call it.
If any part of the reserved mmio has been allocated, it returns Error, the caller
should handler it.

BUG=b:197877871
TEST=tools/presubmit

Change-Id: If64542ee0cef7b8949e4bd01d27f6119aea4eea0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3605162
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-12 01:17:33 +00:00
Junichi Uekawa
350e0520c9 crosvm: Sort struct Config
The order doesn't matter and every time I add something it conflicts.

BUG=None
TEST=build

Change-Id: Iebf3bc2636160e05ad120f5f8d2a16de60e54034
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3636539
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-12 00:49:49 +00:00
Vikram Auradkar
151a573acc base: catch-up with downstream windows changes
- Updates changes to named-pipe.
- Adds high resolution timer support.

BUG=b:213153157
TEST=presubmit

Change-Id: I08615d343aaa0f6576f3e8df884310adf3ade087
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3639144
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-12 00:21:59 +00:00
Keiichi Watanabe
2d93d4473c devices: vvu: Make driver exit when a sibling closes connection
When a sibling shuts down, the VVU device process in the guest will exit

BUG=b:216407443
TEST=run vvu on workstation

Change-Id: I0c067b3fbea705dab362f9a3fd05e3770f1dc519
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3591104
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Auto-Submit: Keiichi Watanabe <keiichiw@chromium.org>
2022-05-11 22:40:49 +00:00
Long Cheng
1d32cd6312 Only ingore first set_config to active config
When a usb device is attached to guest kernel, guest kernel will
Try to set the usb configuration to value returned by
usb_choose_configuration. Unless the device has multiple configurations
and host side set it before attach to guest os, it will be same value
as what host kernel would set it during initialization. This would casue
a device reset and for Android devices in adb mode it will cause a
disconnect and reconnect.

Also we should allow user space trying to reset the device by setting
device configuration to active configuration.

BUG=b:123374026
BUG=b:232272092
TEST=Able to attach Pixel2 and Pixel4 to vm
TEST=Run CTS usb device verifer test on both phones
TEST=adb from crostini to test phones

Change-Id: I0e30aaa1b42a18741a2981e256d2268c1a70c46f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3631026
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Long Cheng <lgcheng@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-11 20:02:03 +00:00
Ryan Neph
4b23ee78bc gfxstream: enable async_fence_cb
Flip the switch for Gfxstream to stop using timer-based fence
polling and start using async fence handling callback.

BUG=b:175527587
BUG=b:192614792
TEST=cargo build --features=virgl_renderer,virgl_renderer_next,gfxstream
TEST=Run glxgears and vkcube in a crosvm guest VM with virglrenderer

Change-Id: I5f00f44d29bd584ad554d8892e9f13448c29c712
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3628303
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Ryan Neph <ryanneph@google.com>
2022-05-11 19:44:16 +00:00
Ryan Neph
d255742197 gfxstream: add support for per-context fencing
This adds the asynchronous interrupts in crosvm-gpu for gfxstream.
This will allow gfxstream to alternate between the main signalling
method (ASG [1]) and the more traditional interrupts when it
makes sense performance-wise.

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

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

BUG=b:175527587
BUG=b:192614792
TEST=cargo build --features=virgl_renderer,virgl_renderer_next,gfxstream
TEST=Run glxgears and vkcube in a crosvm guest VM with virglrenderer

Change-Id: I52b8eb0e70671e8b43bae6e9e5264268bfb076df
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3628301
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Ryan Neph <ryanneph@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Kaiyi Li <kaiyili@google.com>
2022-05-11 19:44:15 +00:00
Ryan Neph
d5fa537753 rutabaga_gfx: avoid fence_poll() if all components use async_fence_cb
An optional performance optimization that almost completely avoids the
wakeup cost of timer-based fence polling when all RutabagaComponents use
async_fence_cb. There is still a small overhead from the per-loop
virtio_gpu.needs_fence_poll() tests. This overhead will be removed in
later CLs, when timer-based fencing support is removed.

BUG=b:175527587
TEST=cargo build --features=virgl_renderer,virgl_renderer_next,gfxstream
TEST=Run glxgears and vkcube in a crosvm guest VM with virglrenderer

Change-Id: Id9f14bcbdaa4dcdc42b24be12d85cad2ea0efed5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3628300
Commit-Queue: Ryan Neph <ryanneph@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-11 19:44:15 +00:00
Ryan Neph
e246fff20c rutabaga_gfx: support fence handling via async callback
Adds another method for fencing where a rutabaga component may provide
an asynchronous callback for fence completion. When this method is
enabled, fences no longer need to be polled on the main thread.

When async_fence_cb is enabled, optional polling still occurs for
Rutabaga Components that still rely on it for other purposes (e.g.
virglrenderer for GL query checking).

Both the old and new methods of fence handling are supported with this
CL; e.g. timer-based polling and async callback, but timer-based polling
is the only one active. Follow-up CL(s) will switch to using the async
callback for each RutabagaComponent. Support for the old timer-based
polling will be removed after the async callback method stabilizes in
production.

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

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

This is a pseudo-reland of commit
a999284da2, but modifications have been
made to support both fencing methods simultaneously.

BUG=b:175527587
TEST=cargo build --features=virgl_renderer,virgl_renderer_next,gfxstream
TEST=Run glxgears and vkcube in a crosvm guest VM with virglrenderer

Change-Id: I28f754aeef01972a01dab7990267415814a36c77
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3628299
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Ryan Neph <ryanneph@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-05-11 19:44:13 +00:00
Daniel Verkamp
b5f8224312 base: windows: use sync::Mutex to avoid unwrap()
Switch the uses of std::sync::Mutex to our custom sync::Mutex, which
panics internally if lock() fails. This helps to reduce the instances of
unwrap(), making it easier to review and understand the code.

BUG=b:213153157
TEST=tools/dev_container tools/run_tests --target=host --arch=win64

Change-Id: I99bfc85967152f50045e64293104de788a5d3829
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3633108
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-05-11 17:56:27 +00:00
Vikram Auradkar
8212e88f83 base: add generate_uuid function
This function will be used by crash reporter to associate a unique id
to a session.

BUG=b:213153157
TEST=presubmit

Change-Id: I5f17e023f8895a75062d80773d1aac6315ce4dcf
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3639685
Commit-Queue: Vikram Auradkar <auradkar@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-11 15:43:25 +00:00
Li-Yu Yu
18f0830489 README: Update link to contributor guide
https://crrev.com/c/3557813 moved
/doc/book/src/contributing.md to /doc/book/scr/contributing/index.md

The link needs to be updated as well.

BUG=b:227345067
TEST=curl -I https://google.github.io/crosvm/contributing/
     shows HTTP/2 200

Change-Id: I6f659fde2d03da573f63cc656d95d24a253138b0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3640903
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
Commit-Queue: Chih-Yang Hsia <paulhsia@chromium.org>
2022-05-11 13:21:04 +00:00
Zyta Szpak
467430613a virtio: video: Increase command queue size
The queue size defines the number of available descriptors, that can be
used for exchanging messages between guest and hypervisor. Each
virtio-video command uses at least 1 descriptor (eg. CMD_QUEUE uses 2).
The amount of descriptors in use depends on the number of sessions and
buffers in input and output video queue.
In the worst case scenario the peak number can reach over 672 for 8
simultaneous streams, with 26 + 16 buffers each just for CMD_QUEUE
commands alone.

If the entire queue is overfilled with CMD_QUEUE for OUTPUT queue only,
the driver has no free descriptors for INPUT queue buffers. This leads
to encoder/decoder starvation, hence no OUTPUT buffer can be produced
and no CMD_QUEUE will finish, which leads to dead locking the device.

This patch increases the queue size with consideration of above details
with some headroom to avoid driver's deadlock.

BUG=b:204055006
TEST=App from https://github.com/chromeos/video-decode-encode-demo.git
with 8 simultaneous stream runs without blocking the device.

Change-Id: If51e340dd501b5b261518fba23fc541e3b55af8a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3606869
Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
Reviewed-by: Emilie Roberts <hadrosaur@google.com>
Reviewed-by: Chih-Yu Huang <akahuang@chromium.org>
Commit-Queue: Marcin Wojtas <mwojtas@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-11 08:05:32 +00:00
Anton Romanov
a4cb63d7ce crosvm: add example rust baremetal app that can be booted with crosvm
BUG=none
TEST=`cargo run`

Change-Id: I97eb56eec0d08c67e62755ef21b5ac0cd3e9a461
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3638965
Tested-by: kokoro <noreply+kokoro@google.com>
Auto-Submit: Anton Romanov <romanton@google.com>
Commit-Queue: Anton Romanov <romanton@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-05-10 23:36:47 +00:00
Vikram Auradkar
878a53ea57 base: remove wildcard exports
Also exports few more windows symbols.

The current exports are not well grouped/organized yet. We will get to
that in another patch.

BUG=b:213153157
TEST=presubmit

Change-Id: I902ec0f9f572ac7889bd7703365dad472fc8d930
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3636274
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
2022-05-10 21:04:22 +00:00
Daniel Verkamp
5297fadcc9 devices: virtio: clean up unsupported flags
Several devices were accepting virtio ring flags that they don't
actually support; remove these, as well as the common base_features
flags that are provided by the generic virtio device infrastructure.

The features removed from device implementations are:
- VIRTIO_F_VERSION_1: set by base_features()
- VIRTIO_RING_F_EVENT_IDX: set by base_features()
- VIRTIO_RING_F_INDIRECT_DESC: unsupported
- VIRTIO_F_NOTIFY_ON_EMPTY: unsupported
- VHOST_F_LOG_ALL: unsupported
- VIRTIO_F_ANY_LAYOUT: unsupported; transitional devices only

BUG=None
TEST=tools/presubmit --all

Change-Id: I9619d9bb784cb47ec85ffa4e25b7a743284d6da6
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3582525
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2022-05-10 21:00:11 +00:00
Daniel Verkamp
3b98d5476a devices: virtio: mask bits in driver ready check
Previously, the check would only accept exactly the combination of bits
we specify in ready_bits due to the == comparison; the second check for
the failed bit would never be reached. Instead, mask off only the bits
we are interested in checking before comparing them.

BUG=None
TEST=tools/presubmit --all

Change-Id: Ib6cccdb249adeb267282ec0e5b51c0ac6b572490
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3582524
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-05-10 21:00:09 +00:00
Daniel Verkamp
78c474d423 virtio: create a DeviceType wrapper enum
This makes the VirtioDevice::device_type() function return type more
descriptive, and it lets us implement fmt::Display for the type instead
of a custom type_to_str() function.

BUG=None
TEST=tools/presubmit --all

Change-Id: Icfc2be37cf31ecab5e73f4b29c2eaaaa417317ab
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3582523
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Abhishek Bhardwaj <abhishekbh@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-05-10 21:00:07 +00:00
Vaibhav Nagarnaik
b929c1e2be kvm: Fix assert check
For handling HYPERV hypercalls, the exit reason needs to be checked
against KVM_EXIT_HYPERV.

TEST=Compiled.

Change-Id: Ib11d558e25e2c5fd037e1bc6ca88a454e957a1c8
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3639149
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Vaibhav Nagarnaik <vnagarnaik@google.com>
2022-05-10 20:45:34 +00:00
Tinghao Zhang
7f1b94e96a devices: pci: use msi for pcie bridge
This patch split msi emulation from vfio-pci to a seperate file
msi.rs and make it usable for other devices. And we make pcie
bridge use msi instead of msi-x. The reason to use msi is that
msi-x would need extra mmio bar allocation, which does not work
when bridge is hotplugged into the system.

BUG=None
TEST=check msi functionality in both pcie root port and vfio device

Change-Id: Id262e4635d074c2a952807a625c8a0bf0afbf86a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3591961
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Xiong Y Zhang <xiong.y.zhang@intel.corp-partner.google.com>
2022-05-10 20:02:51 +00:00
Michael Hoyle
4c2017c757 metrics: Add metrics crate.
This crate is effectively a collection of stubs in this repo,
but will allow a downstream repo to implement those stubs.

BUG=b:213152497
FIXED=b:213152497
TEST=build + kokoro

Change-Id: I3c544644ec3d7917f9ebb2e8621042c35b556db8
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3622799
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Michael Hoyle <mikehoyle@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-10 03:52:13 +00:00
mikehoyle
b10fa49a6f base: Add CloseNotifier support to Linux
This is necessary for its cross-platform usage in metrics.

BUG=b:213152497
TEST=build

Change-Id: I6618777679349d1f6298f79e1f93fe4e9a3ecf7a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3622798
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Michael Hoyle <mikehoyle@google.com>
2022-05-10 03:52:11 +00:00
Zhao Liu
e2f8fb4fcb x86_64: Add description of intel ITMT option
ITMT option allows VM to enable ITMT scheduling, but it doesn't ensure
the success of ITMT scheduling in VM.

Whether ITMT enabling can succeed depends on HWP and ACPI CPPC support
on hardware.

This option exposes related HWP and CPPC information to VM and the
intel_pstate driver of VM will decide wheter to enable ITMT scheduling
or not.

BUG=b:225375705
TEST=Set `--itmt` and check /proc/sys/kernel/sched_itmt_enabled

Change-Id: I5d12cf3fb1a30b040945e8d1db68063e810217b9
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3636808
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
2022-05-10 03:13:53 +00:00