Commit graph

2866 commits

Author SHA1 Message Date
Dennis Kempin
0fcc7ace5a Uprev rust toolchain to 1.56.1
Two new clippy fixes are affecting us, but will be easy to fix in
a follow-up.
Fixed the dev-container so we can create a new version with the new
toolchain.

BUG=b:210037151
TEST=Kokoro

Change-Id: I9ac4d84aff72b1ee5219d6dab0a88667ca6c5951
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3328954
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2021-12-10 02:34:50 +00:00
Chia-I Wu
cba95dba9c rutabaga_gfx: fix gfxstream build
Fix

error[E0560]: struct `renderer_utils::VirglCookie` has no field named `None`
   --> rutabaga_gfx/src/gfxstream.rs:213:13
    |
213 |             None,
    |             ^^^^ `renderer_utils::VirglCookie` does not have this field
    |
    = note: available fields are: `fence_state`, `render_server_fd`

Also silience all warnings related to render server.

Change-Id: I19ef8746b63379a5517ba9abd3faf4e9da0abfc3
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3328098
Auto-Submit: Chia-I Wu <olv@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: Dennis Kempin <denniskempin@google.com>
2021-12-10 01:54:35 +00:00
Chia-I Wu
16fb659272 devices: gpu: add render server support
When "--gpu-render-server path=<path>" is specified, start the render
server shipped with virglrenderer and initialize virglrenderer with
VIRGLRENDERER_MULTI_PROCESS flag.

The flag makes virgl_renderer_context_create_with_flags create proxy
contexts instead of venus contexts.  Each proxy context requests the
render server to fork a subprocess and executes GPU commands in the
subprocess.

BUG=b:177267762
TEST=run vk and gl apps on volteer

Change-Id: If5e2dc3353572cadb60b0c25a3e0ad14f633db91
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3283508
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chia-I Wu <olv@google.com>
2021-12-09 20:16:13 +00:00
Chia-I Wu
2bcec5c3d9 sys_util: impl From<UnixSeqpacket> for SafeDescriptor
BUG=b:177267762
TEST=run vk and gl apps on volteer

Change-Id: Icfd3994ef62f0c27b817a3824da18977a943cc00
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3315233
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chia-I Wu <olv@google.com>
2021-12-09 20:16:12 +00:00
Chia-I Wu
64ba89ac84 seccomp: add gpu_common.policy
Let gpu_device.policy include gpu_common.policy.  No functional change.

BUG=b:177267762
TEST=run vk and gl apps on volteer

Change-Id: Ic83c29b5713c95374562ee6eba35002142e00357
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3311904
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chia-I Wu <olv@google.com>
2021-12-09 20:16:10 +00:00
Chia-I Wu
fffb569137 gpu: refactor create_gpu_device
Add gpu_jail to create a simple jail and customize the jail.  No
functional change.

BUG=b:177267762
TEST=run vk and gl apps on volteer

Change-Id: I63df5f4009e83cfdfa122edac1788eab56a2dfa0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3311903
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chia-I Wu <olv@google.com>
2021-12-09 20:16:09 +00:00
Chia-I Wu
11e32f6ece rutabaga_gfx: prepare for VIRGL_RENDERER_MULTI_PROCESS
When the flag is set, virglrenderer can use the get_server_fd callback
to get the socket to the render server.

BUG=b:177267762
TEST=run vk and gl apps on volteer

Change-Id: I692b5068a04e841b0a0ed2344a77908e720e19eb
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3283506
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chia-I Wu <olv@google.com>
2021-12-09 20:16:07 +00:00
Chia-I Wu
e39bbbd025 rutabaga_gfx: add RUTABAGA_MEM_HANDLE_TYPE_SHM
virglrenderer can return an fd of type VIRGL_RENDERER_BLOB_FD_TYPE_SHM.

BUG=b:177267762
TEST=run vk and gl apps on volteer

Change-Id: Ie8def22f3dc6dc13a4972955aadabb91be838493
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3283505
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Chia-I Wu <olv@google.com>
2021-12-09 20:16:06 +00:00
Chia-I Wu
844160daf1 rutabaga_gfx: re-generate virglrenderer bindings
BUG=b:177267762
TEST=run vk and gl apps on volteer

