Commit graph

2529 commits

Author SHA1 Message Date
Daniel Verkamp
1a98986d1d net_util: convert to ThisError and sort
BUG=b:197143586
TEST=cargo check

Change-Id: I21a7908fbe885b1cc0b98c9b3b17d3f4ea807bde
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3105083
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2021-09-24 21:13:17 +00:00
Daniel Verkamp
8c2b990e16 kernel_loader: convert to ThisError and sort
BUG=b:197143586
TEST=cargo check

Change-Id: Ic58e295f225a01f5f12889bf1537c899ff2725aa
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3105082
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2021-09-24 21:13:16 +00:00
Abhishek Bhardwaj
5b36338f9b crosvm: Plumb read_bar and write_bar to VirtioDevice
This change plumbs read_bar and write_bar methods to the VirtioDevice
trait. VirtioDevice exposes PCI bars and the virtio vhost user proxy
device would need these methods.

BUG=b:194136484
TEST=Compile.

Change-Id: Ib65d0fb81feb8af6913a2c2c2bdba80ef6d20d31
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3176396
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Abhishek Bhardwaj <abhishekbh@chromium.org>
Auto-Submit: Abhishek Bhardwaj <abhishekbh@chromium.org>
2021-09-24 07:30:14 +00:00
Dennis Kempin
bfa99f02ba Add testvm.py tool for managing test VMs
The script can be used to run VMs to test crosvm in a controlled
environment, and most importantly, to test crosvm on aarch64.

This will eventually replace the current Docker based VM setup
process and will be integrated into our test runner to allow aarch64
test runs without using Docker.

Run `/tools/aarch64vm` for usage instructions.

Note: I will make a follow-up change to consolidate all of our dev
tools and scripts (e.g. clippy or rustfmt) in the tools directory.

BUG=b:200562467
TEST=
./tools/aarch64vm ssh
./tools/x86vm ssh

Change-Id: Idef8256bf6737b2915912984a44240ba39c6bc2f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3176381
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-09-23 17:47:20 +00:00
Alexandre Courbot
c5dad3fdee virtio: video: remove suspicious code
When outputting a picture there is a bit of code that updates the size
of each output plane to the size of the visible rect. This looks wrong
on several accounts:

1) The plane size should already have been computed when we received the
   buffers,
2) With this code each plane is assigned the same size, which is
   obviously wrong with formats such as NV12,
3) The size in bytes of a plane depends on the coded size, not the
   visible size.

Looking at the git history it appears that this code has been here since
the initial revision of the decoder, and then moved around. Maybe it was
just here to make things work in the beginning and slipped under the
radar. In any case, removing that code does not seem to hurt.

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

Change-Id: I6c8949c49c070daaa3540b757dd35469b571c43c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3026344
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Chih-Yu Huang <akahuang@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2021-09-23 10:50:03 +00:00
Dmitry Torokhov
cc03cdbecc plugin: capture stderr when spawning/jailing plugin binary
While minijail uses syslog to log errors during jail setup, ld.so simply
dumps error into stderr. When debugging plugin startup issues it is
beneficial to see what ld.so might be upset about, so let's capture
stderr of the child and log it.

BUG=None
TEST=removed /opt/pita/lib symlink, tried starting Parallels VM,
observed meaningful error message captured from stderr.

Change-Id: I7e57e110a969653e0d27e6e93f4a8104efeca978
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3170589
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dmitry Torokhov <dtor@chromium.org>
2021-09-23 04:57:15 +00:00
Gurchetan Singh
e4d14af544 devices: gpu: update to latest CONTEXT_INIT protocol
Changes __le32 info --> u8 ring_idx + padding u8[3], as per:

https://www.oasis-open.org/committees/ballot.php?id=3645

BUG=b:150239451
TEST=run wayland apps

