Commit graph

2165 commits

Author SHA1 Message Date
Alexandre Courbot
0b96ae0720 virtio: video: encoder: remove lifetimes on VEA instance/sessions
The libvda API has been changed and both instances and sessions do not
use lifetimes anymore. Remove them from our code or it won't compile.

BUG=b:169295147
TEST=arc.VideoEncodeAccel.h264_192p_i420_vm passes on hatch-arc-r

Cq-Depend: chromium:2887389
Change-Id: I9821e7f3b92b89fceb843fb0e60d041a44602f20
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2887525
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: David Staessens <dstaessens@chromium.org>
Tested-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2021-05-13 04:40:59 +00:00
Tomasz Jeznach
1eea877519 crosvm: use ACPI for PCI routing if available.
BUG=b:179648314
TEST=Provide DSDT/MADT to the guest OS.

Change-Id: I46d221de9b5d942915c6e6f46f2630bdaaccbaac
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2891216
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Tomasz Jeznach <tjeznach@chromium.org>
2021-05-13 04:34:06 +00:00
Tomasz Jeznach
d93c29fdf1 crosvm: flag to disable legacy x86 IO devices.
BUG=b:179648314
TEST=Keyboard pass-through enabled.

Change-Id: Ie2e5fdc85367ddb9d5f216291773cf8065d8c956
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2885078
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Tomasz Jeznach <tjeznach@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-05-13 04:34:04 +00:00
Daniel Verkamp
a8423d73c3 devices: pass MMIO and IO bus to PciRoot::new()
This will be used to dynamically add and remove bus ranges when the PCI
command register is updated to enable/disable memory and IO decode.

BUG=b:174705596
TEST=cargo test -p devices

Change-Id: I6bb175e0628bf598d049562700e2f55a2a62df59
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2689081
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Tomasz Jeznach <tjeznach@chromium.org>
Reviewed-by: Tomasz Jeznach <tjeznach@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2021-05-12 00:09:37 +00:00
Keiichi Watanabe
8c817dd349 vhost_user_devices: Add vhost-user net device
Add a vhost-user net device executable which communiates with a VMM having vhost-user net device.

Example command:
vhost-user-net-device \
         --tap 10.0.2.2,255.255.255.0,12:34:56:78:9a:bc \
         --socket /tmp/vhost-net.sock

BUG=b:179755448
TEST=run as a backend of crosvm with vhost-user net device

Cq-Depend: chromium:2861979
Change-Id: Ib723cdd00381b29464855378e568a9fa3de01536
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2807205
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2021-05-11 18:34:40 +00:00
Keiichi Watanabe
8e7bc96616 Add vhost_user_devices crate
Add `vhost_user_devices` crate which will be used to create a vhost-user
device executables.

BUG=b:185089400
TEST=cargo test in /vhost_user_devices

Change-Id: I7256d68316f7763d3ceaa65abc97663975e7608f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2822169
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2021-05-11 18:34:39 +00:00
Dennis Kempin
acdf8de5c6 Kokoro: Add debian bullseye version of libwayland/protocols
This is required by the latest gfx changes.

BUG=None
TEST=./ci/kokoro/simulate_all

Change-Id: I13280a3c5213d12730bcb154514b7864663a1682
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2880148
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2021-05-10 18:27:07 +00:00
Keiichi Watanabe
8ec40a7fa0 device: vhost: user: Fix offset of GET_CONFIG
BUG=none
TEST=run vhost-user block vmm with dpdk

Cq-Depend: chromium:2861979
Change-Id: I7cf6694338b3eadf910e85af7c0db85805e32451
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2856171
Tested-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2021-05-10 13:08:00 +00:00
Dennis Kempin
e6216f926c Uprev rust-toolchain for Kokoro to 1.51.0
Change-Id: I27b30762207021bbaf307bb02118992442021a93
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2877257
Reviewed-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Zach Reizner <zachr@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
2021-05-07 00:49:19 +00:00
Daniel Verkamp
7fb40344ff devices: pci: add PciDevice function to get BARs
This will be used to enumerate BARs when the command register is updated
to enable/disable memory or I/O decode.

BUG=b:174705596
TEST=cargo test -p devices