Change-Id: Ife4ef9ef3db4ad421ed0b24e902dd0d06915273f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3283504
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chia-I Wu <olv@google.com>
2021-12-09 20:16:03 +00:00
Chia-I Wu
39ad06d10a rutabaga_gfx: impl Drop for VirglRenderer
We should clean up virglrenderer.

BUG=b:177267762
TEST=run vk and gl apps on volteer

Change-Id: I6fb0075f28a7c1fb35ff977e98652326e1297da4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3315232
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Commit-Queue: Chia-I Wu <olv@google.com>
2021-12-09 20:16:02 +00:00
Keiichi Watanabe
9d7887049d tools: Stop generating API docs for libvda
This should fix the GitHub Action as well.

BUG=none
TEST=kokoro
TEST=Run GitHub Action on my crosvm fork

Change-Id: Iff00d7d68c8dc38cda8222850bcc06ba2b558d01
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3327801
Auto-Submit: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2021-12-09 18:01:34 +00:00
Keiichi Watanabe
879868ad0f Fix cargo-doc warnings
BUG=none
TEST=./tools/cargo-doc

Change-Id: If2a89761d47464eb139f1f32c8cb3cb10fad3f81
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3305959
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2021-12-09 14:34:33 +00:00
Keiichi Watanabe
3e7c388efa tools: Add cargo-doc script
BUG=none
TEST=Run GitHub Action on my personal GitHub repository

Change-Id: I62de2693f3a654e0bbd327eff5931380a153395d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3305958
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2021-12-09 14:34:31 +00:00
Chirantan Ekbote
48ee10414c asyncv2: Split fallocate into separate functions
Rather than exposing fallocate directly, add separate functions for each
of the high level operations.  This should make it easier to add
cross-platform support as well as avoid the need to force callers to
deal with libc flags.

BUG=b:195468578
TEST=unit tests

Change-Id: I2aa6affa5cd87b299065b83bfc9bd400565308b2
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3276119
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
2021-12-09 12:33:09 +00:00
Chirantan Ekbote
0e81fd02dd data_model: Add advance() truncate() to VolatileSlice
BUG=b:195468578
TEST=unit tests

Change-Id: I0f17cb13867fdc7681e3d2124e53adb1e5354b03
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3276118
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
2021-12-09 12:33:08 +00:00
Chirantan Ekbote
0bf7cd0f2c data_model: Change VolatileSlice::as_iobuf() to return IoBufMut
This is more cross-platform and makes it easier to integrate with the
new async framework.

BUG=b:195468578
TEST=unit tests

Change-Id: Ia49413f35d71aaf3c1f9af86922372b96b69483d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3276117
Reviewed-by: Michael Hoyle <mikehoyle@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
2021-12-09 12:33:06 +00:00
Chirantan Ekbote
be39e5eff0 cros_asyncv2: Add support for timers
BUG=b:195468578
TEST=unit tests

Change-Id: I61f6bca1cfb5b0fe020e2fd5af33aa915c24ec54
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3225746
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
2021-12-09 12:33:05 +00:00
Chirantan Ekbote
7b13ef3ea6 cros_asyncv2: Add crate
Based on the previous proposal in [1].

* The Executor is now completely platform-agnostic and only relies on
  the platform to provide a type that implements the `PlatformState`
  trait.
* The crate provides concrete high-level types rather than forcing users
  to deal with trait objects and async-trait.  Currently, only File and
  Event are supported.  Support for timers, sockets, and pipes will be
  added in subsequent changes.
* Each high-level type delegates the implementation to a
  platform-specific type and exists mainly as a place to hold
  documentation and tests.
* On Unix the io_driver module provides async versions of various
  IO-related syscalls, which are used by the platform-specific File and
  Event types to implement the required behavior.
* io-uring support can be disabled at compile time.  When uring support
  is enabled, we make a runtime check to decide whether or not to use
  it.  The actual io-uring driver is currently unimplemented and will be
  added in a subsequent change.