Change-Id: I6a65ca0deb7b66c50982a70949e75c0241c8300d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3173068
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2021-09-22 22:14:22 +00:00
Gurchetan Singh
686d37a82b rutabaga_gfx: RutabagaFenceData --> RutabagaFence
It's a little bit less wordy.

BUG=b:150239451
TEST=none

Change-Id: Ia25ac6b3db77ce8e9b074273967294909fb56e87
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3173067
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2021-09-22 22:14:21 +00:00
Tomasz Nowicki
bea1935867 vfio: Remove PCI dependency
VFIO-PCI device has its own region naming but eventually it starts from 0
(as well as it suppose for others VFIO device types) so simply use 0
instead of VFIO_PCI_BAR0_REGION_INDEX.
At the same time move PCI-specific checks to helper function for clarity.

BUG=b:185504618
TEST=manatee PCI device passthrough boots/works

Change-Id: I404a9585016d230c48a6db7248172d2381a0a3e1
Signed-off-by: Tomasz Nowicki <tn@semihalf.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2961213
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Tomasz Nowicki <tnowicki@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-09-22 13:57:29 +00:00
Andrew Scull
82f723fede crosvm: arm64: Use helper function for entry address
Rather than duplicate the calculation, resuse the helper function that
calculates the entry address. This means there's just one place to make
changes and everything will be kept in sync.

BUG=none
TEST=presubmit

Change-Id: I2fd31dbaf2479ad0ce9d05c7341323b695268fa4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3111366
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Andrew Scull <ascull@google.com>
2021-09-22 12:21:14 +00:00
Keiichi Watanabe
533c5c8258 vm_memory: Add from_desciptor() in MemoryMappingBuilder
MemoryMappingBuilder had `from_file()` and `from_shared_memory`, which
are almost the same. So, this commit adds `from_descriptor()` to replace
both of the two.

BUG=b:194137301
TEST=build

Change-Id: Ia13f5e8e0f95a5c32e47dc9b3be13b7a7fa510bf
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3159881
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2021-09-22 04:37:44 +00:00
Charles William Dick
4745f03ce0 virtio_balloon shared and unevictable stats
This CL adds support for parsing stats introduced by:
https://crrev.com/c/3115084

BUG=b:198468047
TEST=candy crush runs

Change-Id: I8e258ebf7f2b7dd7a3019f40397c59514e7b18bc
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3168561
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Commit-Queue: Charles William Dick <cwd@google.com>
2021-09-22 01:06:43 +00:00
Daniel Verkamp
127a90ff3e linux: disable PCI to PCI bridge
The presence of the PCI bridge introduces a regression when booting
OVMF:

  PciHostBridgeDxe: IntersectMemoryDescriptor: desc [0, A0000) type 2 cap
  800000000002600F conflicts with aperture [0, D0021000) cap 1

The root cause is that the bridge does not correctly populate the memory
base/limit and prefetchable memory base/limit PCI bridge configuration
registers.

For the short term, since this bridge is only needed for the PCI hotplug
feature that is not enabled yet, remove the creation of the bridge from
the startup code.  Fixing the bridge will be done in another commit to
keep this change small and easy to backport.

BUG=b:199442120
BUG=b:185084350
TEST=crosvm run --bios OVMF.fd

Change-Id: I91b2cc6628e320ac2403bd8b74d18ef5a26d7c0f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3158942
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-09-22 01:04:31 +00:00
Tomasz Nowicki
70a71f8d89 devices: virtio: vhost: fix device initialization race condition
Complete vhost worker queue init before spawning thread routine.

Enabling a virtio devices requires updating the
VIRTIO_CONFIG_S_DRIVER_OK bit, which signifies that the devices is
ready to process the virtio queue. Do this before spawning the worker
thread in order to avoid the situation where a guest VM starts using the
queues before initialization has been completed.

Also make this fix for vhost net and vsock.

BUG=b:200658613
TEST=boot with vhost-net interface and check that network is working fine