Change-Id: I992a2004dc58955b464467914c4ad735fb2cdd44
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2689085
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Tomasz Jeznach <tjeznach@chromium.org>
2021-05-07 00:37:49 +00:00
Daniel Verkamp
2da1f27fd5 devices: vfio: use PciBarConfiguration struct
Replace the VFIO-specific MmioInfo and IoInfo structs with
PciBarConfiguration.

This will allow a unified interface for retrieving BAR information for
all PciDevice implementations; all other PciDevices use PciConfiguration
to store a list of PciBarConfiguration, so this brings VfioPciDevice in
line with those.

BUG=b:174705596
TEST=cargo test -p devices

Change-Id: Idafd8f9af2ce817877450cfb842805475785ba20
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2689084
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Tomasz Jeznach <tjeznach@chromium.org>
2021-05-07 00:37:49 +00:00
Daniel Verkamp
8954f04e82 devices: pci: add config support for ROM BAR
Extend PciBarConfiguration to support the expansion ROM BAR in addition
to the usual 6 BARs.

This will be used when adapting vfio_pci to use PciBarConfiguration.

BUG=b:174705596
TEST=cargo test -p devices

Change-Id: I712728def41b0f2981029d77c3b9d7ec065e9d9b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2689083
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Tomasz Jeznach <tjeznach@chromium.org>
2021-05-07 00:37:48 +00:00
Daniel Verkamp
b2b4d8cabf devices: pci: PciBarConfiguration cleanup
- Consistently use reg_idx to represent an index into all PCI
  configuration space registers and bar_idx to represent an index into
  just the BAR list. (e.g. bar_idx 0 is at reg_idx 0x10).
- Add a PciBarIndex type to make the related APIs clearer versus using
  usize directly.
- Remove Default impl for PciBarConfiguration and fix up the previous
  callers to fully configure the BAR type instead of depending on the
  defaults.
- Omit "get_" from the names of getter functions to follow Rust
  convention.

BUG=b:174705596
TEST=cargo test -p devices

Change-Id: I6921ac627f51e0df9c07585545be031ac3055a7b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2689082
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Tomasz Jeznach <tjeznach@chromium.org>
2021-05-07 00:37:46 +00:00
Daniel Verkamp
34050dc2e1 bin/clippy: temporarily ignore warnings from external crates
These need to be resolved in repositories outside crosvm, so add them to
the ignored list for now.

BUG=None
TEST=bin/clippy

Change-Id: I75b20ff2c84bfc72cd7d3c4421428a82600e6778
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2864371
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-05-06 22:06:58 +00:00
Daniel Verkamp
18750c09df devices: acpi: collapsed nested if inside else
Fixes a new clippy warning ("this `else { if .. }` can be collapsed.").

BUG=None
TEST=bin/clippy

Change-Id: I58aec38b9fac6b7cbdcfe62e81e3b38ca3373a4c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2864370
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Reviewed-by: Tomasz Jeznach <tjeznach@chromium.org>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-05-06 22:06:57 +00:00
Daniel Verkamp
d8ff7fa7e4 devices: fix redundant ? inside Ok
Fixes a new clippy warning ("Question mark operator is useless here").

https://rust-lang.github.io/rust-clippy/master/index.html#needless_question_mark

BUG=None
TEST=bin/clippy