One non-trivial downside of this change is that the futures returned by
the various async methods are !Send and !Sync, which means that they can
only be awaited from the same thread on which they were started.  In
practice this should be fine since current crosvm (and Chrome OS) code
doesn't really make use of sending futures to different threads. This
can also be mitigated by using `Executor::spawn_local` and a
`oneshot::channel` to isolate the !Send future from the outer async
fn (as long as the output of the future is Send). See the crate
documentation and the `outer_future_is_send` test in `src/executor.rs`
for more details.

[1]: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3062166

BUG=b:195468578
TEST=unit tests

Change-Id: I1aad0885e67a957149e2ec3b4d9df215d9b20d81
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3222223
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
2021-12-09 12:33:02 +00:00
Chih-Yang Hsia
99829b3e17 devices: virtio: snd: Support num_{output,input}_streams
Since Android needs separated PCM devices for different use
cases, we add multiple PCM streams support in virtio-snd
for both input and output direction.

Changes:
- Add num_{output, input}_streams support in ChromeOS's backend
- Remove todos since hardcoded_snd_data and
  hardcoded_virtio_snd_config are used in cras_backend
  implementation only.
- Update help message

BUG=b:199001477
TEST=`cargo test` for Parameters parsing
TEST=`crosvm run --cras-snd=num_output_streams=<num> ...`
     and check with `aplay -l`
TEST=`crosvm run --cras-snd=num_input_streams=<num> ...`
     and check with `arecord -l`

Change-Id: I59b2fd547b101d099f837f85c0b739f720795990
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3322796
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Woody Chow <woodychow@google.com>
Commit-Queue: Chih-Yang Hsia <paulhsia@chromium.org>
2021-12-09 02:05:09 +00:00
Anton Romanov
14e024ae4e Make aarch64 vm usable for running armhf binaries.
BUG: b/203152778
TEST: ./tools/run_tests --target vm:aarch64; ./tools/run_tests vm:aarch64 --arch armhf
Change-Id: I5b774ebf66f1a0a71e025dc364a6e85d43d3b6cb
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3324410
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Anton Romanov <romanton@google.com>
2021-12-09 01:08:45 +00:00
Xiong Zhang
91a56fe9da x86_64: Change E820Type from constants to enum
In order to comply with kernel E820Type definition and make code more
readable, this commit changes E820Type from constants to enum.

BUG=None
TEST=tools/presubmit

Change-Id: I514a3f71c734305c19cebbca6844f09d1fb16dab
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3314866
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-12-09 00:19:44 +00:00
Xiong Zhang
65700032fb x86_64: remove "pcie_ports=native" command line
Since _OSC is added, OS could negotiate any pcie features with firmware
through _OSC, so remove "pcie_ports=native" parameter from command line.

BUG=b:197877871
TEST=check pcie native hotplug compability in VM

Change-Id: Iba363aa0d5c6acaf61d72ed9cc4697677f9ace6c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3305946
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-12-09 00:19:43 +00:00
Xiong Zhang
b5fa790d53 x86_64: Add _OSC for pcie hotplug
OS call acpi _OSC method to request control for PCIE natvie features like
pcie hotplug, pcie advanced error report, pcie PME. But currently crosvm
lack of _OSC method, so OS couldn't enable these pcie features.

This commit add _OSC method, enable pcie hotplug and pcie cap structure
control, but disable SHPC hotplug, pcie PME and pcie AER.

BUG=b:197877871
TEST=Check pcie hotplug capability in VM

Change-Id: If4b6c8026c312ebfdeb18df7c0673571e3e9b631
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3305945
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-12-09 00:19:42 +00:00
Dennis Kempin
f4d5d32970 Add documentation for ChromeOS integration
BUG=b:209034086
TEST=None

Change-Id: Ia26a1fdd110dd72e3801a189d2854fd876469030
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3321735
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Dennis Kempin <denniskempin@google.com>
2021-12-08 18:50:50 +00:00
Dennis Kempin
cd0c2b846a kokoro: Add user name / email to commits
This prevents gerrit from claiming we are forging email addresses.

BUG=b:209034086
TEST=None

Change-Id: I9f5bab0684f40ad5220d8c88d89a34e23facab99
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3321734
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2021-12-08 18:50:50 +00:00
Keiichi Watanabe
d448be0d0d devices: vfio: Add methods to read/write region at specified address
Add utility methods to read/write VFIO memory region