Change-Id: Ibc505ba63d692d9c5380d9ec3b6f80d75ff99181
Signed-off-by: Tomasz Nowicki <tn@semihalf.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3015206
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Tomasz Nowicki <tnowicki@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-09-21 18:44:40 +00:00
Woody Chow
f5183c26be Set rtprio in virtio-snd (cras backend) worker
to 10 (following other cros audio client)

BUG=b:199796992
TEST=Examine output of `ps -AT -eo rtprio,command` when the device
  is running

Change-Id: I1293c693e1bd699788d87d5bc085fd4fd281fff1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3159894
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
Commit-Queue: Woody Chow <woodychow@google.com>
2021-09-21 10:49:57 +00:00
Chirantan Ekbote
44292f58f3 Support out-of-tree vhost-user-gpu
BUG=b:179755651
TEST=`glxinfo -B | grep virgl` inside a crostini vm

Change-Id: I37b98fcccfb8e56af4d07a2afe828ca3b5087b1f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2987595
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
2021-09-21 10:08:51 +00:00
Gurchetan Singh
084c87baad rutabaga_gfx: cross_domain: save iovecs in cross domain context
Essentially, the same issue as crrev.com/c/3131442.  The kernel
driver doesn't pass the ctx_id (even though that information is
available), so need two component.create_blob function.  Long-term
solution might to modify virtio spec.

BUG=b:150239451
TEST=run cross domain context without building any 3D renderers

Change-Id: I8d23eed7fa20de37633a6e915f137c481cb82e47
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3169356
Reviewed-by: Jason Macnak <natsu@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2021-09-20 19:21:28 +00:00
Keiichi Watanabe
7e68e485ca mdbook: Add "Code Overview" section to CONTRIBUTING.md
Move `Code Overview`  section from README to CONTRIBUTING.md

BUG=b:199874828
TEST=mdbook build

Change-Id: Id3947f958d31816f4fc802a1a35177c0ceafa4dd
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3159889
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2021-09-20 12:45:45 +00:00
Keiichi Watanabe
eced721cc8 mdbook: Add 'Running Crosvm' section
BUG=b:199874828
TEST=mdbook build

Change-Id: I760ce0aa072fcc0194353ceaf2396357005b3aea
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3159888
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2021-09-20 12:45:44 +00:00
Keiichi Watanabe
db6b0170c8 mdbook: Add "Building Crosvm" section
Duplicate sections from README

BUG=b:199874828
TEST=mdbook build

Change-Id: Id097a4077f5e844bf36528fc49de887df6409c9e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3159887
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2021-09-20 12:45:43 +00:00
Keiichi Watanabe
9ad1788661 mdbook: Simplify SUMMARY.md
* Remove sections whose contents don't exist.
* Move supplementary or/and out-dated documentations to Appendix.
  - Add notes in example_usage.md

BUG=b:199874828
TEST=run `mdbook build` in /docs/book/

Change-Id: Id9d3e90df40fdd138d6c3a39066c5352ec66c41d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3159886
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2021-09-20 12:45:42 +00:00
Keiichi Watanabe
8f6e61705c Add GitHub Action for mdbook
BUG=b:199688855
TEST=run at personal account

Change-Id: I7e44424deccf64be5fdf0d14d24109c3245e37c1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3159885
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2021-09-20 12:45:41 +00:00
Abhishek Bhardwaj
7a1a6cd58b crosvm: Implement communication logic in virtio-vhost-user PCI device
This change adds the PCI device that will act as the conduit between
vhost vmm and vhost device in a virtio-vhost-user
specification. It only implements the communication logic i.e. rx / tx
from the vmm socket and virtio queues associated with the device.

BUG=b:194136484
TEST=Compile.