Change-Id: I2888f070030d2838b8fb63e5d98a929f57cdfde7
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2864369
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-05-06 22:06:57 +00:00
Daniel Verkamp
0fe970bd9a rutabaga_gfx: collapse nested if in else block
Fixes a new clippy warning ("this `else { if .. }` block can be
collapsed").

https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_else_if

BUG=None
TEST=bin/clippy

Change-Id: Ib8a080a9afc39c272936012c9c1ecb92862e4189
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2864368
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-05-06 22:06:56 +00:00
Daniel Verkamp
05485a91ee acpi_tables: use vec![] to initialize vectors
Fix a few instances of a new clippy warning ("calls to `push`
immediately after creation").

https://rust-lang.github.io/rust-clippy/master/index.html#vec_init_then_push

BUG=None
TEST=bin/clippy

Change-Id: I8bf2abbb4dfeac16ddfb64f160f04176d89c4719
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2864367
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Reviewed-by: Tomasz Jeznach <tjeznach@chromium.org>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-05-06 22:06:55 +00:00
Daniel Verkamp
8f325301ec devices: vfio_pci: rewrite nested ifs as match
Simplify a lookup against two boolean variables that was implemented as
a nested set of ifs as a single match.

This also fixes a clippy warning about nested if inside else.

BUG=None
TEST=bin/clippy

Change-Id: Ia8e57a87dc5555ba505bcca67912eef978db0420
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2864366
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-05-06 22:06:54 +00:00
Daniel Verkamp
c7215b5dc4 devices: vfio: use vec![] in keep_rds
Replace an instance of Vec::new() followed by push to fix a new clippy
warning and simplify the code.

BUG=None
TEST=bin/clippy

Change-Id: Ie216df8ce5dcc12f5a2cceda8e322303804b451d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2864365
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Reviewed-by: Tomasz Jeznach <tjeznach@chromium.org>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-05-06 22:06:54 +00:00
Daniel Verkamp
19a12403cf devices: vfio: take a slice instead of Vec for irq_enable
Generalize the irq_enable() interface to accept a slice instead of a
Vec.  This also fixes a few instances of the new clippy warning about
calling Vec::new() immediately followed by inserting items.

BUG=None
TEST=bin/clippy

Change-Id: If4c66999a245f340f54c96ccafc904c99bedf1ce
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2864364
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Reviewed-by: Tomasz Jeznach <tjeznach@chromium.org>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-05-06 22:06:53 +00:00
Daniel Verkamp
87ca23156d arch: serial: fix redundant slice
Fixes clippy warning for redundant slice of the whole range.

https://rust-lang.github.io/rust-clippy/master/index.html#redundant_slicing

BUG=None
TEST=bin/clippy

Change-Id: I672f728adc79ff24c8287eceedf3863e9a42e4ec
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2864363
Reviewed-by: Zach Reizner <zachr@chromium.org>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-05-06 22:06:52 +00:00
Daniel Verkamp
9901c7509c cros_async: switch to std::hint::spin_loop
Replace the deprecated std::sync::spin_loop_hint with
std::hint::spin_loop.

Fixes this new warning from Rust 1.51:

  warning: use of deprecated function `std::sync::atomic::spin_loop_hint`:
  use hint::spin_loop instead

BUG=None
TEST=bin/clippy

Change-Id: Ic975c77ea19bcf256f73c0b3b89f85866abfe0bb
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2864362
Reviewed-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-05-06 22:06:52 +00:00
Daniel Verkamp
548754cd2f Specify file paths via Path instead of PathBuf
Many functions took a reference to PathBuf, but then just passed the
parameter to File::open(), so they can be changed to a reference to
Path instead to avoid a potential allocation.

https://rust-lang.github.io/rust-clippy/master/index.html#ptr_arg

BUG=None
TEST=bin/clippy

Change-Id: Ife5a52df2ba16da1ce1307efb2fe921cd8b4f956
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2862581
Reviewed-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-05-06 22:06:51 +00:00
Daniel Verkamp
2924f8bfb7 kernel_cmdline, cros_async: impl From instead of Into
As recommended by the clippy from_over_into warning, allow conversion to
Vec<u8> by adding a more flexible From impl instead of Into.

https://rust-lang.github.io/rust-clippy/master/index.html#from_over_into

BUG=None
TEST=bin/clippy

Change-Id: Iaa6455b11629846e5ce9bc9be4a6cae0baf87d5b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2862580
Reviewed-by: Zach Reizner <zachr@chromium.org>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-05-06 22:06:50 +00:00
Daniel Verkamp
435f608501 Cargo.toml: remove libchromeos dependency
All of the functions that had been in libchromeos-rs are now moved into
sys-util, so drop the dependency from Cargo.toml and update Cargo.lock
to match.

BUG=None
TEST=cargo build

Change-Id: I253a635b37b18a52977b5028c08f311db1cf26cd
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2862577
Reviewed-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Allen Webb <allenwebb@google.com>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Curtis Malainey <cujomalainey@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-05-06 22:06:48 +00:00
Zach Reizner
dc74848b7c arch: Simplify build_vm by removing closure parameters
These parameters multiplied the number of type arguments to build_vm
unnecessarily and complicated the thread of execution in the programmers
head. Closures also complicate the borrow rules, making things much
harder to change.

This change uses the results of the closures (e.g. PCI devices, IRQ
chips) as parameters instead. The rest of this change follows naturally
from pulling on that thread until tests pass.

As a result of the removal of several type arguments, the code size was
reduced by ~100KiB on a 5MiB build.

BUG=b:185170486
TEST=./test_all

Change-Id: I6bcc5eb1b1f3031d4328bb4a81ddef618d04767b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2829136
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Zach Reizner <zachr@chromium.org>
Reviewed-by: Tomasz Jeznach <tjeznach@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-05-06 16:31:49 +00:00
Zach Reizner
b0ae5378c6 ci: install bindgen and required header files
The cras client library has switch to build time generation for their
Rust bindings and requires the bindgen binary and the usual standard
header files to run the build script. This change adds those needed
components to the Docker images so that kokoro may work again.

BUG=None
TEST=./test_all

Change-Id: Ib16b164f44d536be84f9ecca6b5187eaba7d57ca
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2863167
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Zach Reizner <zachr@chromium.org>
2021-05-04 20:59:54 +00:00
Allen Webb
e6c584a6aa devices: Deduplicate mapped file descriptors.
A bugfix to minijail made the logic more strict so deduplicate the
mapping requests before giving them to libminijail.

BUG=b:2591867,chromium:1198756
TEST=CQ passes

Change-Id: Ide397e9aa82b493418d8ac4e51a73af649295424
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2851078
Tested-by: Allen Webb <allenwebb@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Allen Webb <allenwebb@google.com>
2021-05-03 23:09:47 +00:00
Dennis Kempin
a88cb19890 Add kokoro information to CONTRIBUTING.md
Change-Id: I094b90c10f5a60b7f7dfe594e2f9242abad2d18f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2864374
Tested-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-04-30 21:56:56 +00:00
Gurchetan Singh
538128dc98 data_model: add flexible_array_impl! macro
- Removes duplicated code
- Assumes "u32" as the type of the flexible array
  length field, which should be fine.

BUG=b:173630595
TEST=compile and run

Change-Id: Ia2d9f74b823e06d2f2f0b60cebb8a3b999a9cba0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2848283
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Auto-Submit: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2021-04-30 20:49:53 +00:00
Dennis Kempin
d5b4cbe6d9 Remove sync_ebuild_files script
This script was a hack to reduce some manual work we had to do
regularly. A better script has been submitted at:

https://source.corp.google.com/chromeos_public/src/platform/dev/contrib/cargo2ebuild.py

BUG=b:175120466
TEST=None

Change-Id: I8b14ad22576fd80370287bf798f31e6a7b93f04d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2848285
Auto-Submit: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-04-26 20:37:48 +00:00
Daniel Verkamp
6ded64f192 unblocked_terms.txt: clean up trivial cases
Avoid some easily-replaced non-inclusive words and remove them from the
unblocked_terms.txt list.

Remove a clippy lint with a name matching the list since all affected
warnings have already been removed.

Remove all terms that are already not present in the crosvm
repository from unblocked_terms.txt (including the commented lines).

BUG=b:178821708
TEST=../dev/contrib/search_blocked_words.sh unblocked_terms.txt
TEST=cargo test -p devices
TEST=cargo test -p disk
TEST=bin/clippy

Change-Id: I8261921380decc839f01adb9ad1d4d14d5a85114
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2847462
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-04-26 20:32:38 +00:00
Zach Reizner
6869e53101 syscall_defines removed
Now that syscall_defines isn't used, remove it.

TEST=./test_all
BUG=None

Cq-Depend: chromium:2836985
Change-Id: I3333e1417bb1e88e3614366bb8524e89ddfe6e76
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2837374
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Allen Webb <allenwebb@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Zach Reizner <zachr@chromium.org>
2021-04-26 19:59:01 +00:00
Alexandre Courbot
62a57e9656 virtio: video: decoder: remove LibvdaSession struct
This structure only embeds libvda::decode::Session, so we can directly
implement our traits on it. Doing so is actually more consistent with
the way the rest of the module is implemented.

BUG=None
TEST=cargo build

Change-Id: Ib03481ae91affca03cff21829e09d6d94731f78d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2845634
Tested-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2021-04-25 07:13:23 +00:00
Alexandre Courbot
e604c331e6 virtio: video: decoder: make decoder own its VDA instance
The current design of having the VDA instance outside of the Decoder was
mandated by the use of lifetimes on libvda Sessions, which have been
removed from libvda. So it is now possible for the Decoder to own its
VDA instance.

This makes sense in itself since there is no reason for the VDA instance
to also be used by someone else, but is also required to add support for
non-libvda decoder backends.

BUG=b:169295147
TEST=Video plays correctly on hatch-arc-r.

Change-Id: I7cbafbb48373a25195de07e954846e1bd9f1cc0e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2839464
Tested-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2021-04-25 07:13:22 +00:00
Alexandre Courbot
10722b260e virtio: video: decoder: remove lifetimes on VDA instance/sessions
The libvda API has been changes and both instances and sessions do not
use lifetimes anymore. Remove them from our code or it won't compile.

BUG=b:169295147
TEST=cargo build --features="video-decoder"

Cq-Depend: chromium:2838714
Change-Id: I7ba771abcdddfc4bc366dc38e37c0568ce5a9cb3
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2845633
Tested-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2021-04-25 07:13:16 +00:00
Gurchetan Singh
33079335ad gpu_display: rustify error handling
As new features are about to be added, it only makes sense to
improve error handling first.

Also improve/update naming of errors in other GPU-focused areas.

BUG=b:173630595
TEST=compile and run

Change-Id: If0d4f8b7d548c46f0a15b64699502e0fefeaae3e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2844350
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Auto-Submit: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2021-04-23 22:51:59 +00:00
Andrew Scull
74bf69a567 aarch64: pass arguments to protected VM firmware
A protected VM will have the PC set to the start of the firmware at boot
by EL2. Pass the address of the next stage to the firmware in x1.

BUG=b:175729255
TEST=cargo test

Change-Id: I8d5a2aae4e2790914e12358f52511c8f18b3d769
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2843605
Tested-by: kokoro <noreply+kokoro@google.com>
Auto-Submit: Andrew Scull <ascull@google.com>
Commit-Queue: Dylan Reid <dgreid@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2021-04-23 22:48:40 +00:00
Daniel Verkamp
ff1ed69c6b devices: usb: filter unclaimed interfaces
Replace the interface descriptors for unclaimed interfaces with
vendor-specific class codes so that the guest driver does not attempt to
bind to them.

BUG=b:180238956
BUG=chromium:1030778
TEST=Attach YubiKey, Circuit Playground Express to Crostini

Change-Id: Ia2826479c470e6f8a6dff21fe12e6c4bb5fd2efa
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2811862
Reviewed-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-04-22 17:25:25 +00:00
Daniel Verkamp
ccb95543ee usb_util: add raw access to descriptors
Also allow querying the offset of each descriptor within the raw slice
of bytes.

BUG=b:180238956
BUG=chromium:1030778
TEST=cargo test -p usb_util

Change-Id: I1e7de89e075b78b3675c8f95c992d247e8f83ce3
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2811861
Reviewed-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-04-22 17:25:24 +00:00
Daniel Verkamp
425e4aad1e devices: usb: clean up intercepted_control_transfer
Rearrange the control request type match to check the request and
recipient together in a tuple (along with direction, which will be
different for a Get Descriptor request, to be added in the next commit).

No functional change.

BUG=b:180238956
BUG=chromium:1030778
TEST=Share USB device with Crostini

Change-Id: I51badd8f8b067a5e19216a92257c2b75c2041663
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2811860
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2021-04-22 17:25:23 +00:00
Daniel Verkamp
7b17f50df9 devices: usb: claim interfaces on device creation
This initializes the claimed_interfaces list at startup (before the
first Set Configuration request).  It also makes it possible to catch
initialization errors earlier in the process of adding a device, before
it is added to the emulated USB hub.

BUG=b:180238956
BUG=chromium:1030778
TEST=Share USB device with Crostini

Change-Id: I6f27ec9b7ff6cda2ff23cadd77611f8ce1cfc89e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2811859
Reviewed-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-04-22 17:25:22 +00:00
Daniel Verkamp
d3935a5702 usb_util: assume active config for single-config devices
When there is only one configuration listed in a device's descriptors,
assume that configuration is the active one without needing to send a
blocking control request to get the active configuration from the
device.

This moves the logic used in the USB host device code into usb_util, so
it will be used for all callers of get_active_configuration().

BUG=b:180238956
BUG=chromium:1030778
TEST=Share USB device with Crostini

Change-Id: I71a7d12a7edcd1fd0d063af58f63708b3dbda348
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2811858
Reviewed-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-04-22 17:25:21 +00:00
Allen Webb
009afce6d4 sys_util: Migrate libchromeos::read_dir and syscall!
BUG=chromium:1193155
TEST=cargo test -- --test-threads=1

Change-Id: Ic5f8d23299d0f217b607231c56dfc6d9866e30df
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2829947
Tested-by: Allen Webb <allenwebb@google.com>
Commit-Queue: Allen Webb <allenwebb@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2021-04-22 13:43:57 +00:00
Tomasz Jeznach
cf55111b9b acpi: FACS support, minor fixes for acpi forwarding.
User provided DSDT/MADT/FADT tables will have precedence
over crosvm generated data, with crosvm only overriding
critical FADT fields to match ACPI tables placement.
Also, this patch adds mandataory empty FACS structure.

BUG=None
TEST=run guest with set of ACPI tables provided and verify content.

Change-Id: I3f3ff2170c08b3f570ff863ecc45c5bf203eb940
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2841754
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Tomasz Jeznach <tjeznach@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-04-22 07:25:33 +00:00
Daniel Verkamp
5be4f273e8 disk: read up to 4K block when detecting image type
This makes detect_image_type do a single read of size 4096 instead of
doing two smaller reads matching the size of the magic values.  This
eliminates one source of misaligned disk access, which is needed to
enable O_DIRECT. It also reduces the number of reads required, although
this probably has very little, if any, performance impact.

In addition, the magic comparison is rewritten to make the endian
conversion more readable - the qcow2 magic number is written in big
endian and the Android sparse disk magic is little endian, but
previously this was unclear since the sparse comparison did a double
big-endian conversion to get to little endian.

BUG=b:184204645
TEST=cargo test -p disk --features=composite-disk

Change-Id: I35ae0a6c415d3cf69733a5c6288b99a4cfb30e2f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2824810
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-04-22 00:30:20 +00:00
Daniel Verkamp
3055722ae0 disk: add detect_image_type unit tests
BUG=None
TEST=cargo test -p disk --features=composite-disk

Change-Id: Ib1dd4cbf6b7f22dfa4ef5a8dcda3ca8679487884
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2824809
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-04-22 00:30:17 +00:00
Jorge E. Moreira
6021705055 Improve code around creation of VioS recv thread
The mutex around the thread is locked-unlocked twice, the first time
just to check that something actually needs to be done, the second time
to check again and do it. The temporary release of the lock is to avoid
holding multiple locks while duplicating the fds and avoid the risk of
deadlock.

Change-Id: I455415dc32a31ae54025454f2709583e54a216b5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2844354
Tested-by: Jorge Moreira Broche <jemoreira@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Jorge Moreira Broche <jemoreira@google.com>
Commit-Queue: Zach Reizner <zachr@chromium.org>
Auto-Submit: Jorge Moreira Broche <jemoreira@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2021-04-22 00:21:40 +00:00
Andrew Scull
0131dd3579 aarch64: refactor register initialization
Use single purpose, immutable variables with meaningful names.

BUG=b:163789172
TEST=cargo test

Change-Id: Icc90918f6154bef8ab93358ba0651fb0ed7b041a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2843604
Reviewed-by: Andrew Walbran <qwandor@google.com>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Auto-Submit: Andrew Scull <ascull@google.com>
Commit-Queue: Dylan Reid <dgreid@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2021-04-21 23:19:49 +00:00