BUG=b:194137301
TEST=build

Change-Id: Ia1054bb74bed791451e7bb8c87c2eb9b84353a2d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3149873
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2021-12-08 16:19:48 +00:00
Keiichi Watanabe
75da78b21b vmm_vhost: Remove SlaveReqHandler type parameter in SlaveReqHelper
The type parameter `S: SlaveReqHandler` for `SlaveReqHelper` was
introduced to check if it's vvu or not.
Howver, SlaveReqHelper shouldn't take a type parameter of
`SlaveReqHandler` because the helper will be used in the VVU proxy
device which doesn't  have its own req_handler.

So, instead of taking the type parameter, we should have a new bool
field which indicates if it's VVU or not.

BUG=b:194136484
TEST=cargo test --all-features in vmm_vhost
TEST=kokoro

Change-Id: I35f20ef7c42cd74678ab5d87b68bbb58586d2fa5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3320122
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2021-12-08 14:50:59 +00:00
Xiong Zhang
a41f6c9be5 pci_root: Emulate PCIE base address register in host bridge
Intel acpi method reads PCIEBAR Base Address Register in host bridge to
get the pcie config mmio base address. This commit emulates this
register, so the acpi method could get the right information.

BUG=b:197877871
TEST=Verify this regsiter's value in a vm

Change-Id: I93bf8e678acc0e085b102a2eb3a88cbf466aed78
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3305944
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
2021-12-08 12:30:30 +00:00
Xiong Zhang
4c55b20376 x86_64: Add acpi MCFG table
In order to enable pcie enhanced configurtion access mechanism in kernel,
acpi mcfg table is mandatory. So kernel could know the base and size of
pcie enhanced configuration access mmio.

BUG=b:197877871
TEST=Boot a vm and r/w pci config regiser through pcie ECAM

Change-Id: Icecedba3f31cd94bed76e48932c5e77f56effb9c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3305943
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
2021-12-08 12:30:29 +00:00
Xiong Zhang
0b8318a2be Linux: Change root_config from PciConfigArch to PciRoot
Since PciRoot has been modified into Arc<Mutex<>>, RunnableLinuxVm->root_config
could be changed from PciConfigArch to PciRoot also, this could simplify code
and reduce two functions from PciConfigArch.

BUG=b:197877871
TEST=tools/presubmit

Change-Id: Ibc18587900d6f8259ac1d6f8fe7b3ea4fedad07e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3305942
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
2021-12-08 12:30:28 +00:00
Chih-Yang Hsia
41dc04fc82 crosvm: Support multiple CRAS virtio-snd cards
Support creating multiple CRAS virtio-snd cards.

Changes:
- Change `cras_snd` to `cras_snds: Vec<CrasSndParameters>`
- Push multiple virtio-snd cards to device list

BUG=b:199001477
TEST=Run crosvm with 2 `--cras-snd` params and check
     `aplay -l` and `arecord -l`

Change-Id: I8c9f82a4f5b8749ca7a289226b209673646b62b0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3320921
Auto-Submit: Chih-Yang Hsia <paulhsia@chromium.org>
Reviewed-by: Woody Chow <woodychow@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chih-Yang Hsia <paulhsia@chromium.org>
2021-12-08 08:38:50 +00:00
Keiichi Watanabe
60334439a1 vmm_vhost: Parametrize Endpoint in Master trait
Allow having a Master struct with a backend other than socket. This will
be helpful for multi-platform support.

BUG=b:194137301
TEST=cargo test --all-features in vmm_vhost

Change-Id: Ie1bd8949ddb708c87a964544c6ae2fe7391b1fb5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3320904
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2021-12-08 07:47:41 +00:00
Keiichi Watanabe
155d01df43 vmm_vhost: Implement From<UnixStream> for socket::Endpoint
Instead of having `from_stream()` method, use `From` trait.

BUG=b:206900656
TEST=cargo test --all-features in vmm_vhost