Change-Id: Ib47045b7633b77b73ed7bd428ca981caa6645275
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3146213
Auto-Submit: Abhishek Bhardwaj <abhishekbh@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Abhishek Bhardwaj <abhishekbh@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2021-09-17 22:07:55 +00:00
Chirantan Ekbote
3e8d52b802 vhost: Don't require GuestMemory in ::new()
GuestMemory is only needed for the set_mem_table and set_vring_addr
methods so take it in as a parameter there rather than storing it in the
struct.  Vhost-user devices don't have access to GuestMemory when the
vhost device is first constructed.

BUG=b:179756331
TEST=unit tests

Change-Id: Id446db43777c26b0dfbe8b37366f2da93de53b23
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3153211
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2021-09-17 12:21:30 +00:00
Daniel Verkamp
eb1640e301 disk: limit maximum nesting depth
Impose a limit on the maximum nesting of file formats that can open more
files. For example, a qcow2 file can have a backing file, which could be
another qcow2 file with a backing file (or even the same file as the
original), potentially causing unbounded recursion.

BUG=b:198326611
TEST=cros_fuzz

Change-Id: I2f8573a7c71c6d8b310f2c2a75a240f2f8f0c9b1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3146214
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Cody Schuffelen <schuffelen@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-09-17 02:55:04 +00:00
Dennis Kempin
e9aa5f9598 Fix ./ci/kokoro/simulate
Somehow, after rsyncing the whole directory, git will no longer work in the
copy. So instead, we are now using 'git clone'.
This changes the behavior to not include local workspace modifications in
kokoro simulations. Which is ok, we have test_all for that and the behavior
will more closely match what's happening in kokoro presubmits.

BUG=None
TEST=./ci/simulate_all

Change-Id: I439b9eadcac65d99782e2b0eb869519abb2ada37
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3152425
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2021-09-15 17:06:48 +00:00
Dennis Kempin
3b3545b2c3 Upgrade ci containers to bullseye and clean up
We no longer need to build dependencies from source and provide them
via pkg-config, this simplifies much of our builder container setup.

As debian bullseye got promoted to stable, we can now also simplify
further by just using bullseye stable instead of mixing stable and
testing packages.

BUG=b:181359683
TEST=./test_all

Change-Id: I2ce61992d5cfe6eb5dc3f0ec61920dcc5455ca40
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3141772
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2021-09-15 17:06:46 +00:00
Federico 'Morg' Pareschi
a1184822c7 Add vhost-user-fs device
This CL adds a vhost user FS device to crosvm. The implementation
requires the following arguments:

--socket = a path to a unix socket crosvm is going to connect to
--tag = a virtio fs tag to mount within the VM
--shared-dir = path to the shared directory

Optional arguments are:
--uid-map = UID translation from inside the VM to the outside
--gid-map = GID translation from inside the VM to the outside

Example command:
crosvm device fs --socket $HOME/test --tag fs-tag --shared-dir $DIR
crosvm run --vhost-user-fs=$HOME/test:fs-tag ...

BUG=b:179636297
TEST=launch fs device and verified that mounted directory works

Change-Id: Icab9e4be65092ef817006408b50bb3bf35033c62
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3062161
Tested-by: kokoro <noreply+kokoro@google.com>
Auto-Submit: Morg <morg@chromium.org>
Commit-Queue: Morg <morg@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2021-09-15 02:06:49 +00:00
Daniel Verkamp
9c3ebfb410 usb_util: validate bLength in next_descriptor
When skipping descriptors in the next_descriptor() helper function, we
advance the offset in the input bytestream by adding the user-controlled
bLength field.  If bLength was 0, next_descriptor() would get stuck in a
loop and never return.

Add a check for this case as well as a unit test based on the failing
fuzzer input.

BUG=b:198320695
TEST=cargo test -p usb_util
TEST=cros_fuzz

Change-Id: Iec130a33b28f05219907265b7acafa9ee3791c1a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3155363
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-09-15 00:16:57 +00:00
Woody Chow
0b2b606c93 Add capture, client_type and socket_type options to cras snd device
They are needed to run virtio-snd with concierge