Change-Id: I8b6f06231c0b28e3e5f7b924221fe51f050c077b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3320903
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2021-12-08 07:47:40 +00:00
Keiichi Watanabe
5f5f6afacd vmm_vhost: Add TODO comments about IoSlice::advance_slice()
BUG=b:194137301
TEST=cargo test

Change-Id: I28466597209e4e81dc566d66d69875f59808eb0f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3317325
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2021-12-08 07:47:39 +00:00
Keiichi Watanabe
7d4d02fc94 vmm_vhost: Expose connection::{socket, vfio} module
Expose connection::{socket, vfio} modules so that we don't need to have
prefix for structs there.
e.g. SocketEndpoint -> connection::socket::Endpoint

BUG=b:194137301
TEST=cargo test --all-features in vmm_vhost
TEST=cargo check in crosvm

Change-Id: I7d992a0df5a838fa6a726f366e9595b20405ec3b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3317324
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2021-12-08 07:47:38 +00:00
Dmitry Torokhov
22eb7c044c x86_64: stop forcing reboot via keyboard port
Now that we have wired up PCI reset and exposed it via ACPI reset
register we no longer need to force resetting via keyboard port.

BUG=b:3169569
TEST=Reboot mantee board

Change-Id: I4bc02909199b3f519993794e28ed742432ebd64b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3317156
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dmitry Torokhov <dtor@chromium.org>
2021-12-08 06:33:03 +00:00
Dmitry Torokhov
f75699f59c crosvm: return 32 exit code when guest issues reset request
Instead of returning 0 for both shutdown and reset/reboot, let's have
shutdown continue returning 0, but reset will now return 32 exit code,
so that callers will have an option to handle this case differently.

BUG=b:3169569
TEST=Examine crosvm exit codes when resetting and shutting down VM

Change-Id: I2c7c11b7f8c8528744f7e25e5d17c6fa9810f409
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3316835
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dmitry Torokhov <dtor@chromium.org>
2021-12-08 06:33:02 +00:00
Dmitry Torokhov
d05fc4e6f4 acpi: expose PCI reset register in ACPI
This will allow guest OS to issue reset requests via ACPI methods.

BUG=b:3169569
TEST=Build and boot.

Change-Id: I6d29422f962c21a2e513cb4da78515e31468a1e5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3316834
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dmitry Torokhov <dtor@chromium.org>
2021-12-08 06:33:00 +00:00
Dmitry Torokhov
b41b9bbb42 devices: pci: wire up reset via 0xcf9 register
This is a bit of a hack, but crosvm does not support overlapping IO/MMIO
regions, so we have to handle reset register in PciConfigIo handler
(which covers 0xcf8 - 0xcff range) instead of installing a dedicated
reset handler separate from PCI root handler.

BUG=b:3169569
TEST=Try rebooting Manatee booted with "reboot=p"

Change-Id: I79991f456d4aaaab2c904e312996208aa72ab6ec
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3316833
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dmitry Torokhov <dtor@chromium.org>
2021-12-08 06:32:59 +00:00
Alexandre Courbot
00065869cf linux: disambiguate error context messages
Error context messages should be unique to easily identify where they
come from.

BUG=None
TEST=cargo build

Change-Id: I1c1deb051a6c77f624c60c581ee680dbad1ae997
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3320914
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2021-12-08 05:41:56 +00:00
Alexandre Courbot
a184e31757 crosvm: display error chain when VM fails
Use the '{:#}' formatter to display the complete error chain. This turns
the following error:

	crosvm has exited with error: failed to set up virtio networking

into the more helpful:

	crosvm has exited with error: failed to set up virtio
	networking: failed to open tap device: failed to create tap
	interface: Operation not permitted (os error 1)

BUG=None
TEST=cargo build

Change-Id: I65126af54a9a3cef7823e55c021dcd591660077a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3320913
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2021-12-08 05:41:55 +00:00
Keiichi Watanabe
31bc5998bb devices: vhost: user: Add README
BUG=none
TEST=none

Change-Id: I6a7b27c5dbb44d417ff9e0e7b213403efee92ec5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3320905
Auto-Submit: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
2021-12-08 05:29:58 +00:00
Xiong Zhang
fd032f2a77 x86_64: Add pcie enhanced configruation into mmio_bus
Reserved 64MB mmio space for pcie enhanced configuration access,
and added it into mmio_bus with PciConfigMmio.