BUG=b:198730031
TEST=vm.Audio.virtio_cras_snd (https://crrev.com/c/3119399)

Cq-Depend: chromium:3141054
Cq-Depend: chromium:3143588
Change-Id: I9a53afe527a4533c0fa4ce54040d7c48651bc599
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3141086
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Woody Chow <woodychow@google.com>
Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
2021-09-14 08:49:37 +00:00
Woody Chow
b27dea4c36 Add socket_type to AC97Parameters
to allow testing ac97 with raw crosvm

BUG=b:195267672
TEST=Unit test, CQ

Change-Id: I49e2eefba76a5c3e9e1c6c213a00904162bcee08
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3146700
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
Commit-Queue: Woody Chow <woodychow@google.com>
2021-09-14 08:45:10 +00:00
Dennis Kempin
ab0ad4caa0 Move virglrenderer/minigbm build into build.rs
Both libraries have previously been built as part of
ci/build_environment/Makefile. This CL moves that behavior into the
build.rs file of rutabaga_gfx.

This is the last third party dependency that we need to build from
source, and allows us to build/test on the host machine instead of
requiring the builder container.

It also allows us to greatly simplify the builder containers, which
I will do in a follow-up CL as we also need to upgrade them to bullseye.

This CL uprevs virglrenderer to include:
https://gitlab.freedesktop.org/virgl/virglrenderer/-/merge_requests/609

and minigbm to include: https://crrev.com/c/3141018

BUG=b:196059146
TEST=./test_all && ./run_tests --run-privileged

Change-Id: I4442ccc991d13a3fcfa224de50e916b3926f0cb4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3141771
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Tested-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
2021-09-09 23:13:24 +00:00
Chirantan Ekbote
dfa32ea035 Fix kokoro
Update to the latest version of vmm_vhost to pick up the API change.
Also fix clippy errors in the gpu device.

BUG=b:179755651
TEST=cargo build

Change-Id: Ia42681aee1d92f38dfcca1fbf87e8cfd7ac15d95
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3151109
Auto-Submit: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-09-09 22:23:29 +00:00
Chirantan Ekbote
7822529aad Add vhost-user-gpu-device
BUG=b:179755651
TEST=`glxinfo -B | grep virgl` inside a crostini vm

Cq-Depend: chromium:2988140
Change-Id: Ib4102e887650b9dda97debb4c6b4737f0b0a642f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2987594
Tested-by: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
2021-09-09 08:26:47 +00:00
Daniel Verkamp
8031d3b514 system_api_stub: use 2018 edition of Rust
The Cargo.toml originally requested edition = 2021, which is not
available in a released version of Rust yet.

BUG=None
TEST=`cargo build` without the real system_api

Change-Id: I9577301b6bfb83cafd5fd9bb0ec5024b385b324e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3145914
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Ryo Hashimoto <hashimoto@chromium.org>
Commit-Queue: Ryo Hashimoto <hashimoto@chromium.org>
2021-09-09 06:42:46 +00:00
Daniel Verkamp
4b0135bf6e vmm_vhost: update submodule to get warning fixes
Fixes Rust 1.53+ warnings when building crosvm:

  warning: lint `safe_packed_borrows` has been renamed to `unaligned_references`

BUG=None
TEST=cargo build

Change-Id: If2d2852e0fc20e6afd7fe8e712a2718b640f052b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3145915
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-09-09 00:01:22 +00:00
Tomasz Jeznach
770c0935da devices/ac97: keep irq event descriptors
Fix to preserve ac97 event/resample events handles for minijail.
Broken by crrev/c/3143586

BUG=b:198773299
TEST=arcvm audio access, record/play.

Change-Id: I34d85a9f9355257c98e0c5c28e87d1e289117ed0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3144532
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Kazuhiro Inaba <kinaba@chromium.org>
Commit-Queue: Tomasz Jeznach <tjeznach@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-09-07 20:15:20 +00:00
Dennis Kempin
3407843bd4 Build minijail through build.rs file in CI containers
This removes the minijail build from build_environment, which will
cause the minijail-sys crate to build it from source.

Minijail is upreved to include https://r.android.com/1815277

BUG=b:198305518
TEST=./test_all

Change-Id: I38c46c2a7df43e3d3a94ae0c5f8a9aae2abd3555
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3141770
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-09-07 17:42:19 +00:00
Alexandre Courbot
de86c8253d virtio: video: decoder: fix NV12 plane format
A NV12 frame is made of one Y plane at full resolution, and one plane
include one U and one V component for each four pixels. Thus the size of
the second plane should be half of that of the first one.

This is important to get right as ffmpeg conversion functions wil rely
on this information and will fail if the computed size is bigger than
the target buffer.

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

Change-Id: I4196983389def3a4914c076d68067874041fab55
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3023743
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2021-09-07 16:35:48 +00:00
Keiichi Watanabe
12a694e45e Remove vhost_user_devices crate
BUG=b:195495971
TEST=cargo build

Change-Id: Ib1b43e40fbdcebb7dc66c5a5f349b8de2da25cb5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3070725
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2021-09-07 13:11:53 +00:00
Chirantan Ekbote
e3364b743a fs: Fix enable_verity() impl
The fsverity_enable_arg struct contains optional pointers to additional
data.  Check for them and try to copy them in if necessary.  This
requires a corresponding kernel change where the fuse driver also
reads the struct and copies the relevant data from the userspace
application.

Steps to test this change:

// Create a test file
head -c 1000000 /dev/urandom > file

// Generate a new certificate and private key:
openssl req -newkey rsa:4096 -nodes -keyout key.pem -x509 -out cert.pem

// Convert the certificate from PEM to DER format:
openssl x509 -in cert.pem -out cert.der -outform der

// Load the certificate into the fs-verity keyring.  This step MUST be
// done on the host kernel.
keyctl padd asymmetric '' %keyring:.fs-verity < cert.der

// Now set up fs-verity on the test file:
fsverity sign file file.sig --key=key.pem --cert=cert.pem \
    --salt 12345678
fsverity enable file --signature=file.sig --salt 12345678

BUG=b:141632062
TEST=See above

Change-Id: Ied7106cfbd2919f1f0c7f605166769d4916925b0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3141298
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
2021-09-06 05:17:13 +00:00
Chirantan Ekbote
e1663eeae4 Only change uid/gid when it's not 0
Only change the device uid/gid in the sandbox when it is not 0.
Otherwise, running crosvm as root makes minijail complain:

   libminijail[16370]: useless change to uid 0

BUG=none
TEST=run crosvm as root

Change-Id: Ida4b0e772ed000d3e42f77012af9d2505f64d92a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3141297
Auto-Submit: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Fergus Dall <sidereal@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-09-03 22:08:16 +00:00
Daniel Verkamp
3eeaf6a339 linux: fill pmem alignment area with anon map
Rather than mapping past the end of the file when using a pmem backing
file that is not 2 MiB aligned, use an anonymous mapping to fill the
remaining part of the arena.

This partially reverts https://crrev.com/c/2153103 while keeping the
effective change: the anonymous mapping used to fill the padding is now
added with the same protection as the file mapping.

Also handle images that are not a multiple of the page size (typically
4096 bytes) - the memory mapping on the host will handle zero-filling
reads and discarding writes past the end of the mapped file as long as
we map a size containing the partial last page.

BUG=chromium:1244217
TEST=Boot crosvm with non-2MB aligned pmem disk; read the last few bytes
TEST=./test_all

Change-Id: Ibe8da170175bb9befce924122b912a28a6dc0e7b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3131444
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-09-03 20:00:13 +00:00
Marc Zyngier
7af8b6f879 kvm: Explicitly provide an argument to KVM_CREATE_VM
On all architectures, KVM_CREATE_VM takes an argument known
as the 'machine type identifier'. This machine type is
architecture dependent, and the documentation helpfully says:

	You probably want to use 0 as machine type.

So let's do that.

Change-Id: I8a8a0f7b78e32012c5ab841097c05a02fe0532ff
Signed-off-by: Marc Zyngier <mzyngier@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3124676
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Andrew Walbran <qwandor@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2021-09-03 18:39:23 +00:00
Tom Cherry
731f0809a3 x86_64: pass kernel command line to bios
This enables the bios to read kernel command line parameters
from crosvm and pass them to the kernel that it loads.

BUG=b:195323844
TEST=pass --params through uboot to Linux

Change-Id: I306bb16421393583edc8b0dbdb3198a5b3cc0377
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3140277
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Tom Cherry <tomcherry@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-09-03 17:11:39 +00:00
Chirantan Ekbote
2590740b08 cros_async: Fix underflow in BlockingPool worker threads
The `num_idle` field of the shared state between BlockingPool worker
threads can underflow in the following case:

* state.num_idle == 2.
* We spawn 2 new tasks into the BlockingPool.
* Both idle worker threads are woken up.  `state.num_idle` goes to 0.
* The first worker thread wakes up and pulls a task from the queue.
  That task finishes very quickly so the worker thread pulls the second
  task from the queue before the second worker thread is scheduled.
* The second worker thread is scheduled.  It sees that
  `s.tasks.is_empty() == true` so it goes back to waiting on the
  Condvar.
* The second worker thread's wait times out and it tries to decrement
  `state.num_idle` leading to underflow.

Fix this by adding a `num_notified` field to the shared worker state.
This field acts like a counter for the number of idle worker threads
that have been woken up.

When an idle thread is waiting on a Condvar, rather than checking if the
task queue is empty, it will instead check if num_notified > 0.  When an
idle worker thread observes that num_notified > 0 it decrements it by 1
and then goes back to processing tasks from the queue.  num_idle is only
decremented when num_notified is 0.

Change the num_idle decrement to a checked_sub so that we can catch it
even when -Coverflow_checks=off.  Also add a test for this case.  This
test consistently panics without the num_notified changes.

BUG=none
TEST=unit tests

Change-Id: Ia1b348605e0d02415635cdd023db1c10201ab661
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3139159
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Richard Zhang <rizhang@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
2021-09-03 12:58:17 +00:00
Ryo Hashimoto
6d9243865b fs: Support setting quota project ID
A new command line parameter to specify privileged UIDs.
If the requester UID is privileged, PassthroughFs uses D-Bus to set
quota project ID.

BUG=b:190791826
TEST=build

Cq-Depend: chromium:3129049,chromium:3129048
Change-Id: Ie27f200e8c651be6a5503f69e7b784c5e8f968ea
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3014623
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Ryo Hashimoto <hashimoto@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2021-09-03 00:47:25 +00:00
Daniel Verkamp
a5884b5a6e kernel_cmdline: convert to ThisError and sort
BUG=b:197143586
TEST=cargo check

Change-Id: Ic86f0d08b36e5f1b30ea35def38e3875c972c938
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3105081
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-09-02 21:00:23 +00:00
Daniel Verkamp
793b4703cf io_uring: convert to ThisError and sort
BUG=b:197143586
TEST=cargo check

Cq-Depend: chromium:3105310
Change-Id: I661c65e095d0a8274a68ff44d70a65bce21970f5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3105080
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-09-02 21:00:22 +00:00
Daniel Verkamp
c3f546906b gpu_display: convert to ThisError and sort
BUG=b:197143586
TEST=cargo check

Change-Id: I461144d021314984e9ec2c738144b8e3065efcf4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3105079
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-09-02 21:00:22 +00:00