Now pci_root will be added into PciConfigIo and PciConfigMmio, so
Arc<Mux<pci_root>> is used.

BUG=b:197877871
TEST=tools/presubmit

Change-Id: Ic90a4cc3dfb00b09358478e129cc8a16e91012c6
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3305941
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
2021-12-08 00:22:50 +00:00
Junichi Uekawa
b180f9ce0f crosvm: use BusRange in DirectIoOption.
Used to use an unnamed tuple there but instead use the BusRange because
it's semantic and now there's less copying.

BUG=b:188011323
TEST=cargo test --features=direct

Change-Id: I4a10251c758d330b8938090fb5971badcb9b7bdf
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3319716
Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
2021-12-08 00:22:43 +00:00
Dennis Kempin
f18de38a02 kokoro: clean repo before merging
There can be leftover files from a previous build.

BUG=b:209034086
TEST=./ci/kokoro/simulate build-merge-into-chromeos.sh

Change-Id: I0f7223bc6dd1769db04408f595764931c3ff2af8
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3321730
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Dennis Kempin <denniskempin@google.com>
2021-12-07 21:03:03 +00:00
Dennis Kempin
fbb2de0188 kokoro: Various fixes to merge-into-chromeos job
- Adds the needed job config
- Makes a copy of the script before git checkout
- Follow naming scheme of other build scripts
- Add reviewer when uploading

BUG=b:209034086
TEST=./ci/kokoro/simulate build-merge-into-chromeos.sh

Change-Id: I279ff6aca7c3c304354a238ebd5c40b4dd272385
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3321726
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Dennis Kempin <denniskempin@google.com>
2021-12-07 20:50:29 +00:00
Keiichi Watanabe
0d801c9cd2 devices: vfio: Avoid arch-dependent type conversion for IommuType
Since ioctl_with_val takes c_ulong, whose size is 64-bit in x86 but
32-bit in ARM, we must not assume it can be converted to u64.

BUG=none
TEST=cargo check

Change-Id: Ib0060bbbe2e06c94bf8802c8e775c808c07ff6a6
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3320123
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Auto-Submit: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2021-12-07 17:45:57 +00:00
Anton Romanov
bbec8ebf65 Use tmpfs for /tmp in dev container
This works around quirkiness of sparse file support in overlayfs.

Revert "sys_util: ignore seek_hole tests for kokoro uprev"
This reverts commit 3d0e51f71c.

BUG=b:208901617

TEST=./tools/dev_container --hermetic bash -c "cd common/sys_util; cargo test seek_"

Change-Id: Id4d809f09a71b5cd134b5eb9bf6a5f970e5503c8
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3319404
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Anton Romanov <romanton@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Anton Romanov <romanton@google.com>
2021-12-07 17:44:17 +00:00
Abhishek Bhardwaj
e396dca250 crosvm: vvu: proxy: Implement device configuration
This change implements the proxy device configuration.

BUG=b:194136484
TEST=Compile.

Change-Id: I648890117e5609447086d130e7c3fe6b63dc8724
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3288869
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Abhishek Bhardwaj <abhishekbh@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2021-12-07 09:22:26 +00:00
Chih-Yang Hsia
049746fb8a device: virtio: snd: Call release_worker in prepare
Since VIRTIO_SND_R_PCM_PREPARE -> VIRTIO_SND_R_PCM_PREPARE is a valid
transition, we need to release the worker if it's already in
VIRTIO_SND_R_PCM_PREPARE state. Or we could trigger

```
Error in handling tx queue: Error in mpsc: send failed because receiver is gone
```

in handle_pcm_queue while sending `desc_chain` to start_pcm_worker
through the `stream_info.sender()`.

BUG=b:202368198
TEST=Run alsa_conformance_test multiple times

Change-Id: I5f8ee370832ee162fdef71d396dfe848d88af7e1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3317328
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chih-Yang Hsia <paulhsia@chromium.org>
Reviewed-by: Woody Chow <woodychow@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2021-12-07 03:33:47 +00:00